From 06f5aabdb0246c4876904cef82f4f8b6aa17e264 Mon Sep 17 00:00:00 2001 From: Mark Poliakov Date: Fri, 3 Sep 2021 11:01:55 +0300 Subject: [PATCH] Clean up warnings --- build.sh | 13 +++- kernel/src/arch/mach_bcm283x/irq.rs | 13 ---- kernel/src/arch/mach_bcm283x/mod.rs | 5 +- kernel/src/arch/mach_bcm283x/timer.rs | 86 --------------------------- kernel/src/arch/mach_virt/irq.rs | 9 --- kernel/src/arch/mach_virt/mod.rs | 6 +- kernel/src/arch/smp.rs | 2 +- kernel/src/arch/timer.rs | 3 +- kernel/src/arch/vectors.S | 2 +- kernel/src/dev/irq.rs | 12 ++-- kernel/src/dev/irq/gic.rs | 2 +- kernel/src/fdt.rs | 11 ++-- kernel/src/main.rs | 8 +-- 13 files changed, 32 insertions(+), 140 deletions(-) delete mode 100644 kernel/src/arch/mach_bcm283x/irq.rs delete mode 100644 kernel/src/arch/mach_virt/irq.rs diff --git a/build.sh b/build.sh index c74fcbb..fa85160 100755 --- a/build.sh +++ b/build.sh @@ -6,8 +6,19 @@ fi LLVM_DIR=$(llvm-config --bindir) ARCH=aarch64-unknown-none-${MACH} +CARGO_ARGS="--target ../etc/aarch64-unknown-none-$MACH.json \ + --features mach_$MACH,fdt-rs" set -e -cd kernel && cargo build --target ../etc/aarch64-unknown-none-$MACH.json --features=mach_$MACH,fdt-rs + +cd kernel +case $1 in + check) + cargo check $CARGO_ARGS + ;; + build|"") + cargo build $CARGO_ARGS + ;; +esac cd .. ${LLVM_DIR}/llvm-objcopy -O binary target/${ARCH}/debug/kernel target/${ARCH}/debug/kernel.bin diff --git a/kernel/src/arch/mach_bcm283x/irq.rs b/kernel/src/arch/mach_bcm283x/irq.rs deleted file mode 100644 index 1bfca50..0000000 --- a/kernel/src/arch/mach_bcm283x/irq.rs +++ /dev/null @@ -1,13 +0,0 @@ -use crate::{ - arch::{ - cpu, - mach_bcm283x::mbox::CORE_MBOX0, - mmio_read, - }, - dev::irq::IrqRegisters, -}; - -#[no_mangle] -extern "C" fn do_fiq() { - loop {} -} diff --git a/kernel/src/arch/mach_bcm283x/mod.rs b/kernel/src/arch/mach_bcm283x/mod.rs index 3b5115e..7465979 100644 --- a/kernel/src/arch/mach_bcm283x/mod.rs +++ b/kernel/src/arch/mach_bcm283x/mod.rs @@ -1,4 +1,3 @@ -pub mod irq; pub mod mbox; pub mod smp; pub mod timer; @@ -33,7 +32,7 @@ impl InterruptController for Intc { } } - unsafe fn disable_irq(&self, irq: u32) { + unsafe fn disable_irq(&self, _irq: u32) { todo!(); } @@ -41,7 +40,7 @@ impl InterruptController for Intc { unsafe { mmio_read(Self::REG_INT_SRC) & (1 << irq) != 0 } } - unsafe fn clear_irq(&self, irq: u32) { + unsafe fn clear_irq(&self, _irq: u32) { } } diff --git a/kernel/src/arch/mach_bcm283x/timer.rs b/kernel/src/arch/mach_bcm283x/timer.rs index 7df7c09..e69de29 100644 --- a/kernel/src/arch/mach_bcm283x/timer.rs +++ b/kernel/src/arch/mach_bcm283x/timer.rs @@ -1,86 +0,0 @@ -use crate::arch::{ - cpu, intrin, mmio_read, mmio_write, -}; - -//pub struct CoreTimer; -//pub struct SocTimer; -// -//impl CoreTimer { -// const REG_PSC: usize = 0x40000008; -// const REG_INTC: usize = 0x40000040; -// -// const INTC_CNTPNSIRQ_FIQ: u32 = 1 << 5; -// const INTC_CNTPNSIRQ_IRQ: u32 = 1 << 1; -// -// const PRESCALER: u32 = 0x80000000; -// const RELOAD_VALUE: usize = 1 << 18; -//} -// -//impl LocalTimer for CoreTimer { -// unsafe fn enable(mode: LocalTimerMode) { -// let phys_core_id = cpu::get_phys_id(); -// -// mmio_write(Self::REG_PSC + 4 * phys_core_id, Self::PRESCALER); -// let tmp = mmio_read(Self::REG_INTC + 4 * phys_core_id); -// let flags = match mode { -// LocalTimerMode::Irq => Self::INTC_CNTPNSIRQ_IRQ, -// LocalTimerMode::Fiq => Self::INTC_CNTPNSIRQ_FIQ, -// }; -// mmio_write(Self::REG_INTC + 4 * phys_core_id, tmp | flags); -// -// intrin::write_cntp_ctl_el0(1); -// } -// -// fn do_irq() { -// local_tick(); -// Self::update(Self::RELOAD_VALUE); -// } -// -// #[inline(always)] -// fn update(value: usize) { -// let current = intrin::read_cntp_cval_el0(); -// unsafe { -// intrin::write_cntp_cval_el0(current + value); -// } -// } -//} -// -//impl SocTimer { -// const REG_CTL: usize = 0x40000034; -// const REG_IRQ_RT: usize = 0x40000024; -// const REG_IRQ_CLR: usize = 0x40000038; -// -// const CTL_TIMER_EN: u32 = 1 << 28; -// const CTL_IRQ_EN: u32 = 1 << 29; -// const IRQ_RT_IRQ0: u32 = 0; -// const IRQ_CLR_VALUE: u32 = (1 << 31) | (1 << 30); -// -// const BASE_FREQ: u32 = 38400000; -// -// pub const fn new() -> Self { -// Self {} -// } -//} -// -//impl GlobalTimer for SocTimer { -// unsafe fn enable(&self) { -// let reload = Self::BASE_FREQ / (GLOBAL_TIMER_FREQ as u32); -// -// mmio_write(Self::REG_IRQ_RT, Self::IRQ_RT_IRQ0); -// mmio_write( -// Self::REG_CTL, -// reload | Self::CTL_TIMER_EN | Self::CTL_IRQ_EN, -// ); -// } -// -// fn reset(&self) { -// unsafe { -// mmio_write(Self::REG_IRQ_CLR, Self::IRQ_CLR_VALUE); -// } -// } -// -// fn do_irq(&self) { -// global_tick(); -// self.reset(); -// } -//} diff --git a/kernel/src/arch/mach_virt/irq.rs b/kernel/src/arch/mach_virt/irq.rs deleted file mode 100644 index 94644ec..0000000 --- a/kernel/src/arch/mach_virt/irq.rs +++ /dev/null @@ -1,9 +0,0 @@ -use crate::{ - arch::intrin, - dev::irq::{IrqRegisters, GIC}, -}; - -#[no_mangle] -extern "C" fn do_fiq(_regs: &mut IrqRegisters) { - loop {} -} diff --git a/kernel/src/arch/mach_virt/mod.rs b/kernel/src/arch/mach_virt/mod.rs index 77ba3d4..778f17c 100644 --- a/kernel/src/arch/mach_virt/mod.rs +++ b/kernel/src/arch/mach_virt/mod.rs @@ -1,4 +1,8 @@ pub mod timer; -pub mod irq; + +use address::PhysicalAddress; pub const IRQ_LOCAL_TIMER: u32 = 30; + +pub const GICD_BASE: PhysicalAddress = PhysicalAddress::new(0x08000000usize); +pub const GICC_BASE: PhysicalAddress = PhysicalAddress::new(0x08010000usize); diff --git a/kernel/src/arch/smp.rs b/kernel/src/arch/smp.rs index f3df4f9..8b65ea3 100644 --- a/kernel/src/arch/smp.rs +++ b/kernel/src/arch/smp.rs @@ -28,7 +28,7 @@ cfg_if! { impl IpiDelivery for IpiDeliveryImpl { fn enable(&self) {} - fn send_ipi(target_id: u32, message: IpiMessage) {} + fn send_ipi(_target_id: u32, _message: IpiMessage) {} } pub(super) fn cpu_ready(_index: usize) {} diff --git a/kernel/src/arch/timer.rs b/kernel/src/arch/timer.rs index b481444..3710a91 100644 --- a/kernel/src/arch/timer.rs +++ b/kernel/src/arch/timer.rs @@ -1,6 +1,5 @@ -use core::sync::atomic::{AtomicU64, Ordering}; use crate::{ - arch::{intrin, machine, smp::{self, IpiMessage}}, + arch::{intrin, machine}, dev::irq::{self, InterruptController, InterruptHandler}, }; diff --git a/kernel/src/arch/vectors.S b/kernel/src/arch/vectors.S index 61b6b09..320347f 100644 --- a/kernel/src/arch/vectors.S +++ b/kernel/src/arch/vectors.S @@ -44,7 +44,7 @@ vec_el1_sp_elx_fiq: __exc_save_ctx mov x0, sp - bl do_fiq + b . __exc_restore_ctx diff --git a/kernel/src/dev/irq.rs b/kernel/src/dev/irq.rs index da33ae7..907682a 100644 --- a/kernel/src/dev/irq.rs +++ b/kernel/src/dev/irq.rs @@ -1,6 +1,4 @@ -use crate::arch::{intrin, machine}; use alloc::collections::LinkedList; -use address::PhysicalAddress; #[repr(C)] pub struct IrqRegisters { @@ -46,7 +44,7 @@ pub trait InterruptHandler { pub struct InterruptEntry { irq: u32, - handler: &'static dyn InterruptHandler + handler: &'static dyn InterruptHandler, } static mut IRQ_HANDLERS: LinkedList = LinkedList::new(); @@ -66,9 +64,7 @@ extern "C" fn do_irq(_regs: &mut IrqRegisters) { pub fn set_irq_handler(irq: u32, handler: &'static dyn InterruptHandler) { unsafe { - IRQ_HANDLERS.push_front(InterruptEntry { - irq, handler - }); + IRQ_HANDLERS.push_front(InterruptEntry { irq, handler }); } } @@ -82,10 +78,10 @@ cfg_if! { } else { pub mod gic; use gic::Gic; + use crate::arch::machine; pub static GIC: Gic = Gic::new( - PhysicalAddress::new(0x08000000usize), - PhysicalAddress::new(0x08010000usize), + machine::GICD_BASE, machine::GICC_BASE ); pub fn get_intc() -> &'static impl InterruptController { diff --git a/kernel/src/dev/irq/gic.rs b/kernel/src/dev/irq/gic.rs index cf0ba7a..fbe68b7 100644 --- a/kernel/src/dev/irq/gic.rs +++ b/kernel/src/dev/irq/gic.rs @@ -21,7 +21,7 @@ impl InterruptController for Gic { self.unmask_irq(irq); } - unsafe fn disable_irq(&self, irq: u32) { + unsafe fn disable_irq(&self, _irq: u32) { todo!(); } diff --git a/kernel/src/fdt.rs b/kernel/src/fdt.rs index 1c77be5..ea01422 100644 --- a/kernel/src/fdt.rs +++ b/kernel/src/fdt.rs @@ -9,7 +9,7 @@ use address::{PhysicalAddress, VirtualAddress}; use core::mem::MaybeUninit; use fdt_rs::{ base::{DevTree, DevTreeProp}, - index::{DevTreeIndex, DevTreeIndexNode}, + index::DevTreeIndex, prelude::*, }; @@ -44,14 +44,11 @@ pub fn init(fdt_base_phys: PhysicalAddress) { debugln!("Allocating {} pages for fdt index", page_count); let pages = mem::phys::alloc_contiguous_pages(PageUsage::Kernel, page_count).unwrap(); let pages_virt = VirtualAddress::::from(pages); - let index = DevTreeIndex::new(fdt, unsafe { - pages_virt.as_slice_mut(page_count * 0x1000) - }).unwrap(); + let index = + DevTreeIndex::new(fdt, unsafe { pages_virt.as_slice_mut(page_count * 0x1000) }).unwrap(); unsafe { - FDT_MANAGER.write(FdtManager { - fdt, index - }); + FDT_MANAGER.write(FdtManager { fdt, index }); } } diff --git a/kernel/src/main.rs b/kernel/src/main.rs index 8f911f3..b2c4bbf 100644 --- a/kernel/src/main.rs +++ b/kernel/src/main.rs @@ -10,11 +10,8 @@ #[macro_use] extern crate cfg_if; -#[macro_use] extern crate alloc; -use alloc::boxed::Box; - #[macro_use] pub mod debug; @@ -28,10 +25,7 @@ pub mod mem; pub use mem::KernelSpace; use address::PhysicalAddress; -use arch::{ - cpu::{self, Cpu}, - intrin, smp, timer, -}; +use arch::{cpu, intrin, smp, timer}; use dev::irq; pub fn entry_common() -> ! {