I am implementing a Paging Management Routine. But there are some questions i have.
So first of all, this is my code:
Code: Select all
unsigned long page_usage_bitmap[32768];
unsigned long *frames;
unsigned long max_mem;
unsigned long num_pages;
unsigned long size_bitmap;
unsigned int find_free_frame(void)
{
unsigned int i;
// Find a 32-Bit entry where a free Frame is available
for(i = 0; ((frames[i] == 0xFFFFFFFF) && i < (size_bitmap)); i++);
for(j = 0; j < 32; j++)
{
check = 1 << j;
/* Test wheather Page is free or not */
if(!(frames[i] & check))
return( ((i * 32) + j) ); /* We found a free frame, so return it */
}
}
void init_frame_allocation(multiboot_info_t *mbt)
{
int i=0, address;
/* ToDo: Change */
num_pages = ((mem_lower + mem_upper) * 1024) / 4096;
/* Calculate the Size of the bitmap */
size_bitmap = (num_pages / 32) * 4;
frames = (unsigned long *)kmalloc(size_bitmap);
memset((void*)frames, 0, size_bitmap);
}
Example:
i = 5
j = 24
so the function will return (5*32)+24 which is 184.
and this is not an address or is it?
Cheers Christian