浏览代码

github: add workflow configurations

luojia65 2 年之前
父节点
当前提交
20998d0456
共有 3 个文件被更改,包括 122 次插入2 次删除
  1. 120 0
      .github/workflows/rust.yml
  2. 1 1
      Cargo.toml
  3. 1 1
      src/ecall/mod.rs

+ 120 - 0
.github/workflows/rust.yml

@@ -0,0 +1,120 @@
+name: CI
+
+on:
+  push:
+    branches: [ "main" ]
+  pull_request:
+    branches: [ "main" ]
+  workflow_dispatch:
+
+env:
+  CARGO_UNSTABLE_SPARSE_REGISTRY: true
+  CARGO_TERM_COLOR: always
+
+jobs:
+  fmt:
+    name: Rustfmt
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+          components: rustfmt
+      - name: Cache Dependencies
+        uses: Swatinem/rust-cache@v2
+      - uses: actions-rs/cargo@v1
+        with:
+          command: fmt
+          args: --all -- --check
+
+  check-stable:
+    name: Cargo check (stable)
+    runs-on: ubuntu-latest
+    needs: fmt
+    strategy:
+      matrix:
+        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+          target: ${{ matrix.TARGET }}
+      - name: Cache Dependencies
+        uses: Swatinem/rust-cache@v2
+        with:
+          key: ${{ matrix.TARGET }}
+      - name: Check (no default features)
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target ${{ matrix.TARGET }} --no-default-features --verbose
+      - name: Check (machine)
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --target ${{ matrix.TARGET }} --features "machine" --verbose
+
+  check-nightly:
+    name: Cargo check (nightly)
+    runs-on: ubuntu-latest
+    needs: fmt
+    strategy:
+      matrix:
+        TARGET: [riscv64imac-unknown-none-elf, riscv32imac-unknown-none-elf]
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: nightly
+          override: true
+          target: ${{ matrix.TARGET }}
+      - name: Cache Dependencies
+        uses: Swatinem/rust-cache@v2
+        with:
+          key: ${{ matrix.TARGET }}
+      - name: Check (singleton)
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --features "singleton" --target ${{ matrix.TARGET }} --verbose
+      - name: Check (legacy)
+        uses: actions-rs/cargo@v1
+        with:
+          command: check
+          args: --features "legacy" --target ${{ matrix.TARGET }} --verbose
+
+  tests:
+    name: Run tests
+    needs: fmt
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          components: clippy
+          override: true
+      - name: Cache Dependencies
+        uses: Swatinem/rust-cache@v2
+      - name: Clippy
+        uses: actions-rs/cargo@v1
+        with:
+          command: clippy
+      - name: Run tests (no default features)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --no-default-features --verbose
+      - name: Run tests (machine)
+        uses: actions-rs/cargo@v1
+        with:
+          command: test
+          args: --features "machine" --verbose

+ 1 - 1
Cargo.toml

@@ -32,7 +32,7 @@ machine = ["dep:riscv"]
 # Disable this feature to use instance based RustSBI environment.
 singleton = ["dep:riscv", "machine"]
 # Support legacy extension; this feature is not included by default.
-legacy = ["sbi-spec/legacy"]
+legacy = ["sbi-spec/legacy", "singleton"]
 
 [package.metadata.docs.rs]
 default-target = "riscv64imac-unknown-none-elf"

+ 1 - 1
src/ecall/mod.rs

@@ -91,7 +91,7 @@ pub fn handle_ecall(extension: usize, function: usize, param: [usize; 6]) -> Sbi
                 #[cfg(target_pointer_width = "64")]
                 () => crate::timer::set_timer(param[0] as _),
                 #[cfg(target_pointer_width = "32")]
-                () => crate::timer::set_timer(param[0] as _, param[1] as _),
+                () => crate::timer::set_timer(concat_u32(param[1] as _, param[0] as _)),
             };
             SbiRet {
                 error: param[0],