From 02b1affcf53572150db29f125f34965956495d31 Mon Sep 17 00:00:00 2001 From: WCIofQMandRA Date: Tue, 28 Jun 2022 23:59:16 +0800 Subject: [PATCH] quiet boot --- .gitmodules | 3 +++ lib/rkplat/src/drivers/device_tree.rs | 5 +++-- lib/rkplat/src/drivers/uart/ns16550.rs | 4 +++- makefile | 12 +++++++++--- makefiles/test.mk.1 | 2 +- makefiles/test.mk.sh | 13 +++++-------- opensbi | 1 + 7 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 .gitmodules create mode 160000 opensbi diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..3846fe7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "opensbi"] + path = opensbi + url = https://github.com/riscv-software-src/opensbi diff --git a/lib/rkplat/src/drivers/device_tree.rs b/lib/rkplat/src/drivers/device_tree.rs index 17c54e1..13398ce 100644 --- a/lib/rkplat/src/drivers/device_tree.rs +++ b/lib/rkplat/src/drivers/device_tree.rs @@ -31,6 +31,7 @@ use core::ptr::addr_of; use super::uart; #[cfg(feature="driver_virtio")] use super::virtio; +use log::{info, warn}; use rkalloc::{RKalloc,alloc_type}; use crate::console; use crate::drivers::virtio::GPU_DEIVCE; @@ -290,7 +291,7 @@ fn parse_device(a: &dyn RKalloc, name: &str, props: &[(&str,&[u8])], props_size: &mut *(prop_u64(props, props_size, "reg"). unwrap() as *mut virtio::VirtIOHeader) }; - println_bios!("Detected virtio device with vendor id {:#X}",header.vendor_id()); + info!("Detected virtio device with vendor id {:#X}",header.vendor_id()); match header.device_type() { #[cfg(feature="driver_virtio_blk")] virtio::DeviceType::Block => {todo!()}, @@ -306,7 +307,7 @@ fn parse_device(a: &dyn RKalloc, name: &str, props: &[(&str,&[u8])], props_size: virtio::DeviceType::Input => {todo!()}, #[cfg(feature="driver_virtio_net")] virtio::DeviceType::Network => {todo!()}, - t => println_bios!("WARNING: Unrecognized virtio device: {:?}",t), + t => warn!("Unrecognized virtio device: {:?}",t), } }, _ => {} diff --git a/lib/rkplat/src/drivers/uart/ns16550.rs b/lib/rkplat/src/drivers/uart/ns16550.rs index 87b0f10..799e3e4 100644 --- a/lib/rkplat/src/drivers/uart/ns16550.rs +++ b/lib/rkplat/src/drivers/uart/ns16550.rs @@ -32,6 +32,8 @@ #![allow(dead_code)] use core::{str, slice}; +use log::info; + use super::UartDevice; use crate::drivers::Device; use crate::device::{ioreg_read8,ioreg_write8}; @@ -69,7 +71,7 @@ impl Ns16550 { for i in 0..name.len() { name1[i] = name.as_bytes()[i]; } - println_bios!("Init ns16550 device, name={},addr=0x{:x},irq={}.",name,addr,irq); + info!("Init ns16550 device, name={},addr=0x{:x},irq={}.",name,addr,irq); Self { addr,irq, diff --git a/makefile b/makefile index 271ccba..8e7b31b 100644 --- a/makefile +++ b/makefile @@ -40,7 +40,7 @@ export REPORT_ROOT_DIR := $(PWD)/report export TEST_ROOT_DIR := $(PWD)/test export SRC_ROOT_DIR := $(PWD) export MAKE_BUILD_TYPE := debug -export OBJCOPY_PREFIX := rust- +export CROSS_COMPILE := riscv64-linux-gnu- TEST_LIST := @all IGNORED_LIST := @@ -59,7 +59,7 @@ $(MAKE_ROOT_DIR)/report/makefile: makefiles/report.mk cp makefiles/report.mk "$(MAKE_ROOT_DIR)/report/makefile" .PHONY: test build_test $(MAKE_ROOT_DIR)/test/makefile -test: $(MAKE_ROOT_DIR)/test/makefile +test: $(MAKE_ROOT_DIR)/test/makefile opensbi cd "$(MAKE_ROOT_DIR)/test" && $(MAKE) build_test: $(MAKE_ROOT_DIR)/test/makefile @@ -67,4 +67,10 @@ build_test: $(MAKE_ROOT_DIR)/test/makefile $(MAKE_ROOT_DIR)/test/makefile: makefiles/test.mk.sh makefiles/test.mk.0 makefiles/test.mk.1 -mkdir --parents "$(MAKE_ROOT_DIR)/test" - makefiles/test.mk.sh makefiles/test.mk "$(MAKE_ROOT_DIR)/test/makefile" "$(TEST_ROOT_DIR)" "$(TEST_LIST)" "$(IGNORED_LIST)" + makefiles/test.mk.sh makefiles/test.mk "$(MAKE_ROOT_DIR)/test/makefile" "$(TEST_ROOT_DIR)" "$(TEST_LIST)" "$(IGNORED_LIST)" "$(MAKE_ROOT_DIR)/opensbi/platform/generic/firmware/fw_jump.bin" + +.PHONY: opensbi +opensbi: +#FW_OPTIONS=1 indicates quiet boot + -mkdir --parents "$(MAKE_ROOT_DIR)/opensbi" + cd opensbi && $(MAKE) PLATFORM=generic FW_OPTIONS=1 FW_DYNAMIC=n FW_JUMP=y FW_PAYLOAD=n O="$(MAKE_ROOT_DIR)/opensbi" diff --git a/makefiles/test.mk.1 b/makefiles/test.mk.1 index ff944dc..e0a0b17 100644 --- a/makefiles/test.mk.1 +++ b/makefiles/test.mk.1 @@ -13,4 +13,4 @@ else endif endif @rm $(TEST_ROOT_DIR)/@testname@/Cargo.lock - @$(OBJCOPY_PREFIX)objcopy --strip-all $(TEST_BUILD_DIR)/test-@testname@ -O binary @testname@.bin + @$(CROSS_COMPILE)objcopy --strip-all $(TEST_BUILD_DIR)/test-@testname@ -O binary @testname@.bin diff --git a/makefiles/test.mk.sh b/makefiles/test.mk.sh index ddbddc8..dc641f7 100755 --- a/makefiles/test.mk.sh +++ b/makefiles/test.mk.sh @@ -1,5 +1,5 @@ #!/bin/bash -#usage: test.mk.sh <输入> <输出> <测试列表> <忽略列表> +#usage: test.mk.sh <输入> <输出> <测试列表> <忽略列表> #如果测试列表是@all,则测试test目录下的所有文件夹 if [ "$4" = @all ] @@ -55,25 +55,22 @@ QEMU_VERSION=$(qemu-system-riscv64 -version | grep --basic-regexp 'version *[0-9 echo "" >> $2 echo "run: build" >> $2 -if [ -z "$RISCV_BIOS" ] -then - RISCV_BIOS=default -fi for TEST in $TEST_LIST do # old QEMU versions do not support `-kernel` option - if [ QEMU_VERSION>=6 ] + if [ $QEMU_VERSION -ge 6 ] then KERNEL="-kernel $TEST.bin" else KERNEL="-device loader,file=$TEST.bin,addr=0x80200000" fi + echo " @echo Running $TEST..." >> $2 if [ -f $3/$TEST/run_flags.txt ] then - echo " qemu-system-riscv64 -machine virt $(cat $3/$TEST/run_flags.txt) -bios $RISCV_BIOS $KERNEL" >> $2 + echo " @qemu-system-riscv64 -machine virt $(cat $3/$TEST/run_flags.txt) -bios \"$6\" $KERNEL" >> $2 else - echo " qemu-system-riscv64 -machine virt -nographic -bios $RISCV_BIOS $KERNEL" >> $2 + echo " @qemu-system-riscv64 -machine virt -nographic -bios $6 $KERNEL" >> $2 fi done diff --git a/opensbi b/opensbi new file mode 160000 index 0000000..4489876 --- /dev/null +++ b/opensbi @@ -0,0 +1 @@ +Subproject commit 4489876e933d8ba0d8bc6c64bae71e295d45faac