From cddd08b08567e977316fa29f5362510f1207dcd6 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 20 Feb 2023 14:51:50 +0800 Subject: [PATCH 01/12] build: update deps Signed-off-by: YdrMaster --- Cargo.lock | 89 ++++++++++++++++++++++++++--------------- bench-kernel/Cargo.toml | 2 +- rustsbi-qemu/Cargo.toml | 4 +- 3 files changed, 59 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1bb0314..73a6a67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,7 +20,7 @@ version = "0.0.1" dependencies = [ "rcore-console", "riscv", - "sbi-rt", + "sbi-rt 0.0.3-rc.1", "uart_16550", ] @@ -50,9 +50,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.4" +version = "4.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f13b9c79b5d1dd500d20ef541215a6423c75829ef43117e1b4d17fd8af0b5d76" +checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" dependencies = [ "bitflags", "clap_derive", @@ -136,31 +136,28 @@ checksum = "7fbe69badc2e0dc98ad2787648fa140b5772d24b49e9a6b180a67e1348f7544c" [[package]] name = "heck" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.2.6" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" -dependencies = [ - "libc", -] +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.4", ] [[package]] name = "io-lifetimes" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7d6c6f8c91b4b9ed43484ad1a938e393caf35960fce7f82a040497207bd8e9e" +checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" dependencies = [ "libc", "windows-sys", @@ -168,9 +165,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" +checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" dependencies = [ "hermit-abi", "io-lifetimes", @@ -226,9 +223,9 @@ checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" [[package]] name = "once_cell" -version = "1.17.0" +version = "1.17.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" [[package]] name = "os-xtask-utils" @@ -271,9 +268,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.50" +version = "1.0.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ef7d57beacfaf2d8aee5937dab7b7f28de3cb8b1828479bb5de2a7106f2bae2" +checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" dependencies = [ "unicode-ident", ] @@ -310,9 +307,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.7" +version = "0.36.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4fdebc4b395b7fbb9ab11e462e20ed9051e7b16e42d24042c776eca0ac81b03" +checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" dependencies = [ "bitflags", "errno", @@ -324,12 +321,11 @@ dependencies = [ [[package]] name = "rustsbi" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92aa8dfaaa1376f99da2979fc8393137c1b8a4aa6023369191e179c420e9487d" +version = "0.3.2-rc.1" +source = "git+https://github.com/rustsbi/rustsbi?rev=7118c8c#7118c8cb2aca28b9b64d298731b1c81322eaa93d" dependencies = [ "riscv", - "sbi-spec", + "sbi-spec 0.0.5", ] [[package]] @@ -343,7 +339,7 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec", + "sbi-spec 0.0.5", "sifive-test-device", "spin", "uart_16550", @@ -361,7 +357,16 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c113c53291db8ac141e01f43224ed488b8d6001ab66737b82e04695a43a42b7" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.4", +] + +[[package]] +name = "sbi-rt" +version = "0.0.3-rc.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4434f94ae7a9e42d3292a9552ca6ef6ac774918859626d5e1259096755c04683" +dependencies = [ + "sbi-spec 0.0.5", ] [[package]] @@ -373,6 +378,15 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sbi-spec" +version = "0.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a535b1f16d5517a020539569f7e37e61fad35ed0d5352f9fd7073304e2f2dc72" +dependencies = [ + "static_assertions", +] + [[package]] name = "sbi-testing" version = "0.0.2" @@ -380,8 +394,8 @@ source = "git+https://github.com/rustsbi/sbi-testing?rev=7a5e920#7a5e9204f62f9cf dependencies = [ "log", "riscv", - "sbi-rt", - "sbi-spec", + "sbi-rt 0.0.2", + "sbi-spec 0.0.4", ] [[package]] @@ -398,9 +412,9 @@ checksum = "ba50a6fd7cb5cdb2645fb93fb2bbae7d8d78390677a889bdcfaf13c3d29286d0" [[package]] name = "spin" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" dependencies = [ "lock_api", ] @@ -518,9 +532,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.42.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", diff --git a/bench-kernel/Cargo.toml b/bench-kernel/Cargo.toml index 3f264d7..315baaf 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.2" +sbi-rt = "0.0.3-rc.1" riscv = "0.10.1" uart_16550 = "0.2" rcore-console = "0.0.0" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 7039b45..9cb59ab 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -17,8 +17,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustsbi = "0.3.1" -sbi-spec = { version = "0.0.4", features = ["legacy"] } +rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "7118c8c" } +sbi-spec = { version = "0.0.5", features = ["legacy"] } riscv = "0.10.1" spin = "0.9" uart_16550 = "0.2" From 63b738e2ea1710ff06636afda379f793e2f5efd3 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 20 Feb 2023 16:46:27 +0800 Subject: [PATCH 02/12] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=20DBCN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YdrMaster --- Cargo.lock | 5 ++-- rustsbi-qemu/Cargo.toml | 2 +- rustsbi-qemu/src/dbcn.rs | 58 ++++++++++++++++++++++++++++++++++++++++ rustsbi-qemu/src/main.rs | 4 +++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 rustsbi-qemu/src/dbcn.rs diff --git a/Cargo.lock b/Cargo.lock index 73a6a67..a17615e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -321,8 +321,9 @@ dependencies = [ [[package]] name = "rustsbi" -version = "0.3.2-rc.1" -source = "git+https://github.com/rustsbi/rustsbi?rev=7118c8c#7118c8cb2aca28b9b64d298731b1c81322eaa93d" +version = "0.3.2-rc.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97f4052d1eb0f283b1b781a9b89a5fa4ed332ea31e2343e34372c61188664724" dependencies = [ "riscv", "sbi-spec 0.0.5", diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 9cb59ab..64f0576 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -17,7 +17,7 @@ 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 = "7118c8c" } +rustsbi = { version = "0.3.2-rc.2", features = ["sbi_2_0"] } sbi-spec = { version = "0.0.5", features = ["legacy"] } riscv = "0.10.1" spin = "0.9" diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs new file mode 100644 index 0000000..18c441c --- /dev/null +++ b/rustsbi-qemu/src/dbcn.rs @@ -0,0 +1,58 @@ +use crate::UART; +use core::ops::Range; +use rustsbi::{spec::binary::SbiRet, Console, Physical}; +use spin::Once; + +pub(crate) struct DBCN(Range); + +static INSTANCE: Once = Once::new(); + +pub(crate) fn init(memory: Range) { + INSTANCE.call_once(|| DBCN(memory)); +} + +pub(crate) fn get() -> &'static DBCN { + INSTANCE.wait() +} + +impl Console for DBCN { + fn write(&self, bytes: Physical<&[u8]>) -> SbiRet { + let start = bytes.phys_addr_lo(); + let end = start + bytes.num_bytes(); + if self.0.contains(&start) && self.0.contains(&(end - 1)) { + let mut uart = UART.lock(); + let uart = unsafe { uart.assume_init_mut() }; + for ptr in start..end { + let c = ptr as *const u8; + unsafe { uart.send(c.read_volatile()) }; + } + SbiRet::success(bytes.num_bytes()) + } else { + SbiRet::invalid_param() + } + } + + fn read(&self, bytes: Physical<&mut [u8]>) -> SbiRet { + let start = bytes.phys_addr_lo(); + let end = start + bytes.num_bytes(); + if self.0.contains(&start) && self.0.contains(&(end - 1)) { + let mut uart = UART.lock(); + let uart = unsafe { uart.assume_init_mut() }; + for ptr in start..end { + let c = ptr as *mut u8; + unsafe { c.write_volatile(uart.receive()) }; + } + SbiRet::success(bytes.num_bytes()) + } else { + SbiRet::invalid_param() + } + } + + #[inline] + fn write_byte(&self, byte: u8) -> SbiRet { + let mut uart = UART.lock(); + let uart = unsafe { uart.assume_init_mut() }; + uart.send(byte); + SbiRet::success(0) + } +} diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index f17239b..8ee834b 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -4,6 +4,7 @@ #![deny(warnings)] mod clint; +mod dbcn; mod device_tree; mod hart_csr_utils; mod qemu_test; @@ -87,6 +88,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { rcore_console::set_log_level(option_env!("LOG")); clint::init(board_info.clint.start); qemu_test::init(board_info.test.start); + dbcn::init(SUPERVISOR_ENTRY..board_info.mem.end); // 打印启动信息 print!( "\ @@ -118,6 +120,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { .with_timer(&clint::Clint) .with_hsm(Hsm) .with_reset(qemu_test::get()) + .with_console(dbcn::get()) .build(), ); } @@ -340,6 +343,7 @@ type FixedRustSBI<'a> = RustSBI< Hsm, &'a qemu_test::QemuTest, Infallible, + &'a dbcn::DBCN, >; struct Hsm; From 7b3e0cbdd75f43eabfbc1cbe602dfd3c49353ee6 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 13 Mar 2023 11:00:18 +0800 Subject: [PATCH 03/12] build: update deps Signed-off-by: YdrMaster --- Cargo.lock | 97 ++++++++++++++++------------------------ hsm-cell/Cargo.toml | 2 +- rustsbi-qemu/Cargo.toml | 4 +- rustsbi-qemu/src/dbcn.rs | 4 +- rustsbi-qemu/src/main.rs | 5 ++- test-kernel/Cargo.toml | 2 +- test-kernel/src/main.rs | 9 ++-- 7 files changed, 56 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a17615e..54458c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,15 +20,15 @@ version = "0.0.1" dependencies = [ "rcore-console", "riscv", - "sbi-rt 0.0.3-rc.1", + "sbi-rt", "uart_16550", ] [[package]] name = "bit_field" -version = "0.10.1" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" [[package]] name = "bitflags" @@ -50,9 +50,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.6" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0b0588d44d4d63a87dbd75c136c166bbfd9a86a31cb89e09906521c7d3f5e3" +checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" dependencies = [ "bitflags", "clap_derive", @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.0" +version = "4.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "684a277d672e91966334af371f1a7b5833f9aa00b07c84e92fbce95e00208ce8" +checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" dependencies = [ "heck", "proc-macro-error", @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "783fe232adfca04f90f56201b26d79682d4cd2625e0bc7290b95123afe558ade" +checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" dependencies = [ "os_str_bytes", ] @@ -150,14 +150,14 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec 0.0.4", + "sbi-spec", ] [[package]] name = "io-lifetimes" -version = "1.0.5" +version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1abeb7a0dd0f8181267ff8adc397075586500b81b28a73e8a0208b00fc170fb3" +checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" dependencies = [ "libc", "windows-sys", @@ -165,9 +165,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22e18b0a45d56fe973d6db23972bf5bc46f988a4a2385deac9cc29572f09daef" +checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" dependencies = [ "hermit-abi", "io-lifetimes", @@ -177,9 +177,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.139" +version = "0.2.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" +checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "linux-raw-sys" @@ -212,14 +212,14 @@ version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "801d31da0513b6ec5214e9bf433a77966320625a37860f910be265be6e18d06f" dependencies = [ - "nb 1.0.0", + "nb 1.1.0", ] [[package]] name = "nb" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546c37ac5d9e56f55e73b677106873d9d9f5190605e41a856503623648488cae" +checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "once_cell" @@ -268,18 +268,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.23" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5308e8208729c3e1504a6cfad0d5daacc4614c9a2e65d1ea312a34b5cb00fe84" dependencies = [ "proc-macro2", ] @@ -307,9 +307,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.8" +version = "0.36.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f43abb88211988493c1abb44a70efa56ff0ce98f233b7b276146f1f3f7ba9644" +checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" dependencies = [ "bitflags", "errno", @@ -321,12 +321,11 @@ dependencies = [ [[package]] name = "rustsbi" -version = "0.3.2-rc.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97f4052d1eb0f283b1b781a9b89a5fa4ed332ea31e2343e34372c61188664724" +version = "0.4.0-alpha.1" +source = "git+https://github.com/rustsbi/rustsbi?rev=91cfa36#91cfa36d14b81af3874ba1da2c0663b5bd601fa3" dependencies = [ "riscv", - "sbi-spec 0.0.5", + "sbi-spec", ] [[package]] @@ -340,7 +339,7 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec 0.0.5", + "sbi-spec", "sifive-test-device", "spin", "uart_16550", @@ -348,18 +347,9 @@ dependencies = [ [[package]] name = "rustversion" -version = "1.0.11" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5583e89e108996506031660fe09baa5011b9dd0341b89029313006d1fb508d70" - -[[package]] -name = "sbi-rt" -version = "0.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c113c53291db8ac141e01f43224ed488b8d6001ab66737b82e04695a43a42b7" -dependencies = [ - "sbi-spec 0.0.4", -] +checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" [[package]] name = "sbi-rt" @@ -367,16 +357,7 @@ version = "0.0.3-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4434f94ae7a9e42d3292a9552ca6ef6ac774918859626d5e1259096755c04683" dependencies = [ - "sbi-spec 0.0.5", -] - -[[package]] -name = "sbi-spec" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d4027cf9bb591a9fd0fc0e283be6165c5abe96cb73e9f0e24738c227f425377" -dependencies = [ - "static_assertions", + "sbi-spec", ] [[package]] @@ -391,12 +372,12 @@ dependencies = [ [[package]] name = "sbi-testing" version = "0.0.2" -source = "git+https://github.com/rustsbi/sbi-testing?rev=7a5e920#7a5e9204f62f9cf3c4dcb7a033371dd347bbc8a4" +source = "git+https://github.com/rustsbi/sbi-testing?rev=02aef6d#02aef6d0729291bad07c95bfdff35eef462edb4c" dependencies = [ "log", "riscv", - "sbi-rt 0.0.2", - "sbi-spec 0.0.4", + "sbi-rt", + "sbi-spec", ] [[package]] @@ -434,9 +415,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.107" +version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ "proc-macro2", "quote", @@ -478,9 +459,9 @@ dependencies = [ [[package]] name = "unicode-ident" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "version_check" diff --git a/hsm-cell/Cargo.toml b/hsm-cell/Cargo.toml index 350a150..7da69b6 100644 --- a/hsm-cell/Cargo.toml +++ b/hsm-cell/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-spec = "0.0.4" +sbi-spec = "0.0.5" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 64f0576..fe092c1 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -17,7 +17,9 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustsbi = { version = "0.3.2-rc.2", features = ["sbi_2_0"] } +rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "91cfa36", features = [ + "machine", +] } sbi-spec = { version = "0.0.5", features = ["legacy"] } riscv = "0.10.1" spin = "0.9" diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs index 18c441c..52a044d 100644 --- a/rustsbi-qemu/src/dbcn.rs +++ b/rustsbi-qemu/src/dbcn.rs @@ -1,4 +1,6 @@ -use crate::UART; +#![allow(unused)] + +use crate::UART; use core::ops::Range; use rustsbi::{spec::binary::SbiRet, Console, Physical}; use spin::Once; diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index 8ee834b..ea7667f 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -120,7 +120,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { .with_timer(&clint::Clint) .with_hsm(Hsm) .with_reset(qemu_test::get()) - .with_console(dbcn::get()) + // .with_console(dbcn::get()) .build(), ); } @@ -343,7 +343,8 @@ type FixedRustSBI<'a> = RustSBI< Hsm, &'a qemu_test::QemuTest, Infallible, - &'a dbcn::DBCN, + Infallible, + // &'a dbcn::DBCN, >; struct Hsm; diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 2b798c8..55e9c33 100644 --- a/test-kernel/Cargo.toml +++ b/test-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-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "7a5e920", features = [ +sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "02aef6d", features = [ "log", ] } log = "0.4.17" diff --git a/test-kernel/src/main.rs b/test-kernel/src/main.rs index b603d95..2186889 100644 --- a/test-kernel/src/main.rs +++ b/test-kernel/src/main.rs @@ -70,14 +70,17 @@ extern "C" fn rust_main(hartid: usize, dtb_pa: usize) -> ! { | dtb physical address | {dtb_pa:#20x} | ------------------------------------------------" ); - sbi_testing::Testing { + let testing = sbi_testing::Testing { hartid, hart_mask: (1 << smp) - 1, hart_mask_base: 0, delay: frequency, + }; + if testing.test() { + sbi::system_reset(sbi::Shutdown, sbi::NoReason); + } else { + sbi::system_reset(sbi::Shutdown, sbi::SystemFailure); } - .test(); - sbi::system_reset(sbi::Shutdown, sbi::NoReason); unreachable!() } From 736273e041ff76598a5c948ea536fac3d2c1c05b Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 20 Mar 2023 11:26:14 +0800 Subject: [PATCH 04/12] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=20DBCN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 一个简单的支持非阻塞读写的 16550 驱动 Signed-off-by: YdrMaster --- Cargo.lock | 86 +++++++++++++++++++---------------- rustsbi-qemu/Cargo.toml | 1 - rustsbi-qemu/src/dbcn.rs | 31 +++++++------ rustsbi-qemu/src/main.rs | 36 +++++++++------ rustsbi-qemu/src/uart16550.rs | 55 ++++++++++++++++++++++ test-kernel/Cargo.toml | 2 +- 6 files changed, 141 insertions(+), 70 deletions(-) create mode 100644 rustsbi-qemu/src/uart16550.rs diff --git a/Cargo.lock b/Cargo.lock index 54458c6..abe8924 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,6 +36,12 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +[[package]] +name = "bitflags" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" + [[package]] name = "cc" version = "1.0.79" @@ -50,11 +56,11 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.8" +version = "4.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d7ae14b20b94cb02149ed21a86c423859cbe18dc7ed69845cace50e52b40a5" +checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" dependencies = [ - "bitflags", + "bitflags 2.0.2", "clap_derive", "clap_lex", "is-terminal", @@ -65,9 +71,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.8" +version = "4.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44bec8e5c9d09e439c4335b1af0abaab56dcf3b94999a936e1bb47b9134288f0" +checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" dependencies = [ "heck", "proc-macro-error", @@ -78,9 +84,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.3.2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "350b9cf31731f9957399229e9b2adc51eeabdfbe9d71d9a0552275fd12710d09" +checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" dependencies = [ "os_str_bytes", ] @@ -155,19 +161,20 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.6" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cfa919a82ea574332e2de6e74b4c36e74d41982b335080fa59d4ef31be20fdf3" +checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155" dependencies = [ + "hermit-abi", "libc", "windows-sys", ] [[package]] name = "is-terminal" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857" +checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" dependencies = [ "hermit-abi", "io-lifetimes", @@ -238,9 +245,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.4.1" +version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" +checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" [[package]] name = "proc-macro-error" @@ -277,9 +284,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5308e8208729c3e1504a6cfad0d5daacc4614c9a2e65d1ea312a34b5cb00fe84" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" dependencies = [ "proc-macro2", ] @@ -307,11 +314,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.9" +version = "0.36.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd5c6ff11fecd55b40746d1995a02f2eb375bf8c00d192d521ee09f42bef37bc" +checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778" dependencies = [ - "bitflags", + "bitflags 1.3.2", "errno", "io-lifetimes", "libc", @@ -342,7 +349,6 @@ dependencies = [ "sbi-spec", "sifive-test-device", "spin", - "uart_16550", ] [[package]] @@ -372,7 +378,7 @@ dependencies = [ [[package]] name = "sbi-testing" version = "0.0.2" -source = "git+https://github.com/rustsbi/sbi-testing?rev=02aef6d#02aef6d0729291bad07c95bfdff35eef462edb4c" +source = "git+https://github.com/rustsbi/sbi-testing?rev=9bc51a3#9bc51a3991f013f563e5dc00a73e548dcc3c1e84" dependencies = [ "log", "riscv", @@ -394,9 +400,9 @@ checksum = "ba50a6fd7cb5cdb2645fb93fb2bbae7d8d78390677a889bdcfaf13c3d29286d0" [[package]] name = "spin" -version = "0.9.5" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dccf47db1b41fa1573ed27ccf5e08e3ca771cb994f776668c5ebda893b248fc" +checksum = "b5d6e0250b93c8427a177b849d144a96d5acc57006149479403d7861ab721e34" dependencies = [ "lock_api", ] @@ -452,7 +458,7 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" dependencies = [ - "bitflags", + "bitflags 1.3.2", "rustversion", "x86_64", ] @@ -523,9 +529,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -538,45 +544,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" [[package]] name = "windows_aarch64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" [[package]] name = "windows_i686_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" [[package]] name = "windows_i686_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" [[package]] name = "windows_x86_64_gnu" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" [[package]] name = "windows_x86_64_msvc" -version = "0.42.1" +version = "0.42.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" [[package]] name = "x86_64" @@ -585,7 +591,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" dependencies = [ "bit_field", - "bitflags", + "bitflags 1.3.2", "rustversion", "volatile", ] diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index fe092c1..6121f8e 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -23,7 +23,6 @@ rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "91cfa36", feature sbi-spec = { version = "0.0.5", features = ["legacy"] } riscv = "0.10.1" spin = "0.9" -uart_16550 = "0.2" rcore-console = "0.0.0" aclint = "0.0.0" sifive-test-device = "0.0.0" diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs index 52a044d..50e8eea 100644 --- a/rustsbi-qemu/src/dbcn.rs +++ b/rustsbi-qemu/src/dbcn.rs @@ -1,6 +1,6 @@ #![allow(unused)] -use crate::UART; +use crate::uart16550; use core::ops::Range; use rustsbi::{spec::binary::SbiRet, Console, Physical}; use spin::Once; @@ -22,11 +22,12 @@ impl Console for DBCN { let start = bytes.phys_addr_lo(); let end = start + bytes.num_bytes(); if self.0.contains(&start) && self.0.contains(&(end - 1)) { - let mut uart = UART.lock(); - let uart = unsafe { uart.assume_init_mut() }; + let uart = uart16550::UART.lock(); for ptr in start..end { - let c = ptr as *const u8; - unsafe { uart.send(c.read_volatile()) }; + let c = unsafe { (ptr as *const u8).read_volatile() }; + if !uart.get().write(c) { + return SbiRet::success(ptr - start); + } } SbiRet::success(bytes.num_bytes()) } else { @@ -38,11 +39,13 @@ impl Console for DBCN { let start = bytes.phys_addr_lo(); let end = start + bytes.num_bytes(); if self.0.contains(&start) && self.0.contains(&(end - 1)) { - let mut uart = UART.lock(); - let uart = unsafe { uart.assume_init_mut() }; + let uart = uart16550::UART.lock(); for ptr in start..end { - let c = ptr as *mut u8; - unsafe { c.write_volatile(uart.receive()) }; + if let Some(c) = uart.get().read() { + unsafe { (ptr as *mut u8).write_volatile(c) }; + } else { + return SbiRet::success(ptr - start); + } } SbiRet::success(bytes.num_bytes()) } else { @@ -52,9 +55,11 @@ impl Console for DBCN { #[inline] fn write_byte(&self, byte: u8) -> SbiRet { - let mut uart = UART.lock(); - let uart = unsafe { uart.assume_init_mut() }; - uart.send(byte); - SbiRet::success(0) + let uart = uart16550::UART.lock(); + loop { + if uart.get().write(byte) { + return SbiRet::success(0); + } + } } } diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index ea7667f..47095c6 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -11,6 +11,7 @@ mod qemu_test; mod riscv_spec; mod trap_stack; mod trap_vec; +mod uart16550; mod constants { /// 特权软件入口。 @@ -35,10 +36,9 @@ use device_tree::BoardInfo; use fast_trap::{FastContext, FastResult}; use riscv_spec::*; use rustsbi::{spec::binary::SbiRet, RustSBI}; -use spin::{Mutex, Once}; +use spin::Once; use trap_stack::{local_hsm, local_remote_hsm, remote_hsm}; use trap_vec::trap_vec; -use uart_16550::MmioSerialPort; /// 入口。 /// @@ -83,7 +83,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { // 解析设备树 let board_info = BOARD_INFO.call_once(|| device_tree::parse(opaque)); // 初始化外设 - *UART.lock() = MaybeUninit::new(unsafe { MmioSerialPort::new(board_info.uart.start) }); + uart16550::init(board_info.uart.start); rcore_console::init_console(&Console); rcore_console::set_log_level(option_env!("LOG")); clint::init(board_info.clint.start); @@ -120,7 +120,7 @@ extern "C" fn rust_main(hartid: usize, opaque: usize) { .with_timer(&clint::Clint) .with_hsm(Hsm) .with_reset(qemu_test::get()) - // .with_console(dbcn::get()) + .with_console(dbcn::get()) .build(), ); } @@ -262,10 +262,14 @@ extern "C" fn fast_handler( ret.error = 0; ret.value = a1; } - legacy::LEGACY_CONSOLE_GETCHAR => { - ret.error = unsafe { UART.lock().assume_init_mut() }.receive() as _; - ret.value = a1; - } + legacy::LEGACY_CONSOLE_GETCHAR => loop { + let uart = uart16550::UART.lock(); + if let Some(c) = uart.get().read() { + ret.error = c as _; + ret.value = a1; + break; + } + }, _ => {} } } @@ -316,20 +320,23 @@ struct Supervisor { } struct Console; -static UART: Mutex> = Mutex::new(MaybeUninit::uninit()); impl rcore_console::Console for Console { #[inline] fn put_char(&self, c: u8) { - unsafe { UART.lock().assume_init_mut() }.send(c); + let uart = uart16550::UART.lock(); + while !uart.get().write(c) { + core::hint::spin_loop(); + } } #[inline] fn put_str(&self, s: &str) { - let mut uart = UART.lock(); - let uart = unsafe { uart.assume_init_mut() }; + let uart = uart16550::UART.lock(); for c in s.bytes() { - uart.send(c); + while !uart.get().write(c) { + core::hint::spin_loop(); + } } } } @@ -343,8 +350,7 @@ type FixedRustSBI<'a> = RustSBI< Hsm, &'a qemu_test::QemuTest, Infallible, - Infallible, - // &'a dbcn::DBCN, + &'a dbcn::DBCN, >; struct Hsm; diff --git a/rustsbi-qemu/src/uart16550.rs b/rustsbi-qemu/src/uart16550.rs new file mode 100644 index 0000000..6706336 --- /dev/null +++ b/rustsbi-qemu/src/uart16550.rs @@ -0,0 +1,55 @@ +use core::{cell::UnsafeCell, ptr::null}; +use spin::lock_api::Mutex; + +pub(crate) static UART: Mutex = Mutex::new(Uart16550Map(null())); + +pub(crate) fn init(base: usize) { + *UART.lock() = Uart16550Map(base as _); +} + +pub struct Uart16550Map(*const Uart16550); + +unsafe impl Send for Uart16550Map {} +unsafe impl Sync for Uart16550Map {} + +impl Uart16550Map { + #[inline] + pub fn get(&self) -> &Uart16550 { + unsafe { &*self.0 } + } +} + +#[allow(unused)] +pub struct Uart16550 { + data: UnsafeCell, + int_en: UnsafeCell, + fifo_ctrl: UnsafeCell, + line_ctrl: UnsafeCell, + modem_ctrl: UnsafeCell, + line_sts: UnsafeCell, +} + +impl Uart16550 { + pub fn write(&self, data: u8) -> bool { + const OUTPUT_EMPTY: u8 = 1 << 5; + return unsafe { + if self.line_sts.get().read_volatile() & OUTPUT_EMPTY == OUTPUT_EMPTY { + self.data.get().write_volatile(data); + true + } else { + false + } + }; + } + + pub fn read(&self) -> Option { + const INPUT_FULL: u8 = 1; + return unsafe { + if self.line_sts.get().read_volatile() & INPUT_FULL == INPUT_FULL { + Some(self.data.get().read_volatile()) + } else { + None + } + }; + } +} diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 55e9c33..8640fdc 100644 --- a/test-kernel/Cargo.toml +++ b/test-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-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "02aef6d", features = [ +sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "9bc51a3", features = [ "log", ] } log = "0.4.17" From e0f842cea963a7a8dbaf93c80a0cbabcfdf31e36 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 20 Mar 2023 15:35:57 +0800 Subject: [PATCH 05/12] =?UTF-8?q?refactor:=20uart16550=20=E9=A9=B1?= =?UTF-8?q?=E5=8A=A8=E6=8B=86=E5=88=86=E5=88=B0=E5=8D=95=E7=8B=AC=E7=9A=84?= =?UTF-8?q?=E5=BA=93=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YdrMaster --- Cargo.lock | 6 +++++ rustsbi-qemu/Cargo.toml | 1 + rustsbi-qemu/src/dbcn.rs | 24 +++++--------------- rustsbi-qemu/src/main.rs | 25 ++++++++++++--------- rustsbi-qemu/src/uart16550.rs | 42 ++++------------------------------- 5 files changed, 31 insertions(+), 67 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index abe8924..9031ae9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -349,6 +349,7 @@ dependencies = [ "sbi-spec", "sifive-test-device", "spin", + "uart16550", ] [[package]] @@ -452,6 +453,11 @@ dependencies = [ "uart_16550", ] +[[package]] +name = "uart16550" +version = "0.0.0" +source = "git+https://github.com/YdrMaster/uart16550?rev=68ad4d8#68ad4d86dd28b72c72ff132c3efa7457ce5427d8" + [[package]] name = "uart_16550" version = "0.2.18" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 6121f8e..d330eac 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -27,6 +27,7 @@ rcore-console = "0.0.0" aclint = "0.0.0" sifive-test-device = "0.0.0" dtb-walker = "=0.2.0-alpha.3" +uart16550 = { git = "https://github.com/YdrMaster/uart16550", rev = "68ad4d8" } hsm-cell = { path = "../hsm-cell" } fast-trap = { version = "=0.0.1", features = ["riscv-m"] } diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs index 50e8eea..f332f64 100644 --- a/rustsbi-qemu/src/dbcn.rs +++ b/rustsbi-qemu/src/dbcn.rs @@ -22,14 +22,8 @@ impl Console for DBCN { let start = bytes.phys_addr_lo(); let end = start + bytes.num_bytes(); if self.0.contains(&start) && self.0.contains(&(end - 1)) { - let uart = uart16550::UART.lock(); - for ptr in start..end { - let c = unsafe { (ptr as *const u8).read_volatile() }; - if !uart.get().write(c) { - return SbiRet::success(ptr - start); - } - } - SbiRet::success(bytes.num_bytes()) + let buf = unsafe { core::slice::from_raw_parts(start as *const u8, bytes.num_bytes()) }; + SbiRet::success(uart16550::UART.lock().get().write(buf)) } else { SbiRet::invalid_param() } @@ -39,15 +33,9 @@ impl Console for DBCN { let start = bytes.phys_addr_lo(); let end = start + bytes.num_bytes(); if self.0.contains(&start) && self.0.contains(&(end - 1)) { - let uart = uart16550::UART.lock(); - for ptr in start..end { - if let Some(c) = uart.get().read() { - unsafe { (ptr as *mut u8).write_volatile(c) }; - } else { - return SbiRet::success(ptr - start); - } - } - SbiRet::success(bytes.num_bytes()) + let buf = + unsafe { core::slice::from_raw_parts_mut(start as *mut u8, bytes.num_bytes()) }; + SbiRet::success(uart16550::UART.lock().get().read(buf)) } else { SbiRet::invalid_param() } @@ -57,7 +45,7 @@ impl Console for DBCN { fn write_byte(&self, byte: u8) -> SbiRet { let uart = uart16550::UART.lock(); loop { - if uart.get().write(byte) { + if uart.get().write(&[byte]) == 1 { return SbiRet::success(0); } } diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index 47095c6..c56f501 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -262,14 +262,17 @@ extern "C" fn fast_handler( ret.error = 0; ret.value = a1; } - legacy::LEGACY_CONSOLE_GETCHAR => loop { + legacy::LEGACY_CONSOLE_GETCHAR => { + let mut c = 0u8; let uart = uart16550::UART.lock(); - if let Some(c) = uart.get().read() { - ret.error = c as _; - ret.value = a1; - break; + loop { + if uart.get().read(core::slice::from_mut(&mut c)) == 1 { + ret.error = c as _; + ret.value = a1; + break; + } } - }, + } _ => {} } } @@ -325,7 +328,7 @@ impl rcore_console::Console for Console { #[inline] fn put_char(&self, c: u8) { let uart = uart16550::UART.lock(); - while !uart.get().write(c) { + while uart.get().write(&[c]) == 0 { core::hint::spin_loop(); } } @@ -333,10 +336,10 @@ impl rcore_console::Console for Console { #[inline] fn put_str(&self, s: &str) { let uart = uart16550::UART.lock(); - for c in s.bytes() { - while !uart.get().write(c) { - core::hint::spin_loop(); - } + let mut bytes = s.as_bytes(); + while !bytes.is_empty() { + let count = uart.get().write(bytes); + bytes = &bytes[count..]; } } } diff --git a/rustsbi-qemu/src/uart16550.rs b/rustsbi-qemu/src/uart16550.rs index 6706336..1d7e9ca 100644 --- a/rustsbi-qemu/src/uart16550.rs +++ b/rustsbi-qemu/src/uart16550.rs @@ -1,5 +1,6 @@ -use core::{cell::UnsafeCell, ptr::null}; +use core::ptr::null; use spin::lock_api::Mutex; +use uart16550::Uart16550; pub(crate) static UART: Mutex = Mutex::new(Uart16550Map(null())); @@ -7,49 +8,14 @@ pub(crate) fn init(base: usize) { *UART.lock() = Uart16550Map(base as _); } -pub struct Uart16550Map(*const Uart16550); +pub struct Uart16550Map(*const Uart16550); unsafe impl Send for Uart16550Map {} unsafe impl Sync for Uart16550Map {} impl Uart16550Map { #[inline] - pub fn get(&self) -> &Uart16550 { + pub fn get(&self) -> &Uart16550 { unsafe { &*self.0 } } } - -#[allow(unused)] -pub struct Uart16550 { - data: UnsafeCell, - int_en: UnsafeCell, - fifo_ctrl: UnsafeCell, - line_ctrl: UnsafeCell, - modem_ctrl: UnsafeCell, - line_sts: UnsafeCell, -} - -impl Uart16550 { - pub fn write(&self, data: u8) -> bool { - const OUTPUT_EMPTY: u8 = 1 << 5; - return unsafe { - if self.line_sts.get().read_volatile() & OUTPUT_EMPTY == OUTPUT_EMPTY { - self.data.get().write_volatile(data); - true - } else { - false - } - }; - } - - pub fn read(&self) -> Option { - const INPUT_FULL: u8 = 1; - return unsafe { - if self.line_sts.get().read_volatile() & INPUT_FULL == INPUT_FULL { - Some(self.data.get().read_volatile()) - } else { - None - } - }; - } -} From 98869e4cb600f11fe656b419c73b27fb26974ae9 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Tue, 21 Mar 2023 09:33:37 +0800 Subject: [PATCH 06/12] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=20CHANGELOG?= =?UTF-8?q?=EF=BC=8C=E6=95=B4=E7=90=86=20README=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YdrMaster --- CHANGELOG.md | 15 +++-- README.md | 165 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 114 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c7e4fcc..2be44c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,17 +9,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Hint spin loop in hart state monitor module -- Add bench-kernel crate to workspace for sbi call bench +- Add crate *bench-kernel* to workspace for sbi call bench +- Add crate *uart16550* for 16550 define +- Add SBI DBCN extension support ### Modified - Use instance based RustSBI interface, with separate functions for legacy stdio - Update sbi-testing to version 0.0.1 -- Use crate fast-trap version 0.0.1 in rustsbi-qemu for trap handling -- Use crate rcore-console version 0.0.0 in rustsbi-qemu and test-kernel for `print!` and `println!` -- Use crate aclint version 0.0.0 in rustsbi-qemu for aclint structs -- Use crate os-xtask-utils version 0.0.0 in xtask builder -- Use crate sifive-test-device version 0.0.0 instead of qemu-exit +- Update sbi-spec to version 0.0.5 +- Use crate *fast-trap* version 0.0.1 in rustsbi-qemu for trap handling +- Use crate *rcore-console* version 0.0.0 in rustsbi-qemu and test-kernel for `print!` and `println!` +- Use crate *aclint* version 0.0.0 in rustsbi-qemu for aclint structs +- Use crate *os-xtask-utils* version 0.0.0 in xtask builder +- Use crate *sifive-test-device* version 0.0.0 instead of qemu-exit - Use `wfi` for suspend and stop without enable mie ### Fixed diff --git a/README.md b/README.md index 886b496..0b8ab1f 100644 --- a/README.md +++ b/README.md @@ -18,55 +18,100 @@ cargo qemu When running `cargo qemu`, the test kernel will build and run. Expected output should be: -``` -[rustsbi] RustSBI version 0.2.2, adapting to RISC-V SBI v1.0.0 +```plaintext +[rustsbi] RustSBI version 0.4.0-alpha.1, adapting to RISC-V SBI v1.0.0 .______ __ __ _______.___________. _______..______ __ | _ \ | | | | / | | / || _ \ | | | |_) | | | | | | (----`---| |----`| (----`| |_) || | | / | | | | \ \ | | \ \ | _ < | | | |\ \----.| `--' |.----) | | | .----) | | |_) || | | _| `._____| \______/ |_______/ |__| |_______/ |______/ |__| - -[rustsbi] Implementation: RustSBI-QEMU Version 0.1.1 -[rustsbi-dtb] Hart count: cluster0 with 8 cores -[rustsbi] misa: RV64ACDFIMSU -[rustsbi] mideleg: ssoft, stimer, sext (0x222) -[rustsbi] medeleg: ima, ia, bkpt, la, sa, uecall, ipage, lpage, spage (0xb1ab) -[rustsbi] pmp0: 0x10000000 ..= 0x10001fff (rw-) -[rustsbi] pmp1: 0x2000000 ..= 0x200ffff (rw-) -[rustsbi] pmp2: 0xc000000 ..= 0xc3fffff (rw-) -[rustsbi] pmp3: 0x80000000 ..= 0x8fffffff (rwx) -[rustsbi] enter supervisor 0x80200000 -<< Test-kernel: Hart id = 0, DTB physical address = 0x87000000 ->> Test-kernel: Testing base extension -<< Test-kernel: Base extension version: 1 -<< Test-kernel: SBI specification version: 1.0 -<< Test-kernel: SBI implementation Id: 4 -<< Test-kernel: SBI implementation version: 202 -<< Test-kernel: Device mvendorid: 0 -<< Test-kernel: Device marchid: 0 -<< Test-kernel: Device mimpid: 0 ->> Test-kernel: Testing SBI instruction emulation -<< Test-kernel: Current time: d78c9 -<< Test-kernel: Time after operation: da00f ->> Test-kernel: Trigger illegal exception -<< Test-kernel: Value of scause: Exception(IllegalInstruction) -<< Test-kernel: Illegal exception delegate success ->> Stop hart 3, return value 0 ->> Hart 0 state return value: 0 ->> Hart 1 state return value: 4 ->> Hart 2 state return value: 4 ->> Hart 3 state return value: 1 ->> Hart 4 state return value: 0 -<< Test-kernel: test for hart 0 success, wake another hart ->> Wake hart 1, sbi return value 0 ->> Start test for hart 1, retentive suspend return value 0 ->> Wake hart 2, sbi return value 0 -<< The parameter passed to hart 2 resume is: 0x4567890a ->> Start hart 3 with parameter 0x12345678 ->> SBI return value: 0 -<< The parameter passed to hart 3 start is: 0x12345678 -<< Test-kernel: All hart SBI test SUCCESS, shutdown +[rustsbi] Implementation : RustSBI-QEMU Version 0.2.0-alpha.2 +[rustsbi] Platform Name : riscv-virtio,qemu +[rustsbi] Platform SMP : 8 +[rustsbi] Platform Memory : 0x80000000..0x88000000 +[rustsbi] Boot HART : 6 +[rustsbi] Device Tree Region : 0x87e00000..0x87e01a8e +[rustsbi] Firmware Address : 0x80000000 +[rustsbi] Supervisor Address : 0x80200000 +[rustsbi] pmp01: 0x00000000..0x80000000 (-wr) +[rustsbi] pmp02: 0x80000000..0x80200000 (---) +[rustsbi] pmp03: 0x80200000..0x88000000 (xwr) +[rustsbi] pmp04: 0x88000000..0x00000000 (-wr) + + _____ _ _ __ _ +|_ _|__ ___| |_ | |/ /___ _ __ _ __ ___| | + | |/ _ \/ __| __| | ' // _ \ '__| '_ \ / _ \ | + | | __/\__ \ |_ | . \ __/ | | | | | __/ | + |_|\___||___/\__| |_|\_\___|_| |_| |_|\___|_| +================================================ +| boot hart id | 6 | +| smp | 8 | +| timebase frequency | 10000000 Hz | +| dtb physical address | 0x87e00000 | +------------------------------------------------ +[ INFO] Testing `Base` +[ INFO] sbi spec version = 2.0 +[ INFO] sbi impl = RustSBI +[ INFO] sbi impl version = 0x400 +[ INFO] sbi extensions = [Base, TIME, sPI, HSM, SRST] +[ INFO] mvendor id = 0x0 +[ INFO] march id = 0x70200 +[ INFO] mimp id = 0x70200 +[ INFO] Sbi `Base` test pass +[ INFO] Testing `TIME` +[ INFO] read time register successfuly, set timer +1s +[ INFO] timer interrupt delegate successfuly +[ INFO] Sbi `TIME` test pass +[ INFO] Testing `sPI` +[ INFO] send ipi successfuly +[ INFO] Sbi `sPI` test pass +[ INFO] Testing `HSM` +[ INFO] Testing harts: [0, 1, 2, 3] +[DEBUG] hart 0 started +[DEBUG] hart 0 suspended nonretentive +[DEBUG] hart 1 started +[DEBUG] hart 1 suspended nonretentive +[DEBUG] hart 2 started +[DEBUG] hart 2 suspended nonretentive +[DEBUG] hart 3 started +[DEBUG] hart 3 suspended nonretentive +[DEBUG] hart 0 resumed +[DEBUG] hart 0 suspended retentive +[DEBUG] hart 0 stopped +[DEBUG] hart 1 resumed +[DEBUG] hart 1 suspended retentive +[DEBUG] hart 1 stopped +[DEBUG] hart 2 resumed +[DEBUG] hart 2 suspended retentive +[DEBUG] hart 2 stopped +[DEBUG] hart 3 resumed +[DEBUG] hart 3 suspended retentive +[DEBUG] hart 3 stopped +[ INFO] Testing Pass: [0, 1, 2, 3] +[ INFO] Testing harts: [4, 5, 7] +[DEBUG] hart 4 started +[DEBUG] hart 4 suspended nonretentive +[DEBUG] hart 5 started +[DEBUG] hart 5 suspended nonretentive +[DEBUG] hart 7 started +[DEBUG] hart 7 suspended nonretentive +[DEBUG] hart 4 resumed +[DEBUG] hart 4 suspended retentive +[DEBUG] hart 4 stopped +[DEBUG] hart 5 resumed +[DEBUG] hart 5 suspended retentive +[DEBUG] hart 5 stopped +[DEBUG] hart 7 resumed +[DEBUG] hart 7 suspended retentive +[DEBUG] hart 7 stopped +[ INFO] Testing Pass: [4, 5, 7] +[ INFO] Sbi `HSM` test pass +[ INFO] Testing `DBCN` +Hello, world! +[ INFO] writing slice successfuly +[ INFO] reading 0 bytes from console +[ INFO] Sbi `DBCN` test pass ``` ## Run test kernel @@ -75,7 +120,7 @@ When running `cargo qemu`, the test kernel will build and run. Expected output s You should have `cargo-binutils` installed. -``` +```shell cargo install cargo-binutils ``` @@ -87,10 +132,10 @@ Run with: cargo test ``` -It will run RustSBI-QEMU with a test kernel. The test kernel will test all SBI functions, +It will run RustSBI-QEMU with a test kernel. The test kernel will test all SBI functions, its command emulation and other features. If it succeeds, there would be output like: -``` +```plaintext running 1 test Finished dev [unoptimized + debuginfo] target(s) in 0.14s Compiling test-kernel v0.1.0 (D:\RustProjects\rustsbi-qemu\test-kernel) @@ -104,32 +149,32 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini 1. What kind of kernel does this project support? -The rustsbi-qemu project supports raw binary kernels for educational or -competition use. This project itself is only a showcase example illustrating how -implementations should use RustSBI, it does not include a Linux boot support. -You may visit downstream bootloader projects for a Linux capable bootloader. + The rustsbi-qemu project supports raw binary kernels for educational or + competition use. This project itself is only a showcase example illustrating how + implementations should use RustSBI, it does not include a Linux boot support. + You may visit downstream bootloader projects for a Linux capable bootloader. 2. How to enable hypervisor H extension on QEMU? -You should use these following line of parameters: + You should use these following line of parameters: -```rust - command.args(&["-cpu", "rv64,x-h=true"]); -``` + ```rust + command.args(&["-cpu", "rv64,x-h=true"]); + ``` + + ... to enable H extension on QEMU software. -... to enable H extension on QEMU software. - -The H extension is enabled by default when QEMU version >= 7.0.0. + The H extension is enabled by default when QEMU version >= 7.0.0. 3. What is the minimum supported Rust version of this package? -You should build RustSBI-QEMU on nightly at least `rustc 1.66.0-nightly (a24a020e6 2022-10-18)`. + You should build RustSBI-QEMU on nightly at least `rustc 1.66.0-nightly (a24a020e6 2022-10-18)`. -## License +## License This project is licensed under Mulan PSL v2. -```text +```plaintext Copyright (c) 2021-2023 RustSBI Team RustSBI-QEMU is licensed under Mulan PSL v2. You can use this software according to the terms and conditions of the Mulan PSL v2. From 52de34acc50e116fe0be4ed1cfe2a68158c49e43 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Mon, 27 Mar 2023 10:49:30 +0800 Subject: [PATCH 07/12] =?UTF-8?q?build:=20=E4=BD=BF=E7=94=A8=20uart16550?= =?UTF-8?q?=20v0.0.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YdrMaster --- CHANGELOG.md | 2 +- Cargo.lock | 72 +++++++++++------------------------------ rustsbi-qemu/Cargo.toml | 2 +- 3 files changed, 20 insertions(+), 56 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2be44c2..fb6f260 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Hint spin loop in hart state monitor module - Add crate *bench-kernel* to workspace for sbi call bench -- Add crate *uart16550* for 16550 define - Add SBI DBCN extension support ### Modified @@ -23,6 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Use crate *aclint* version 0.0.0 in rustsbi-qemu for aclint structs - Use crate *os-xtask-utils* version 0.0.0 in xtask builder - Use crate *sifive-test-device* version 0.0.0 instead of qemu-exit +- Use crate *uart16550* version 0.0.0 for 16550 definition - Use `wfi` for suspend and stop without enable mie ### Fixed diff --git a/Cargo.lock b/Cargo.lock index 9031ae9..eec5a30 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -36,12 +36,6 @@ version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" -[[package]] -name = "bitflags" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "487f1e0fcbe47deb8b0574e646def1c903389d95241dd1bbcc6ce4a715dfc0c1" - [[package]] name = "cc" version = "1.0.79" @@ -56,11 +50,11 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.11" +version = "4.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42dfd32784433290c51d92c438bb72ea5063797fc3cc9a21a8c4346bebbb2098" +checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" dependencies = [ - "bitflags 2.0.2", + "bitflags", "clap_derive", "clap_lex", "is-terminal", @@ -71,12 +65,11 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.1.9" +version = "4.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fddf67631444a3a3e3e5ac51c36a5e01335302de677bd78759eaa90ab1f46644" +checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" dependencies = [ "heck", - "proc-macro-error", "proc-macro2", "quote", "syn", @@ -161,9 +154,9 @@ dependencies = [ [[package]] name = "io-lifetimes" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0dd6da19f25979c7270e70fa95ab371ec3b701cd0eefc47667a09785b3c59155" +checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" dependencies = [ "hermit-abi", "libc", @@ -249,35 +242,11 @@ version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" -[[package]] -name = "proc-macro-error" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" -dependencies = [ - "proc-macro-error-attr", - "proc-macro2", - "quote", - "syn", - "version_check", -] - -[[package]] -name = "proc-macro-error-attr" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" -dependencies = [ - "proc-macro2", - "quote", - "version_check", -] - [[package]] name = "proc-macro2" -version = "1.0.52" +version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d0e1ae9e836cc3beddd63db0df682593d7e2d3d891ae8c9083d2113e1744224" +checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" dependencies = [ "unicode-ident", ] @@ -314,11 +283,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.10" +version = "0.36.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2fe885c3a125aa45213b68cc1472a49880cb5923dc23f522ad2791b882228778" +checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" dependencies = [ - "bitflags 1.3.2", + "bitflags", "errno", "io-lifetimes", "libc", @@ -422,9 +391,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.109" +version = "2.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" dependencies = [ "proc-macro2", "quote", @@ -456,7 +425,8 @@ dependencies = [ [[package]] name = "uart16550" version = "0.0.0" -source = "git+https://github.com/YdrMaster/uart16550?rev=68ad4d8#68ad4d86dd28b72c72ff132c3efa7457ce5427d8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99dc416d69f0e6522a060b8a69808da27f9f58250a4ce8e93904a39cecac70ff" [[package]] name = "uart_16550" @@ -464,7 +434,7 @@ version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" dependencies = [ - "bitflags 1.3.2", + "bitflags", "rustversion", "x86_64", ] @@ -475,12 +445,6 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" -[[package]] -name = "version_check" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" - [[package]] name = "void" version = "1.0.2" @@ -597,7 +561,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" dependencies = [ "bit_field", - "bitflags 1.3.2", + "bitflags", "rustversion", "volatile", ] diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index d330eac..8e778c9 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -27,7 +27,7 @@ rcore-console = "0.0.0" aclint = "0.0.0" sifive-test-device = "0.0.0" dtb-walker = "=0.2.0-alpha.3" -uart16550 = { git = "https://github.com/YdrMaster/uart16550", rev = "68ad4d8" } +uart16550 = "0.0.0" hsm-cell = { path = "../hsm-cell" } fast-trap = { version = "=0.0.1", features = ["riscv-m"] } From 104428a8993b523ccc3035145338c697182f2598 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Fri, 31 Mar 2023 17:02:09 +0800 Subject: [PATCH 08/12] build: update Signed-off-by: YdrMaster --- CHANGELOG.md | 2 +- Cargo.lock | 163 +++++++++++++++++++++++----------------- rustsbi-qemu/Cargo.toml | 2 +- xtask/Cargo.toml | 2 +- 4 files changed, 95 insertions(+), 74 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fb6f260..dba6530 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Use crate *aclint* version 0.0.0 in rustsbi-qemu for aclint structs - Use crate *os-xtask-utils* version 0.0.0 in xtask builder - Use crate *sifive-test-device* version 0.0.0 instead of qemu-exit -- Use crate *uart16550* version 0.0.0 for 16550 definition +- Use crate *uart16550* version 0.0.1 for 16550 definition - Use `wfi` for suspend and stop without enable mie ### Fixed diff --git a/Cargo.lock b/Cargo.lock index eec5a30..ffde0e3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8,6 +8,46 @@ version = "0.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a01ba40421eca6c4f1afcedd8465fba6d9e5ef8e0e13060d0141e4cded4ab4a" +[[package]] +name = "anstream" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-wincon", + "concolor-override", + "concolor-query", + "is-terminal", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" + +[[package]] +name = "anstyle-parse" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-wincon" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +dependencies = [ + "anstyle", + "windows-sys", +] + [[package]] name = "autocfg" version = "1.1.0" @@ -50,24 +90,33 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.1.13" +version = "4.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c911b090850d79fc64fe9ea01e28e465f65e821e08813ced95bced72f7a8a9b" +checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" dependencies = [ - "bitflags", + "clap_builder", "clap_derive", - "clap_lex", - "is-terminal", "once_cell", +] + +[[package]] +name = "clap_builder" +version = "4.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +dependencies = [ + "anstream", + "anstyle", + "bitflags", + "clap_lex", "strsim", - "termcolor", ] [[package]] name = "clap_derive" -version = "4.1.12" +version = "4.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a932373bab67b984c790ddf2c9ca295d8e3af3b7ef92de5a5bacdccdee4b09b" +checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" dependencies = [ "heck", "proc-macro2", @@ -77,11 +126,23 @@ dependencies = [ [[package]] name = "clap_lex" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" + +[[package]] +name = "concolor-override" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" + +[[package]] +name = "concolor-query" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "033f6b7a4acb1f358c742aaca805c939ee73b4c6209ae4318ec7aca81c42e646" +checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" dependencies = [ - "os_str_bytes", + "windows-sys", ] [[package]] @@ -108,13 +169,13 @@ dependencies = [ [[package]] name = "errno" -version = "0.2.8" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" dependencies = [ "errno-dragonfly", "libc", - "winapi", + "windows-sys", ] [[package]] @@ -165,9 +226,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8687c819457e979cc940d09cb16e42a1bf70aa6b60a549de6d3a62a0ee90c69e" +checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" dependencies = [ "hermit-abi", "io-lifetimes", @@ -183,9 +244,9 @@ checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" [[package]] name = "linux-raw-sys" -version = "0.1.4" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" [[package]] name = "lock_api" @@ -236,12 +297,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "os_str_bytes" -version = "6.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ceedf44fb00f2d1984b0bc98102627ce622e083e49a5bacdb3e514fa4238e267" - [[package]] name = "proc-macro2" version = "1.0.54" @@ -283,9 +338,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.36.11" +version = "0.37.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" +checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75" dependencies = [ "bitflags", "errno", @@ -370,9 +425,9 @@ checksum = "ba50a6fd7cb5cdb2645fb93fb2bbae7d8d78390677a889bdcfaf13c3d29286d0" [[package]] name = "spin" -version = "0.9.6" +version = "0.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5d6e0250b93c8427a177b849d144a96d5acc57006149479403d7861ab721e34" +checksum = "c0959fd6f767df20b231736396e4f602171e00d95205676286e79d4a4eb67bef" dependencies = [ "lock_api", ] @@ -391,24 +446,15 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.10" +version = "2.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5aad1363ed6d37b84299588d62d3a7d95b5a5c2d9aad5c85609fda12afaa1f40" +checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "termcolor" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be55cf8942feac5c765c2c993422806843c9a9a45d4d5c407ad6dd2ea95eb9b6" -dependencies = [ - "winapi-util", -] - [[package]] name = "test-kernel" version = "0.2.0" @@ -424,9 +470,9 @@ dependencies = [ [[package]] name = "uart16550" -version = "0.0.0" +version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99dc416d69f0e6522a060b8a69808da27f9f58250a4ce8e93904a39cecac70ff" +checksum = "939f6f9ccad815fe3efca8fd06f2ec1620c0387fb1bca2b231b61ce710bffb9b" [[package]] name = "uart_16550" @@ -445,6 +491,12 @@ version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +[[package]] +name = "utf8parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" + [[package]] name = "void" version = "1.0.2" @@ -457,37 +509,6 @@ version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-util" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" -dependencies = [ - "winapi", -] - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - [[package]] name = "windows-sys" version = "0.45.0" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 8e778c9..32d5b06 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -27,7 +27,7 @@ rcore-console = "0.0.0" aclint = "0.0.0" sifive-test-device = "0.0.0" dtb-walker = "=0.2.0-alpha.3" -uart16550 = "0.0.0" +uart16550 = "0.0.1" hsm-cell = { path = "../hsm-cell" } fast-trap = { version = "=0.0.1", features = ["riscv-m"] } diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index ecd8976..c1dbebe 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.1", features = ["derive"] } +clap = { version = "4.2", features = ["derive"] } os-xtask-utils = "0.0.0" once_cell = "1.17" From be8edae05dff30f428798e3f0b94672900960652 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Tue, 11 Apr 2023 14:15:59 +0800 Subject: [PATCH 09/12] build: update sbi-spec to 0.0.6 Signed-off-by: YdrMaster --- CHANGELOG.md | 2 +- Cargo.lock | 186 +++++++++++++++++---------------------- bench-kernel/Cargo.toml | 4 +- bench-kernel/src/main.rs | 25 ++++-- hsm-cell/Cargo.toml | 2 +- rustsbi-qemu/Cargo.toml | 2 +- rustsbi-qemu/src/main.rs | 2 +- test-kernel/Cargo.toml | 4 +- test-kernel/src/main.rs | 28 +++--- 9 files changed, 125 insertions(+), 130 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dba6530..194a147 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), - Use instance based RustSBI interface, with separate functions for legacy stdio - Update sbi-testing to version 0.0.1 -- Update sbi-spec to version 0.0.5 +- Update sbi-spec to version 0.0.6 - Use crate *fast-trap* version 0.0.1 in rustsbi-qemu for trap handling - Use crate *rcore-console* version 0.0.0 in rustsbi-qemu and test-kernel for `print!` and `println!` - Use crate *aclint* version 0.0.0 in rustsbi-qemu for aclint structs diff --git a/Cargo.lock b/Cargo.lock index ffde0e3..4899f4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -10,39 +10,48 @@ checksum = "8a01ba40421eca6c4f1afcedd8465fba6d9e5ef8e0e13060d0141e4cded4ab4a" [[package]] name = "anstream" -version = "0.2.6" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "342258dd14006105c2b75ab1bd7543a03bdf0cfc94383303ac212a04939dff6f" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", + "anstyle-query", "anstyle-wincon", - "concolor-override", - "concolor-query", + "colorchoice", "is-terminal", "utf8parse", ] [[package]] name = "anstyle" -version = "0.3.5" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23ea9e81bd02e310c216d080f6223c179012256e5151c41db88d12c88a1684d2" +checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" [[package]] name = "anstyle-parse" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7d1bb534e9efed14f3e5f44e7dd1a4f709384023a4165199a4241e18dff0116" +checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" dependencies = [ "utf8parse", ] +[[package]] +name = "anstyle-query" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca11d4be1bab0c8bc8734a9aa7bf4ee8316d462a08c6ac5052f888fef5b494b" +dependencies = [ + "windows-sys", +] + [[package]] name = "anstyle-wincon" -version = "0.2.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3127af6145b149f3287bb9a0d10ad9c5692dba8c53ad48285e5bec4063834fa" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys", @@ -61,7 +70,7 @@ dependencies = [ "rcore-console", "riscv", "sbi-rt", - "uart_16550", + "uart16550", ] [[package]] @@ -90,9 +99,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.2.1" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "046ae530c528f252094e4a77886ee1374437744b2bff1497aa898bbddbbb29b3" +checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" dependencies = [ "clap_builder", "clap_derive", @@ -101,9 +110,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.1" +version = "4.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "223163f58c9a40c3b0a43e1c4b50a9ce09f007ea2cb1ec258a687945b4b7929f" +checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" dependencies = [ "anstream", "anstyle", @@ -131,19 +140,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" [[package]] -name = "concolor-override" +name = "colorchoice" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a855d4a1978dc52fb0536a04d384c2c0c1aa273597f08b77c8c4d3b2eec6037f" - -[[package]] -name = "concolor-query" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88d11d52c3d7ca2e6d0040212be9e4dbbcd78b6447f535b6b561f449427944cf" -dependencies = [ - "windows-sys", -] +checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" [[package]] name = "critical-section" @@ -169,9 +169,9 @@ dependencies = [ [[package]] name = "errno" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50d6a0976c999d473fe89ad888d5a284e55366d9dc9038b1ba2aa15128c4afa0" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" dependencies = [ "errno-dragonfly", "libc", @@ -210,14 +210,14 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.6", ] [[package]] name = "io-lifetimes" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09270fd4fa1111bc614ed2246c7ef56239a3063d5be0d1ec3b589c505d400aeb" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" dependencies = [ "hermit-abi", "libc", @@ -226,9 +226,9 @@ dependencies = [ [[package]] name = "is-terminal" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" +checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" dependencies = [ "hermit-abi", "io-lifetimes", @@ -238,15 +238,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.140" +version = "0.2.142" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99227334921fae1a979cf0bfdfcc6b3e5ce376ef57e16fb6fb3ea2ed6095f80c" +checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" [[package]] name = "lock_api" @@ -299,9 +299,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.54" +version = "1.0.56" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e472a104799c74b514a57226160104aa483546de37e839ec50e3c2e41dd87534" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" dependencies = [ "unicode-ident", ] @@ -338,9 +338,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.5" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e78cc525325c06b4a7ff02db283472f3c042b7ff0c391f96c6d5ac6f4f91b75" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", @@ -356,7 +356,7 @@ version = "0.4.0-alpha.1" source = "git+https://github.com/rustsbi/rustsbi?rev=91cfa36#91cfa36d14b81af3874ba1da2c0663b5bd601fa3" dependencies = [ "riscv", - "sbi-spec", + "sbi-spec 0.0.5", ] [[package]] @@ -370,25 +370,19 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec", + "sbi-spec 0.0.6", "sifive-test-device", "spin", "uart16550", ] -[[package]] -name = "rustversion" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f3208ce4d8448b3f3e7d168a73f5e0c43a61e32930de3bceeccedb388b6bf06" - [[package]] name = "sbi-rt" -version = "0.0.3-rc.1" +version = "0.0.3-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4434f94ae7a9e42d3292a9552ca6ef6ac774918859626d5e1259096755c04683" +checksum = "d51b12f0874f198deb881f5b8fde188dd4dee48a72b15bdc733ca4b891ede37a" dependencies = [ - "sbi-spec", + "sbi-spec 0.0.6", ] [[package]] @@ -400,15 +394,24 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "sbi-spec" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebf26c3dc91286b60cf8ac92beed06259b42c1a111cef74e0a05348ddfca224" +dependencies = [ + "static_assertions", +] + [[package]] name = "sbi-testing" version = "0.0.2" -source = "git+https://github.com/rustsbi/sbi-testing?rev=9bc51a3#9bc51a3991f013f563e5dc00a73e548dcc3c1e84" +source = "git+https://github.com/rustsbi/sbi-testing?rev=37b9a3c#37b9a3c75d5e7b1f68fafef5138d4e4beab459d1" dependencies = [ "log", "riscv", "sbi-rt", - "sbi-spec", + "sbi-spec 0.0.6", ] [[package]] @@ -425,9 +428,9 @@ checksum = "ba50a6fd7cb5cdb2645fb93fb2bbae7d8d78390677a889bdcfaf13c3d29286d0" [[package]] name = "spin" -version = "0.9.7" +version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0959fd6f767df20b231736396e4f602171e00d95205676286e79d4a4eb67bef" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" dependencies = [ "lock_api", ] @@ -446,9 +449,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.12" +version = "2.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79d9531f94112cfc3e4c8f5f02cb2b58f72c97b7efd85f70203cc6d8efda5927" +checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" dependencies = [ "proc-macro2", "quote", @@ -465,7 +468,7 @@ dependencies = [ "riscv", "sbi-testing", "spin", - "uart_16550", + "uart16550", ] [[package]] @@ -474,17 +477,6 @@ version = "0.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "939f6f9ccad815fe3efca8fd06f2ec1620c0387fb1bca2b231b61ce710bffb9b" -[[package]] -name = "uart_16550" -version = "0.2.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b074eb9300ad949edd74c529c0e8d451625af71bb948e6b65fe69f72dc1363d9" -dependencies = [ - "bitflags", - "rustversion", - "x86_64", -] - [[package]] name = "unicode-ident" version = "1.0.8" @@ -503,26 +495,20 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" -[[package]] -name = "volatile" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442887c63f2c839b346c192d047a7c87e73d0689c9157b00b53dcc27dd5ea793" - [[package]] name = "windows-sys" -version = "0.45.0" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" dependencies = [ "windows-targets", ] [[package]] name = "windows-targets" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", @@ -535,57 +521,45 @@ dependencies = [ [[package]] name = "windows_aarch64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_i686_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_x86_64_gnu" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnullvm" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_msvc" -version = "0.42.2" +version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - -[[package]] -name = "x86_64" -version = "0.14.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "100555a863c0092238c2e0e814c1096c1e5cf066a309c696a87e907b5f8c5d69" -dependencies = [ - "bit_field", - "bitflags", - "rustversion", - "volatile", -] +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "xtask" diff --git a/bench-kernel/Cargo.toml b/bench-kernel/Cargo.toml index 315baaf..1f3bdc5 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.1" +sbi-rt = "0.0.3-rc.2" riscv = "0.10.1" -uart_16550 = "0.2" +uart16550 = "0.0.1" rcore-console = "0.0.0" diff --git a/bench-kernel/src/main.rs b/bench-kernel/src/main.rs index 5d2592b..bba3760 100644 --- a/bench-kernel/src/main.rs +++ b/bench-kernel/src/main.rs @@ -3,11 +3,10 @@ #![feature(naked_functions, asm_const)] #![deny(warnings)] -use core::mem::MaybeUninit; use rcore_console::log; use riscv::register::*; use sbi_rt::*; -use uart_16550::MmioSerialPort; +use uart16550::Uart16550; #[naked] #[no_mangle] @@ -42,7 +41,7 @@ extern "C" fn rust_main(hartid: usize, _dtb_pa: usize) -> ! { } } // 初始化打印 - unsafe { UART = MaybeUninit::new(MmioSerialPort::new(0x1000_0000)) }; + unsafe { UART = Uart16550Map(0x1000_0000 as _) }; rcore_console::init_console(&Console); rcore_console::set_log_level(option_env!("LOG")); rcore_console::test_log(); @@ -112,11 +111,27 @@ fn panic(info: &core::panic::PanicInfo) -> ! { } struct Console; -static mut UART: MaybeUninit = MaybeUninit::uninit(); +static mut UART: Uart16550Map = Uart16550Map(core::ptr::null()); + +pub struct Uart16550Map(*const Uart16550); + +unsafe impl Sync for Uart16550Map {} + +impl Uart16550Map { + #[inline] + pub fn get(&self) -> &Uart16550 { + unsafe { &*self.0 } + } +} impl rcore_console::Console for Console { #[inline] fn put_char(&self, c: u8) { - unsafe { UART.assume_init_mut() }.send(c); + unsafe { UART.get().write(core::slice::from_ref(&c)) }; + } + + #[inline] + fn put_str(&self, s: &str) { + unsafe { UART.get().write(s.as_bytes()) }; } } diff --git a/hsm-cell/Cargo.toml b/hsm-cell/Cargo.toml index 7da69b6..4a5cc56 100644 --- a/hsm-cell/Cargo.toml +++ b/hsm-cell/Cargo.toml @@ -6,4 +6,4 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-spec = "0.0.5" +sbi-spec = "0.0.6" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 32d5b06..4b69290 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -20,7 +20,7 @@ edition = "2021" rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "91cfa36", features = [ "machine", ] } -sbi-spec = { version = "0.0.5", features = ["legacy"] } +sbi-spec = { version = "0.0.6", 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 c56f501..a061cef 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -225,7 +225,7 @@ extern "C" fn fast_handler( _ => match mcause::read().cause() { // SBI call T::Exception(E::SupervisorEnvCall) => { - use rustsbi::spec::{base, hsm, legacy}; + use sbi_spec::{base, hsm, legacy}; let mut ret = unsafe { SBI.assume_init_mut() }.handle_ecall( a7, a6, diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 8640fdc..1649779 100644 --- a/test-kernel/Cargo.toml +++ b/test-kernel/Cargo.toml @@ -8,12 +8,12 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "9bc51a3", features = [ +sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "37b9a3c", features = [ "log", ] } log = "0.4.17" riscv = "0.10.1" spin = "0.9" -uart_16550 = "0.2" +uart16550 = "0.0.1" rcore-console = "0.0.0" dtb-walker = "=0.2.0-alpha.3" diff --git a/test-kernel/src/main.rs b/test-kernel/src/main.rs index 2186889..bbd5e06 100644 --- a/test-kernel/src/main.rs +++ b/test-kernel/src/main.rs @@ -6,10 +6,9 @@ #[macro_use] extern crate rcore_console; -use core::{arch::asm, mem::MaybeUninit}; +use core::{arch::asm, ptr::null}; use sbi_testing::sbi; -use spin::Mutex; -use uart_16550::MmioSerialPort; +use uart16550::Uart16550; /// 内核入口。 /// @@ -53,7 +52,7 @@ extern "C" fn rust_main(hartid: usize, dtb_pa: usize) -> ! { frequency, uart, } = BoardInfo::parse(dtb_pa); - *UART.lock() = MaybeUninit::new(unsafe { MmioSerialPort::new(uart) }); + unsafe { UART = Uart16550Map(uart as _) }; rcore_console::init_console(&Console); rcore_console::set_log_level(option_env!("LOG")); println!( @@ -155,20 +154,27 @@ impl BoardInfo { } struct Console; -static UART: Mutex> = Mutex::new(MaybeUninit::uninit()); +static mut UART: Uart16550Map = Uart16550Map(null()); + +pub struct Uart16550Map(*const Uart16550); + +unsafe impl Sync for Uart16550Map {} + +impl Uart16550Map { + #[inline] + pub fn get(&self) -> &Uart16550 { + unsafe { &*self.0 } + } +} impl rcore_console::Console for Console { #[inline] fn put_char(&self, c: u8) { - unsafe { UART.lock().assume_init_mut() }.send(c); + unsafe { UART.get().write(core::slice::from_ref(&c)) }; } #[inline] fn put_str(&self, s: &str) { - let mut uart = UART.lock(); - let uart = unsafe { uart.assume_init_mut() }; - for c in s.bytes() { - uart.send(c); - } + unsafe { UART.get().write(s.as_bytes()) }; } } From 2fdc800397c8177b3f8a62a6f045ed81061b521d Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Fri, 28 Jul 2023 09:58:15 +0800 Subject: [PATCH 10/12] fix: update deps Signed-off-by: YdrMaster --- Cargo.lock | 128 +++++++++++++++------------------------ Cargo.toml | 1 + rustsbi-qemu/Cargo.toml | 2 +- rustsbi-qemu/src/dbcn.rs | 5 +- rustsbi-qemu/src/main.rs | 2 + xtask/Cargo.toml | 4 +- 6 files changed, 58 insertions(+), 84 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4899f4d..1693214 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,15 +25,15 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41ed9a86bf92ae6580e0a31281f65a1b1d867c0cc68d5346e2ae128dddfa6a7d" +checksum = "3a30da5c5f2d5e72842e00bcb57657162cdabef0931f40e2deb9b4140440cecd" [[package]] name = "anstyle-parse" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e765fd216e48e067936442276d1d57399e37bce53c264d6fefbe298080cb57ee" +checksum = "938874ff5980b03a87c5524b3ae5b59cf99b1d6bc836848df7bc5ada9643c333" dependencies = [ "utf8parse", ] @@ -81,9 +81,9 @@ checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" [[package]] name = "bitflags" -version = "1.3.2" +version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" +checksum = "630be753d4e58660abd17930c71b647fe46c27ea6b63cc59e1e3851406972e42" [[package]] name = "cc" @@ -91,17 +91,11 @@ version = "1.0.79" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - [[package]] name = "clap" -version = "4.2.7" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34d21f9bf1b425d2968943631ec91202fe5e837264063503708b83013f8fc938" +checksum = "5fd304a20bff958a57f04c4e96a2e7594cc4490a0e809cbd48bb6437edaa452d" dependencies = [ "clap_builder", "clap_derive", @@ -110,22 +104,21 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.7" +version = "4.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "914c8c79fb560f238ef6429439a30023c862f7a28e688c58f7203f12b29970bd" +checksum = "01c6a3f08f1fe5662a35cfe393aec09c4df95f60ee93b7556505260f75eee9e1" dependencies = [ "anstream", "anstyle", - "bitflags", "clap_lex", "strsim", ] [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "54a9bb5758fc5dfe728d1019941681eccaf0cf8a4189b692a0ee2f2ecf90a050" dependencies = [ "heck", "proc-macro2", @@ -135,9 +128,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "colorchoice" @@ -202,57 +195,45 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" [[package]] name = "hermit-abi" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" +checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" [[package]] name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec 0.0.6", -] - -[[package]] -name = "io-lifetimes" -version = "1.0.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" -dependencies = [ - "hermit-abi", - "libc", - "windows-sys", + "sbi-spec", ] [[package]] name = "is-terminal" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adcf93614601c8129ddf72e2d5633df827ba6551541c6d8c59520a371475be1f" +checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ "hermit-abi", - "io-lifetimes", "rustix", "windows-sys", ] [[package]] name = "libc" -version = "0.2.142" +version = "0.2.147" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a987beff54b60ffa6d51982e1aa1146bc42f19bd26be28b0586f252fccf5317" +checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "linux-raw-sys" -version = "0.3.7" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ece97ea872ece730aed82664c424eb4c8291e1ff2480247ccf7409044bc6479f" +checksum = "09fc20d2ca12cb9f044c93e3bd6d32d523e6e2ec3db4f7b2939cd99026ecd3f0" [[package]] name = "lock_api" -version = "0.4.9" +version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" dependencies = [ "autocfg", "scopeguard", @@ -260,12 +241,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.17" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" -dependencies = [ - "cfg-if", -] +checksum = "b06a4cde4c0f271a446782e3eff8de789548ce57dbc8eca9292c27f4a42004b4" [[package]] name = "nb" @@ -284,9 +262,9 @@ checksum = "8d5439c4ad607c3c23abf66de8c8bf57ba8adcd1f129e699851a6e43935d339d" [[package]] name = "once_cell" -version = "1.17.1" +version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" +checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "os-xtask-utils" @@ -299,18 +277,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "50f3b39ccfb720540debaa0164757101c08ecb8d326b15358ce76a62c7e85965" dependencies = [ "proc-macro2", ] @@ -338,13 +316,12 @@ dependencies = [ [[package]] name = "rustix" -version = "0.37.19" +version = "0.38.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" +checksum = "0a962918ea88d644592894bc6dc55acc6c0956488adcebbfb6e273506b7fd6e5" dependencies = [ "bitflags", "errno", - "io-lifetimes", "libc", "linux-raw-sys", "windows-sys", @@ -353,10 +330,10 @@ dependencies = [ [[package]] name = "rustsbi" version = "0.4.0-alpha.1" -source = "git+https://github.com/rustsbi/rustsbi?rev=91cfa36#91cfa36d14b81af3874ba1da2c0663b5bd601fa3" +source = "git+https://github.com/rustsbi/rustsbi?rev=8ebabe#8ebabe32dde74937336a7bc3e94e86a3c561a89c" dependencies = [ "riscv", - "sbi-spec 0.0.5", + "sbi-spec", ] [[package]] @@ -370,7 +347,7 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec 0.0.6", + "sbi-spec", "sifive-test-device", "spin", "uart16550", @@ -382,16 +359,7 @@ version = "0.0.3-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d51b12f0874f198deb881f5b8fde188dd4dee48a72b15bdc733ca4b891ede37a" dependencies = [ - "sbi-spec 0.0.6", -] - -[[package]] -name = "sbi-spec" -version = "0.0.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a535b1f16d5517a020539569f7e37e61fad35ed0d5352f9fd7073304e2f2dc72" -dependencies = [ - "static_assertions", + "sbi-spec", ] [[package]] @@ -411,14 +379,14 @@ dependencies = [ "log", "riscv", "sbi-rt", - "sbi-spec 0.0.6", + "sbi-spec", ] [[package]] name = "scopeguard" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "sifive-test-device" @@ -449,9 +417,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "2.0.15" +version = "2.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a34fcf3e8b60f57e6a14301a2e916d323af98b0ea63c599441eec8558660c822" +checksum = "b60f673f44a8255b9c8c657daf66a596d435f2da81a555b06dc644d080ba45e0" dependencies = [ "proc-macro2", "quote", @@ -479,9 +447,9 @@ checksum = "939f6f9ccad815fe3efca8fd06f2ec1620c0387fb1bca2b231b61ce710bffb9b" [[package]] name = "unicode-ident" -version = "1.0.8" +version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" +checksum = "301abaae475aa91687eb82514b328ab47a211a533026cb25fc3e519b86adfc3c" [[package]] name = "utf8parse" @@ -506,9 +474,9 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.48.0" +version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm", "windows_aarch64_msvc", diff --git a/Cargo.toml b/Cargo.toml index 34f72d8..26bebab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,4 @@ [workspace] members = ["rustsbi-qemu", "hsm-cell", "test-kernel", "bench-kernel", "xtask"] default-members = ["xtask"] +resolver = "2" diff --git a/rustsbi-qemu/Cargo.toml b/rustsbi-qemu/Cargo.toml index 4b69290..9ef7265 100644 --- a/rustsbi-qemu/Cargo.toml +++ b/rustsbi-qemu/Cargo.toml @@ -17,7 +17,7 @@ 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 = "91cfa36", features = [ +rustsbi = { git = "https://github.com/rustsbi/rustsbi", rev = "8ebabe", features = [ "machine", ] } sbi-spec = { version = "0.0.6", features = ["legacy"] } diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs index f332f64..785a7db 100644 --- a/rustsbi-qemu/src/dbcn.rs +++ b/rustsbi-qemu/src/dbcn.rs @@ -2,7 +2,10 @@ use crate::uart16550; use core::ops::Range; -use rustsbi::{spec::binary::SbiRet, Console, Physical}; +use rustsbi::{ + spec::binary::{Physical, SbiRet}, + Console, +}; use spin::Once; pub(crate) struct DBCN(Range); diff --git a/rustsbi-qemu/src/main.rs b/rustsbi-qemu/src/main.rs index a061cef..d0eac21 100644 --- a/rustsbi-qemu/src/main.rs +++ b/rustsbi-qemu/src/main.rs @@ -354,6 +354,8 @@ type FixedRustSBI<'a> = RustSBI< &'a qemu_test::QemuTest, Infallible, &'a dbcn::DBCN, + Infallible, + Infallible, >; struct Hsm; diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index c1dbebe..b9fd041 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.2", features = ["derive"] } +clap = { version = "4.3", features = ["derive"] } os-xtask-utils = "0.0.0" -once_cell = "1.17" +once_cell = "1.18" From eb00136f1a370dc61a127ab8b138e1ad44d4dcad Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Wed, 3 Jan 2024 10:31:56 +0800 Subject: [PATCH 11/12] build: update sbi-testing Signed-off-by: YdrMaster --- Cargo.lock | 23 +++++++---------------- test-kernel/Cargo.toml | 4 ++-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 08b0c0b..4f58985 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -162,7 +162,7 @@ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" name = "hsm-cell" version = "0.1.0" dependencies = [ - "sbi-spec 0.0.7-alpha.3", + "sbi-spec", ] [[package]] @@ -257,7 +257,7 @@ source = "git+https://github.com/rustsbi/rustsbi?rev=4c40cd#4c40cdce2de8d92d69e7 dependencies = [ "riscv", "rustsbi-macros", - "sbi-spec 0.0.7-alpha.3", + "sbi-spec", ] [[package]] @@ -280,7 +280,7 @@ dependencies = [ "rcore-console", "riscv", "rustsbi", - "sbi-spec 0.0.7-alpha.3", + "sbi-spec", "sifive-test-device", "spin", "uart16550", @@ -292,16 +292,7 @@ version = "0.0.3-rc.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16fd1c8d9255a1cc094f2dde32da32dbae1ab945656a684b168bf75ed5dccbb6" dependencies = [ - "sbi-spec 0.0.7-alpha.3", -] - -[[package]] -name = "sbi-spec" -version = "0.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ebf26c3dc91286b60cf8ac92beed06259b42c1a111cef74e0a05348ddfca224" -dependencies = [ - "static_assertions", + "sbi-spec", ] [[package]] @@ -315,13 +306,13 @@ dependencies = [ [[package]] name = "sbi-testing" -version = "0.0.2" -source = "git+https://github.com/rustsbi/sbi-testing?rev=37b9a3c#37b9a3c75d5e7b1f68fafef5138d4e4beab459d1" +version = "0.0.3-rc.0" +source = "git+https://github.com/rustsbi/sbi-testing?rev=3b0089#3b0089d073b2ff43d986f01807cd2759aee90ec7" dependencies = [ "log", "riscv", "sbi-rt", - "sbi-spec 0.0.6", + "sbi-spec", ] [[package]] diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 1649779..4d014c9 100644 --- a/test-kernel/Cargo.toml +++ b/test-kernel/Cargo.toml @@ -8,10 +8,10 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "37b9a3c", features = [ +sbi-testing = { git = "https://github.com/rustsbi/sbi-testing", rev = "3b0089", features = [ "log", ] } -log = "0.4.17" +log = "0.4" riscv = "0.10.1" spin = "0.9" uart16550 = "0.0.1" From 72d0a1d4e55cc3b893c7580f8f50380c45e2de01 Mon Sep 17 00:00:00 2001 From: YdrMaster Date: Wed, 3 Jan 2024 10:34:57 +0800 Subject: [PATCH 12/12] fix: remove unused `#[allow(unused)]` Signed-off-by: YdrMaster --- rustsbi-qemu/src/dbcn.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/rustsbi-qemu/src/dbcn.rs b/rustsbi-qemu/src/dbcn.rs index 785a7db..d3a21e9 100644 --- a/rustsbi-qemu/src/dbcn.rs +++ b/rustsbi-qemu/src/dbcn.rs @@ -1,6 +1,4 @@ -#![allow(unused)] - -use crate::uart16550; +use crate::uart16550; use core::ops::Range; use rustsbi::{ spec::binary::{Physical, SbiRet},