Haiku's ARM efi bootloader

Alexander von Gluck IV

Good morning!

I'm getting a bit desperate, so posting here for any ideas :-)
I've been working on porting Haiku's x86_64 EFI bootloader over to ARM.

We're super close, but have been hung up for a while with the following.

We can successfully make a call to EFI's runtime services (printing hello for example)
However, the second call to EFI always hangs with similar errors.

In the example below i'm booting as a cd, but sd card, etc suffer the same fate.

qemu boot:
qemu-system-arm -bios /usr/share/edk2/arm/QEMU_EFI.fd -M virt -cdrom haiku-mmc.image -m 2048

[Bds]Booting UEFI Misc Device 2
BlockSize : 512
LastBlock : A5FFF
FatDiskIo: Cache Page OutBound occurred!
FSOpen: Open '\EFI\BOOT\BOOTARM.EFI' Success
[Bds] Expand PciRoot(0x0)/Pci(0x2,0x0) -> PciRoot(0x0)/Pci(0x2,0x0)/HD(1,MBR,0x00000000,0x9FF6,0x1D394)/\EFI\BOOT\BOOTARM.EFI
BdsDxe: loading Boot0002 "UEFI Misc Device 2" from PciRoot(0x0)/Pci(0x2,0x0)
[Security] 3rd party image[0] can be loaded after EndOfDxe: PciRoot(0x0)/Pci(0x2,0x0)/HD(1,MBR,0x00000000,0x9FF6,0x1D394)/\EFI\BOOT\BOOTARM.EFI.
InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B BD994928
Loading driver at 0x000BC570000 EntryPoint=0x000BC570138
Loading driver at 0x000BC570000 EntryPoint=0x000BC570138
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF BEFFD290
ProtectUefiImageCommon - 0xBD994928
- 0x00000000BC570000 - 0x000000000004A4E4
!!!!!!!! ProtectUefiImageCommon - Section Alignment(0x20) is incorrect !!!!!!!!
BdsDxe: starting Boot0002 "UEFI Misc Device 2" from PciRoot(0x0)/Pci(0x2,0x0)

Data Abort Exception PC at 0xBC570D34 CPSR 0x60000013
Data Abort Exception PC at 0xBC570D34 CPSR 0x60000013 nZCveaift_svc

R0 0xBFA58F10 R1 0x00043028 R2 0x0003C088 R3 0x00800080
R4 0xBFA58010 R5 0xBD994790 R6 0xBC5AC088 R7 0x00043030
R8 0x00000001 R9 0xBEFFD4D8 R10 0x00000000 R11 0x00000000
R12 0xBFA9ACC0 SP 0xBFA7A9F8 LR 0xBC5709A4 PC 0xBC570D34
DFSR 0x00000005 DFAR 0x008000AC IFSR 0x00000000 IFAR 0x00000000
Translation fault on Section: read from 0x008000AC

ASSERT [ArmCpuDxe] /builddir/build/BUILD/edk2-edk2-stable202002/ArmPkg/Library/DefaultExceptionHandlerLib/Arm/DefaultExceptionHandler.c(267): ((BOOLEAN)(0==1))

$ ~/Code/efi_analyzer/efianalyze ./objects/haiku/arm/release/system/boot/efi/haiku_loader.efi
Offset to PE: 0x40
Machine type: 0x01c2, ARM or Thumb ("interworking")
NumberOfSymbols should be 0.
Characteristics: 0x0306
* The file is executable.
* COFF line numbers were stripped from the file.
* The computer supports 32-bit words.
* Debugging information was removed.
Image type: PE32
Size of optional header: 0x90 != 0xe0
Subsystem: EFI application
ImageBase: 0x0
SectionAlignment: 0x20
SizeOfImage: 0x4a4e4
.reloc.address: 0x0
.reloc.size: 0x0
BaseOfCode: 0x138
AddressOfEntryPoint: 0x138
Number of sections: 2
Section[0]: .reloc
Virtual size: 0x0
Virtual address: 0x0
Size of raw data: 0x0
Pointer to raw data: 0x0
End of raw data: 0x0
Characteristics: 0x42100040
* The section contains initialized data.
* Align data on a 1-byte boundary.
* The section can be discarded as needed.
* The section can be read.
Section[1]: .text
Virtual size: 0x4a300
Virtual address: 0x138
Size of raw data: 0x4a3ac
Pointer to raw data: 0x138
End of raw data: 0x4a4e4
Characteristics: 0xe0500020
* The section contains executable code.
* Align data on a 1-byte boundary.
* Align data on a 8-byte boundary.
* The section can be executed as code.
* The section can be read.
* The section can be written to.

Relevant sources:

Linker script:
Our "fake" Pe:
Our efi_main:

Nightly ARM build with latest compiled code (it will autoboot in qemu due to EFI/BOOT/BOOTARM.EFI)

Any help (no matter how minor) would be appreciated!


-- Alex

Join discuss@edk2.groups.io to automatically receive all group messages.