Skip to content

Commit

Permalink
ARM64: Public release.
Browse files Browse the repository at this point in the history
Should only work for 8992/8994 (because it initializes PCIe too).
  • Loading branch information
imbushuo committed Jun 27, 2018
1 parent 3d7ea9c commit c957edf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 82 deletions.
13 changes: 4 additions & 9 deletions include/EFIApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,15 @@

#define GIC_DIST_CTRL GIC_DIST_REG(0x000)

BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr);
BOOLEAN CheckElf64Header(
Elf64_Ehdr * bl_elf_hdr
);

VOID JumpToAddressAArch64(
EFI_HANDLE ImageHandle,
EFI_PHYSICAL_ADDRESS Address,
VOID* PayloadBuffer,
UINT64 PayloadLength
);

VOID JumpToAddressAArch32(
EFI_HANDLE ImageHandle,
EFI_PHYSICAL_ADDRESS AArch32Address,
EFI_PHYSICAL_ADDRESS AArch64Address,
VOID* AArch64PayloadBuffer,
UINT64 AArch64PayloadLength
);

#endif
1 change: 0 additions & 1 deletion include/lk.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#define _LK_DEFINITION_H_

#define PAYLOAD_BINARY_NAME L"UEFI.elf"
#define LK_BINARY_NAME L"emmc_appsboot.mbn"
#define PAYLOAD_ENTRY_POINT_ADDR_INVALID 0x00000000

#endif
4 changes: 2 additions & 2 deletions include/scm.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ typedef struct {
uint64_t el1_x7;
uint64_t el1_x8;
uint64_t el1_elr;
} el1_system_param;
} EL1_SYSTEM_PARAM;

enum
{
SMC_PARAM_TYPE_VALUE = 0,
SMC_PARAM_TYPE_BUFFER_READ,
SMC_PARAM_TYPE_BUFFER_READWRITE,
SMC_PARAM_TYPE_BUFFER_VALIDATION,
} scm_arg_type;
} SCM_ARG_TYPE;

#define SIP_SVC_CALLS 0x02000000
#define MAKE_SIP_SCM_CMD(svc_id, cmd_id) ((((svc_id << 8) | (cmd_id)) & 0xFFFF) | SIP_SVC_CALLS)
Expand Down
79 changes: 9 additions & 70 deletions src/EFIApp.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ VOID JumpToAddressAArch64(
UINT32 DesVersion = 0;
UINT32 PayloadAddress32 = (UINT32) Address;
UINT32 PayloadLength32 = (UINT32) PayloadLength;

EFI_PHYSICAL_ADDRESS DynamicEl1ParamAddress = 0xA0000000;
el1_system_param* DynamicEl1Param;
EL1_SYSTEM_PARAM* DynamicEl1Param;

// This is a bit hacky, but it can save me some time
// on the call convention.
Status = gBS->AllocatePages(
AllocateAddress,
EfiRuntimeServicesData,
Expand Down Expand Up @@ -92,73 +93,9 @@ VOID JumpToAddressAArch64(
while (TRUE) { }
}

VOID JumpToAddressAArch32(
EFI_HANDLE ImageHandle,
EFI_PHYSICAL_ADDRESS AArch32Address,
EFI_PHYSICAL_ADDRESS AArch64Address,
VOID* AArch64PayloadBuffer,
UINT64 AArch64PayloadLength
BOOLEAN CheckElf64Header(
Elf64_Ehdr * bl_elf_hdr
)
{

EFI_STATUS Status;
UINTN MemMapSize = 0;
EFI_MEMORY_DESCRIPTOR* MemMap = 0;
UINTN MapKey = 0;
UINTN DesSize = 0;
UINT32 DesVersion = 0;
UINT32 PayloadAddress32 = (UINT32) AArch64Address;
UINT32 PayloadLength32 = (UINT32) AArch64PayloadLength;

/* Entry */
VOID(*entry)() = (VOID*) AArch32Address;

Print(L"Exiting boot services... \n");

gBS->GetMemoryMap(
&MemMapSize,
MemMap,
&MapKey,
&DesSize,
&DesVersion
);

/* Shutdown */
Status = gBS->ExitBootServices(
ImageHandle,
MapKey
);

if (EFI_ERROR(Status))
{
Print(L"Failed to exit BS\n");
return;
}

/* Move LOAD section to actual location */
SetMem(
(VOID*)PayloadAddress32,
PayloadLength32,
0xFF);

CopyMem(
(VOID*)PayloadAddress32,
AArch64PayloadBuffer,
PayloadLength32
);

/* De-initialize */
ArmDeInitialize();

/* Disable GIC */
writel(0, GIC_DIST_CTRL);

/* Lets go */
entry();

}

BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr)
{

EFI_PHYSICAL_ADDRESS ElfEntryPoint;
Expand Down Expand Up @@ -222,7 +159,9 @@ BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr)
return TRUE;
}

static BOOLEAN PCIExpressIsPhyReady(VOID)
static BOOLEAN PCIExpressIsPhyReady(
VOID
)
{
if (readl(MSM_PCIE_PHY + PCIE_PHY_PCS_STATUS) & BIT(6))
return FALSE;
Expand Down Expand Up @@ -326,7 +265,7 @@ EFI_STATUS efi_main(
continue;
}

// Read image and parse ELF32 file
// Read image and parse ELF64 file
Print(L"Opened payload image\n");

Status = PayloadFileProtocol->GetInfo(
Expand Down

0 comments on commit c957edf

Please sign in to comment.