From a55f3b61e6eb08d111d0bc768f0c93dcc1ea29a6 Mon Sep 17 00:00:00 2001 From: equation314 Date: Thu, 20 Dec 2018 17:34:24 +0800 Subject: [PATCH] add Makefile option `graphic` & cargo feature `nographic` --- kernel/Cargo.toml | 1 + kernel/Makefile | 52 +++++++++++++-------- kernel/src/arch/aarch64/board/raspi3/mod.rs | 1 + 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 6718500..f1040ee 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -12,6 +12,7 @@ no_mmu = [] # Kernel in M-mode (for riscv32) m_mode = ["no_mmu"] # (for aarch64 RaspberryPi3) +nographic = [] board_raspi3 = ["bcm2837"] raspi3_use_generic_timer = ["bcm2837/use_generic_timer"] diff --git a/kernel/Makefile b/kernel/Makefile index 7173184..a6cfb7a 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,22 +1,23 @@ # Commands: -# make build Build -# make run Build and run in QEMU -# make justrun Run the last build -# make doc Generate docs -# make asm Open the deassemble file of the last build -# make header Open 'objdump -h' of the last build -# make clean Clean +# make build Build +# make run Build and run in QEMU +# make justrun Run the last build +# make doc Generate docs +# make asm Open the deassemble file of the last build +# make header Open 'objdump -h' of the last build +# make clean Clean # # Options: -# arch = x86_64 | riscv32 | aarch64 -# d = int | in_asm | ... QEMU debug info -# mode = debug | release -# LOG = off | error | warn | info | debug | trace -# SFSIMG = SFS image path of user programs -# smp = 1 | 2 | ... SMP core number -# board = fpga Only available on riscv32, build without bbl, run on board -# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+ -# m_mode Only available on riscv32, build for M-Mode, without MMU +# arch = x86_64 | riscv32 | aarch64 +# d = int | in_asm | ... QEMU debug info +# mode = debug | release +# LOG = off | error | warn | info | debug | trace +# SFSIMG = SFS image path of user programs +# smp = 1 | 2 | ... SMP core number +# graphic = on | off enable/disable qemu graphical output +# board = fpga Only available on riscv32, build without bbl, run on board +# | raspi3 Only available on aarch64, run on Raspberry Pi 3 Model B/B+ +# m_mode Only available on riscv32, build for M-Mode, without MMU arch ?= riscv32 board ?= raspi3 @@ -24,7 +25,7 @@ mode ?= debug LOG ?= debug smp ?= 4 # NOTE: crate 'process' use this name 'm_mode' as an environment -# to set interrupt (MIE or SIE) +# to set interrupt (MIE or SIE) m_mode ?= target := $(arch)-blog_os @@ -40,10 +41,15 @@ user_obj := build/$(arch)/user.o export ARCH = $(arch) export SFSIMG = $(user_dir)/build/user-$(arch).img +ifeq ($(arch), aarch64) +graphic ?= on +else +graphic ?= off +endif + ### qemu options ### qemu_opts := \ - -smp cores=$(smp) \ - -nographic + -smp cores=$(smp) ifeq ($(arch), x86_64) qemu_opts += \ @@ -67,6 +73,10 @@ qemu_opts += \ -kernel $(bin) endif +ifneq ($(graphic), on) +qemu_opts += -nographic +endif + ifdef d qemu_opts += -d $(d) endif @@ -78,6 +88,10 @@ features += no_bbl endif endif +ifneq ($(graphic), on) +features += nographic +endif + ifeq ($(board), raspi3) # qemu only has generic timer # TODO: configure system/generic timer automatically diff --git a/kernel/src/arch/aarch64/board/raspi3/mod.rs b/kernel/src/arch/aarch64/board/raspi3/mod.rs index 2bbee12..6954e99 100644 --- a/kernel/src/arch/aarch64/board/raspi3/mod.rs +++ b/kernel/src/arch/aarch64/board/raspi3/mod.rs @@ -22,6 +22,7 @@ pub fn init_serial_early() { /// Initialize raspi3 drivers pub fn init_driver() { + #[cfg(not(feature = "nographic"))] fb::init(); timer::init(); }