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