浏览代码

refactor: merge rustsbi repository and prototyper repository (#95)

This pull request merges the rustsbi repository with the prototyper repository.
- Move the rustsbi library files into the `library` directory.
- Merge prototyper into the `prototyper` directory.
- Merge CI and xtask.

Signed-off-by: guttatus <[email protected]>
Signed-off-by: Woshiluo Luo <[email protected]>
Signed-off-by: Zongyao Chen <[email protected]>
Signed-off-by: Nowherechan <[email protected]>
Co-authored-by: Plucky923 <[email protected]>
Co-authored-by: Zhouqi Jiang <[email protected]>
Luo Jia / Zhouqi Jiang 1 月之前
父节点
当前提交
eb5a100f81
共有 100 个文件被更改,包括 274 次插入56 次删除
  1. 5 0
      .cargo/config.toml
  2. 4 4
      .github/workflows/Rust.yml
  3. 50 0
      .github/workflows/prototyper.yml
  4. 11 47
      Cargo.toml
  5. 0 0
      library/macros/CHANGELOG.md
  6. 1 1
      library/macros/Cargo.toml
  7. 0 0
      library/macros/src/lib.rs
  8. 43 0
      library/rustsbi/Cargo.toml
  9. 0 0
      library/rustsbi/examples/derive/commons.rs
  10. 0 0
      library/rustsbi/examples/derive/main.rs
  11. 0 0
      library/rustsbi/src/console.rs
  12. 0 0
      library/rustsbi/src/cppc.rs
  13. 0 0
      library/rustsbi/src/forward.rs
  14. 0 0
      library/rustsbi/src/hsm.rs
  15. 0 0
      library/rustsbi/src/ipi.rs
  16. 0 0
      library/rustsbi/src/lib.rs
  17. 0 0
      library/rustsbi/src/nacl.rs
  18. 0 0
      library/rustsbi/src/pmu.rs
  19. 0 0
      library/rustsbi/src/reset.rs
  20. 0 0
      library/rustsbi/src/rfence.rs
  21. 0 0
      library/rustsbi/src/sta.rs
  22. 0 0
      library/rustsbi/src/susp.rs
  23. 0 0
      library/rustsbi/src/timer.rs
  24. 0 0
      library/rustsbi/src/traits.rs
  25. 0 0
      library/rustsbi/tests/build-full.rs
  26. 0 0
      library/rustsbi/tests/build-generics.rs
  27. 0 0
      library/rustsbi/tests/build-rename.rs
  28. 0 0
      library/rustsbi/tests/build-skip.rs
  29. 0 0
      library/rustsbi/tests/dynamic-generics.rs
  30. 0 0
      library/rustsbi/tests/dynamic-priority.rs
  31. 0 0
      library/rustsbi/tests/forward-struct.rs
  32. 0 0
      library/sbi-rt/.cargo/config.toml
  33. 0 0
      library/sbi-rt/.gitignore
  34. 0 0
      library/sbi-rt/CHANGELOG.md
  35. 0 0
      library/sbi-rt/Cargo.toml
  36. 0 0
      library/sbi-rt/LICENSE-MIT
  37. 0 0
      library/sbi-rt/LICENSE-MULAN
  38. 0 0
      library/sbi-rt/README.md
  39. 0 0
      library/sbi-rt/README_EN.md
  40. 0 0
      library/sbi-rt/src/base.rs
  41. 0 0
      library/sbi-rt/src/binary.rs
  42. 0 0
      library/sbi-rt/src/cppc.rs
  43. 0 0
      library/sbi-rt/src/dbcn.rs
  44. 0 0
      library/sbi-rt/src/hsm.rs
  45. 0 0
      library/sbi-rt/src/legacy.rs
  46. 0 0
      library/sbi-rt/src/lib.rs
  47. 0 0
      library/sbi-rt/src/nacl.rs
  48. 0 0
      library/sbi-rt/src/pmu.rs
  49. 0 0
      library/sbi-rt/src/rfnc.rs
  50. 0 0
      library/sbi-rt/src/spi.rs
  51. 0 0
      library/sbi-rt/src/srst.rs
  52. 0 0
      library/sbi-rt/src/sta.rs
  53. 0 0
      library/sbi-rt/src/susp.rs
  54. 0 0
      library/sbi-rt/src/time.rs
  55. 0 0
      library/sbi-spec/.gitignore
  56. 0 0
      library/sbi-spec/CHANGELOG.md
  57. 0 0
      library/sbi-spec/Cargo.toml
  58. 0 0
      library/sbi-spec/LICENSE-MIT
  59. 0 0
      library/sbi-spec/LICENSE-MULAN
  60. 0 0
      library/sbi-spec/README.md
  61. 0 0
      library/sbi-spec/src/base.rs
  62. 0 0
      library/sbi-spec/src/binary.rs
  63. 0 0
      library/sbi-spec/src/cppc.rs
  64. 0 0
      library/sbi-spec/src/dbcn.rs
  65. 0 0
      library/sbi-spec/src/dbtr.rs
  66. 0 0
      library/sbi-spec/src/fwft.rs
  67. 0 0
      library/sbi-spec/src/hsm.rs
  68. 0 0
      library/sbi-spec/src/legacy.rs
  69. 0 0
      library/sbi-spec/src/lib.rs
  70. 0 0
      library/sbi-spec/src/mpxy.rs
  71. 0 0
      library/sbi-spec/src/nacl.rs
  72. 0 0
      library/sbi-spec/src/pmu.rs
  73. 0 0
      library/sbi-spec/src/rfnc.rs
  74. 0 0
      library/sbi-spec/src/spi.rs
  75. 0 0
      library/sbi-spec/src/srst.rs
  76. 0 0
      library/sbi-spec/src/sse.rs
  77. 0 0
      library/sbi-spec/src/sta.rs
  78. 0 0
      library/sbi-spec/src/susp.rs
  79. 0 0
      library/sbi-spec/src/time.rs
  80. 0 0
      library/sbi-testing/.cargo/config.toml
  81. 0 0
      library/sbi-testing/.gitignore
  82. 0 0
      library/sbi-testing/CHANGELOG.md
  83. 0 0
      library/sbi-testing/Cargo.toml
  84. 0 0
      library/sbi-testing/LICENSE-MIT
  85. 0 0
      library/sbi-testing/LICENSE-MULAN
  86. 0 0
      library/sbi-testing/README.md
  87. 0 0
      library/sbi-testing/README_EN.md
  88. 0 0
      library/sbi-testing/rust-toolchain.toml
  89. 0 0
      library/sbi-testing/src/base.rs
  90. 0 0
      library/sbi-testing/src/dbcn.rs
  91. 0 0
      library/sbi-testing/src/hsm.rs
  92. 0 0
      library/sbi-testing/src/lib.rs
  93. 0 0
      library/sbi-testing/src/log_test.rs
  94. 0 0
      library/sbi-testing/src/spi.rs
  95. 2 2
      library/sbi-testing/src/thread.rs
  96. 2 2
      library/sbi-testing/src/time.rs
  97. 87 0
      prototyper/.pre-commit-config.yaml
  98. 6 0
      prototyper/CHANGELOG.md
  99. 56 0
      prototyper/README.md
  100. 7 0
      prototyper/_typos.toml

+ 5 - 0
.cargo/config.toml

@@ -0,0 +1,5 @@
+[alias]
+xtask = "run --package xtask --release --"
+prototyper = "xtask prototyper"
+test-kernel = "xtask test"
+bench-kernel = "xtask bench"

+ 4 - 4
.github/workflows/Rust.yml

@@ -45,16 +45,16 @@ jobs:
           key: ${{ matrix.TARGET }}
       - name: Build (no default features)
         run: |
-          cargo build --target ${{ matrix.TARGET }} --verbose
+          cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose
       - name: Build (machine)
         run: |
-          cargo build --target ${{ matrix.TARGET }} --verbose --features "machine"
+          cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "machine"
       - name: Build (forward)
         run: |
-          cargo build --target ${{ matrix.TARGET }} --verbose --features "forward"
+          cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "forward"
       - name: Build (machine + forward)
         run: |
-          cargo build --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
+          cargo build -p rustsbi --target ${{ matrix.TARGET }} --verbose --features "machine, forward"
 
   test-rustsbi:
     name: Test rustsbi

+ 50 - 0
.github/workflows/prototyper.yml

@@ -0,0 +1,50 @@
+# This workflow uses actions that are not certified by GitHub.
+# They are provided by a third-party and are governed by
+# separate terms of service, privacy policy, and support
+# documentation.
+# rust-clippy is a tool that runs a bunch of lints to catch common
+# mistakes in your Rust code and help improve your Rust code.
+# More details at https://github.com/rust-lang/rust-clippy
+# and https://rust-lang.github.io/rust-clippy/
+
+name: CI
+
+on:
+  pull_request:
+  push:
+    paths-ignore:
+      - '**.md'
+      - 'LICENSE'
+
+jobs:
+  rust-clippy-analyze:
+    name: Run rust-clippy analyzing
+    runs-on: ubuntu-latest
+    permissions:
+      security-events: write
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v4
+
+      - name: Check format
+        run: cargo fmt --check
+
+      - name: Run test
+        run: |
+            cargo test -p rustsbi-prototyper
+
+      - name: Install required cargo
+        run: cargo install clippy-sarif sarif-fmt
+
+      - name: Run rust-clippy
+        run: |
+          cargo clippy -p rustsbi-prototyper --target riscv64imac-unknown-none-elf  --message-format=json  | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
+          cargo clippy -p rustsbi-test-kernel --target riscv64imac-unknown-none-elf --message-format=json  | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
+          cargo clippy -p rustsbi-bench-kernel --target riscv64imac-unknown-none-elf --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
+        continue-on-error: true
+
+      - name: Upload analysis results to GitHub
+        uses: github/codeql-action/upload-sarif@v3
+        with:
+          sarif_file: rust-clippy-results.sarif
+          wait-for-processing: true

+ 11 - 47
Cargo.toml

@@ -1,53 +1,15 @@
-[package]
-name = "rustsbi"
-description = "Minimal RISC-V's SBI implementation library in Rust"
-version = "0.4.0"
-authors = [
-    "Luo Jia <[email protected]>",
-    "Campbell He <[email protected]>",
-    "Yifan Wu <[email protected]>",
-]
-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",
+    "prototyper/prototyper",
+    "prototyper/bench-kernel",
+    "prototyper/test-kernel",
+    "xtask",
 ]
 
 [workspace.package]
@@ -55,4 +17,6 @@ edition = "2024"
 license = "MulanPSL-2.0 OR MIT"
 repository = "https://github.com/rustsbi/rustsbi"
 
+[profile.release]
+debug = true
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

+ 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 <[email protected]>",
+    "Campbell He <[email protected]>",
+    "Yifan Wu <[email protected]>",
+]
+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,

+ 87 - 0
prototyper/.pre-commit-config.yaml

@@ -0,0 +1,87 @@
+fail_fast: false
+repos:
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.3.0
+    hooks:
+      - id: check-byte-order-marker
+      - id: check-case-conflict
+      - id: check-merge-conflict
+      - id: check-symlinks
+      - id: check-yaml
+      - id: end-of-file-fixer
+      - id: mixed-line-ending
+      - id: trailing-whitespace
+  - repo: https://github.com/psf/black
+    rev: 22.10.0
+    hooks:
+      - id: black
+  - repo: local
+    hooks:
+      - id: cargo-fmt
+        name: cargo fmt
+        description: Format files with rustfmt.
+        entry: bash -c 'cargo fmt -- --check'
+        language: rust
+        files: \.rs$
+        args: []
+      - id: typos
+        name: typos
+        description: check typo
+        entry: bash -c 'typos'
+        language: rust
+        files: \.*$
+        pass_filenames: false
+      - id: cargo-check
+        name: cargo check
+        description: Check the package for errors.
+        entry: |
+          bash -c '
+            # Get all packages in the workspace
+            packages=$(cargo metadata --format-version 1 | jq -r ".packages[] | select(.name != \"xtask\") | .name")
+
+            # Check each package
+            for package in $packages; do
+              echo "Checking package: $package"
+              cargo check -p "$package" --target riscv64imac-unknown-none-elf
+              check_status=$?
+
+              # If the check fails, exit with the error code
+              if [ "$check_status" -ne 0 ]; then
+                echo "Package $package check failed, exit status: $check_status!"
+                exit $check_status
+              fi
+            done
+
+            echo "All packages checked successfully."
+            exit 0
+          '
+        language: rust
+        files: \.rs$
+        pass_filenames: false
+      - id: cargo-clippy
+        name: cargo clippy
+        description: Lint Rust sources.
+        entry: |
+          bash -c '
+            # Get all packages in the workspace
+            packages=$(cargo metadata --format-version 1 | jq -r ".packages[] | select(.name != \"xtask\") | .name")
+
+            # Lint each package
+            for package in $packages; do
+              echo "Linting package: $package"
+              cargo clippy -p "$package" --target riscv64imac-unknown-none-elf -- -D warnings
+              clippy_status=$?
+
+              # If the linting fails, exit with the error code
+              if [ "$clippy_status" -ne 0 ]; then
+                echo "Package $package clippy check failed, exit status: $clippy_status!"
+                exit $clippy_status
+              fi
+            done
+
+            echo "All packages linted successfully."
+            exit 0
+          '
+        language: rust
+        files: \.rs$
+        pass_filenames: false

+ 6 - 0
prototyper/CHANGELOG.md

@@ -0,0 +1,6 @@
+# Changelog
+
+All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.
+
+---
+## [unreleased]

+ 56 - 0
prototyper/README.md

@@ -0,0 +1,56 @@
+# RustSBI Prototyper
+
+RustSBI Prototyper is a developing RISC-V Secure Bootloader solution. It can be integrated with the Rust or C language ecosystem to form a complete RISC-V bootloader ecosystem.
+
+## Setting Up the Development Environment
+
+### Packages to be installed
+
+```bash
+cargo install cargo-binutils
+sudo apt install u-boot-tools
+```
+
+
+### Optional Tools
+
+The following tools are not mandatory but can be useful for enhancing your development experience.
+
+#### Install pre-commit
+
+pre-commit is a tool that runs code checks before you commit your code.
+
+```bash
+pipx install pre-commit
+
+# After installation, run pre-commit install to set it up for your project.
+pre-commit install
+```
+
+#### Install Cargo Deny
+
+Cargo deny is a Cargo plugin used to check the security of your dependencies.
+
+```bash
+cargo install --locked cargo-deny
+```
+
+#### Install typos
+
+typos is a spell-checking tool.
+
+```bash
+cargo install typos-cli
+```
+
+#### Install git cliff
+
+git cliff is a tool for generating changelogs.
+
+```bash
+cargo install git-cliff
+```
+
+## License
+
+This project is dual-licensed under MIT or Mulan-PSL v2. See [LICENSE-MIT](./LICENSE-MIT) and [LICENSE-MULAN](./LICENSE-MULAN) for details.

+ 7 - 0
prototyper/_typos.toml

@@ -0,0 +1,7 @@
+[default.extend-words]
+rela = "rela"
+sie = "sie"
+stip = "stip"
+
+[files]
+extend-exclude = ["CHANGELOG.md"]

部分文件因为文件数量过多而无法显示