59 lines
1.3 KiB
ArmAsm
59 lines
1.3 KiB
ArmAsm
# Declare constants for the multiboot header.
|
|
.set ALIGN, 1<<0 # align loaded modules on page boundaries
|
|
.set MEMINFO, 1<<1 # provide memory map
|
|
.set FLAGS, ALIGN | MEMINFO # 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
|
|
|
|
# Declare a header as in the Multiboot Standard.
|
|
.section .multiboot
|
|
.align 4
|
|
.long MAGIC
|
|
.long FLAGS
|
|
.long CHECKSUM
|
|
|
|
# Reserve a stack for the initial thread.
|
|
.section .bss
|
|
.align 16
|
|
stack_bottom:
|
|
.skip 16384 # 16 KiB
|
|
stack_top:
|
|
|
|
# The kernel entry point.
|
|
.section .text
|
|
.global _start
|
|
.type _start, @function
|
|
_start:
|
|
movl $stack_top, %esp
|
|
|
|
# Call the global constructors.
|
|
call _init
|
|
|
|
# Call early kernel (init GDT, IDT and other)
|
|
call kernel_early_main
|
|
|
|
# Transfer control to the main kernel.
|
|
call kernel_main
|
|
|
|
# Hang if kernel_main unexpectedly returns.
|
|
cli
|
|
1: hlt
|
|
jmp 1b
|
|
.size _start, . - _start
|
|
|
|
.global gdt_flush
|
|
gdt_flush:
|
|
cli
|
|
mov 0x4(%esp),%eax
|
|
sgdtl (%eax)
|
|
mov $0x10,%ax
|
|
mov %eax,%ds
|
|
mov %eax,%es
|
|
mov %eax,%fs
|
|
mov %eax,%gs
|
|
mov %eax,%ss
|
|
ljmp $0x8,$.flush
|
|
.flush:
|
|
ret
|
|
|