Rev 680 | Rev 1037 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 680 | Rev 693 | ||
|---|---|---|---|
| Line 1... | Line 1... | ||
| 1 | # |
1 | # |
| 2 | # Copyright (C) 2001-2004 Jakub Jermar |
2 | # Copyright (C) 2001-2004 Jakub Jermar |
| - | 3 | # Copyright (C) 2005-2006 Martin Decky |
|
| 3 | # All rights reserved. |
4 | # All rights reserved. |
| 4 | # |
5 | # |
| 5 | # Redistribution and use in source and binary forms, with or without |
6 | # Redistribution and use in source and binary forms, with or without |
| 6 | # modification, are permitted provided that the following conditions |
7 | # modification, are permitted provided that the following conditions |
| 7 | # are met: |
8 | # are met: |
| Line 29... | Line 30... | ||
| 29 | #include <arch/boot/boot.h> |
30 | #include <arch/boot/boot.h> |
| 30 | #include <arch/boot/memmap.h> |
31 | #include <arch/boot/memmap.h> |
| 31 | #include <arch/mm/page.h> |
32 | #include <arch/mm/page.h> |
| 32 | #include <arch/pm.h> |
33 | #include <arch/pm.h> |
| 33 | 34 | ||
| - | 35 | #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) |
|
| - | 36 | ||
| 34 | .section K_TEXT_START, "ax" |
37 | .section K_TEXT_START, "ax" |
| 35 | 38 | ||
| 36 | KTEXT=8 |
39 | KTEXT=8 |
| 37 | KDATA=16 |
40 | KDATA=16 |
| 38 | 41 | ||
| 39 | .code32 |
42 | .code32 |
| 40 | .align 4 |
43 | .align 4 |
| - | 44 | .global multiboot_image_start |
|
| 41 | multiboot_header: |
45 | multiboot_header: |
| 42 | .long MULTIBOOT_HEADER_MAGIC |
46 | .long MULTIBOOT_HEADER_MAGIC |
| 43 | .long MULTIBOOT_HEADER_FLAGS |
47 | .long MULTIBOOT_HEADER_FLAGS |
| 44 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
48 | .long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
| 45 | .long multiboot_header + BOOT_OFFSET |
49 | .long multiboot_header |
| 46 | .long unmapped_ktext_start + BOOT_OFFSET |
50 | .long unmapped_ktext_start |
| 47 | .long 0 |
51 | .long 0 |
| 48 | .long 0 |
52 | .long 0 |
| 49 | .long multiboot_image_start + BOOT_OFFSET |
53 | .long multiboot_image_start |
| 50 | 54 | ||
| 51 | multiboot_image_start: |
55 | multiboot_image_start: |
| 52 | movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
56 | movl $START_STACK, %esp # initialize stack pointer |
| 53 | - | ||
| 54 | lgdt protected_bootstrap_gdtr - 0x80000000 # initialize Global Descriptor Table register |
57 | lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
| 55 | 58 | ||
| 56 | movw $KDATA, %cx |
59 | movw $KDATA, %cx |
| 57 | movw %cx, %es |
60 | movw %cx, %es |
| 58 | movw %cx, %gs |
61 | movw %cx, %gs |
| 59 | movw %cx, %fs |
62 | movw %cx, %fs |
| 60 | movw %cx, %ds # kernel data + stack |
63 | movw %cx, %ds # kernel data + stack |
| 61 | movw %cx, %ss |
64 | movw %cx, %ss |
| 62 | 65 | ||
| 63 | jmpl $KTEXT, $multiboot_meeting_point + BOOT_OFFSET |
66 | jmpl $KTEXT, $multiboot_meeting_point |
| 64 | multiboot_meeting_point: |
67 | multiboot_meeting_point: |
| 65 | 68 | ||
| 66 | pushl %ebx # save parameters from GRUB |
69 | pushl %ebx # save parameters from GRUB |
| 67 | pushl %eax |
70 | pushl %eax |
| 68 | 71 | ||
| 69 | movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %esi |
- | |
| 70 | movl $BOOTSTRAP_OFFSET, %edi |
- | |
| 71 | movl $_hardcoded_unmapped_size, %ecx |
- | |
| 72 | cld |
- | |
| 73 | rep movsb |
- | |
| 74 | - | ||
| 75 | call map_kernel # map kernel and turn paging on |
72 | call map_kernel # map kernel and turn paging on |
| 76 | 73 | ||
| 77 | popl %eax |
74 | popl %eax |
| 78 | popl %ebx |
75 | popl %ebx |
| 79 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature |
76 | cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature |
| Line 168... | Line 165... | ||
| 168 | mmap_invalid: |
165 | mmap_invalid: |
| 169 | movl %edx, e820counter |
166 | movl %edx, e820counter |
| 170 | 167 | ||
| 171 | invalid_boot: |
168 | invalid_boot: |
| 172 | 169 | ||
| - | 170 | #ifdef CONFIG_SMP |
|
| - | 171 | ||
| - | 172 | # copy AP bootstrap routines below 1 MB |
|
| - | 173 | ||
| - | 174 | movl $BOOT_OFFSET, %esi |
|
| - | 175 | movl $AP_BOOT_OFFSET, %edi |
|
| - | 176 | movl $_hardcoded_unmapped_size, %ecx |
|
| - | 177 | cld |
|
| - | 178 | rep movsb |
|
| - | 179 | ||
| - | 180 | #endif |
|
| - | 181 | ||
| 173 | call main_bsp - BOOT_OFFSET # never returns |
182 | call main_bsp # never returns |
| 174 | 183 | ||
| 175 | cli |
184 | cli |
| 176 | hlt |
185 | hlt |
| 177 | 186 | ||
| 178 | .global map_kernel |
187 | .global map_kernel |
| Line 212... | Line 221... | ||
| 212 | .section K_DATA_START, "aw", @progbits |
221 | .section K_DATA_START, "aw", @progbits |
| 213 | 222 | ||
| 214 | .align 4096 |
223 | .align 4096 |
| 215 | page_directory: |
224 | page_directory: |
| 216 | .space 4096, 0 |
225 | .space 4096, 0 |
| 217 | - | ||
| 218 | .global real_bootstrap_gdtr_boot |
- | |
| 219 | real_bootstrap_gdtr_boot: |
- | |
| 220 | .word selector(GDT_ITEMS) |
- | |
| 221 | .long KA2PA(gdt)-BOOT_OFFSET |
- | |
| 222 | - | ||