pci first commit
This commit is contained in:
parent
381b86d5e0
commit
85afa2b437
4 changed files with 36 additions and 9 deletions
|
|
@ -12,7 +12,8 @@ qemu:
|
||||||
-monitor unix:${QEMU_SOCKET},server,nowait
|
-monitor unix:${QEMU_SOCKET},server,nowait
|
||||||
|
|
||||||
qemu-gdb:
|
qemu-gdb:
|
||||||
gdb -q\
|
gdb\
|
||||||
|
-q\
|
||||||
-symbols "$(KERNEL)" \
|
-symbols "$(KERNEL)" \
|
||||||
-ex "target remote :$(QEMU_GDB_PORT)"\
|
-ex "target remote :$(QEMU_GDB_PORT)"\
|
||||||
-ex "set arch i386"
|
-ex "set arch i386"
|
||||||
|
|
@ -20,5 +21,6 @@ qemu-gdb:
|
||||||
qemu-monitor:
|
qemu-monitor:
|
||||||
$(QEMU_MONITOR)
|
$(QEMU_MONITOR)
|
||||||
qemu-reload:
|
qemu-reload:
|
||||||
echo "change ide1-cd0 $(ISO)" | $(QEMU_MONITOR) &>-
|
echo "stop" | $(QEMU_MONITOR) &>/dev/null
|
||||||
echo "system_reset" | $(QEMU_MONITOR) &>-
|
echo "change ide1-cd0 $(ISO)" | $(QEMU_MONITOR) &>/dev/null
|
||||||
|
echo "system_reset" | $(QEMU_MONITOR) &>/dev/null
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,11 @@ impl Console {
|
||||||
}
|
}
|
||||||
b'\n' => {
|
b'\n' => {
|
||||||
unsafe { VGA.write_byte(b'\n'); }
|
unsafe { VGA.write_byte(b'\n'); }
|
||||||
self.exec();
|
if let Err(msg) = self.exec() {
|
||||||
|
set_color!(Red);
|
||||||
|
println!("{}", msg);
|
||||||
|
set_color!();
|
||||||
|
}
|
||||||
self.command_len = 0;
|
self.command_len = 0;
|
||||||
self.prompt();
|
self.prompt();
|
||||||
}
|
}
|
||||||
|
|
@ -83,9 +87,7 @@ impl Console {
|
||||||
pub fn exec(&self) -> core::result::Result<(), &'static str> {
|
pub fn exec(&self) -> core::result::Result<(), &'static str> {
|
||||||
let command = self.get_command();
|
let command = self.get_command();
|
||||||
if let Err(msg) = command {
|
if let Err(msg) = command {
|
||||||
set_color!(Red);
|
return Err(msg)
|
||||||
println!("{}", msg);
|
|
||||||
set_color!();
|
|
||||||
}
|
}
|
||||||
match command.unwrap() {
|
match command.unwrap() {
|
||||||
"help" | "h" => self::help(),
|
"help" | "h" => self::help(),
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,8 @@ extern crate rlibc;
|
||||||
extern crate slab_allocator;
|
extern crate slab_allocator;
|
||||||
extern crate spin;
|
extern crate spin;
|
||||||
|
|
||||||
|
extern crate bitflags;
|
||||||
|
|
||||||
// used by arch/x86, need conditional compilation here
|
// used by arch/x86, need conditional compilation here
|
||||||
extern crate x86;
|
extern crate x86;
|
||||||
|
|
||||||
|
|
@ -44,7 +46,7 @@ pub mod pci;
|
||||||
/// calling this once the core has loaded
|
/// calling this once the core has loaded
|
||||||
pub fn kmain() -> ! {
|
pub fn kmain() -> ! {
|
||||||
// memory init after heap is available
|
// memory init after heap is available
|
||||||
memory::init_noncore();
|
// memory::init_noncore();
|
||||||
|
|
||||||
// unsafe VGA
|
// unsafe VGA
|
||||||
unsafe { console::CONSOLE.init(); }
|
unsafe { console::CONSOLE.init(); }
|
||||||
|
|
@ -68,5 +70,4 @@ pub extern "C" fn panic_fmt(info: &core::panic::PanicInfo) -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
// pub static ALLOCATOR: slab_allocator::LockedHeap = allocator::ALLOCATOR;
|
|
||||||
pub static ALLOCATOR: slab_allocator::LockedHeap = slab_allocator::LockedHeap::empty();
|
pub static ALLOCATOR: slab_allocator::LockedHeap = slab_allocator::LockedHeap::empty();
|
||||||
|
|
|
||||||
22
kernel-rs/src/pci/mod.rs
Normal file
22
kernel-rs/src/pci/mod.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
// https://wiki.osdev.org/PCI
|
||||||
|
|
||||||
|
use x86::devices::io::{Pio};
|
||||||
|
|
||||||
|
pub static mut PCI_CONFIG_ADDRESS: Pio<u8> = Pio::new(0xCF8);
|
||||||
|
pub static mut PCI_CONFIG_DATA: Pio<u8> = Pio::new(0xCFC);
|
||||||
|
|
||||||
|
pub fn lspci() {
|
||||||
|
pci_config_read_word(1, 1, 1, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn pci_config_read_word(bus: u32, slot: u32, func: u32, offset: u32) {
|
||||||
|
// let address: u64 = (bus as u32) << 16
|
||||||
|
// | (slot as u32) << 11
|
||||||
|
// | (func as u32) << 8
|
||||||
|
// | (offset as u32) & 0xfc
|
||||||
|
// | 0x80000000;
|
||||||
|
let address: u64 = 0x80000000;
|
||||||
|
println!("{} {} {} {}", bus, slot, func, offset);
|
||||||
|
println!("{:#x}", address);
|
||||||
|
println!("{:#b}", address);
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue