Okay, I went back and tried this:
Code: Select all
u32 phys = vmm_get_phys(0xC0000000, kdir); // Get the physical address of the start of the heap
vmm_map(phys, phys); // Identity map it
*((u32*)phys) = 0xBADF00D; // Set it's value
k_printf("\nphys=0x%x", *((u32*)phys)); // Print it's value
and it worked. The value was indeed set to "BADF00D". This means that it is a problem with my page mapping. I will have to go over my mapping code, but thought I would post this to see if it gave anyone an idea. This makes the error even wierder, because this means there is a problem with my page mapping, and yet I'm not getting a Page Fault... hmmm....
EDIT
It appears that this is a problem with VMs. I decided to run it from a flash drive, and it works. I don't get my "Assertion failed... etc" message (which was stating that a variables value was wrong. I used an assertion since I don't have the debugger on a physical machine btw). It doesn't work with VirtualBox or qemu. Bochs is a pain to setup so I haven't tried it (well actually it just didn't like my disk image because of the geometry crap).
EDIT 2
Just confirmed that it is working with the physical machine. I ran this:
Code: Select all
k_printf("\tMemory test:\n\tSetting *((u32*)(0x%x))=0x%x\n", KHEAP_START, 0xBADF00D);
*((u32*)(KHEAP_START)) = 0xBADF00D;
k_printf("\t*((u32*)(0x%x))==0x%x\n",KHEAP_START, *((u32*)(KHEAP_START)));
Just after enabling pagin, and it worked correctly. I don't understand how this could not work. I know that mainstream OS's use higher-half kernels which need access to addresses like 0xC0000000, and THEY run in qemu/VB, so it must be something with my settings in the VM or my code. I think it's the VM settings since my code works on a physical machine.
EDIT 3
It appears the VMs aren't using the page tables correctly, because when I set my heap address to 0x70000000 and give my VM an outragous amount of memory ( i think I slid the bar in VB to like 2.9 GBs) it runs. The amount of physical memory that the machine has should not matter though! Paging is enabled and the memory is mapped to a address within the current memory size! This doesn't make sense...