Quellcode durchsuchen

refactor: move the rustsbi library to the `library` directory

Signed-off-by: guttatus <xingzhiang2020@gmail.com>
guttatus vor 2 Monaten
Ursprung
Commit
5cb8f954a0
93 geänderte Dateien mit 53 neuen und 52 gelöschten Zeilen
  1. 5 47
      Cargo.toml
  2. 0 0
      library/macros/CHANGELOG.md
  3. 1 1
      library/macros/Cargo.toml
  4. 0 0
      library/macros/src/lib.rs
  5. 43 0
      library/rustsbi/Cargo.toml
  6. 0 0
      library/rustsbi/examples/derive/commons.rs
  7. 0 0
      library/rustsbi/examples/derive/main.rs
  8. 0 0
      library/rustsbi/src/console.rs
  9. 0 0
      library/rustsbi/src/cppc.rs
  10. 0 0
      library/rustsbi/src/forward.rs
  11. 0 0
      library/rustsbi/src/hsm.rs
  12. 0 0
      library/rustsbi/src/ipi.rs
  13. 0 0
      library/rustsbi/src/lib.rs
  14. 0 0
      library/rustsbi/src/nacl.rs
  15. 0 0
      library/rustsbi/src/pmu.rs
  16. 0 0
      library/rustsbi/src/reset.rs
  17. 0 0
      library/rustsbi/src/rfence.rs
  18. 0 0
      library/rustsbi/src/sta.rs
  19. 0 0
      library/rustsbi/src/susp.rs
  20. 0 0
      library/rustsbi/src/timer.rs
  21. 0 0
      library/rustsbi/src/traits.rs
  22. 0 0
      library/rustsbi/tests/build-full.rs
  23. 0 0
      library/rustsbi/tests/build-generics.rs
  24. 0 0
      library/rustsbi/tests/build-rename.rs
  25. 0 0
      library/rustsbi/tests/build-skip.rs
  26. 0 0
      library/rustsbi/tests/dynamic-generics.rs
  27. 0 0
      library/rustsbi/tests/dynamic-priority.rs
  28. 0 0
      library/rustsbi/tests/forward-struct.rs
  29. 0 0
      library/sbi-rt/.cargo/config.toml
  30. 0 0
      library/sbi-rt/.gitignore
  31. 0 0
      library/sbi-rt/CHANGELOG.md
  32. 0 0
      library/sbi-rt/Cargo.toml
  33. 0 0
      library/sbi-rt/LICENSE-MIT
  34. 0 0
      library/sbi-rt/LICENSE-MULAN
  35. 0 0
      library/sbi-rt/README.md
  36. 0 0
      library/sbi-rt/README_EN.md
  37. 0 0
      library/sbi-rt/src/base.rs
  38. 0 0
      library/sbi-rt/src/binary.rs
  39. 0 0
      library/sbi-rt/src/cppc.rs
  40. 0 0
      library/sbi-rt/src/dbcn.rs
  41. 0 0
      library/sbi-rt/src/hsm.rs
  42. 0 0
      library/sbi-rt/src/legacy.rs
  43. 0 0
      library/sbi-rt/src/lib.rs
  44. 0 0
      library/sbi-rt/src/nacl.rs
  45. 0 0
      library/sbi-rt/src/pmu.rs
  46. 0 0
      library/sbi-rt/src/rfnc.rs
  47. 0 0
      library/sbi-rt/src/spi.rs
  48. 0 0
      library/sbi-rt/src/srst.rs
  49. 0 0
      library/sbi-rt/src/sta.rs
  50. 0 0
      library/sbi-rt/src/susp.rs
  51. 0 0
      library/sbi-rt/src/time.rs
  52. 0 0
      library/sbi-spec/.gitignore
  53. 0 0
      library/sbi-spec/CHANGELOG.md
  54. 0 0
      library/sbi-spec/Cargo.toml
  55. 0 0
      library/sbi-spec/LICENSE-MIT
  56. 0 0
      library/sbi-spec/LICENSE-MULAN
  57. 0 0
      library/sbi-spec/README.md
  58. 0 0
      library/sbi-spec/src/base.rs
  59. 0 0
      library/sbi-spec/src/binary.rs
  60. 0 0
      library/sbi-spec/src/cppc.rs
  61. 0 0
      library/sbi-spec/src/dbcn.rs
  62. 0 0
      library/sbi-spec/src/dbtr.rs
  63. 0 0
      library/sbi-spec/src/fwft.rs
  64. 0 0
      library/sbi-spec/src/hsm.rs
  65. 0 0
      library/sbi-spec/src/legacy.rs
  66. 0 0
      library/sbi-spec/src/lib.rs
  67. 0 0
      library/sbi-spec/src/mpxy.rs
  68. 0 0
      library/sbi-spec/src/nacl.rs
  69. 0 0
      library/sbi-spec/src/pmu.rs
  70. 0 0
      library/sbi-spec/src/rfnc.rs
  71. 0 0
      library/sbi-spec/src/spi.rs
  72. 0 0
      library/sbi-spec/src/srst.rs
  73. 0 0
      library/sbi-spec/src/sse.rs
  74. 0 0
      library/sbi-spec/src/sta.rs
  75. 0 0
      library/sbi-spec/src/susp.rs
  76. 0 0
      library/sbi-spec/src/time.rs
  77. 0 0
      library/sbi-testing/.cargo/config.toml
  78. 0 0
      library/sbi-testing/.gitignore
  79. 0 0
      library/sbi-testing/CHANGELOG.md
  80. 0 0
      library/sbi-testing/Cargo.toml
  81. 0 0
      library/sbi-testing/LICENSE-MIT
  82. 0 0
      library/sbi-testing/LICENSE-MULAN
  83. 0 0
      library/sbi-testing/README.md
  84. 0 0
      library/sbi-testing/README_EN.md
  85. 0 0
      library/sbi-testing/rust-toolchain.toml
  86. 0 0
      library/sbi-testing/src/base.rs
  87. 0 0
      library/sbi-testing/src/dbcn.rs
  88. 0 0
      library/sbi-testing/src/hsm.rs
  89. 0 0
      library/sbi-testing/src/lib.rs
  90. 0 0
      library/sbi-testing/src/log_test.rs
  91. 0 0
      library/sbi-testing/src/spi.rs
  92. 2 2
      library/sbi-testing/src/thread.rs
  93. 2 2
      library/sbi-testing/src/time.rs

+ 5 - 47
Cargo.toml

@@ -1,53 +1,11 @@
-[package]
-name = "rustsbi"
-description = "Minimal RISC-V's SBI implementation library in Rust"
-version = "0.4.0"
-authors = [
-    "Luo Jia <me@luojia.cc>",
-    "Campbell He <hkp18@mails.tsinghua.edu.cn>",
-    "Yifan Wu <shinbokuow@163.com>",
-]
-documentation = "https://docs.rs/rustsbi"
-edition.workspace = true
-license.workspace = true
-repository.workspace = true
-readme = "README.md"
-keywords = ["riscv", "sbi", "rustsbi"]
-categories = ["os", "embedded", "hardware-support", "no-std"]
-exclude = ["/.github"]
-
-[dependencies]
-sbi-spec = { version = "0.0.8", path = "sbi-spec" }
-riscv = { version = "0.12.0", optional = true, default-features = false }
-sbi-rt = { version = "0.0.3", features = ["integer-impls"], optional = true, path = "sbi-rt" }
-rustsbi-macros = { version = "0.0.2", path = "macros" }
-
-[features]
-default = []
-# Run RustSBI on machine mode.
-# This feature enables to use RISC-V primitives on current machine mode environment
-# If you are developing a cross-architecture virtual machine, consider disabling this feature
-# to customize environment variables for RISC-V architecture like mvendorid, mimpid, etc.
-machine = ["rustsbi-macros/machine", "dep:riscv"]
-# Enables the struct `Forward`.
-# Struct `Forward` uses the current SBI environment to implement the RustSBI environment.
-# This feature is only usable when current software runs on another SBI environment,
-# e.g., hypervisors for RISC-V architecture.
-forward = ["dep:sbi-rt"]
-
-[package.metadata.docs.rs]
-default-target = "riscv64imac-unknown-none-elf"
-targets = [
-    "riscv32imac-unknown-none-elf", "riscv64imac-unknown-none-elf",
-]
-
 [workspace]
 resolver = "2"
 members = [
-    "macros",
-    "sbi-rt",
-    "sbi-spec",
-    "sbi-testing",
+    "library/macros",
+    "library/sbi-rt",
+    "library/sbi-spec",
+    "library/sbi-testing",
+    "library/rustsbi",
 ]
 
 [workspace.package]

+ 0 - 0
macros/CHANGELOG.md → library/macros/CHANGELOG.md


+ 1 - 1
macros/Cargo.toml → library/macros/Cargo.toml

@@ -9,7 +9,7 @@ documentation = "https://docs.rs/rustsbi"
 edition.workspace = true
 license.workspace = true
 repository.workspace = true
-readme = "../README.md"
+readme = "../../README.md"
 keywords = ["riscv", "sbi", "rustsbi"]
 categories = ["os", "embedded", "hardware-support", "no-std"]
 

+ 0 - 0
macros/src/lib.rs → library/macros/src/lib.rs


+ 43 - 0
library/rustsbi/Cargo.toml

@@ -0,0 +1,43 @@
+[package]
+name = "rustsbi"
+description = "Minimal RISC-V's SBI implementation library in Rust"
+version = "0.4.0"
+authors = [
+    "Luo Jia <me@luojia.cc>",
+    "Campbell He <hkp18@mails.tsinghua.edu.cn>",
+    "Yifan Wu <shinbokuow@163.com>",
+]
+documentation = "https://docs.rs/rustsbi"
+edition.workspace = true
+license.workspace = true
+repository.workspace = true
+readme = "../../README.md"
+keywords = ["riscv", "sbi", "rustsbi"]
+categories = ["os", "embedded", "hardware-support", "no-std"]
+
+[dependencies]
+sbi-spec = { version = "0.0.8", path = "../sbi-spec" }
+riscv = { version = "0.12.0", optional = true, default-features = false }
+sbi-rt = { version = "0.0.3", features = ["integer-impls"], optional = true, path = "../sbi-rt" }
+rustsbi-macros = { version = "0.0.2", path = "../macros" }
+
+[features]
+default = []
+# Run RustSBI on machine mode.
+# This feature enables to use RISC-V primitives on current machine mode environment
+# If you are developing a cross-architecture virtual machine, consider disabling this feature
+# to customize environment variables for RISC-V architecture like mvendorid, mimpid, etc.
+machine = ["rustsbi-macros/machine", "dep:riscv"]
+# Enables the struct `Forward`.
+# Struct `Forward` uses the current SBI environment to implement the RustSBI environment.
+# This feature is only usable when current software runs on another SBI environment,
+# e.g., hypervisors for RISC-V architecture.
+forward = ["dep:sbi-rt"]
+
+[package.metadata.docs.rs]
+default-target = "riscv64imac-unknown-none-elf"
+targets = [
+    "riscv32imac-unknown-none-elf", "riscv64imac-unknown-none-elf",
+]
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

+ 0 - 0
examples/derive/commons.rs → library/rustsbi/examples/derive/commons.rs


+ 0 - 0
examples/derive/main.rs → library/rustsbi/examples/derive/main.rs


+ 0 - 0
src/console.rs → library/rustsbi/src/console.rs


+ 0 - 0
src/cppc.rs → library/rustsbi/src/cppc.rs


+ 0 - 0
src/forward.rs → library/rustsbi/src/forward.rs


+ 0 - 0
src/hsm.rs → library/rustsbi/src/hsm.rs


+ 0 - 0
src/ipi.rs → library/rustsbi/src/ipi.rs


+ 0 - 0
src/lib.rs → library/rustsbi/src/lib.rs


+ 0 - 0
src/nacl.rs → library/rustsbi/src/nacl.rs


+ 0 - 0
src/pmu.rs → library/rustsbi/src/pmu.rs


+ 0 - 0
src/reset.rs → library/rustsbi/src/reset.rs


+ 0 - 0
src/rfence.rs → library/rustsbi/src/rfence.rs


+ 0 - 0
src/sta.rs → library/rustsbi/src/sta.rs


+ 0 - 0
src/susp.rs → library/rustsbi/src/susp.rs


+ 0 - 0
src/timer.rs → library/rustsbi/src/timer.rs


+ 0 - 0
src/traits.rs → library/rustsbi/src/traits.rs


+ 0 - 0
tests/build-full.rs → library/rustsbi/tests/build-full.rs


+ 0 - 0
tests/build-generics.rs → library/rustsbi/tests/build-generics.rs


+ 0 - 0
tests/build-rename.rs → library/rustsbi/tests/build-rename.rs


+ 0 - 0
tests/build-skip.rs → library/rustsbi/tests/build-skip.rs


+ 0 - 0
tests/dynamic-generics.rs → library/rustsbi/tests/dynamic-generics.rs


+ 0 - 0
tests/dynamic-priority.rs → library/rustsbi/tests/dynamic-priority.rs


+ 0 - 0
tests/forward-struct.rs → library/rustsbi/tests/forward-struct.rs


+ 0 - 0
sbi-rt/.cargo/config.toml → library/sbi-rt/.cargo/config.toml


+ 0 - 0
sbi-rt/.gitignore → library/sbi-rt/.gitignore


+ 0 - 0
sbi-rt/CHANGELOG.md → library/sbi-rt/CHANGELOG.md


+ 0 - 0
sbi-rt/Cargo.toml → library/sbi-rt/Cargo.toml


+ 0 - 0
sbi-rt/LICENSE-MIT → library/sbi-rt/LICENSE-MIT


+ 0 - 0
sbi-rt/LICENSE-MULAN → library/sbi-rt/LICENSE-MULAN


+ 0 - 0
sbi-rt/README.md → library/sbi-rt/README.md


+ 0 - 0
sbi-rt/README_EN.md → library/sbi-rt/README_EN.md


+ 0 - 0
sbi-rt/src/base.rs → library/sbi-rt/src/base.rs


+ 0 - 0
sbi-rt/src/binary.rs → library/sbi-rt/src/binary.rs


+ 0 - 0
sbi-rt/src/cppc.rs → library/sbi-rt/src/cppc.rs


+ 0 - 0
sbi-rt/src/dbcn.rs → library/sbi-rt/src/dbcn.rs


+ 0 - 0
sbi-rt/src/hsm.rs → library/sbi-rt/src/hsm.rs


+ 0 - 0
sbi-rt/src/legacy.rs → library/sbi-rt/src/legacy.rs


+ 0 - 0
sbi-rt/src/lib.rs → library/sbi-rt/src/lib.rs


+ 0 - 0
sbi-rt/src/nacl.rs → library/sbi-rt/src/nacl.rs


+ 0 - 0
sbi-rt/src/pmu.rs → library/sbi-rt/src/pmu.rs


+ 0 - 0
sbi-rt/src/rfnc.rs → library/sbi-rt/src/rfnc.rs


+ 0 - 0
sbi-rt/src/spi.rs → library/sbi-rt/src/spi.rs


+ 0 - 0
sbi-rt/src/srst.rs → library/sbi-rt/src/srst.rs


+ 0 - 0
sbi-rt/src/sta.rs → library/sbi-rt/src/sta.rs


+ 0 - 0
sbi-rt/src/susp.rs → library/sbi-rt/src/susp.rs


+ 0 - 0
sbi-rt/src/time.rs → library/sbi-rt/src/time.rs


+ 0 - 0
sbi-spec/.gitignore → library/sbi-spec/.gitignore


+ 0 - 0
sbi-spec/CHANGELOG.md → library/sbi-spec/CHANGELOG.md


+ 0 - 0
sbi-spec/Cargo.toml → library/sbi-spec/Cargo.toml


+ 0 - 0
sbi-spec/LICENSE-MIT → library/sbi-spec/LICENSE-MIT


+ 0 - 0
sbi-spec/LICENSE-MULAN → library/sbi-spec/LICENSE-MULAN


+ 0 - 0
sbi-spec/README.md → library/sbi-spec/README.md


+ 0 - 0
sbi-spec/src/base.rs → library/sbi-spec/src/base.rs


+ 0 - 0
sbi-spec/src/binary.rs → library/sbi-spec/src/binary.rs


+ 0 - 0
sbi-spec/src/cppc.rs → library/sbi-spec/src/cppc.rs


+ 0 - 0
sbi-spec/src/dbcn.rs → library/sbi-spec/src/dbcn.rs


+ 0 - 0
sbi-spec/src/dbtr.rs → library/sbi-spec/src/dbtr.rs


+ 0 - 0
sbi-spec/src/fwft.rs → library/sbi-spec/src/fwft.rs


+ 0 - 0
sbi-spec/src/hsm.rs → library/sbi-spec/src/hsm.rs


+ 0 - 0
sbi-spec/src/legacy.rs → library/sbi-spec/src/legacy.rs


+ 0 - 0
sbi-spec/src/lib.rs → library/sbi-spec/src/lib.rs


+ 0 - 0
sbi-spec/src/mpxy.rs → library/sbi-spec/src/mpxy.rs


+ 0 - 0
sbi-spec/src/nacl.rs → library/sbi-spec/src/nacl.rs


+ 0 - 0
sbi-spec/src/pmu.rs → library/sbi-spec/src/pmu.rs


+ 0 - 0
sbi-spec/src/rfnc.rs → library/sbi-spec/src/rfnc.rs


+ 0 - 0
sbi-spec/src/spi.rs → library/sbi-spec/src/spi.rs


+ 0 - 0
sbi-spec/src/srst.rs → library/sbi-spec/src/srst.rs


+ 0 - 0
sbi-spec/src/sse.rs → library/sbi-spec/src/sse.rs


+ 0 - 0
sbi-spec/src/sta.rs → library/sbi-spec/src/sta.rs


+ 0 - 0
sbi-spec/src/susp.rs → library/sbi-spec/src/susp.rs


+ 0 - 0
sbi-spec/src/time.rs → library/sbi-spec/src/time.rs


+ 0 - 0
sbi-testing/.cargo/config.toml → library/sbi-testing/.cargo/config.toml


+ 0 - 0
sbi-testing/.gitignore → library/sbi-testing/.gitignore


+ 0 - 0
sbi-testing/CHANGELOG.md → library/sbi-testing/CHANGELOG.md


+ 0 - 0
sbi-testing/Cargo.toml → library/sbi-testing/Cargo.toml


+ 0 - 0
sbi-testing/LICENSE-MIT → library/sbi-testing/LICENSE-MIT


+ 0 - 0
sbi-testing/LICENSE-MULAN → library/sbi-testing/LICENSE-MULAN


+ 0 - 0
sbi-testing/README.md → library/sbi-testing/README.md


+ 0 - 0
sbi-testing/README_EN.md → library/sbi-testing/README_EN.md


+ 0 - 0
sbi-testing/rust-toolchain.toml → library/sbi-testing/rust-toolchain.toml


+ 0 - 0
sbi-testing/src/base.rs → library/sbi-testing/src/base.rs


+ 0 - 0
sbi-testing/src/dbcn.rs → library/sbi-testing/src/dbcn.rs


+ 0 - 0
sbi-testing/src/hsm.rs → library/sbi-testing/src/hsm.rs


+ 0 - 0
sbi-testing/src/lib.rs → library/sbi-testing/src/lib.rs


+ 0 - 0
sbi-testing/src/log_test.rs → library/sbi-testing/src/log_test.rs


+ 0 - 0
sbi-testing/src/spi.rs → library/sbi-testing/src/spi.rs


+ 2 - 2
sbi-testing/src/thread.rs → library/sbi-testing/src/thread.rs

@@ -147,7 +147,7 @@ unsafe extern "C" fn execute_naked() {
             SAVE_ALL
         ",
             // 设置陷入入口
-            "   la   t0, 1f
+            "   la   t0, 2f
             csrw stvec, t0
         ",
             // 保存调度上下文地址并切换上下文
@@ -164,7 +164,7 @@ unsafe extern "C" fn execute_naked() {
             // 陷入
             "   .align 2",
             // 切换上下文
-            "1: csrrw sp, sscratch, sp",
+            "2: csrrw sp, sscratch, sp",
             // 保存线程上下文
             "   SAVE_ALL
             csrrw t0, sscratch, sp

+ 2 - 2
sbi-testing/src/time.rs → library/sbi-testing/src/time.rs

@@ -52,13 +52,13 @@ pub fn test(delay: u64, mut f: impl FnMut(Case)) {
     let mut ok = 0xffusize;
     unsafe {
         core::arch::asm!(
-            "   la   {stvec}, 1f
+            "   la   {stvec}, 2f
                 csrw stvec,   {stvec}
                 csrr {begin}, time
                 csrr {end},   time
                 mv   {ok},    zero
             .align 2
-            1:
+            2:
             ",
             stvec = out(reg) _,
             begin = out(reg) begin,