diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 74a7eb4..9e9791e 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -24,6 +24,7 @@ default = ["sv39"] sv39 = [] board_u540 = ["sv39", "link_user"] board_k210 = ["sv39", "link_user"] +board_rocket_chip = ["sv39", "link_user"] # (for aarch64 RaspberryPi3) nographic = [] board_raspi3 = ["bcm2837", "link_user"] diff --git a/kernel/Makefile b/kernel/Makefile index edb5858..59fb48b 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -26,6 +26,7 @@ # | pc Only available on x86_64, run on real pc # | u540 Only available on riscv64, run on HiFive U540, use Sv39 # | k210 Only available on riscv64, run on K210, use Sv39 +# | rocket_chip Only available on riscv64, run on Rocket Chip, use Sv39 # | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+ # pci_passthru = 0000:00:00.1 Only available on x86_64, passthrough the specified PCI device # init = /bin/ls Only available on riscv64, run specified program instead of user shell @@ -60,7 +61,7 @@ ifeq ($(arch), $(filter $(arch), aarch64 mipsel)) export SFSIMG = $(user_dir)/build/$(arch).img else # board is pc or qemu? -ifeq ($(board), $(filter $(board), pc u540 k210)) +ifeq ($(board), $(filter $(board), pc u540 k210 rocket_chip)) #link user img, so use original image export SFSIMG = $(user_dir)/build/$(arch).img else diff --git a/kernel/src/arch/riscv32/memory.rs b/kernel/src/arch/riscv32/memory.rs index ef0509b..314c7f2 100644 --- a/kernel/src/arch/riscv32/memory.rs +++ b/kernel/src/arch/riscv32/memory.rs @@ -92,6 +92,8 @@ fn remap_the_kernel(dtb: usize) { Linear::new(offset), "bss", ); + // TODO: dtb on rocket chip + #[cfg(not(feature = "board_rocket_chip"))] ms.push( dtb, dtb + super::consts::MAX_DTB_SIZE, diff --git a/kernel/src/arch/riscv32/mod.rs b/kernel/src/arch/riscv32/mod.rs index f05a082..75b7ccc 100644 --- a/kernel/src/arch/riscv32/mod.rs +++ b/kernel/src/arch/riscv32/mod.rs @@ -53,10 +53,11 @@ pub extern "C" fn rust_main(hartid: usize, device_tree_paddr: usize) -> ! { memory::init(device_tree_vaddr); timer::init(); // FIXME: init driver on u540 - #[cfg(not(feature = "board_u540"))] + #[cfg(not(any(feature = "board_u540", feature = "board_rocket_chip")))] crate::drivers::init(device_tree_vaddr); #[cfg(not(feature = "board_k210"))] unsafe { + #[cfg(not(feature = "board_rocket_chip"))] board::enable_serial_interrupt(); board::init_external_interrupt(); }