This repository was archived by the owner on Jul 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathboot.asm
More file actions
51 lines (41 loc) · 1.38 KB
/
Copy pathboot.asm
File metadata and controls
51 lines (41 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
;This is a kernel entry point of the boot loader.
;We can either choose to do a useful stuff or setup stack
;load gdt or other stuff.
;Written by sunil <sunilbn@live.com>
[BITS 32]
global start
start:
mov esp, system_stack ;setup a new stack
jmp post_header ;jump post the multi-boot header
;Multi boot header
;Define multiboot header macros for readability
MULTIBOOT_PAGE_ALIGN equ 1<<0
MULTIBOOT_MEMORY_INFO equ 1<<1
MULTIBOOT_AOUT_KLUDGE equ 1<<16
MULTIBOOT_HEADER_MAGIC equ 0x1BADB002
MUTLIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
MUTLIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MUTLIBOOT_HEADER_FLAGS)
extern code, bss, end
;Align the header on a word boundary. In some machines, accesses to objects larger than a byte must be aligned.
;An access to an object of size s bytes at byte address A is aligned if A mod s = 0. Misalignment causes hardware complications and require
;CPU cycles to access
ALIGN 4
mboot:
dd MULTIBOOT_HEADER_MAGIC ;GRUB multiboot header magic
dd MUTLIBOOT_HEADER_FLAGS
dd MUTLIBOOT_CHECKSUM
dd mboot
dd code
dd bss
dd end
dd start
extern kmain
;jump to kmain
post_header:
push ebx ;pointer to multiboot info structure
call kmain ;call kernel main
hangup: ;kmain should never return;
jmp hangup
SECTION .bss
resb 8192 ;reserve 8K bytes. Note: stack grows downwards
system_stack: