Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
BMW
Member
Posts: 286 Joined: Mon Nov 05, 2012 8:31 pm
Location: New Zealand
Post
by BMW » 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:
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;
}
If "*phys = placement_address;" gives a physical address, why doesn't "u32int tmp = placement_address; return tmp;"?
Currently developing
Lithium OS (LiOS) .
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
thepowersgang
Member
Posts: 734 Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:
Post
by thepowersgang » Sat Feb 02, 2013 2:58 am
Congratulations, you've found one of the places where JamesM's tutorial sucks.
I'd assume the code is designed for identity mappings, so phys=virtual, but the prototype is designed to be easily extended.