From 8c3b610da632e3c357a557e0c6cad57fe98ed748 Mon Sep 17 00:00:00 2001 From: lucic71 Date: Sat, 27 Jun 2020 13:43:30 +0300 Subject: [PATCH] Added i386 crt's and fixed boot file --- kernel/arch/i386/{loader.s => boot.s} | 6 +++--- kernel/arch/i386/crti.S | 15 +++++++++++++++ kernel/arch/i386/crtn.S | 9 +++++++++ kernel/arch/i386/linker.ld | 2 +- kernel/arch/i386/make.config | 7 +++++++ 5 files changed, 35 insertions(+), 4 deletions(-) rename kernel/arch/i386/{loader.s => boot.s} (94%) create mode 100644 kernel/arch/i386/crti.S create mode 100644 kernel/arch/i386/crtn.S create mode 100644 kernel/arch/i386/make.config diff --git a/kernel/arch/i386/loader.s b/kernel/arch/i386/boot.s similarity index 94% rename from kernel/arch/i386/loader.s rename to kernel/arch/i386/boot.s index 63671ae..da1220b 100644 --- a/kernel/arch/i386/loader.s +++ b/kernel/arch/i386/boot.s @@ -1,4 +1,4 @@ -.global loader +.global _start /* Entry point in the kernel. */ @@ -41,10 +41,10 @@ .text -loader: +_start: mov $kstack, %esp - add KSTACK_SIZE, %esp + add $KSTACK_SIZE, %esp call kmain cli diff --git a/kernel/arch/i386/crti.S b/kernel/arch/i386/crti.S new file mode 100644 index 0000000..cebea3e --- /dev/null +++ b/kernel/arch/i386/crti.S @@ -0,0 +1,15 @@ +.section .init +.global _init +.type _init, @function +_init: + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .init section here. */ + +.section .fini +.global _fini +.type _fini, @function +_fini: + push %ebp + movl %esp, %ebp + /* gcc will nicely put the contents of crtbegin.o's .fini section here. */ diff --git a/kernel/arch/i386/crtn.S b/kernel/arch/i386/crtn.S new file mode 100644 index 0000000..33957bf --- /dev/null +++ b/kernel/arch/i386/crtn.S @@ -0,0 +1,9 @@ +.section .init + /* gcc will nicely put the contents of crtend.o's .init section here. */ + popl %ebp + ret + +.section .fini + /* gcc will nicely put the contents of crtend.o's .fini section here. */ + popl %ebp + ret diff --git a/kernel/arch/i386/linker.ld b/kernel/arch/i386/linker.ld index 6984a7e..4df0135 100644 --- a/kernel/arch/i386/linker.ld +++ b/kernel/arch/i386/linker.ld @@ -1,4 +1,4 @@ -ENTRY(loader) +ENTRY(_start) SECTIONS { diff --git a/kernel/arch/i386/make.config b/kernel/arch/i386/make.config new file mode 100644 index 0000000..b4268d7 --- /dev/null +++ b/kernel/arch/i386/make.config @@ -0,0 +1,7 @@ +KERNEL_ARCH_CFLAGS= +KERNEL_ARCH_CPPFLAGS= +KERNEL_ARCH_LDFLAGS= +KERNEL_ARCH_LIBS= + +KERNEL_ARCH_OBJS=\ +$(ARCHDIR)/boot.o \