diff --git a/CHANGELOG.md b/CHANGELOG.md index 194a147..e425bb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Modified -- Use instance based RustSBI interface, with separate functions for legacy stdio +- Use derive macro based RustSBI interface, with separate functions for legacy stdio - Update sbi-testing to version 0.0.1 - Update sbi-spec to version 0.0.6 - Use crate *fast-trap* version 0.0.1 in rustsbi-qemu for trap handling diff --git a/Cargo.lock b/Cargo.lock index 1693214..08b0c0b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,48 +10,47 @@ checksum = "8a01ba40421eca6c4f1afcedd8465fba6d9e5ef8e0e13060d0141e4cded4ab4a" [[package]] name = "anstream" -version = "0.3.2" +version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" +checksum = "d664a92ecae85fd0a7392615844904654d1d5f5514837f471ddef4a057aba1b6" dependencies = [ "anstyle", "anstyle-parse", "anstyle-query", "anstyle-wincon", "colorchoice", - "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "1.0.1" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" +checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" [[package]] name = "anstyle-parse" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" +checksum = "c75ac65da39e5fe5ab759307499ddad880d724eed2f6ce5b5e8a26f4f387928c" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.0.0" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +checksum = "e28923312444cdd728e4738b3f9c9cac739500909bb3d3c94b43551b16517648" dependencies = [ "windows-sys", ] [[package]] name = "anstyle-wincon" -version = "1.0.1" +version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" +checksum = "1cd54b81ec8d6180e24654d0b371ad22fc3dd083b6ff8ba325b72e00c87660a7" dependencies = [ "anstyle", "windows-sys", @@ -79,34 +78,21 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" -[[package]] -name = "bitflags" -version = "2.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" - -[[package]] -name = "cc" -version = "1.0.79" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" - [[package]] name = "clap" -version = "4.3.19" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" +checksum = "dcfab8ba68f3668e89f6ff60f5b205cea56aa7b769451a59f34b8682f51c056d" dependencies = [ "clap_builder", "clap_derive", - "once_cell", ] [[package]] name = "clap_builder" -version = "4.3.19" +version = "4.4.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" +checksum = "fb7fb5e4e979aec3be7791562fcba452f94ad85e954da024396433e0e25a79e9" dependencies = [ "anstream", "anstyle", @@ -116,9 +102,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.3.12" +version = "4.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" +checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" dependencies = [ "heck", "proc-macro2", @@ -128,9 +114,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" +checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "colorchoice" @@ -140,9 +126,9 @@ checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "critical-section" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6548a0ad5d2549e111e1f6a11a6c2e2d00ce6a3dafe22948d67c2b443f775e52" +checksum = "7059fff8937831a9ae6f0fe4d658ffabf58f2ca96aa9dec1c889f936f705f216" [[package]] name = "dtb-walker" @@ -160,27 +146,6 @@ dependencies = [ "void", ] -[[package]] -name = "errno" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" -dependencies = [ - "errno-dragonfly", - "libc", - "windows-sys", -] - -[[package]] -name = "errno-dragonfly" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" -dependencies = [ - "cc", - "libc", -] - [[package]] name = "fast-trap" version = "0.0.1" @@ -193,47 +158,18 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" - [[package]] name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.7-alpha.3", ] -[[package]] -name = "is-terminal" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" -dependencies = [ - "hermit-abi", - "rustix", - "windows-sys", -] - -[[package]] -name = "libc" -version = "0.2.147" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" - -[[package]] -name = "linux-raw-sys" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" - [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -241,9 +177,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.19" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" +checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "nb" @@ -262,9 +198,9 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "once_cell" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" [[package]] name = "os-xtask-utils" @@ -277,18 +213,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.66" +version = "1.0.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" +checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.32" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" +checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] @@ -315,30 +251,27 @@ dependencies = [ ] [[package]] -name = "rustix" -version = "0.38.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" +name = "rustsbi" +version = "0.4.0-alpha.1" +source = "git+https://github.com/rustsbi/rustsbi?rev=4c40cd#4c40cdce2de8d92d69e7ea200e51fdc23c9635fe" dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", + "riscv", + "rustsbi-macros", + "sbi-spec 0.0.7-alpha.3", ] [[package]] -name = "rustsbi" -version = "0.4.0-alpha.1" -source = "git+https://github.com/rustsbi/rustsbi?rev=8ebabe#8ebabe32dde74937336a7bc3e94e86a3c561a89c" +name = "rustsbi-macros" +version = "0.0.0" +source = "git+https://github.com/rustsbi/rustsbi?rev=4c40cd#4c40cdce2de8d92d69e7ea200e51fdc23c9635fe" dependencies = [ - "riscv", - "sbi-spec", + "quote", + "syn", ] [[package]] name = "rustsbi-qemu" -version = "0.2.0-alpha.2" +version = "0.2.0-alpha.3" dependencies = [ "aclint", "dtb-walker", @@ -347,7 +280,7 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec", + "sbi-spec 0.0.7-alpha.3", "sifive-test-device", "spin", "uart16550", @@ -355,11 +288,11 @@ dependencies = [ [[package]] name = "sbi-rt" -version = "0.0.3-rc.2" +version = "0.0.3-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51b12f0874f198deb881f5b8fde188dd4dee48a72b15bdc733ca4b891ede37a" +checksum = "16fd1c8d9255a1cc094f2dde32da32dbae1ab945656a684b168bf75ed5dccbb6" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.7-alpha.3", ] [[package]] @@ -371,6 +304,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sbi-spec" +version = "0.0.7-alpha.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c890910c48a523b53b7cb0a27f20d169facd2281a2cae2220cddd314c7bee951" +dependencies = [ + "static_assertions", +] + [[package]] name = "sbi-testing" version = "0.0.2" @@ -379,7 +321,7 @@ dependencies = [ "log", "riscv", "sbi-rt", - "sbi-spec", + "sbi-spec 0.0.6", ] [[package]] @@ -417,9 +359,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.27" +version = "2.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" +checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e" dependencies = [ "proc-macro2", "quote", @@ -447,9 +389,9 @@ checksum = "939f6f9ccad815fe3efca8fd06f2ec1620c0387fb1bca2b231b61ce710bffb9b" [[package]] name = "unicode-ident" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] name = "utf8parse" @@ -465,18 +407,18 @@ checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" [[package]] name = "windows-sys" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.48.1" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" +checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -489,45 +431,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" +checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" [[package]] name = "windows_aarch64_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" +checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" [[package]] name = "windows_i686_gnu" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" +checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" [[package]] name = "windows_i686_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" +checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" [[package]] name = "windows_x86_64_gnu" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" +checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" [[package]] name = "windows_x86_64_gnullvm" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" +checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" [[package]] name = "windows_x86_64_msvc" -version = "0.48.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" +checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "xtask" diff --git a/Cargo.toml b/Cargo.toml index 26bebab..6b1b227 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,3 +2,6 @@ members = ["rustsbi-qemu", "hsm-cell", "test-kernel", "bench-kernel", "xtask"] default-members = ["xtask"] resolver = "2" + +[profile.release] +opt-level = 3 diff --git a/bench-kernel/Cargo.toml b/bench-kernel/Cargo.toml index 1f3bdc5..376bd62 100644 --- a/bench-kernel/Cargo.toml +++ b/bench-kernel/Cargo.toml @@ -8,7 +8,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-rt = "0.0.3-rc.2" +sbi-rt = "0.0.3-rc.5" riscv = "0.10.1" uart16550 = "0.0.1" rcore-console = "0.0.0" diff --git a/hsm-cell/Cargo.toml b/hsm-cell/Cargo.toml index 4a5cc56..e357157 100644 --- a/hsm-cell/Cargo.toml +++ b/hsm-cell/Cargo.toml @@ -6,4 +6,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-spec = "0.0.6" +sbi-spec = "0.0.7-alpha.3" + +[lib] +name = "hsm_cell" +test = false +bench = false diff --git a/hsm-cell/src/lib.rs b/hsm-cell/src/lib.rs index 1a009ae..75e9a81 100644 --- a/hsm-cell/src/lib.rs +++ b/hsm-cell/src/lib.rs @@ -31,7 +31,7 @@ impl HsmCell { /// 创建一个新的共享对象。 pub const fn new() -> Self { Self { - status: AtomicUsize::new(HART_STATE_STOPPED), + status: AtomicUsize::new(hart_state::STOPPED), val: UnsafeCell::new(None), } } @@ -59,8 +59,8 @@ impl LocalHsmCell<'_, T> { pub fn start(&self) -> Result { loop { match self.0.status.compare_exchange( - HART_STATE_START_PENDING, - HART_STATE_STARTED, + hart_state::START_PENDING, + hart_state::STARTED, Ordering::AcqRel, Ordering::Relaxed, ) { @@ -74,19 +74,21 @@ impl LocalHsmCell<'_, T> { /// 关闭。 #[inline] pub fn stop(&self) { - self.0.status.store(HART_STATE_STOPPED, Ordering::Release) + self.0.status.store(hart_state::STOPPED, Ordering::Release) } /// 关闭。 #[inline] pub fn suspend(&self) { - self.0.status.store(HART_STATE_SUSPENDED, Ordering::Relaxed) + self.0 + .status + .store(hart_state::SUSPENDED, Ordering::Relaxed) } /// 关闭。 #[inline] pub fn resume(&self) { - self.0.status.store(HART_STATE_STARTED, Ordering::Relaxed) + self.0.status.store(hart_state::STARTED, Ordering::Relaxed) } } @@ -98,7 +100,7 @@ impl RemoteHsmCell<'_, T> { .0 .status .compare_exchange( - HART_STATE_STOPPED, + hart_state::STOPPED, HART_STATE_START_PENDING_EXT, Ordering::Acquire, Ordering::Relaxed, @@ -108,7 +110,7 @@ impl RemoteHsmCell<'_, T> { unsafe { *self.0.val.get() = Some(t) }; self.0 .status - .store(HART_STATE_START_PENDING, Ordering::Release); + .store(hart_state::START_PENDING, Ordering::Release); true } else { false @@ -119,7 +121,7 @@ impl RemoteHsmCell<'_, T> { #[inline] pub fn sbi_get_status(&self) -> usize { match self.0.status.load(Ordering::Relaxed) { - HART_STATE_START_PENDING_EXT => HART_STATE_START_PENDING, + HART_STATE_START_PENDING_EXT => hart_state::START_PENDING, normal => normal, } } @@ -129,7 +131,7 @@ impl RemoteHsmCell<'_, T> { pub fn allow_ipi(&self) -> bool { matches!( self.0.status.load(Ordering::Relaxed), - HART_STATE_STARTED | HART_STATE_SUSPENDED + hart_state::STARTED | hart_state::SUSPENDED ) } } diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 9ef7265..e02470d 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustsbi-qemu" description = "RustSBI support package for QEMU" -version = "0.2.0-alpha.2" +version = "0.2.0-alpha.3" authors = [ "Luo Jia ", "YdrMaster ", @@ -17,10 +17,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "8ebabe", features = [ +rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "4c40cd", features = [ "machine", ] } -sbi-spec = { version = "0.0.6", features = ["legacy"] } +sbi-spec = { version = "0.0.7-alpha.3", features = ["legacy"] } riscv = "0.10.1" spin = "0.9" rcore-console = "0.0.0" diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index d0eac21..2e2c58b 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -28,14 +28,13 @@ extern crate rcore_console; use constants::*; use core::{ arch::asm, - convert::Infallible, mem::MaybeUninit, sync::atomic::{AtomicBool, Ordering}, }; use device_tree::BoardInfo; use fast_trap::{FastContext, FastResult}; use riscv_spec::*; -use rustsbi::{spec::binary::SbiRet, RustSBI}; +use rustsbi::{RustSBI, SbiRet}; use spin::Once; use trap_stack::{local_hsm, local_remote_hsm, remote_hsm}; use trap_vec::trap_vec; @@ -92,7 +91,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { // 打印启动信息 print!( "\ -[rustsbi] RustSBI version {ver_sbi}, adapting to RISC-V SBI v1.0.0 +[rustsbi] RustSBI version {ver_sbi}, adapting to RISC-V SBI v2.0.0 {logo} [rustsbi] Implementation : RustSBI-QEMU Version {ver_impl} [rustsbi] Platform Name : {model} @@ -114,15 +113,12 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { ); // 初始化 SBI unsafe { - SBI = MaybeUninit::new( - rustsbi::Builder::new_machine() - .with_ipi(&clint::Clint) - .with_timer(&clint::Clint) - .with_hsm(Hsm) - .with_reset(qemu_test::get()) - .with_console(dbcn::get()) - .build(), - ); + SBI = MaybeUninit::new(FixedRustSBI { + clint: &clint::Clint, + hsm: Hsm, + reset: qemu_test::get(), + dbcn: dbcn::get(), + }); } // 设置并打印 pmp set_pmp(board_info); @@ -237,10 +233,7 @@ extern "C" fn fast_handler( (hsm::EID_HSM, hsm::HART_STOP) => continue, // 不可恢复挂起 (hsm::EID_HSM, hsm::HART_SUSPEND) - if matches!( - ctx.a0() as u32, - hsm::HART_SUSPEND_TYPE_NON_RETENTIVE - ) => + if matches!(ctx.a0() as u32, hsm::suspend_type::NON_RETENTIVE) => { break boot(ctx, a1, a2); } @@ -346,17 +339,14 @@ impl rcore_console::Console for Console { static mut SBI: MaybeUninit = MaybeUninit::uninit(); -type FixedRustSBI<'a> = RustSBI< - &'a clint::Clint, - &'a clint::Clint, - Infallible, - Hsm, - &'a qemu_test::QemuTest, - Infallible, - &'a dbcn::DBCN, - Infallible, - Infallible, ->; +#[derive(RustSBI)] +struct FixedRustSBI<'a> { + #[rustsbi(ipi, timer)] + clint: &'a clint::Clint, + hsm: Hsm, + reset: &'a qemu_test::QemuTest, + dbcn: &'a dbcn::DBCN, +} struct Hsm; @@ -390,11 +380,8 @@ impl rustsbi::Hsm for Hsm { } fn hart_suspend(&self, suspend_type: u32, _resume_addr: usize, _opaque: usize) -> SbiRet { - use rustsbi::spec::hsm::{HART_SUSPEND_TYPE_NON_RETENTIVE, HART_SUSPEND_TYPE_RETENTIVE}; - if matches!( - suspend_type, - HART_SUSPEND_TYPE_NON_RETENTIVE | HART_SUSPEND_TYPE_RETENTIVE - ) { + use rustsbi::spec::hsm::suspend_type::{NON_RETENTIVE, RETENTIVE}; + if matches!(suspend_type, NON_RETENTIVE | RETENTIVE) { local_hsm().suspend(); unsafe { riscv::asm::wfi() }; local_hsm().resume(); diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index b9fd041..03810fc 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -9,6 +9,6 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -clap = { version = "4.3", features = ["derive"] } +clap = { version = "4.4", features = ["derive"] } os-xtask-utils = "0.0.0" once_cell = "1.18"