This repository has been archived by the owner on Jul 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
complete configuration system based on kconfig
- Loading branch information
1 parent
83f431c
commit fbbb389
Showing
12 changed files
with
447 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[submodule "opensbi"] | ||
path = opensbi | ||
url = https://github.com/riscv-software-src/opensbi | ||
[submodule "support/scripts/kconfig"] | ||
path = support/scripts/kconfig | ||
url = https://github.com/linux-kdevops/kconfig.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
mainmenu "Runikraft/0.1.0 Configuration" | ||
|
||
menu "Memory and CPU Configuration" | ||
config HEAP_SIZE | ||
int "Heap size(MiB)" | ||
default 16 | ||
|
||
config STACK_SIZE_PAGE_ORDER | ||
int "Page order of stack size(log STACK_SIZE)" | ||
default 4 | ||
|
||
menu "Limit Configuration" | ||
config MEMORY_SIZE | ||
int "the maximum size of memory(B)" | ||
default -1 | ||
help | ||
-1: unlimited | ||
|
||
config OPEN_FILES | ||
int "the maximum size of open files" | ||
default 1024 | ||
|
||
config PIPE_FILES | ||
int "the maximum size of pipe files" | ||
default 4096 | ||
|
||
config CPU_TIME | ||
int "the limit of CPU time(ms)" | ||
default -1 | ||
help | ||
-1: Duration::MAX | ||
endmenu | ||
|
||
config LCPU_MAXCOUNT | ||
int "the maximum count of CPU(less than 8)" | ||
default 8 | ||
|
||
config MAIN_STACK_SIZE | ||
int "the main stack size(B)" | ||
default 65536 | ||
|
||
config PAGE_SZIE | ||
int "the page size(B)" | ||
default 4096 | ||
endmenu | ||
|
||
menu "Library Configuration" | ||
menu "rkplat features" | ||
config has_smp | ||
bool "Symmetric multiprocessor support" | ||
default y | ||
|
||
config save_fp | ||
bool "Save floating point registers when thread switches" | ||
default n | ||
|
||
config driver_uart | ||
bool "Uart device driver" | ||
default n | ||
|
||
config driver_ns16550 | ||
bool "ns16550 driver" | ||
default y | ||
select driver_uart | ||
|
||
config driver_virtio | ||
bool "Virtio driver" | ||
default n | ||
help | ||
Depend on volatile-v0.3 and bitflags-v1.3 | ||
|
||
config driver_virtio_blk | ||
bool "Virtio block driver" | ||
default y | ||
select driver_virtio | ||
|
||
config driver_virtio_console | ||
bool "Virtio console driver" | ||
default y | ||
select driver_virtio | ||
|
||
config driver_virtio_gpu | ||
bool "Virtio GPU driver" | ||
default y | ||
select driver_virtio | ||
|
||
config driver_virtio_input | ||
bool "Virtio input driver" | ||
default y | ||
select driver_virtio | ||
|
||
config driver_virtio_net | ||
bool "Virtio net driver" | ||
default y | ||
select driver_virtio | ||
|
||
config driver_rtc | ||
bool "Real time clock driver" | ||
default n | ||
|
||
config driver_goldfish_rtc | ||
bool "Goldfish real time clock driver" | ||
default y | ||
select driver_rtc | ||
|
||
config bios_io | ||
bool "Use BIOS to output" | ||
default n | ||
endmenu | ||
|
||
menu "rkboot features" | ||
config have_scheduler | ||
bool "Have scheduler" | ||
help | ||
Depend on rksched | ||
|
||
config sched_coop | ||
bool "Cooperative scheduler" | ||
default y | ||
select have_scheduler | ||
help | ||
Depend on rksched and rkschedcoop | ||
endmenu | ||
endmenu | ||
|
||
menu "Make Build Configuration" | ||
choice | ||
prompt "Make build type" | ||
default debug | ||
|
||
config debug | ||
bool "debug type" | ||
help | ||
Compile without "--release" | ||
config release | ||
bool "release type" | ||
help | ||
Compile with "--release" | ||
endchoice | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
# makefile for Runikraft | ||
|
||
# Authors: 张子辰 <[email protected]> | ||
# 陈建绿 <[email protected]> | ||
|
||
# Copyright (C) 2022 吴骏东, 张子辰, 蓝俊玮, 郭耸霄 and 陈建绿. | ||
|
||
|
@@ -39,37 +40,49 @@ export MAKE_ROOT_DIR := $(PWD)/build | |
export REPORT_ROOT_DIR := $(PWD)/report | ||
export TEST_ROOT_DIR := $(PWD)/test | ||
export SRC_ROOT_DIR := $(PWD) | ||
export MAKE_BUILD_TYPE := debug | ||
export CROSS_COMPILE := riscv64-linux-gnu- | ||
TEST_LIST := @all | ||
IGNORED_LIST := | ||
|
||
.PHONY: all | ||
export PROJECT = Runikraft | ||
export VERSION = 0 | ||
export PATCHLEVEL = 1 | ||
export SUBLEVEL = 0 | ||
export EXTRAVERSION = | ||
|
||
CONFIG_DIR := $(MAKE_ROOT_DIR)/config | ||
SUPPORT_DIR := $(SRC_ROOT_DIR)/support | ||
SCRIPTS_DIR := $(SUPPORT_DIR)/scripts | ||
export KCONFIG_DIR := $(SCRIPTS_DIR)/kconfig | ||
|
||
PHNOY += all | ||
all: test | ||
|
||
.PHONY: everything | ||
PHNOY += everything | ||
everything: all report | ||
|
||
.PHONY: report | ||
PHNOY += report | ||
report: $(MAKE_ROOT_DIR)/report/makefile | ||
cd "$(MAKE_ROOT_DIR)/report" && $(MAKE) | ||
|
||
$(MAKE_ROOT_DIR)/report/makefile: makefiles/report.mk | ||
-mkdir --parents "$(MAKE_ROOT_DIR)/report" | ||
cp makefiles/report.mk "$(MAKE_ROOT_DIR)/report/makefile" | ||
|
||
.PHONY: test build_test $(MAKE_ROOT_DIR)/test/makefile | ||
PHNOY += test | ||
test: $(MAKE_ROOT_DIR)/test/makefile opensbi | ||
cd "$(MAKE_ROOT_DIR)/test" && $(MAKE) | ||
|
||
PHNOY += build_test | ||
build_test: $(MAKE_ROOT_DIR)/test/makefile | ||
cd "$(MAKE_ROOT_DIR)/test" && $(MAKE) build | ||
|
||
PHNOY += $(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)" "$(MAKE_ROOT_DIR)/opensbi/platform/generic/firmware/fw_jump.bin" | ||
|
||
.PHONY: opensbi | ||
PHNOY += opensbi | ||
opensbi: | ||
#FW_OPTIONS=1 indicates quiet boot | ||
-mkdir --parents "$(MAKE_ROOT_DIR)/opensbi" | ||
|
@@ -78,26 +91,51 @@ opensbi: | |
$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib: $(SRC_ROOT_DIR)/lib/rkalloc/alloc_error_handler.rs | ||
@env RUSTC_BOOTSTRAP=1 rustc --edition=2021 $(SRC_ROOT_DIR)/lib/rkalloc/alloc_error_handler.rs --crate-type lib --target riscv64gc-unknown-none-elf -o $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib | ||
|
||
$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/deps/liballoc_error_handler.rlib: $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib | ||
@-mkdir --parents $(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/deps/ | ||
@cp $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/deps/liballoc_error_handler.rlib | ||
|
||
$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/deps/liballoc_error_handler.rlib: $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(CONFIG_DIR)/features2.txt | ||
@-mkdir --parents $(TEST_BUILD_DIR)/deps | ||
@cp $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/deps/liballoc_error_handler.rlib | ||
|
||
.PHONY: example run | ||
example: $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/deps/liballoc_error_handler.rlib | ||
ifeq ($(MAKE_BUILD_TYPE), release) | ||
cd example/sudoku && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build --release | ||
PHNOY += example | ||
example: $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/deps/liballoc_error_handler.rlib $(CONFIG_DIR)/features1.txt $(CONFIG_DIR)/features2.txt | ||
ifeq ($(shell cat $(CONFIG_DIR)/features2.txt), release) | ||
cd example/sudoku && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build --release $(shell cat $(CONFIG_DIR)/features1.txt) | ||
else | ||
ifeq ($(MAKE_BUILD_TYPE), debug) | ||
cd example/sudoku && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build | ||
ifeq ($(shell cat $(CONFIG_DIR)/features2.txt), debug) | ||
cd example/sudoku && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build $(shell cat $(CONFIG_DIR)/features1.txt) | ||
else | ||
@echo "Unknown build type, expect release/debug." | ||
false | ||
endif | ||
endif | ||
$(CROSS_COMPILE)objcopy --strip-all "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/sudoku" -O binary "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/sudoku.bin" | ||
|
||
$(CROSS_COMPILE)objcopy --strip-all "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/sudoku" -O binary "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/sudoku.bin" | ||
|
||
PHNOY += run | ||
run: | ||
qemu-system-riscv64 -machine virt -kernel "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(MAKE_BUILD_TYPE)/sudoku.bin" -device virtio-gpu-device,xres=1280,yres=800 -serial mon:stdio -device virtio-keyboard-device -device virtio-rng-device -bios "$(MAKE_ROOT_DIR)/opensbi/platform/generic/firmware/fw_jump.bin" | ||
qemu-system-riscv64 -machine virt -kernel "$(MAKE_ROOT_DIR)/riscv64gc-unknown-none-elf/$(shell cat $(CONFIG_DIR)/features2.txt)/sudoku.bin" -device virtio-gpu-device,xres=1280,yres=800 -serial mon:stdio -device virtio-keyboard-device -device virtio-rng-device -bios "$(MAKE_ROOT_DIR)/opensbi/platform/generic/firmware/fw_jump.bin" | ||
|
||
$(CONFIG_DIR)/features1.txt: menuconfig | ||
$(CONFIG_DIR)/features2.txt: menuconfig | ||
|
||
PHNOY += menuconfig | ||
menuconfig: $(KCONFIG_DIR)/mconf include/config/project.release $(CONFIG_DIR)/handle_config | ||
@$< Kconfig | ||
@mkdir -p $(CONFIG_DIR) | ||
@$(CONFIG_DIR)/handle_config $(SRC_ROOT_DIR) $(CONFIG_DIR) | ||
|
||
include $(SCRIPTS_DIR)/objects.Makefile | ||
|
||
$(CONFIG_DIR)/handle_config: $(SUPPORT_DIR)/handle_config.cpp | ||
@mkdir -p $(CONFIG_DIR) | ||
@g++ $(SUPPORT_DIR)/handle_config.cpp -o $(CONFIG_DIR)/handle_config | ||
|
||
PHONY += clean | ||
clean: | ||
$(MAKE) -f $(SCRIPTS_DIR)/build.Makefile $@ | ||
|
||
PHONY += help | ||
help: | ||
@echo "Configuration options:" | ||
@echo "menuconfig - demos the menuconfig functionality" | ||
@echo " configuration options will be written in $(CONFIG_DIR)/config.rs" | ||
|
||
.PHONY: $(PHONY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,15 +2,6 @@ | |
.PHONY: @[email protected] | ||
|
||
@[email protected]: $(MAKE_ROOT_DIR)/liballoc_error_handler.rlib $(TEST_BUILD_DIR)/deps/liballoc_error_handler.rlib | ||
ifeq ($(MAKE_BUILD_TYPE), release) | ||
@cd $(TEST_ROOT_DIR)/@testname@ && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build --offline --release | ||
else | ||
ifeq ($(MAKE_BUILD_TYPE), debug) | ||
@cd $(TEST_ROOT_DIR)/@testname@ && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build --offline | ||
else | ||
@echo "Unknown build type, expect release/debug." | ||
false | ||
endif | ||
endif | ||
@cd $(TEST_ROOT_DIR)/@testname@ && env RUSTFLAGS="-Clink-arg=-T$(SRC_ROOT_DIR)/linker.ld --cfg __alloc_error_handler --extern __alloc_error_handler=$(MAKE_ROOT_DIR)/liballoc_error_handler.rlib" cargo build --offline | ||
@rm $(TEST_ROOT_DIR)/@testname@/Cargo.lock | ||
@$(CROSS_COMPILE)objcopy --strip-all $(TEST_BUILD_DIR)/test-@testname@ -O binary @[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Support | ||
scripts 中的内容修改自 https://github.com/mcgrof/init-kconfig 中的同名文件夹。 |
Oops, something went wrong.