commit ed1241341b252cf9eba81aa81ed3573bd4cde0c9 Author: Gitea Date: Tue Dec 1 20:41:09 2020 -0600 Working basics diff --git a/arch/i386/boot.S b/arch/i386/boot.S new file mode 100755 index 0000000..c28621b --- /dev/null +++ b/arch/i386/boot.S @@ -0,0 +1,39 @@ + # Constants for multiboot + .set ALIGN, 1<<0 # align on page boundaries + .set MEMINFO, 1<<1 # memory map + .set FLAGS, ALIGN | MEMINFO # for multiboot 'flag' field + .set MAGIC, 0x1BADB002 # magic number for bootloader + .set CHECKSUM, -(MAGIC + FLAGS) # checksum to prove we're multiboot + + # Declare header for multiboot + .section .multiboot + .align 4 + .long MAGIC + .long FLAGS + .long CHECKSUM + + # Reserve stack for initial thread + .section .bss + .align 16 +stack_bottom: + .skip 16384 # 16K +stack_top: + + # Kernel entry + .section .text + .global _start + .type _start, @function +_start: + movl $stack_top, %esp + + # Call global constructors + call _init + + # Start kernel + call kern_main + + # Hang if kernel returns + cli +1: hlt + jmp 1b + .size _start, . - _start diff --git a/arch/i386/crti.S b/arch/i386/crti.S new file mode 100755 index 0000000..f8c7b7b --- /dev/null +++ b/arch/i386/crti.S @@ -0,0 +1,13 @@ + .section .init + .global _init + .type _init, @function +_init: + push %ebp + movl %esp, %ebp + + .section .fini + .global _fini + .type _fini, @function +_fini: + push %ebp + movl %esp, %ebp diff --git a/arch/i386/crtn.S b/arch/i386/crtn.S new file mode 100755 index 0000000..b465896 --- /dev/null +++ b/arch/i386/crtn.S @@ -0,0 +1,7 @@ + .section .init + popl %ebp + ret + + .section .fini + popl %ebp + ret