diff options
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/Makefile | 40 | ||||
| -rw-r--r-- | kernel/entry_efi.c | 14 | ||||
| -rw-r--r-- | kernel/kernel.ld | 28 |
3 files changed, 82 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile new file mode 100644 index 0000000..36cca4c --- /dev/null +++ b/kernel/Makefile @@ -0,0 +1,40 @@ +include ../defaults.mk + +TARGET := kernel.os +.DEFAULT: $(TARGET) + +# EFI API for temporary things + +EFIAPIDIR := /usr/local/include/efi + +CPPFLAGS += -I../api -I$(EFIAPIDIR) -I$(EFIAPIDIR)/$(ARCH) -I$(EFIAPIDIR)/protocol +CFLAGS += -Wno-unused-const-variable -Wno-unused-function -fvisibility=hidden -g + +LIBDIRS += -L$(dir $(shell $(CC) -print-libgcc-file-name)) +LDSCRIPT := kernel.ld +LDFLAGS += -z max-page-size=4096 --export-dynamic +LOADLIBES := -lgcc + +SOBJS := +GOBJS := entry_efi.o +IOBJS := + +$(SOBJS): CFLAGS += -fPIC +# __attribute__((interrupt)) requires -mgeneral-regs-only +$(IOBJS): CFLAGS += -mgeneral-regs-only +$(IOBJS) $(GOBJS): CFLAGS += -mcmodel=kernel + +OBJS := $(SOBJS) $(GOBJS) $(IOBJS) +DEPS := $(patsubst %.o,%.d,$(OBJS)) + +$(TARGET): $(LDSCRIPT) $(MAKEFILE_LIST) +$(TARGET): $(OBJS) + +CLEANLIST := $(wildcard $(OBJS) $(TARGET)) +DCLEANLIST := $(wildcard $(DEPS)) + +include ../rules.mk +-include $(DEPS) + +.DEFAULT: $(TARGET) + diff --git a/kernel/entry_efi.c b/kernel/entry_efi.c new file mode 100644 index 0000000..1acd399 --- /dev/null +++ b/kernel/entry_efi.c @@ -0,0 +1,14 @@ +#include <stdbool.h> +#include <stdnoreturn.h> + +#include <boot/entry/entry_efi.h> + +static const char kernel_entry_data[4096]; + +noreturn void kernel_entry(struct efi_boot_data *data) +{ + (void)data; + __asm__ ("cli\n\t"); + while (true) __asm__ ("hlt\n\t"); +} + diff --git a/kernel/kernel.ld b/kernel/kernel.ld new file mode 100644 index 0000000..9538056 --- /dev/null +++ b/kernel/kernel.ld @@ -0,0 +1,28 @@ +ENTRY(kernel_entry) + +SECTIONS +{ + . = SIZEOF_HEADERS; + + .text 0 : + { + *(.text) + } =0x90 + + .data : ALIGN(4K) + { + *(.rodata) + *(.data) + } + + .bss : + { + *(.bss) + } + + /DISCARD/ : + { + *(.eh_frame) + } +} + |
