From 0fff2e6dc6fae82da1c7978918a490c25cc36f04 Mon Sep 17 00:00:00 2001 From: Miguel Date: Sat, 1 Sep 2018 12:44:10 +0200 Subject: rename multiboot.s to start.s --- asm/multiboot.h | 16 ----------- asm/multiboot.s | 85 --------------------------------------------------------- asm/start.h | 21 ++++++++++++++ asm/start.s | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 106 insertions(+), 101 deletions(-) delete mode 100644 asm/multiboot.h delete mode 100644 asm/multiboot.s create mode 100644 asm/start.h create mode 100644 asm/start.s (limited to 'asm') diff --git a/asm/multiboot.h b/asm/multiboot.h deleted file mode 100644 index f2acaf1..0000000 --- a/asm/multiboot.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * @file - * _multiboot.s_ defines the following sections/functions, some are linked at - * specific addresses in the final ELF kernel binary. - * This is specified in the _linker.ld_ file. - * - * * 0x07000 .smp - entry point for application processors (16bit code) - * * 0x10000 .multiboot - the multiboot header - * * .text - * * .bootstrap_stack - * * _start() - main entry point for booting cpu, calls kernel_main(). - */ - -/** This will be called by a multiboot compilant boot-loader (i.e. grub2) */ -void _start(); - diff --git a/asm/multiboot.s b/asm/multiboot.s deleted file mode 100644 index bb12a7c..0000000 --- a/asm/multiboot.s +++ /dev/null @@ -1,85 +0,0 @@ -# https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format -# http://wiki.osdev.org/Bare_Bones - -# Fill Multiboot Haeder, init stack and call kernel_main passing to params: -# eax - magic number -# ebx - multiboot structure - -# Declare constants used for creating a multiboot header. -.set ALIGN, 1<<0 # align loaded modules on page boundaries -.set MEMINFO, 1<<1 # provide memory map -.set GFXINFO, 1<<2 # provide gfx info -.set FLAGS, ALIGN | MEMINFO | GFXINFO # this is the Multiboot 'flag' field -.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header -.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot - -# entry point for application processors at 0x7000 -.section .smp -.code16 -call smp_go # TODO: align later before going C - -# Declare a header as in the Multiboot Standard. We put this into a special -# section so we can force the header to be in the start of the final program. -# You don't need to understand all these details as it is just magic values that -# is documented in the multiboot standard. The bootloader will search for this -# magic sequence and recognize us as a multiboot kernel. - -.section .multiboot -.code32 -.align 4 -.long MAGIC -.long FLAGS -.long CHECKSUM - -.long 0 # we dont need this for ELF -.long 0 -.long 0 -.long 0 -.long 0 - -# we override this from grub anyway -.long 0 #gfx_stuff 0=enable! -.long 640 -.long 480 -.long 32 - -# Currently the stack pointer register (esp) points at anything and using it may -# cause massive harm. Instead, we'll provide our own stack. We will allocate -# room for a small temporary stack by creating a symbol at the bottom of it, -# then allocating 16384 bytes for it, and finally creating a symbol at the top. -.section .bootstrap_stack, "aw", @nobits -stack_bottom: -.skip 16384 # 16 KiB -stack_top: - -# The linker script specifies _start as the entry point to the kernel and the -# bootloader will jump to this position once the kernel has been loaded. It -# doesn't make sense to return from this function as the bootloader is gone. -.section .text -.global _start -.global stack_top -.global stack_bottom -.type _start, @function -_start: - - - # To set up a stack, we simply set the esp register to point to the top of - # our stack (as it grows downwards). - movl $stack_top, %esp - - sub $8, %esp #to align on 16byte before calling C - push %ebx #pass address of the multiboot information data structure - push %eax #pass eax, so kernel can check for magic number - - call kernel_main - - # should never be reached - - cli - hlt -.Lhang: - jmp .Lhang - -# Set the size of the _start symbol to the current location '.' minus its start. -# This is useful when debugging or when you implement call tracing. -.size _start, . - _start diff --git a/asm/start.h b/asm/start.h new file mode 100644 index 0000000..ff30326 --- /dev/null +++ b/asm/start.h @@ -0,0 +1,21 @@ +/** + * @file + * Defines the following sections/functions, some are linked at + * specific addresses in the final ELF kernel binary. + * This is specified in the _linker.ld_ file. + * + * * 0x007000 .smp - entry point for application processors (16bit code) + * * 0x100000 .multiboot - the multiboot header + * + * * .text + * * .bootstrap_stack + * * _start() - main entry point for booting cpu, calls kernel_main(). + * + * The addresses for .smp and .multiboot are based on the assumption: + * * 0x00000500 - 0x00007BFF : guaranteed free to use + * * 0x00100000 - 0x00EFFFFF : free for use (if it exists) + */ + +/** This will be called by a multiboot compilant boot-loader (i.e. grub2) */ +void _start(); + diff --git a/asm/start.s b/asm/start.s new file mode 100644 index 0000000..bb12a7c --- /dev/null +++ b/asm/start.s @@ -0,0 +1,85 @@ +# https://www.gnu.org/software/grub/manual/multiboot/multiboot.html#Boot-information-format +# http://wiki.osdev.org/Bare_Bones + +# Fill Multiboot Haeder, init stack and call kernel_main passing to params: +# eax - magic number +# ebx - multiboot structure + +# Declare constants used for creating a multiboot header. +.set ALIGN, 1<<0 # align loaded modules on page boundaries +.set MEMINFO, 1<<1 # provide memory map +.set GFXINFO, 1<<2 # provide gfx info +.set FLAGS, ALIGN | MEMINFO | GFXINFO # this is the Multiboot 'flag' field +.set MAGIC, 0x1BADB002 # 'magic number' lets bootloader find the header +.set CHECKSUM, -(MAGIC + FLAGS) # checksum of above, to prove we are multiboot + +# entry point for application processors at 0x7000 +.section .smp +.code16 +call smp_go # TODO: align later before going C + +# Declare a header as in the Multiboot Standard. We put this into a special +# section so we can force the header to be in the start of the final program. +# You don't need to understand all these details as it is just magic values that +# is documented in the multiboot standard. The bootloader will search for this +# magic sequence and recognize us as a multiboot kernel. + +.section .multiboot +.code32 +.align 4 +.long MAGIC +.long FLAGS +.long CHECKSUM + +.long 0 # we dont need this for ELF +.long 0 +.long 0 +.long 0 +.long 0 + +# we override this from grub anyway +.long 0 #gfx_stuff 0=enable! +.long 640 +.long 480 +.long 32 + +# Currently the stack pointer register (esp) points at anything and using it may +# cause massive harm. Instead, we'll provide our own stack. We will allocate +# room for a small temporary stack by creating a symbol at the bottom of it, +# then allocating 16384 bytes for it, and finally creating a symbol at the top. +.section .bootstrap_stack, "aw", @nobits +stack_bottom: +.skip 16384 # 16 KiB +stack_top: + +# The linker script specifies _start as the entry point to the kernel and the +# bootloader will jump to this position once the kernel has been loaded. It +# doesn't make sense to return from this function as the bootloader is gone. +.section .text +.global _start +.global stack_top +.global stack_bottom +.type _start, @function +_start: + + + # To set up a stack, we simply set the esp register to point to the top of + # our stack (as it grows downwards). + movl $stack_top, %esp + + sub $8, %esp #to align on 16byte before calling C + push %ebx #pass address of the multiboot information data structure + push %eax #pass eax, so kernel can check for magic number + + call kernel_main + + # should never be reached + + cli + hlt +.Lhang: + jmp .Lhang + +# Set the size of the _start symbol to the current location '.' minus its start. +# This is useful when debugging or when you implement call tracing. +.size _start, . - _start -- cgit v1.2.3