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