Hello!
It seems like your kernel64.elf is being opened.
I also noticed a bug with your Log(); function that causes text to move back to the top of the screen. (Unless that is what you wanted)
Adding Print() statements to your error conditions can help pinpoint the error easier for you and make debugging less guesswork.
For example:
Code:
Status = uefi_call_wrapper(
Kernel->GetInfo,
4,
Kernel,
&gEfiFileInfoGuid,
&FileInfoSize,
NULL
);
if(EFI_ERROR(Status)) {
Print(L"Failed to GetInfo\n");
return Status;
}
This can tell you exactly which call failed.
It seems like AllocatePages is returning an error in your for loop.
Have you tried using gnuefi's AllocatePool(); function? I have found that it works better (and easier) than calling AllocatePages and it doesn't need a uefi_call_wrapper.
Also, imo, it is easier to loop through the ELF and add up the section sizes you need so you only have to call AllocatePool/AllocatePages once for each section and then you can load your kernel code/data to it.
You can see how I do this
here. (No guarantee it is bug free)
You don't have to worry about where the kernel is in physical memory (just don't overwrite it) since you can map it anywhere in virtual memory.
P.S
I would recommend changing these
Code:
static const uint16_t ET_NONE = 0;
Into
Code:
#define ET_NONE 0
It is more readable imo.