Compare commits

...

2 commits

Author SHA1 Message Date
gil 6846ecbcc0 Print hartid after hello world 2024-05-16 00:36:19 -05:00
gil 1644d5a068 Add riscv crate 2024-05-16 00:18:11 -05:00
3 changed files with 26 additions and 0 deletions

23
Cargo.lock generated
View file

@ -8,11 +8,24 @@ version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
[[package]]
name = "critical-section"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216"
[[package]]
name = "embedded-hal"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
[[package]] [[package]]
name = "kernel" name = "kernel"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"linked_list_allocator", "linked_list_allocator",
"riscv",
"spinning_top 0.3.0", "spinning_top 0.3.0",
] ]
@ -35,6 +48,16 @@ dependencies = [
"scopeguard", "scopeguard",
] ]
[[package]]
name = "riscv"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f5c1b8bf41ea746266cdee443d1d1e9125c86ce1447e1a2615abd34330d33a9"
dependencies = [
"critical-section",
"embedded-hal",
]
[[package]] [[package]]
name = "scopeguard" name = "scopeguard"
version = "1.2.0" version = "1.2.0"

View file

@ -5,4 +5,5 @@ edition = "2021"
[dependencies] [dependencies]
linked_list_allocator = "0.10.5" linked_list_allocator = "0.10.5"
riscv = "0.11.1"
spinning_top = "0.3.0" spinning_top = "0.3.0"

View file

@ -63,6 +63,8 @@ extern "C" fn start() -> ! {
unsafe { uart::init_console(0x1000_0000) }; unsafe { uart::init_console(0x1000_0000) };
println!("Hello, world!"); println!("Hello, world!");
println!("hartid: {}", riscv::register::mhartid::read());
loop { loop {
let c = uart::CONSOLE.lock().as_mut().and_then(uart::Device::get); let c = uart::CONSOLE.lock().as_mut().and_then(uart::Device::get);
if let Some(c) = c { if let Some(c) = c {