heap management in JamesM tutorial
Posted: Fri Apr 20, 2012 7:46 pm
Hi,
I am not understanding the calculation of physical address in the kmalloc function in JamesM tutorial.
As far as I understand , every address is identity-mapped. So the virtual address of the allocated block (addr) should
equal its physical address. Why is it added to address of the frame ?
I am not understanding the calculation of physical address in the kmalloc function in JamesM tutorial.
As far as I understand , every address is identity-mapped. So the virtual address of the allocated block (addr) should
equal its physical address. Why is it added to address of the frame ?
Code: Select all
u32int kmalloc_int(u32int sz, int align, u32int *phys)
{
if (kheap != 0)
{
void *addr = alloc(sz, (u8int)align, kheap);
if (phys != 0)
{
pte_t *page = get_pte((u32int)addr, 0, kernel_directory);
*phys = page->frame*0x1000 + (u32int)addr&0xFFF;
}
return (u32int)addr;
}else {.... }