Changes in kernel/arch/ia32/src/boot/multiboot.S [36df4109:f66c203d] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/multiboot.S
r36df4109 rf66c203d 29 29 */ 30 30 31 #include <abi/asmtool.h>32 31 #include <arch/boot/boot.h> 33 #include <arch/boot/memmap.h>34 32 #include <arch/mm/page.h> 35 33 #include <arch/pm.h> 36 34 #include <genarch/multiboot/multiboot.h> 37 35 #include <arch/cpuid.h> 38 #include <arch/cpu.h>39 36 40 37 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) … … 64 61 65 62 .align 4 63 .global multiboot_image_start 66 64 multiboot_header: 67 65 .long MULTIBOOT_HEADER_MAGIC … … 74 72 .long multiboot_image_start 75 73 76 SYMBOL(multiboot_image_start) 74 multiboot_image_start: 77 75 cli 78 76 cld … … 142 140 pm2_status $status_prot3 143 141 144 /* Call ia32_pre_main(multiboot_eax, multiboot_ebx) */142 /* Call arch_pre_main(multiboot_eax, multiboot_ebx) */ 145 143 pushl multiboot_ebx 146 144 pushl multiboot_eax 147 call ia32_pre_main145 call arch_pre_main 148 146 149 147 pm2_status $status_main … … 164 162 * 165 163 */ 166 FUNCTION_BEGIN(map_kernel_pse) 164 .global map_kernel_pse 167 165 map_kernel_pse: 168 166 /* Paging features */ 169 167 movl %cr4, %ecx 170 orl $ CR4_PSE, %ecx/* PSE on */171 andl $ ~CR4_PAE, %ecx/* PAE off */168 orl $(1 << 4), %ecx /* PSE on */ 169 andl $(~(1 << 5)), %ecx /* PAE off */ 172 170 movl %ecx, %cr4 173 171 … … 178 176 179 177 floop_pse: 180 movl $( PDE_4M | PDE_RW | PDE_P), %eax178 movl $((1 << 7) | (1 << 1) | (1 << 0)), %eax 181 179 orl %ebx, %eax 182 180 /* Mapping 0x00000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ … … 193 191 194 192 movl %cr0, %ebx 195 orl $ CR0_PG, %ebx/* paging on */193 orl $(1 << 31), %ebx /* paging on */ 196 194 movl %ebx, %cr0 197 195 ret 198 FUNCTION_END(map_kernel_pse)199 196 200 197 /** Setup mapping for the kernel (non-PSE variant). … … 204 201 * 205 202 */ 206 FUNCTION_BEGIN(map_kernel_non_pse) 203 .global map_kernel_non_pse 204 map_kernel_non_pse: 207 205 /* Paging features */ 208 206 movl %cr4, %ecx 209 andl $ ~CR4_PAE, %ecx /* PAE off */207 andl $(~(1 << 5)), %ecx /* PAE off */ 210 208 movl %ecx, %cr4 211 209 … … 222 220 223 221 /* Align address down to 4k */ 224 andl $(~ (PAGE_SIZE - 1)), %esi222 andl $(~4095), %esi 225 223 226 224 use_kernel_end: 227 225 228 226 /* Align address to 4k */ 229 addl $ (PAGE_SIZE - 1), %esi230 andl $(~ (PAGE_SIZE - 1)), %esi227 addl $4095, %esi 228 andl $(~4095), %esi 231 229 232 230 /* Allocate space for page tables */ 233 231 movl %esi, pt_loc 234 movl $KA2PA(ballocs), %edi 232 movl $ballocs, %edi 233 andl $0x7fffffff, %edi 235 234 236 235 movl %esi, (%edi) … … 243 242 244 243 floop_pt: 245 movl $( PTE_RW | PTE_P), %eax244 movl $((1 << 1) | (1 << 0)), %eax 246 245 orl %ebx, %eax 247 246 movl %eax, (%esi, %ecx, 4) 248 addl $ PAGE_SIZE, %ebx247 addl $(4 * 1024), %ebx 249 248 250 249 incl %ecx … … 260 259 261 260 floop: 262 movl $( PDE_RW | PDE_P), %eax261 movl $((1 << 1) | (1 << 0)), %eax 263 262 orl %ebx, %eax 264 263 … … 268 267 /* Mapping 0x80000000 + %ecx * 4M => 0x00000000 + %ecx * 4M */ 269 268 movl %eax, (%edi, %ecx, 4) 270 addl $ PAGE_SIZE, %ebx269 addl $(4 * 1024), %ebx 271 270 272 271 incl %ecx … … 278 277 279 278 movl %cr0, %ebx 280 orl $ CR0_PG, %ebx /* paging on */279 orl $(1 << 31), %ebx /* paging on */ 281 280 movl %ebx, %cr0 282 281 283 282 ret 284 FUNCTION_END(map_kernel_non_pse)285 283 286 284 /** Calculate unmapped address of the end of the kernel. */ 287 285 calc_kernel_end: 288 movl $KA2PA(hardcoded_load_address), %edi 286 movl $hardcoded_load_address, %edi 287 andl $0x7fffffff, %edi 289 288 movl (%edi), %esi 290 leal KA2PA(0)(%esi), %esi 291 292 movl $KA2PA(hardcoded_ktext_size), %edi 289 andl $0x7fffffff, %esi 290 291 movl $hardcoded_ktext_size, %edi 292 andl $0x7fffffff, %edi 293 293 addl (%edi), %esi 294 leal KA2PA(0)(%esi), %esi 295 296 movl $KA2PA(hardcoded_kdata_size), %edi 294 andl $0x7fffffff, %esi 295 296 movl $hardcoded_kdata_size, %edi 297 andl $0x7fffffff, %edi 297 298 addl (%edi), %esi 298 leal KA2PA(0)(%esi), %esi299 andl $0x7fffffff, %esi 299 300 movl %esi, kernel_end 300 301 … … 316 317 /* Check if memory map flag is present */ 317 318 movl (%ebx), %edx 318 andl $ MULTIBOOT_INFO_FLAGS_MMAP, %edx319 andl $(1 << 6), %edx 319 320 jnz use_multiboot_map 320 321 … … 324 325 325 326 /* Copy address of the memory map to edx */ 326 movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx327 movl 48(%ebx), %edx 327 328 movl %edx, %ecx 328 329 329 addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx330 addl 44(%ebx), %ecx 330 331 331 332 /* Find a free region at least 2M in size */ … … 333 334 334 335 /* Is this a free region? */ 335 cmp l $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx)336 cmp $1, 20(%edx) 336 337 jnz next_region 337 338 338 339 /* Check size */ 339 cmp l $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx)340 cmp $0, 16(%edx) 340 341 jnz next_region 341 cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx) 342 343 cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx) 342 344 jbe next_region 343 345 344 cmp l $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx)346 cmp $0, 8(%edx) 345 347 jz found_region 346 348 … … 354 356 next_region_do: 355 357 356 addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx357 addl $ MULTIBOOT_MEMMAP_SIZE_SIZE, %edx358 addl (%edx), %edx 359 addl $4, %edx 358 360 jmp check_memmap_loop 359 361 … … 361 363 362 364 /* Use end of the found region */ 363 mov MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS(%edx), %ecx364 add MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx), %ecx365 mov 4(%edx), %ecx 366 add 12(%edx), %ecx 365 367 sub $(2 * 1024 * 1024), %ecx 366 368 mov %ecx, free_area … … 705 707 .space 4096, 0 706 708 707 SYMBOL(bootstrap_idtr) 709 .global bootstrap_idtr 710 bootstrap_idtr: 708 711 .word 0 709 712 .long 0 710 713 711 SYMBOL(bootstrap_gdtr) 714 .global bootstrap_gdtr 715 bootstrap_gdtr: 712 716 .word GDT_SELECTOR(GDT_ITEMS) 713 717 .long KA2PA(gdt) 714 718 715 SYMBOL(multiboot_eax) 719 .global multiboot_eax 720 multiboot_eax: 716 721 .long 0 717 722 718 SYMBOL(multiboot_ebx) 723 .global multiboot_ebx 724 multiboot_ebx: 719 725 .long 0 720 726
Note:
See TracChangeset
for help on using the changeset viewer.