Changes in kernel/arch/ia32/src/boot/multiboot.S [7ba16eb:8844e70] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/src/boot/multiboot.S
r7ba16eb r8844e70 31 31 #include <abi/asmtool.h> 32 32 #include <arch/boot/boot.h> 33 #include <arch/boot/memmap.h>34 33 #include <arch/mm/page.h> 35 34 #include <arch/pm.h> 36 35 #include <genarch/multiboot/multiboot.h> 37 36 #include <arch/cpuid.h> 38 #include <arch/cpu.h>39 37 40 38 #define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) … … 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 … … 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 … … 286 285 /** Calculate unmapped address of the end of the kernel. */ 287 286 calc_kernel_end: 288 movl $KA2PA(hardcoded_load_address), %edi 287 movl $hardcoded_load_address, %edi 288 andl $0x7fffffff, %edi 289 289 movl (%edi), %esi 290 leal KA2PA(0)(%esi), %esi 291 292 movl $KA2PA(hardcoded_ktext_size), %edi 290 andl $0x7fffffff, %esi 291 292 movl $hardcoded_ktext_size, %edi 293 andl $0x7fffffff, %edi 293 294 addl (%edi), %esi 294 leal KA2PA(0)(%esi), %esi 295 296 movl $KA2PA(hardcoded_kdata_size), %edi 295 andl $0x7fffffff, %esi 296 297 movl $hardcoded_kdata_size, %edi 298 andl $0x7fffffff, %edi 297 299 addl (%edi), %esi 298 leal KA2PA(0)(%esi), %esi300 andl $0x7fffffff, %esi 299 301 movl %esi, kernel_end 300 302 … … 316 318 /* Check if memory map flag is present */ 317 319 movl (%ebx), %edx 318 andl $ MULTIBOOT_INFO_FLAGS_MMAP, %edx320 andl $(1 << 6), %edx 319 321 jnz use_multiboot_map 320 322 … … 324 326 325 327 /* Copy address of the memory map to edx */ 326 movl MULTIBOOT_INFO_OFFSET_MMAP_ADDR(%ebx), %edx328 movl 48(%ebx), %edx 327 329 movl %edx, %ecx 328 330 329 addl MULTIBOOT_INFO_OFFSET_MMAP_LENGTH(%ebx), %ecx331 addl 44(%ebx), %ecx 330 332 331 333 /* Find a free region at least 2M in size */ … … 333 335 334 336 /* Is this a free region? */ 335 cmp l $MEMMAP_MEMORY_AVAILABLE, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_TYPE(%edx)337 cmp $1, 20(%edx) 336 338 jnz next_region 337 339 338 340 /* Check size */ 339 cmp l $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE + 4(%edx)341 cmp $0, 16(%edx) 340 342 jnz next_region 341 cmpl $(2 * 1024 * 1024 + PAGE_SIZE), MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_SIZE(%edx) 343 344 cmpl $(2 * 1024 * 1024 + 4 * 1024), 12(%edx) 342 345 jbe next_region 343 346 344 cmp l $0, MULTIBOOT_MEMMAP_OFFSET_MM_INFO + E820MEMMAP_OFFSET_BASE_ADDRESS + 4(%edx)347 cmp $0, 8(%edx) 345 348 jz found_region 346 349 … … 354 357 next_region_do: 355 358 356 addl MULTIBOOT_MEMMAP_OFFSET_SIZE(%edx), %edx357 addl $ MULTIBOOT_MEMMAP_SIZE_SIZE, %edx359 addl (%edx), %edx 360 addl $4, %edx 358 361 jmp check_memmap_loop 359 362 … … 361 364 362 365 /* 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), %ecx366 mov 4(%edx), %ecx 367 add 12(%edx), %ecx 365 368 sub $(2 * 1024 * 1024), %ecx 366 369 mov %ecx, free_area
Note:
See TracChangeset
for help on using the changeset viewer.