瀏覽代碼

fix(prototyper): fix typo and make code clean

guttatus 3 月之前
父節點
當前提交
e815d20bba

+ 5 - 13
Cargo.lock

@@ -289,7 +289,7 @@ dependencies = [
  "sbi-spec 0.0.8",
  "sbi-testing 0.0.3-alpha.2 (git+https://github.com/rustsbi/rustsbi?rev=4821073)",
  "serde",
- "serde-device-tree 0.0.1 (git+https://github.com/rustsbi/serde-device-tree)",
+ "serde-device-tree",
  "spin",
  "uart16550",
 ]
@@ -318,7 +318,7 @@ dependencies = [
  "rustsbi",
  "sbi-spec 0.0.7",
  "serde",
- "serde-device-tree 0.0.1 (git+https://github.com/woshiluo/serde-device-tree?branch=aliases)",
+ "serde-device-tree",
  "sifive-test-device",
  "spin",
  "uart16550",
@@ -418,15 +418,7 @@ dependencies = [
 [[package]]
 name = "serde-device-tree"
 version = "0.0.1"
-source = "git+https://github.com/woshiluo/serde-device-tree?branch=aliases#2f51fdf7fbe3ed394af41d83652c45f8acd51636"
-dependencies = [
- "serde",
-]
-
-[[package]]
-name = "serde-device-tree"
-version = "0.0.1"
-source = "git+https://github.com/rustsbi/serde-device-tree#6d152e0160ff1dadd2f42638c3d85e0d6a2914bf"
+source = "git+https://github.com/rustsbi/serde-device-tree#cffb488e2bb73f0daae1a889813ef21dc6a02450"
 dependencies = [
  "serde",
 ]
@@ -465,9 +457,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
 
 [[package]]
 name = "syn"
-version = "2.0.89"
+version = "2.0.90"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "44d46482f1c1c87acd84dea20c1bf5ebff4c757009ed6bf19cfd36fb10e92c4e"
+checksum = "919d3b74a5dd0ccd15aeb8f93e7006bd9e14c295087c9896a110f490752bcf31"
 dependencies = [
  "proc-macro2",
  "quote",

+ 3 - 4
bench-kernel/scripts/rustsbi-bench-kernel.its

@@ -1,11 +1,11 @@
 /*
- * Configuration to load RustSBI before RustSBI Test Kernel
+ * Configuration to load RustSBI before RustSBI Bench Kernel
  */
- 
+
 /dts-v1/;
 
 / {
-			description = "Configuration to load RustSBI before RustSBI Test Kernel";
+			description = "Configuration to load RustSBI before RustSBI Bench Kernel";
 
 			images {
 				kernel {
@@ -41,4 +41,3 @@
 				};
 		};
 };
-

+ 1 - 1
prototyper/Cargo.toml

@@ -16,7 +16,7 @@ riscv = "0.11.1"
 rustsbi = { version = "0.4.0", features = ["machine"] }
 sbi-spec = { version = "0.0.7", features = ["legacy"] }
 serde = { version = "1.0.202", default-features = false, features = ["derive"] }
-serde-device-tree = { git = "https://github.com/woshiluo/serde-device-tree", branch = "aliases", default-features = false }
+serde-device-tree = { git = "https://github.com/rustsbi/serde-device-tree", default-features = false }
 sifive-test-device = "0.0.0"
 spin = "0.9.8"
 uart16550 = "0.0.1"

+ 6 - 5
prototyper/src/board.rs

@@ -1,11 +1,9 @@
 use aclint::SifiveClint;
 use core::{
-    cell::RefCell,
     fmt::{Display, Formatter, Result},
     ops::Range,
     sync::atomic::{AtomicBool, AtomicPtr, Ordering},
 };
-use serde_device_tree::Dtb;
 use sifive_test_device::SifiveTestDevice;
 use spin::Mutex;
 use uart16550::Uart16550;
@@ -83,8 +81,8 @@ impl Board {
         }
     }
 
-    pub fn init(&mut self, dtb: &RefCell<Dtb>) {
-        self.info_init(dtb);
+    pub fn init(&mut self, fdt_address: usize) {
+        self.info_init(fdt_address);
         self.sbi_init();
         logger::Logger::init().unwrap();
         trap_stack::prepare_for_trap();
@@ -126,7 +124,10 @@ impl Board {
         info!("Console device: {:x?}", self.info.console);
     }
 
-    fn info_init(&mut self, dtb: &RefCell<Dtb>) {
+    fn info_init(&mut self, fdt_address: usize) {
+        let dtb = dt::parse_device_tree(fdt_address).unwrap_or_else(fail::device_tree_format);
+        let dtb = dtb.share();
+
         let root: serde_device_tree::buildin::Node = serde_device_tree::from_raw_mut(&dtb)
             .unwrap_or_else(fail::device_tree_deserialize_root);
         let tree: dt::Tree = root.deserialize();

+ 3 - 5
prototyper/src/main.rs

@@ -41,12 +41,10 @@ extern "C" fn rust_main(_hart_id: usize, opaque: usize, nonstandard_a2: usize) {
     // boot hart task entry.
     if boot_hart_info.is_boot_hart {
         // parse the device tree
-        let fdt_addr = boot_hart_info.fdt_address;
-        let dtb = dt::parse_device_tree(fdt_addr).unwrap_or_else(fail::device_tree_format);
-        let dtb = dtb.share();
+        let fdt_address = boot_hart_info.fdt_address;
 
         unsafe {
-            BOARD.init(&dtb);
+            BOARD.init(fdt_address);
             BOARD.print_board_info();
         }
         firmware::set_pmp(unsafe { BOARD.info.memory_range.as_ref().unwrap() });
@@ -59,7 +57,7 @@ extern "C" fn rust_main(_hart_id: usize, opaque: usize, nonstandard_a2: usize) {
         local_remote_hsm().start(NextStage {
             start_addr: next_addr,
             next_mode: mpp,
-            opaque: fdt_addr,
+            opaque: fdt_address,
         });
 
         info!(

+ 1 - 1
prototyper/src/sbi/early_trap.rs

@@ -1,7 +1,7 @@
 use core::arch::asm;
 
 /// When you expected some insts will cause trap, use this.
-/// If trap happend, a0 will set to 1, otherwise will be 0.
+/// If trap happened, a0 will set to 1, otherwise will be 0.
 ///
 /// This function will change a0 and a1 and will NOT change them back.
 #[naked]

+ 2 - 2
prototyper/src/sbi/ipi.rs

@@ -79,7 +79,7 @@ impl<T: IpiDevice> rustsbi::Ipi for SbiIpi<T> {
             // There are 2 situation to return invalid_param:
             // 1. We can not get hsm, which usually means this hart_id is bigger than MAX_HART_ID.
             // 2. BOARD hasn't init or this hart_id is not enabled by device tree.
-            // In the next loop, we'll assume that all of above situation will not happend and
+            // In the next loop, we'll assume that all of above situation will not happened and
             // directly send ipi.
             let Some(hsm) = remote_hsm(hart_id) else {
                 return SbiRet::invalid_param();
@@ -140,7 +140,7 @@ impl<T: IpiDevice> SbiIpi<T> {
             // There are 2 situation to return invalid_param:
             // 1. We can not get hsm, which usually means this hart_id is bigger than MAX_HART_ID.
             // 2. BOARD hasn't init or this hart_id is not enabled by device tree.
-            // In the next loop, we'll assume that all of above situation will not happend and
+            // In the next loop, we'll assume that all of above situation will not happened and
             // directly send ipi.
             let Some(hsm) = remote_hsm(hart_id) else {
                 return SbiRet::invalid_param();

+ 1 - 1
xtask/src/utils/mod.rs

@@ -1,4 +1,4 @@
-pub mod cargo; 
+pub mod cargo;
 
 #[macro_use]
 pub mod envs;