diff --git a/kernel-rs/src/arch/x86/device/cpu.rs b/kernel-rs/src/arch/x86/device/cpu.rs index 83051d5d..eaadb10b 100644 --- a/kernel-rs/src/arch/x86/device/cpu.rs +++ b/kernel-rs/src/arch/x86/device/cpu.rs @@ -8,27 +8,27 @@ pub fn cpu_info() -> Result { let cpuid = CpuId::new(); if let Some(info) = cpuid.get_vendor_info() { - println!("CPU Vendor: {}", info.as_string()); + println!("Vendor: {}", info.as_string()); } if let Some(info) = cpuid.get_extended_function_info() { if let Some(brand) = info.processor_brand_string() { - println!("CPU Model: {}", brand); + println!("Model: {}", brand); } } if let Some(info) = cpuid.get_processor_frequency_info() { - println!("CPU Base MHz: {}", info.processor_base_frequency()); - println!("CPU Max MHz: {}", info.processor_max_frequency()); + println!("Base MHz: {}", info.processor_base_frequency()); + println!("Max MHz: {}", info.processor_max_frequency()); println!("Bus MHz: {}", info.bus_frequency()); } else { set_color!(Red); - println!("couldn't retrieve CPU frequency info"); + println!("Couldn't retrieve cpu frequency info"); set_color!(); } if let Some(info) = cpuid.get_feature_info() { - print!("CPU Features:"); + print!("Features:"); if info.has_fpu() { print!(" fpu") }; if info.has_vme() { print!(", vme") }; if info.has_de() { print!(", de") }; @@ -97,7 +97,7 @@ pub fn cpu_info() -> Result { } if let Some(info) = cpuid.get_extended_function_info() { - print!("CPU extended function:"); + print!("Extended function:"); if info.has_64bit_mode() { print!(" lm") }; if info.has_rdtscp() { print!(", rdtscp") }; if info.has_1gib_pages() { print!(", pdpe1gb") }; @@ -111,7 +111,7 @@ pub fn cpu_info() -> Result { } if let Some(info) = cpuid.get_extended_feature_info() { - print!("CPU extended features:"); + print!("Extended features:"); if info.has_fsgsbase() { print!(" fsgsbase") }; if info.has_tsc_adjust_msr() { print!(", tsc_adjust") }; if info.has_bmi1() { print!(", bmi1") }; @@ -128,6 +128,5 @@ pub fn cpu_info() -> Result { println!(""); } - Ok(()) } diff --git a/kernel-rs/src/arch/x86/device/local_apic.rs b/kernel-rs/src/arch/x86/device/local_apic.rs index dea9cd2b..3a4e79c6 100644 --- a/kernel-rs/src/arch/x86/device/local_apic.rs +++ b/kernel-rs/src/arch/x86/device/local_apic.rs @@ -15,9 +15,7 @@ pub struct LocalApic { } impl LocalApic { - unsafe fn init(&mut self, active_table: &mut ActivePageTable) { - // let efer = Efer::read(); - // println!("efer = {:?}", efer); - // flush!(); + unsafe fn init(&mut self, _active_table: &mut ActivePageTable) { + // ??? } } diff --git a/kernel-rs/src/arch/x86/device/mod.rs b/kernel-rs/src/arch/x86/device/mod.rs index d9b91aa5..dc1eac30 100644 --- a/kernel-rs/src/arch/x86/device/mod.rs +++ b/kernel-rs/src/arch/x86/device/mod.rs @@ -6,5 +6,4 @@ pub mod cpu; pub unsafe fn init(active_table: &mut ActivePageTable) { pic::init(); local_apic::init(active_table); - cpu::cpu_info().expect("cpuid not available"); } diff --git a/kernel-rs/src/arch/x86/device/pic.rs b/kernel-rs/src/arch/x86/device/pic.rs index c36e8ee8..00b5ab21 100644 --- a/kernel-rs/src/arch/x86/device/pic.rs +++ b/kernel-rs/src/arch/x86/device/pic.rs @@ -36,11 +36,12 @@ pub unsafe fn init() { MASTER.data.write(master_mask); wait(); SLAVE.data.write(slave_mask); wait(); - println!("master={:#x}", MASTER.data.read()); - println!("slave ={:#x}", SLAVE.data.read()); - - MASTER.mask_set(0); - MASTER.mask_clear(1); + // disable all irqs + MASTER.data.write(!0); wait(); + SLAVE.data.write(!0); wait(); + + // keyboard active + MASTER.mask_clear(1); wait(); // asm!("sti"); ::x86::instructions::interrupts::enable(); diff --git a/kernel-rs/src/arch/x86/interrupt/irq.rs b/kernel-rs/src/arch/x86/interrupt/irq.rs index 46d2d6e2..04a64b83 100644 --- a/kernel-rs/src/arch/x86/interrupt/irq.rs +++ b/kernel-rs/src/arch/x86/interrupt/irq.rs @@ -6,13 +6,15 @@ macro_rules! interrupt { ($i:expr, $name:ident, $func:block) => { pub extern "x86-interrupt" fn $name(stack_frame: &mut ExceptionStackFrame) { - unsafe { trigger(1); } + unsafe { trigger($i); } + #[allow(unused_variables)] fn inner(stack: &mut ExceptionStackFrame) { $func } inner(stack_frame); - unsafe { acknowledge(1); } + + unsafe { acknowledge($i); } } } } diff --git a/kernel-rs/src/arch/x86/mod.rs b/kernel-rs/src/arch/x86/mod.rs index 45f657b7..ddf17a1c 100644 --- a/kernel-rs/src/arch/x86/mod.rs +++ b/kernel-rs/src/arch/x86/mod.rs @@ -42,7 +42,6 @@ pub unsafe extern fn x86_rust_start(multiboot_info_addr: usize) { // after core has loaded ::memory::init_noncore(); - // primary CPU entry point ::kmain(); } diff --git a/kernel-rs/src/console.rs b/kernel-rs/src/console.rs index 73a307bc..6dc8f781 100644 --- a/kernel-rs/src/console.rs +++ b/kernel-rs/src/console.rs @@ -23,6 +23,7 @@ fn dispatch(command: &str) -> Result <(), &'static str> { // others "stack" => self::print_stack(), "regs" => self::regs(), + "cpu" => self::cpu(), _ => Err("Command unknown. (h|help for help)"), } @@ -48,6 +49,7 @@ fn help() -> Result <(), &'static str> { println!("shutdown | halt | q => Kill a kitten, then shutdown"); println!("stack => Print kernel stack in a fancy way"); println!("regs => Print controle register"); + println!("cpu => Print cpu information"); flush!(); Ok(()) } @@ -177,11 +179,17 @@ pub fn acpi_info() -> Result <(), &'static str> { } pub fn regs() -> Result <(), &'static str> { - use x86::registers::control::*; + use ::x86::registers::control::*; println!("cr0={:#b}", Cr0::read()); println!("cr3={:?}", Cr3::read()); + println!("cr4={:?}", Cr4::read()); + flush!(); + Ok(()) +} + +pub fn cpu() -> Result <(), &'static str> { + use ::arch::x86::device::cpu; + cpu::cpu_info().expect("cpu info not available"); flush!(); - // TODO implement cr4 flags in `x86` module - // println!("cr4={:#b}", Cr4::read()); Ok(()) } diff --git a/kernel-rs/src/vga/mod.rs b/kernel-rs/src/vga/mod.rs index 979c5939..b773b4ff 100644 --- a/kernel-rs/src/vga/mod.rs +++ b/kernel-rs/src/vga/mod.rs @@ -199,21 +199,21 @@ impl fmt::Write for Writer { pub fn init() { set_color!(White, Cyan); - // print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}", - // format_args!("{: ^80}", r#" ,--, "#), - // format_args!("{: ^80}", r#" ,--.'| ,----, "#), - // format_args!("{: ^80}", r#" ,--, | : .' .' \ "#), - // format_args!("{: ^80}", r#",---.'| : ' ,----,' | "#), - // format_args!("{: ^80}", r#"; : | | ; | : . ; "#), - // format_args!("{: ^80}", r#"| | : _' | ; |.' / "#), - // format_args!("{: ^80}", r#": : |.' | `----'/ ; "#), - // format_args!("{: ^80}", r#"| ' ' ; : / ; / "#), - // format_args!("{: ^80}", r#"\ \ .'. | ; / /-, "#), - // format_args!("{: ^80}", r#" `---`: | ' / / /.`| "#), - // format_args!("{: ^80}", r#" ' ; |./__; : "#), - // format_args!("{: ^80}", r#" | : ;| : .' "#), - // format_args!("{: ^80}", r#" ' ,/ ; | .' "#), - // format_args!("{: ^80}", r#" '--' `---' "#)); + print!("{}{}{}{}{}{}{}{}{}{}{}{}{}{}", + format_args!("{: ^80}", r#" ,--, "#), + format_args!("{: ^80}", r#" ,--.'| ,----, "#), + format_args!("{: ^80}", r#" ,--, | : .' .' \ "#), + format_args!("{: ^80}", r#",---.'| : ' ,----,' | "#), + format_args!("{: ^80}", r#"; : | | ; | : . ; "#), + format_args!("{: ^80}", r#"| | : _' | ; |.' / "#), + format_args!("{: ^80}", r#": : |.' | `----'/ ; "#), + format_args!("{: ^80}", r#"| ' ' ; : / ; / "#), + format_args!("{: ^80}", r#"\ \ .'. | ; / /-, "#), + format_args!("{: ^80}", r#" `---`: | ' / / /.`| "#), + format_args!("{: ^80}", r#" ' ; |./__; : "#), + format_args!("{: ^80}", r#" | : ;| : .' "#), + format_args!("{: ^80}", r#" ' ,/ ; | .' "#), + format_args!("{: ^80}", r#" '--' `---' "#)); set_color!(); unsafe { VGA.prompt(); } unsafe { VGA.flush(); }