Changeset 46d26ee in mainline
- Timestamp:
- 2006-01-08T18:53:24Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42edee68
- Parents:
- 8725fb4
- Location:
- arch/amd64
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
arch/amd64/include/boot/boot.h
r8725fb4 r46d26ee 34 34 #define BOOT_STACK_SIZE 0x400 35 35 36 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 37 #define MULTIBOOT_HEADER_FLAGS 0x00010003 36 #define MULTIBOOT_HEADER_MAGIC 0x1BADB002 37 #define MULTIBOOT_HEADER_FLAGS 0x00010003 38 39 #define MULTIBOOT_LOADER_MAGIC 0x2BADB002 38 40 39 41 #endif -
arch/amd64/src/boot/boot.S
r8725fb4 r46d26ee 27 27 # 28 28 29 #include <arch/boot/boot.h> 30 #include <arch/boot/memmap.h> 29 31 #include <arch/mm/page.h> 30 32 #include <arch/mm/ptl.h> … … 32 34 #include <arch/cpu.h> 33 35 #include <arch/cpuid.h> 34 #include <arch/boot/boot.h>35 36 36 37 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) 37 #define START_STACK_64 0xffffffff80007c0038 38 39 39 .section K_TEXT_START, "ax" … … 42 42 # .global multiboot_image_start 43 43 # kernel_image_start: 44 # cli 45 # xorw %ax,%ax 46 # movw %ax,%ds 47 # movw %ax,%es 48 # movw %ax,%ss # initialize stack segment register 49 # movl $(START_STACK), %esp # initialize stack pointer 50 # 51 # call memmap_arch_init 52 # 44 53 45 # movl $0x80000000, %eax 54 46 # cpuid … … 60 52 # jnc no_long_mode 61 53 # 62 # # Load gdtr, idtr63 # lgdt real_bootstrap_gdtr_boot64 #65 # movl %cr0,%eax66 # orl $0x1,%eax67 # movl %eax,%cr0 # switch to protected mode68 #69 # jmpl $gdtselector(KTEXT32_DES), $now_in_prot70 54 # 71 55 # no_long_mode: … … 75 59 .code32 76 60 .align 4 61 .global multiboot_image_start 77 62 multiboot_header: 78 63 .long MULTIBOOT_HEADER_MAGIC … … 86 71 87 72 multiboot_image_start: 88 movl $START_STACK, %esp # initialize stack pointer 89 90 lgdt protected_bootstrap_gdtr + BOOT_OFFSET # initialize Global Descriptor Table register 73 movl $START_STACK, %esp # initialize stack pointer 74 lgdt bootstrap_gdtr # initialize Global Descriptor Table register 91 75 92 76 movw $gdtselector(KDATA_DES), %cx … … 97 81 movw %cx, %ss 98 82 99 jmpl $gdtselector(KTEXT _DES), $multiboot_meeting_point + BOOT_OFFSET83 jmpl $gdtselector(KTEXT32_DES), $multiboot_meeting_point 100 84 multiboot_meeting_point: 85 86 movl %eax, grub_eax # save parameters from GRUB 87 movl %ebx, grub_ebx 101 88 102 89 # Protected 32-bit. We want to reuse the code-seg descriptor, 103 90 # the Default operand size must not be 1 when entering long mode 104 105 pushl %ebx # save parameters from GRUB106 pushl %eax107 91 108 92 # Enable 64-bit page transaltion entries - CR4.PAE = 1. … … 138 122 start64: 139 123 movq $(PA2KA(START_STACK)), %rsp 140 124 movl grub_eax, %eax 125 movl grub_ebx, %ebx 126 127 cmpl $MULTIBOOT_LOADER_MAGIC, %eax # compare GRUB signature 128 je valid_boot 129 130 xorl %ecx, %ecx # no memory size or map available 131 movl %ecx, e801memorysize 132 movl %ecx, e820counter 133 134 jmp invalid_boot 135 136 valid_boot: 137 138 movl (%ebx), %eax # ebx = physical address of struct multiboot_info 139 140 bt $0, %eax # mbi->flags[0] (mem_lower, mem_upper valid) 141 jc mem_valid 142 143 xorl %ecx, %ecx 144 jmp mem_invalid 145 146 mem_valid: 147 movl 4(%ebx), %ecx # mbi->mem_lower 148 addl 8(%ebx), %ecx # mbi->mem_upper 149 150 mem_invalid: 151 movl %ecx, e801memorysize 152 153 bt $3, %eax # mbi->flags[3] (mods_count, mods_addr valid) 154 jc mods_valid 155 156 xorl %ecx, %ecx 157 xorl %edx, %edx 158 jmp mods_invalid 159 160 mods_valid: 161 movl 20(%ebx), %ecx # mbi->mods_count 162 cmpl $0, %ecx 163 je mods_invalid 164 165 movl 24(%ebx), %esi # mbi->mods_addr 166 movl 0(%esi), %edx # mods->mod_start 167 movl 4(%esi), %ecx # mods->mod_end 168 subl %edx, %ecx 169 addl $0x80000000, %edx 170 171 mods_invalid: 172 movl %ecx, init_size 173 movl %edx, init_addr 174 175 bt $6, %eax # mbi->flags[6] (mmap_length, mmap_addr valid) 176 jc mmap_valid 177 178 xorl %edx, %edx 179 jmp mmap_invalid 180 181 mmap_valid: 182 movl 44(%ebx), %ecx # mbi->mmap_length 183 movl 48(%ebx), %esi # mbi->mmap_addr 184 movq $e820table, %rdi 185 xorl %edx, %edx 186 187 mmap_loop: 188 cmpl $0, %ecx 189 jle mmap_end 190 191 movl 4(%esi), %eax # mmap->base_addr_low 192 movl %eax, (%rdi) 193 194 movl 8(%esi), %eax # mmap->base_addr_high 195 movl %eax, 4(%rdi) 196 197 movl 12(%esi), %eax # mmap->length_low 198 movl %eax, 8(%rdi) 199 200 movl 16(%esi), %eax # mmap->length_high 201 movl %eax, 12(%rdi) 202 203 movl 20(%esi), %eax # mmap->type 204 movl %eax, 16(%rdi) 205 206 movl (%esi), %eax # mmap->size 207 addl $0x4, %eax 208 addl %eax, %esi 209 subl %eax, %ecx 210 addq $MEMMAP_E820_RECORD_SIZE, %rdi 211 incl %edx 212 jmp mmap_loop 213 214 mmap_end: 215 216 mmap_invalid: 217 movl %edx, e820counter 218 219 invalid_boot: 220 141 221 call main_bsp # never returns 142 222 … … 198 278 .quad ptl_1 + (PTL_WRITABLE | PTL_PRESENT) 199 279 200 .global protected_bootstrap_gdtr201 protected_bootstrap_gdtr:280 .global bootstrap_gdtr 281 bootstrap_gdtr: 202 282 .word gdtselector(GDT_ITEMS) 203 283 .long KA2PA(gdt) 284 285 grub_eax: 286 .long 0 287 288 grub_ebx: 289 .long 0
Note:
See TracChangeset
for help on using the changeset viewer.