Ok, here is the problem as I find it.
first, here is the code in question
Code: Select all
[section .cr1_data]
; Page table to map the first 4MB of physical memory
boot_page_directory:
dd (0x00000003 + boot_page_table)
times (KERNEL_DIR_NUMBER - 1) dd 0 ; Pages before kernel space.
; This page directory entry defines a 4MB page containing the kernel.
dd (0x00000003 + boot_page_table)
times (1024 - KERNEL_DIR_NUMBER - 1) dd 0 ; Pages after the kernel image.
boot_page_table:
%assign i 0
%rep 1024
dd (0x00000003 + (i * 4096))
%assign i (i+1)
%endrep
next, the relevant section of the linker script
Code: Select all
.dataB ALIGN (0x1000)
: AT ( ADDR (.textA) + SIZEOF (.textA) + SIZEOF(.textB))
{ cr1.o(.cr1_data) }
finally, heres what bochs displays as the contents of memory where both these data structures should be stored.
Code: Select all
<bochs:3> x /10 0x00101000
[bochs]:
0x00101000 <bogus+ 0>: 0x00000000 0x00000000 0x00000000 0x00000000
0x00101010 <bogus+ 16>: 0x00000000 0x00000000 0x00000000 0x00000000
0x00101020 <bogus+ 32>: 0x00000000 0x00000000
<bochs:4> x /10 0x00102000
[bochs]:
0x00102000 <bogus+ 0>: 0x0003003d 0x1003003e 0x2003003e 0x3003003e
0x00102010 <bogus+ 16>: 0x4003003e 0x5003003e 0x6003003e 0x7003003e
0x00102020 <bogus+ 32>: 0x8003003e 0x9003003e
So I figured out its failing because my tables are junk, but I dont know why they are turning out like this and it appears to be the data is not aligned properly and is overwriting itself. I also tried in the nasm code to put in align 8, but this still will not produce the same results. Shouldnt align 8 make it so that every 8 bytes it will start over again? I also tried align 4 for fun and no results. Is it the align directive in the linker code changing things? This appears like a simple answer, but Im not too sure how align really works or whats going on, because the way I understood it does not appear to be correct