pci first commit

This commit is contained in:
Jack Halford 2019-01-16 22:30:06 +01:00
parent 381b86d5e0
commit 85afa2b437
4 changed files with 36 additions and 9 deletions

View file

@ -12,7 +12,8 @@ qemu:
-monitor unix:${QEMU_SOCKET},server,nowait
qemu-gdb:
gdb -q\
gdb\
-q\
-symbols "$(KERNEL)" \
-ex "target remote :$(QEMU_GDB_PORT)"\
-ex "set arch i386"
@ -20,5 +21,6 @@ qemu-gdb:
qemu-monitor:
$(QEMU_MONITOR)
qemu-reload:
echo "change ide1-cd0 $(ISO)" | $(QEMU_MONITOR) &>-
echo "system_reset" | $(QEMU_MONITOR) &>-
echo "stop" | $(QEMU_MONITOR) &>/dev/null
echo "change ide1-cd0 $(ISO)" | $(QEMU_MONITOR) &>/dev/null
echo "system_reset" | $(QEMU_MONITOR) &>/dev/null

View file

@ -54,7 +54,11 @@ impl Console {
}
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.prompt();
}
@ -83,9 +87,7 @@ impl Console {
pub fn exec(&self) -> core::result::Result<(), &'static str> {
let command = self.get_command();
if let Err(msg) = command {
set_color!(Red);
println!("{}", msg);
set_color!();
return Err(msg)
}
match command.unwrap() {
"help" | "h" => self::help(),

View file

@ -24,6 +24,8 @@ extern crate rlibc;
extern crate slab_allocator;
extern crate spin;
extern crate bitflags;
// used by arch/x86, need conditional compilation here
extern crate x86;
@ -44,7 +46,7 @@ pub mod pci;
/// calling this once the core has loaded
pub fn kmain() -> ! {
// memory init after heap is available
memory::init_noncore();
// memory::init_noncore();
// unsafe VGA
unsafe { console::CONSOLE.init(); }
@ -68,5 +70,4 @@ pub extern "C" fn panic_fmt(info: &core::panic::PanicInfo) -> ! {
}
#[global_allocator]
// pub static ALLOCATOR: slab_allocator::LockedHeap = allocator::ALLOCATOR;
pub static ALLOCATOR: slab_allocator::LockedHeap = slab_allocator::LockedHeap::empty();

22
kernel-rs/src/pci/mod.rs Normal file
View 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);
}