Fix some smol issues

This commit is contained in:
Curle 2019-07-25 00:22:35 +01:00
parent 862a6e0c7c
commit e10f110a1f
2 changed files with 9 additions and 7 deletions

View File

@ -435,7 +435,7 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
AwaitKey(L"PE Header found, checking format..\r\n");
#endif
if (PEHeader.FileHeader.Machine == IMAGE_FILE_MACHINE_X64 && PEHeader.OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR_MAGIC) {
if (PEHeader.FileHeader.Machine == IMAGE_FILE_MACHINE_X64 && PEHeader.OptionalHeader.Magic == 0x20b /* IMAGE_NT_OPTIONAL_HDR64_MAGIC */) {
// PE32+ File (64 bit).
#ifdef LOADER_DEBUG_MAIN
AwaitKey(L"PE32+ Header found..\r\n");
@ -504,7 +504,7 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
// Kernel file is max 4GB.
size_t Pages = EFI_SIZE_TO_PAGES(DataSize);
size_t Pages = EFI_SIZE_TO_PAGES(PEHeader.OptionalHeader.SizeOfImage);
KernelPages = Pages;
#ifdef LOADER_DEBUG_PE
@ -757,7 +757,7 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
#ifdef LOADER_DEBUG_PE
// The target is Little-Endian, so we have to do some weird stuff when printing.
Print(L"\r\nCheck this.\r\n The Section address is 32 bytes long. It is at 0x%llx. \r\n The first 16 bytes are 0x016llx%016llx.\r\n", KernelAllocatedMemory, *(EFI_PHYSICAL_ADDRESS*)(KernelAllocatedMemory + 8), *(EFI_PHYSICAL_ADDRESS*)KernelAllocatedMemory);
Print(L"\r\nCheck this.\r\n The Section address is 32 bytes long. It is at 0x%llx. \r\n The first 16 bytes are 0x%016llx%016llx.\r\n", KernelAllocatedMemory, *(EFI_PHYSICAL_ADDRESS*)(KernelAllocatedMemory + 8), *(EFI_PHYSICAL_ADDRESS*)KernelAllocatedMemory);
Print(L"The next 16 bytes are 0x%016llx%016llx\r\n", *(EFI_PHYSICAL_ADDRESS*)(KernelAllocatedMemory + HeaderSize + 8), *(EFI_PHYSICAL_ADDRESS*)(KernelAllocatedMemory + HeaderSize));
Print(L"The next 16 bytes should be 0s: 0x%016llx%016llx\r\n", *(EFI_PHYSICAL_ADDRESS *)(KernelAllocatedMemory + HeaderSize + 8), *(EFI_PHYSICAL_ADDRESS *)(KernelAllocatedMemory + HeaderSize));
AwaitKey(L"\0");
@ -768,8 +768,8 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
EFI_PHYSICAL_ADDRESS SectionAddress = KernelAllocatedMemory + (size_t)CurrentHeader->VirtualAddress;
#ifdef LOADER_DEBUG_PE
Print(L"\n%llu. current section address: 0x%x, RawDataSize: 0x%llx\r\n", Iter + 1, CurrentHeader->VirtualAddress, RawSize);
Print(L"current destination address: 0x%llx, AllocatedMemory base: 0x%llx\r\n", SectionAddress, KernelAllocatedMemory);
Print(L"\n%llu. Current Section: Address = 0x%x, RawDataSize: 0x%llx\r\n", Iter + 1, CurrentHeader->VirtualAddress, RawSize);
Print(L"Current Destination: Address = 0x%llx, AllocatedMemory base: 0x%llx\r\n", SectionAddress, KernelAllocatedMemory);
Print(L"PointerToRawData: 0x%llx\r\n", (UINT64)CurrentHeader->PointerToRawData);
Print(L"Check:\r\nSectionAddress: 0x%llx\r\nData there: 0x%016llx%016llx (should be 0)\r\n", SectionAddress, *(EFI_PHYSICAL_ADDRESS*)(SectionAddress + 8), *(EFI_PHYSICAL_ADDRESS *)SectionAddress); // Print the first 128 bits of data at that address to compare
Print(L"About to load section %llu of %llu...\r\n", Iter + 1, NumDataSections);
@ -1477,7 +1477,7 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
KernelStatus = BS->GetMemoryMap(&MapSize, Map, &MapKey, &MapDescSize, &MapDescriptorVersion);
}
//Print(L"Memory Key: %llx", MapKey);
KernelStatus = BS->ExitBootServices(ImageHandle, MapKey);
if (EFI_ERROR(KernelStatus)) {
KernelStatus = BS->FreePool(Map);
@ -1516,6 +1516,8 @@ EFI_STATUS LoadKernel(EFI_HANDLE ImageHandle, GFX_INFO* Graphics, EFI_CONFIGURAT
}
}
AwaitKey(L"Done! Next step is jumping to kernel.\r\n");
// Call the kernel!
LoaderBlock->UEFI_Version = UEFIVer;
LoaderBlock->Bootloader_MajorVersion = MAJOR_VER;

View File

@ -156,7 +156,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
ST->ConfigurationTable[i].VendorGuid.Data4[6],
ST->ConfigurationTable[i].VendorGuid.Data4[7]);
if (strncmpa(&ST->ConfigurationTable[i].VendorGuid, &AcpiTableGuid, 16)) {
if (Compare(&ST->ConfigurationTable[i].VendorGuid, &AcpiTableGuid, 16)) {
Print(L"RSDP 2.0 Found!\r\n");
RSDP_Index = i;
RSDP_Found = 2;