From b3f8b11c5a364afa3ef8b0a80b4c2c071534c55e Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 12 Apr 2022 13:46:50 -0500 Subject: [PATCH] riscv work --- ableos/.cargo/config.toml | 3 +- ableos/src/arch/riscv/drivers/mod.rs | 1 + ableos/src/arch/riscv/drivers/sysinfo.rs | 22 ++++++++++ ableos/src/arch/riscv/mod.rs | 42 +++++++++++--------- ableos/src/experiments/kinfo.rs | 1 - ableos/src/rhai_shell/mod.rs | 2 +- ableos/src/wasm_jumploader/host_functions.rs | 5 ++- 7 files changed, 52 insertions(+), 24 deletions(-) diff --git a/ableos/.cargo/config.toml b/ableos/.cargo/config.toml index cc0f2e33..79f7f7a4 100644 --- a/ableos/.cargo/config.toml +++ b/ableos/.cargo/config.toml @@ -11,4 +11,5 @@ rustflags = ["-C", "target-feature=+rdrand"] runner = "bootimage runner" [target.riscv64gc-unknown-none-elf] -rustflags = "-C link-arg=-T../ableos/src/arch/riscv/virt.lds" +rustflags = "-C link-arg=-Tableos/src/arch/riscv/virt.lds" +# ableos/src/arch/riscv/virt.lds \ No newline at end of file diff --git a/ableos/src/arch/riscv/drivers/mod.rs b/ableos/src/arch/riscv/drivers/mod.rs index aeaf2b21..082f9605 100644 --- a/ableos/src/arch/riscv/drivers/mod.rs +++ b/ableos/src/arch/riscv/drivers/mod.rs @@ -1,4 +1,5 @@ pub mod allocator; pub mod graphics; pub mod mmio; +pub mod sysinfo; pub mod uart; diff --git a/ableos/src/arch/riscv/drivers/sysinfo.rs b/ableos/src/arch/riscv/drivers/sysinfo.rs index 73efc452..56ff1555 100644 --- a/ableos/src/arch/riscv/drivers/sysinfo.rs +++ b/ableos/src/arch/riscv/drivers/sysinfo.rs @@ -1 +1,23 @@ pub fn sysinfo() {} +pub fn master() -> Option { + Some(Master { + brand_string: Some("riscv".to_string()), + }) +} + +pub struct Master { + // TODO: Rename struct + // version_information: Option, + // thermal_power_management_information: Option, + // structured_extended_information: Option, + // extended_processor_signature: Option, + pub brand_string: Option, + // cache_line: Option, + // time_stamp_counter: Option, + // physical_address_size: Option, +} +impl Master { + pub fn brand_string(&self) -> Option<&str> { + self.brand_string.as_deref() + } +} diff --git a/ableos/src/arch/riscv/mod.rs b/ableos/src/arch/riscv/mod.rs index d5416341..b49e0575 100644 --- a/ableos/src/arch/riscv/mod.rs +++ b/ableos/src/arch/riscv/mod.rs @@ -51,25 +51,29 @@ extern "C" fn _start() -> ! { uart.put('\r' as u8); } - 91 => { - if let Some(ch) = uart.get() { - match ch as char { - 'A' => { - serial_println!("That's the up arrow!"); - } - 'B' => { - serial_println!("That's the down arrow!"); - } - 'C' => { - serial_println!("That's the right arrow!"); - } - 'D' => { - serial_println!("That's the left arrow!"); - } - } - } - } - + /* + 91 => { + if let Some(ch) = uart.get() { + match ch as char { + 'A' => { + serial_println!("That's the up arrow!"); + } + 'B' => { + serial_println!("That's the down arrow!"); + } + 'C' => { + serial_println!("That's the right arrow!"); + } + 'D' => { + serial_println!("That's the left arrow!"); + } + _ => { + serial_println!("That's something else!"); + } + } + } + } + */ _ => { uart.put(c); } diff --git a/ableos/src/experiments/kinfo.rs b/ableos/src/experiments/kinfo.rs index c292f99c..c729f341 100644 --- a/ableos/src/experiments/kinfo.rs +++ b/ableos/src/experiments/kinfo.rs @@ -42,7 +42,6 @@ impl KernelInfo { enable(); let cpu = CpuType::X86_64(master().unwrap().brand_string().unwrap().to_string()); - KernelInfo { kernel_version: Version { major: 0, diff --git a/ableos/src/rhai_shell/mod.rs b/ableos/src/rhai_shell/mod.rs index 2528e363..6582abc4 100644 --- a/ableos/src/rhai_shell/mod.rs +++ b/ableos/src/rhai_shell/mod.rs @@ -69,7 +69,6 @@ pub fn afetch() { let used = allocator.used(); enable(); - // let mem = format!("{}/{}", used, size); println!( include_str!("balloon.txt"), kstate.hostname, @@ -77,6 +76,7 @@ pub fn afetch() { KERNEL_VERSION, tick_time, master().unwrap().brand_string().unwrap(), + // "", // mem used, size diff --git a/ableos/src/wasm_jumploader/host_functions.rs b/ableos/src/wasm_jumploader/host_functions.rs index 9d0a51cf..adcf4733 100644 --- a/ableos/src/wasm_jumploader/host_functions.rs +++ b/ableos/src/wasm_jumploader/host_functions.rs @@ -167,8 +167,9 @@ impl Externals for HostExternals { } GET_INPUT_INDEX => { - let input = - x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()); + let input = + // None; + x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()); if let Some(chr) = input { trace!("SYSCALL: input: {}", chr); }