Rev 629 | Rev 1037 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 629 | Rev 680 | ||
---|---|---|---|
Line 30... | Line 30... | ||
30 | #include <arch/boot/memmap.h> |
30 | #include <arch/boot/memmap.h> |
31 | #include <arch/mm/page.h> |
31 | #include <arch/mm/page.h> |
32 | #include <arch/pm.h> |
32 | #include <arch/pm.h> |
33 | 33 | ||
34 | .section K_TEXT_START, "ax" |
34 | .section K_TEXT_START, "ax" |
35 | .global kernel_image_start |
- | |
36 | 35 | ||
37 | KTEXT=8 |
36 | KTEXT=8 |
38 | KDATA=16 |
37 | KDATA=16 |
39 | 38 | ||
40 | .code16 |
- | |
41 | # |
- | |
42 | # This is where we require any SPARTAN-kernel-compatible boot loader |
- | |
43 | # to pass control in real mode. |
- | |
44 | # |
- | |
45 | # Protected mode tables are statically initialised during compile |
- | |
46 | # time. So we can just load the respective table registers and |
- | |
47 | # switch to protected mode. |
- | |
48 | # |
- | |
49 | kernel_image_start: |
- | |
50 | cli |
- | |
51 | xorw %ax, %ax |
- | |
52 | movw %ax, %ds |
- | |
53 | movw %ax, %es |
- | |
54 | movw %ax, %ss # initialize stack segment register |
- | |
55 | movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
- | |
56 | - | ||
57 | call memmap_arch_init |
- | |
58 | - | ||
59 | lgdt real_bootstrap_gdtr_boot # initialize Global Descriptor Table register |
- | |
60 | - | ||
61 | movl %cr0, %eax |
- | |
62 | orl $0x1, %eax |
- | |
63 | movl %eax, %cr0 # switch to protected mode |
- | |
64 | - | ||
65 | jmpl $KTEXT, $boot_image_start |
- | |
66 | - | ||
67 | .code32 |
39 | .code32 |
68 | .align 4 |
40 | .align 4 |
69 | multiboot_header: |
41 | multiboot_header: |
70 | .long MULTIBOOT_HEADER_MAGIC |
42 | .long MULTIBOOT_HEADER_MAGIC |
71 | .long MULTIBOOT_HEADER_FLAGS |
43 | .long MULTIBOOT_HEADER_FLAGS |
Line 74... | Line 46... | ||
74 | .long unmapped_ktext_start + BOOT_OFFSET |
46 | .long unmapped_ktext_start + BOOT_OFFSET |
75 | .long 0 |
47 | .long 0 |
76 | .long 0 |
48 | .long 0 |
77 | .long multiboot_image_start + BOOT_OFFSET |
49 | .long multiboot_image_start + BOOT_OFFSET |
78 | 50 | ||
79 | boot_image_start: |
- | |
80 | movw $KDATA, %ax |
- | |
81 | movw %ax, %es |
- | |
82 | movw %ax, %gs |
- | |
83 | movw %ax, %fs |
- | |
84 | movw %ax, %ds # kernel data + stack |
- | |
85 | movw %ax, %ss |
- | |
86 | - | ||
87 | movb $0xd1, %al # enable A20 using i8042 controller |
- | |
88 | outb %al, $0x64 |
- | |
89 | movb $0xdf, %al |
- | |
90 | outb %al, $0x60 |
- | |
91 | - | ||
92 | movl $BOOTSTRAP_OFFSET, %esi |
- | |
93 | movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %edi |
- | |
94 | movl $_hardcoded_kernel_size, %ecx |
- | |
95 | cld |
- | |
96 | rep movsb |
- | |
97 | - | ||
98 | call map_kernel # map kernel and turn paging on |
- | |
99 | - | ||
100 | call main_bsp # never returns |
- | |
101 | - | ||
102 | cli |
- | |
103 | hlt |
- | |
104 | - | ||
105 | multiboot_image_start: |
51 | multiboot_image_start: |
106 | movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
52 | movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
107 | 53 | ||
108 | lgdt protected_bootstrap_gdtr - 0x80000000 # initialize Global Descriptor Table register |
54 | lgdt protected_bootstrap_gdtr - 0x80000000 # initialize Global Descriptor Table register |
109 | 55 |