diff --git a/kernel/Makefile b/kernel/Makefile index 9ba6c2c..faff60a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -42,17 +42,11 @@ build_path := target/$(target)/$(mode) kernel := $(build_path)/rcore kernel_img := $(build_path)/kernel.img bootimage := $(build_path)/bootimage.bin -dtb := src/arch/$(arch)/boot/dts/$(board).dtb bootloader_dir = ../bootloader bootloader := $(bootloader_dir)/target/$(target)/$(mode)/rcore-bootloader bbl_path := $(PWD)/../riscv-pk user_dir := ../user -ifeq ($(arch), aarch64) -board := raspi3 - -ifeq ($(arch), mipsel) -board := malta ### export environments ### export ARCH = $(arch) @@ -60,9 +54,17 @@ export BOARD = $(board) export SMP = $(smp) export DTB = $(dtb) export SFSIMG = $(user_dir)/build/$(arch).qcow2 + +ifeq ($(arch), aarch64) +board := raspi3 export SFSIMG = $(user_dir)/build/$(arch).img +else ifeq ($(arch), mipsel) +board := malta endif +dtb := src/arch/$(arch)/boot/dts/$(board).dtb + + ### qemu options ### qemu_opts := \ -smp cores=$(smp) @@ -108,7 +110,6 @@ qemu_opts += \ -machine $(board) \ -serial null -serial mon:stdio \ -kernel $(kernel_img) -endif else ifeq ($(arch), mipsel) qemu_opts += \ diff --git a/kernel/build.rs b/kernel/build.rs index 9602b9b..be0e3b3 100644 --- a/kernel/build.rs +++ b/kernel/build.rs @@ -2,6 +2,7 @@ extern crate cc; use std::fs::File; use std::io::{Result, Write}; +use std::path::Path; fn main() { println!("cargo:rerun-if-env-changed=LOG"); @@ -19,7 +20,7 @@ fn main() { "riscv64" => { } "mipsel" => { - gen_dtb_asm().unwrap(); + gen_dtb_asm(&arch, &board).unwrap(); } "aarch64" => { } @@ -52,10 +53,8 @@ fn gen_vector_asm() -> Result<()> { } -fn gen_dtb_asm() -> Result<()> { - let arch = std::env::var("ARCH").unwrap(); +fn gen_dtb_asm(arch: &String, board: &String) -> Result<()> { let dtb = std::env::var("DTB").unwrap(); - let board = std::env::var("BOARD").unwrap(); if !Path::new(&dtb).is_file() { panic!("DTB `{}` not found", dtb)