Virtual/physical addresses
Posted: Sat Feb 02, 2013 1:48 am
In James Molloy's tutorial (http://www.jamesmolloy.co.uk/tutorial_h ... aging.html), he has a function to allocate memory:
If "*phys = placement_address;" gives a physical address, why doesn't "u32int tmp = placement_address; return tmp;"?
Code: Select all
u32int kmalloc(u32int sz, int align, u32int *phys)
{
if (align == 1 && (placement_address & 0xFFFFF000)) // If the address is not already page-aligned
{
// Align it.
placement_address &= 0xFFFFF000;
placement_address += 0x1000;
}
if (phys)
{
*phys = placement_address;
}
u32int tmp = placement_address;
placement_address += sz;
return tmp;
}