So the basic code aims to set the value of some global variables. Then it will setup a memory bitmap in main memory right after the end of the Kernel, and set all bits in that bitmap to 1 (later we set the correct 0/1 values). The area in memory in which we are putting the bitmap, in extended memory right after the kernel, is supposed to be available.
Code: Select all
uint32_t pmmngr_initialize (uint32_t m_memoryLo, uint32_t m_memoryHi, physical_addr bitmap) {
_mmngr_memory_size = 1024 + m_memoryLo + m_memoryHi*64;
_mmngr_memory_map = (uint32_t*) bitmap;
_mmngr_max_frames = (pmmngr_get_memory_size()*1024) / PMMNGR_FRAME_SIZE;
_mmngr_used_frames = _mmngr_max_frames;
//! By default, all of memory is in use
memset(_mmngr_memory_map, 0xf, pmmngr_get_frame_count() / PMMNGR_FRAMES_PER_BYTE );
}
So that doesn't work. It causes the system to triple-fault.
I've tried to figure out why by breaking up the loop in memset. By writing the 0xF value byte per byte, I found a few bytes that cause the system to triple-fault when I write them (59, 61 and 62... weird numbers). So I tried writing some blocks starting from 63. I've tried writing them in three loops:
Code: Select all
uint32_t i;
uint8_t* temp = (uint8_t*)(_mmngr_memory_map);
for (i = 63; i < 100; i++) {
temp[i] = 0xF;
}
for (i = 100; i < 170; i++) {
temp[i] = 0xF;
}
for (i = 170; i < 200; i++) {
temp[i] = 0xF;
}
I'm stumped. If anyone can understand what's going on here, please tell me.