Conditional kernel inclusion

parent 962004fc
......@@ -4,18 +4,27 @@ TARGET=$(ARCH)-unknown-none
export LD=ld
export OBJCOPY=objcopy
export RUST_TARGET_PATH=$(CURDIR)/targets
export XARGO_HOME=$(CURDIR)/build/xargo
export XARGO_HOME=$(CURDIR)/target/xargo
all: build/bootloader
build/libstartup.o: src/nasm/startup.asm src/nasm/* build/kernel
clean:
rm -rf build
build/libstartup.o: src/nasm/startup.asm src/nasm/*
mkdir -p build
ifeq ($(KERNEL),)
nasm -f elf32 $< -I src/nasm/ -o $@
else
nasm -f elf32 $< -I src/nasm/ -D KERNEL=$(KERNEL) -o $@
endif
build/libbootloader.a: Cargo.lock Cargo.toml src/* src/*/* src/*/*/* src/*/*/*/*
mkdir -p build
xargo rustc --lib --target $(TARGET) --release -- -C soft-float -C debuginfo=2 --emit link=$@
build/bootloader: linkers/$(ARCH).ld build/libstartup.o build/libbootloader.a
mkdir -p build
$(LD) -m elf_i386 --gc-sections -z max-page-size=0x1000 -T $< -o $@ build/libstartup.o build/libbootloader.a && \
$(OBJCOPY) --only-keep-debug $@ $@.sym && \
$(OBJCOPY) --strip-debug $@
......@@ -43,6 +43,7 @@ long_mode:
mov gs, rax
mov ss, rax
%ifdef KERNEL
; set kernel size
mov rax, __kernel_end
sub rax, __kernel
......@@ -61,6 +62,8 @@ long_mode:
; entry point
mov rax, [args.kernel_base]
call [rax + 0x18]
%endif
.halt:
cli
hlt
......@@ -111,6 +114,9 @@ iend
.end equ $ - gdt
SECTION .kernel
%ifdef KERNEL
__kernel:
INCBIN "build/kernel"
%defstr KERNEL_STR %[KERNEL]
INCBIN KERNEL_STR
__kernel_end:
%endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment