Rhodez wrote:For me it looks like it wants a pointer, and i would mean that my variable is a pointer?
The specification also says that the value that the pointer holds is ignored when requesting with "AllocateAnyPages"?
I could try to make a variable as EFI_PHYSICAL_ADDRESS, and then parse the address of that, but shouldn't that be the same?
I can understand your confusion, but no, not the same.
I'll try to explain.
EFI_PHYSICAL_ADDRESS - is a memory address
EFI_PHYSICAL_ADDRESS* - is a pointer to a variable that holds a memory address
void* - pointer to a memory (which has a value of an EFI_PHYSICAL_ADDRESS). It doesn't matter what type the pointer points to, it's value always going to be EFI_PHYSICAL_ADDRESS (but the C language hides this from you).
Now the allocate function should return an EFI_PHYSICAL_ADDRESS, a memory address. It cannot do that unless you pass a pointer to a variable. Therefore, assuming you have "EFI_PHYSICAL_ADDRESS P", you should pass &P. Hope this makes sense. Now here comes the problematic part, because you don't have a single memory address variable, but you have a void* pointer. So if you want to make the allocation to return the memory address in that pointer as the pointed address, then you must pass the address of the pointer. The problem is, you have void* type not EFI_PHYSICAL_ADDRESS, so you must cast it to EFI_PHYSICAL_ADDRESS*, without actually dereferencing the pointer (you need the pointer's address and not the pointed address).
For example, let's assume in the memory at address 0x1000 you have a pointer named
p, with the value 0x2000. Passing it to a function
Code: Select all
somefunc(p); // will pass 0x2000 as argument. The function won't be able to change the p pointer, because it doesn't know where it is in the memory, it only knows the pointed value
somefunc(&p); // will pass 0x1000 as argument, the address of the p pointer. The function therefore can change the pointed address in the pointer
This is a very very (very) simplified description of pointer arithmetic, but I hope clearifies the issue a bit.
As for the ignored part, that means that it doesn't matter what the pointer points to, because that will be overridden by the new address.
Code: Select all
void *p = 0x123; // can be whatever you want, makes the pointer to point to 0x123
alloc(&p); // this function never reads the pointed address from the pointer, just sets it
p == 0x456; // the new value, so the pointer now points to 0x456
Cheers,
bzt