A correct argument example would be one of the such:
pmm_init(0x2090A200, 0xC00);
This would say: Tell the physical memory manager to denote the memory address 0x2090A200 and then 0xC00 pages afterward as free.
0x2090A200 = 20MB
0xC00000 = 12MB (0xC00 = How many pages in twelve megabytes.)
20MB + 12MB = 32MB
So in the case above you would have told the physical memory manager that the memory range between 20MB and 32MB is free to use.
I actually have to fix the function again as I foresee another bug. I now have a extra loop to set all bytes to the initial value of five which should help in cases where you might use
pmm_setmaxmem for lets say thirty-two megabytes of RAM, but in the process of doing so the memory used by the bitmap (
g_pmm_map) may become filled with zeros from the default state of RAM in the machine when turned on or something similar. So I use a value of five instead to repersent existing memory in the machine, but not in a freed or allocated state.
Code: Select all
void pmm_init(unsigned int page, unsigned int count){
unsigned int x;
if(g_pmm_map == 0){
if(count >= g_pmm_reqpages){
g_pmm_map = (unsigned char*)page;
page += (g_pmm_reqpages<<12);
count -= g_pmm_reqpages;
pmm_strip((unsigned int)g_pmm_map, g_pmm_reqpages);
for(x = 0; x < ((g_pmm_reqpages-1)<<12); ++x){
g_pmm_map[x] = 5;
}
}else{
__PRINT___ERROR__MESSAGE__;
return;
}
}
for(x = 0; x < count; ++x){
g_pmm_map[(page>>12)+x] = 0;
}
return;
}
I am so sorry for my tutorial causing you the least bit of trouble. My sincere apologies are due. I do really appreciate you taking the time to ask about it since it jump starts my brain into gear so I can fix these things.