diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..958d0de --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,42 @@ +name: Kernel CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@nightly + with: + components: rust-src, clippy + + # - name: Get just + # uses: taiki-e/install-action@just + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} + restore-keys: ${{ runner.os }}-cargo- + + - name: Build + run: cargo build --verbose + + # - name: Test + # run: cargo test --verbose + + - name: Clippy + run: cargo clippy --all-features -- -D warnings diff --git a/src/allocator/tiered.rs b/src/allocator/tiered.rs index 1d81c0a..105a973 100644 --- a/src/allocator/tiered.rs +++ b/src/allocator/tiered.rs @@ -32,7 +32,7 @@ impl BuddySystem { /// # Safety /// This is safe as long as the `addr` is valid pub unsafe fn init(base: usize) -> Result { - if base % PAGE_SIZE != 0 { + if base.is_multiple_of(PAGE_SIZE) { return Err(AllocatorError::AddrNotAligned { addr: base, align: PAGE_SIZE, diff --git a/src/kinit.rs b/src/kinit.rs index e504d5f..f9a0d58 100644 --- a/src/kinit.rs +++ b/src/kinit.rs @@ -14,7 +14,7 @@ pub fn pre_kinit(balloc: &mut BitMapAlloc, fdt: fdt::Fdt) { let addr = balloc.alloc(STACK_PAGES); // the address we are returned is at the top of the allocated space, we need to go lower let stack_bottom = addr + STACK_SIZE; - sbi::hsm::start(id, _start as usize, stack_bottom); + sbi::hsm::start(id, _start as *const () as usize, stack_bottom); } } diff --git a/src/vmem.rs b/src/vmem.rs index e19862d..11060de 100644 --- a/src/vmem.rs +++ b/src/vmem.rs @@ -78,7 +78,7 @@ impl PTEntry { } } -pub fn init(balloc: &mut BitMapAlloc) -> Mapper { +pub fn init(balloc: &mut BitMapAlloc) -> Mapper<'_> { let tbl_addr = balloc.alloc(1); PAGE_TABLE.store(tbl_addr, Ordering::Relaxed); @@ -95,7 +95,7 @@ fn map( perms: Perms, pages: usize, ) -> Result<(), MapError> { - assert!((vaddr & 4096) % 4096 == 0); + assert!((vaddr & 4096).is_multiple_of(4096)); assert!(pages > 0); for i in 0..pages {