Code: Select all
if (phys)
{
*phys = placement_address;
};
EDIT: So, basically, the *phys will become the return value of the function. It doesn't make sense!!!
Code: Select all
if (phys)
{
*phys = placement_address;
};
Did you actually continue on faith until the "later" he refers to, and still don't understand it - or did you lack faith?JamesM wrote:Now, unfortunately, we have one more requirement, and I can't really explain to you why it is required until later in the tutorials. It has to do with when we clone a page directory (when fork()ing processes). At this point, paging will be fully enabled, and kmalloc will return a virtual address. But, we also (bear with me, you'll be glad we did later) need to get the physical address of the memory allocated. Take it on faith for now - it's not much code anyway.
I read the whole tutorial before, and there was no explanation of how it works. I do understnd why we need physical addresses, but not how they are obtained. Storing the return value in a pointer does not make it physical. And since paging is not enabled, and the GDT 'base' for every gate is at 0, the address returned is physical either way.Solar wrote:Since I never did read JamesM's code, and you didn't provide a link, I googled for it and came up with this page. I am assuming this is what you are talking about.
Right before the code is presented, I find this (emphasis mine):
Did you actually continue on faith until the "later" he refers to, and still don't understand it - or did you lack faith?JamesM wrote:Now, unfortunately, we have one more requirement, and I can't really explain to you why it is required until later in the tutorials. It has to do with when we clone a page directory (when fork()ing processes). At this point, paging will be fully enabled, and kmalloc will return a virtual address. But, we also (bear with me, you'll be glad we did later) need to get the physical address of the memory allocated. Take it on faith for now - it's not much code anyway.
Taking code out of the midst of some tutorial without actually working through the tutorial can be quite confusing sometimes, because you miss out on previous and later explanations on why the author did things the way he did. TIMTOWTDI - There is (always) more than one way to do it.
I freely admit I've never read it before, and that I'm just using my cross-reading abilities to point out likely points of explanation.mariuszp wrote:I read the whole tutorial before, and there was no explanation of how it works.
Because placement_address is only used in the pre-paging stages, it has to be physical by definition.I just wondered, how does this code make sure the address is physical?
But if I do:JamesM wrote:Because placement_address is only used in the pre-paging stages, it has to be physical by definition.I just wondered, how does this code make sure the address is physical?
Code: Select all
// placement allocation still active!
u32int phys;
u32int out;
out = kmalloc_p(1234, &phys);
Code: Select all
u32int phys;
phys = kmalloc_p(1234);
And **** tutorial code at that.berkus wrote:It's a tutorial code we're speaking about.