/* Parameters for the multiboot header */ .set ALIGN, 1<<0 .set MEMINFO, 1<<1 .set FLAGS, ALIGN | MEMINFO .set MAGIC, 0x1BADB002 .set CHECKSUM, -(MAGIC + FLAGS) .section .multiboot .align 4 .long MAGIC .long FLAGS .long CHECKSUM /* Allocate room for stack */ .section bss .align 16 stack_bottom: .skip 16384 /* 16 KiB */ stack_top: .section .data gdt: null_gdt: /* null descriptor */ .quad 0x00 code_gdt: .word 0xFFFF /* limit */ .word 0x0000 /* base */ .byte 0x00 /* base */ .byte 0x9A /* type flag (access) */ .byte 0b11001111 /* limit */ .byte 0x00 /* base */ data_gdt: .word 0xFFFF /* limit */ .word 0x0000 /* base */ .byte 0x00 /* base */ .byte 0x92 /* type flag (access) */ .byte 0b11001111 /* limit */ .byte 0x00 /* base */ end_gdt: gdt_desc: .word end_gdt - gdt - 1 .int gdt .section .text .global _start .type _start, @function _start: mov $stack_top, %esp cli lgdt (gdt_desc) /* load GDT */ mov $0x10, %ax mov %ax, %ds mov %ax, %ss mov %ax, %es mov %ax, %fs mov %ax, %gs ljmp $0x08,$continue continue: push %ebx /* pointer to multiboot structure */ call kernel_main cli 1: hlt jmp 1b /* The size of the _start symbol is the current location '.' minus its start. */ .size _start, . - _start