From 6f1f42f5aec36978b03ef5e6fa0c6a0008613df7 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sun, 14 Aug 2016 13:47:06 +0000 Subject: [PATCH 1/1] initial commit --- Makefile | 33 +++++++++++++++++++++++++++++++++ src/boot/lboot.S | 12 ++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 Makefile create mode 100644 src/boot/lboot.S diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e44b643 --- /dev/null +++ b/Makefile @@ -0,0 +1,33 @@ +csrc = $(wildcard src/boot/*.c) $(wildcard src/*.c) $(wildcard src/klibc/*.c) +asmsrc = $(wildcard src/boot/*.S) $(wildcard src/*.S) $(wildcard src/klibc/*.S) +dep = $(asmsrc:.S=.d) $(csrc:.c=.d) +obj = $(asmsrc:.S=.o) $(csrc:.c=.o) + +inc = -Isrc -Isrc/klibc -Isrc/boot -Iinclude + +CFLAGS = $(ccemu) -Wall -g -nostdinc -fno-builtin $(inc) -DKERNEL +ASFLAGS = $(ccemu) -g -nostdinc -fno-builtin $(inc) + +bin = kernel.elf + +$(bin): $(obj) + ld $(ldemu) -o $@ -Ttext 0x8000 -e kentry $(obj) -Map link.map + +%.s: %.c + $(CC) $(CFLAGS) -S -o $@ $< + +-include $(dep) + +%.d: %.c + @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@ + +%.d: %.S + @$(CPP) $(ASFLAGS) -MM -MT $(@:.d=.o) $< >$@ + +.PHONY: clean +clean: + rm -f $(obj) $(bin) + +.PHONY: cleandep +cleandep: + rm -f $(dep) diff --git a/src/boot/lboot.S b/src/boot/lboot.S new file mode 100644 index 0000000..1e56e95 --- /dev/null +++ b/src/boot/lboot.S @@ -0,0 +1,12 @@ +#define STACK_SIZE 0x4000 + + .text + .align 4 + + .globl kentry +kentry: + ldr sp, =$(stack + STACK_SIZE) + + bl kmain + + .comm stack, STACK_SIZE -- 1.7.10.4