From f69a7227ff3ad84af3651fe36162e131d4f2b323 Mon Sep 17 00:00:00 2001 From: Minep Date: Sun, 23 Oct 2022 12:49:15 +0100 Subject: [PATCH 1/1] fix: ensure inlining prerequisites check before compiling add some housekeeping stuff --- lunaix-os/README.md | 10 +++++++++- lunaix-os/flags.h | 11 ++++++++--- lunaix-os/kernel/tty/lxconsole.c | 2 +- lunaix-os/makefile | 21 ++++++++++++++++++--- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/lunaix-os/README.md b/lunaix-os/README.md index 234ea1b..f3d24d0 100644 --- a/lunaix-os/README.md +++ b/lunaix-os/README.md @@ -7,6 +7,8 @@ + `arch` 平台相关代码,LunaixOS的内核引导就在这里。 + `hal` 硬件抽象层,存放主板相关的代码,提供了一些访问主板功能(比如CPU,计时器)的抽象 + `includes` 所有头文件 ++ `debug` 内核调试服务器 ++ `config` makefile配置问题 + `kernel` 这里就是内核了 + `asm` 共内核使用的,且平台相关的代码。 + `ds` 提供一些基本的数据结构支持。 @@ -14,5 +16,11 @@ + `peripheral` 外部设备驱动(如键盘)。 + `time` 为内核提供基本的时间,计时服务。 + `tty` 提供基本的显存操作服务。 + + `fs` 文件系统。 + + `device` 设备(通用)抽象层 + + `block` 块设备抽象层 + + `process` 进程相关 + + `demos` 简单的测试程序 + `lib` 一些内核使用的运行时库,主要提供是内核模式下的一些C标准库里的实现。 -+ `link` 链接器脚本 \ No newline at end of file ++ `link` 链接器脚本 ++ `scripts` 其他脚本(如:用于代码生成) \ No newline at end of file diff --git a/lunaix-os/flags.h b/lunaix-os/flags.h index 90a5a5a..d4262df 100644 --- a/lunaix-os/flags.h +++ b/lunaix-os/flags.h @@ -1,10 +1,15 @@ #ifndef __LUNAIX_FLAGS_H #define __LUNAIX_FLAGS_H -/* - Uncomment below to force LunaixOS use kernel page table when context switch to kernel space - NOTE: This will make the kernel global. +/* + Uncomment below to force LunaixOS use kernel page table when context switch + to kernel space NOTE: This will make the kernel global. */ // #define USE_KERNEL_PG +/* + Uncomment below to disable all assertion +*/ +// #define __LUNAIXOS_NASSERT__ + #endif /* __LUNAIX_FLAGS_H */ diff --git a/lunaix-os/kernel/tty/lxconsole.c b/lunaix-os/kernel/tty/lxconsole.c index 3404450..ae5701b 100644 --- a/lunaix-os/kernel/tty/lxconsole.c +++ b/lunaix-os/kernel/tty/lxconsole.c @@ -29,7 +29,7 @@ static volatile char ttychr; static volatile pid_t fg_pgid = 0; -inline void +static inline void print_control_code(const char cntrl) { console_write_char('^'); diff --git a/lunaix-os/makefile b/lunaix-os/makefile index 058bcc8..ede34f4 100644 --- a/lunaix-os/makefile +++ b/lunaix-os/makefile @@ -3,10 +3,26 @@ include config/make-os include config/make-cc include config/make-debug-tool +DEPS := $(CC) $(LD) xorriso grub-mkrescue + INCLUDES := $(patsubst %, -I%, $(INCLUDES_DIR)) SOURCE_FILES := $(shell find -name "*.[cS]") SRC := $(patsubst ./%, $(OBJECT_DIR)/%.o, $(SOURCE_FILES)) +$(DEPS): + @echo -n "checking $@ .... " + @if which $@ > /dev/null; then \ + echo "ok";\ + else\ + echo "failed" && exit 1;\ + fi + +check-cc: + @echo -n "checking target i686-elf.... " + @test "`i686-elf-gcc -dumpmachine`" = "i686-elf" && echo ok || (echo "failed" && exit 1) + +check: $(DEPS) check-cc + $(OBJECT_DIR): @mkdir -p $(OBJECT_DIR) @@ -32,12 +48,12 @@ $(BIN_DIR)/$(OS_BIN): $(OBJECT_DIR) $(BIN_DIR) $(SRC) @echo " LD $(BIN_DIR)/$(OS_BIN)" @$(CC) -T link/linker.ld -o $(BIN_DIR)/$(OS_BIN) $(SRC) $(LDFLAGS) -$(BUILD_DIR)/$(OS_ISO): $(ISO_DIR) $(BIN_DIR)/$(OS_BIN) GRUB_TEMPLATE +$(BUILD_DIR)/$(OS_ISO): check $(ISO_DIR) $(BIN_DIR)/$(OS_BIN) GRUB_TEMPLATE @./config-grub.sh ${OS_NAME} $(ISO_GRUB_DIR)/grub.cfg @cp $(BIN_DIR)/$(OS_BIN) $(ISO_BOOT_DIR) @grub-mkrescue -o $(BUILD_DIR)/$(OS_ISO) $(ISO_DIR) -all: clean $(BUILD_DIR)/$(OS_ISO) +all: $(BUILD_DIR)/$(OS_ISO) instable: CFLAGS := -g -std=gnu99 -ffreestanding $(O) $(W) $(ARCH_OPT) -D__LUNAIXOS_DEBUG__ instable: all @@ -51,7 +67,6 @@ all-debug: clean $(BUILD_DIR)/$(OS_ISO) clean: @rm -rf $(BUILD_DIR) || exit 1 - @sleep 1 run: $(BUILD_DIR)/$(OS_ISO) @qemu-system-i386 $(QEMU_OPTIONS) -- 2.27.0