Skip to content

Commit c957edf

Browse files
committed
ARM64: Public release.
Should only work for 8992/8994 (because it initializes PCIe too).
1 parent 3d7ea9c commit c957edf

File tree

4 files changed

+15
-82
lines changed

4 files changed

+15
-82
lines changed

include/EFIApp.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,15 @@
3030

3131
#define GIC_DIST_CTRL GIC_DIST_REG(0x000)
3232

33-
BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr);
33+
BOOLEAN CheckElf64Header(
34+
Elf64_Ehdr * bl_elf_hdr
35+
);
36+
3437
VOID JumpToAddressAArch64(
3538
EFI_HANDLE ImageHandle,
3639
EFI_PHYSICAL_ADDRESS Address,
3740
VOID* PayloadBuffer,
3841
UINT64 PayloadLength
3942
);
4043

41-
VOID JumpToAddressAArch32(
42-
EFI_HANDLE ImageHandle,
43-
EFI_PHYSICAL_ADDRESS AArch32Address,
44-
EFI_PHYSICAL_ADDRESS AArch64Address,
45-
VOID* AArch64PayloadBuffer,
46-
UINT64 AArch64PayloadLength
47-
);
48-
4944
#endif

include/lk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#define _LK_DEFINITION_H_
55

66
#define PAYLOAD_BINARY_NAME L"UEFI.elf"
7-
#define LK_BINARY_NAME L"emmc_appsboot.mbn"
87
#define PAYLOAD_ENTRY_POINT_ADDR_INVALID 0x00000000
98

109
#endif

include/scm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ typedef struct {
3737
uint64_t el1_x7;
3838
uint64_t el1_x8;
3939
uint64_t el1_elr;
40-
} el1_system_param;
40+
} EL1_SYSTEM_PARAM;
4141

4242
enum
4343
{
4444
SMC_PARAM_TYPE_VALUE = 0,
4545
SMC_PARAM_TYPE_BUFFER_READ,
4646
SMC_PARAM_TYPE_BUFFER_READWRITE,
4747
SMC_PARAM_TYPE_BUFFER_VALIDATION,
48-
} scm_arg_type;
48+
} SCM_ARG_TYPE;
4949

5050
#define SIP_SVC_CALLS 0x02000000
5151
#define MAKE_SIP_SCM_CMD(svc_id, cmd_id) ((((svc_id << 8) | (cmd_id)) & 0xFFFF) | SIP_SVC_CALLS)

src/EFIApp.c

Lines changed: 9 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ VOID JumpToAddressAArch64(
1818
UINT32 DesVersion = 0;
1919
UINT32 PayloadAddress32 = (UINT32) Address;
2020
UINT32 PayloadLength32 = (UINT32) PayloadLength;
21-
2221
EFI_PHYSICAL_ADDRESS DynamicEl1ParamAddress = 0xA0000000;
23-
el1_system_param* DynamicEl1Param;
22+
EL1_SYSTEM_PARAM* DynamicEl1Param;
2423

24+
// This is a bit hacky, but it can save me some time
25+
// on the call convention.
2526
Status = gBS->AllocatePages(
2627
AllocateAddress,
2728
EfiRuntimeServicesData,
@@ -92,73 +93,9 @@ VOID JumpToAddressAArch64(
9293
while (TRUE) { }
9394
}
9495

95-
VOID JumpToAddressAArch32(
96-
EFI_HANDLE ImageHandle,
97-
EFI_PHYSICAL_ADDRESS AArch32Address,
98-
EFI_PHYSICAL_ADDRESS AArch64Address,
99-
VOID* AArch64PayloadBuffer,
100-
UINT64 AArch64PayloadLength
96+
BOOLEAN CheckElf64Header(
97+
Elf64_Ehdr * bl_elf_hdr
10198
)
102-
{
103-
104-
EFI_STATUS Status;
105-
UINTN MemMapSize = 0;
106-
EFI_MEMORY_DESCRIPTOR* MemMap = 0;
107-
UINTN MapKey = 0;
108-
UINTN DesSize = 0;
109-
UINT32 DesVersion = 0;
110-
UINT32 PayloadAddress32 = (UINT32) AArch64Address;
111-
UINT32 PayloadLength32 = (UINT32) AArch64PayloadLength;
112-
113-
/* Entry */
114-
VOID(*entry)() = (VOID*) AArch32Address;
115-
116-
Print(L"Exiting boot services... \n");
117-
118-
gBS->GetMemoryMap(
119-
&MemMapSize,
120-
MemMap,
121-
&MapKey,
122-
&DesSize,
123-
&DesVersion
124-
);
125-
126-
/* Shutdown */
127-
Status = gBS->ExitBootServices(
128-
ImageHandle,
129-
MapKey
130-
);
131-
132-
if (EFI_ERROR(Status))
133-
{
134-
Print(L"Failed to exit BS\n");
135-
return;
136-
}
137-
138-
/* Move LOAD section to actual location */
139-
SetMem(
140-
(VOID*)PayloadAddress32,
141-
PayloadLength32,
142-
0xFF);
143-
144-
CopyMem(
145-
(VOID*)PayloadAddress32,
146-
AArch64PayloadBuffer,
147-
PayloadLength32
148-
);
149-
150-
/* De-initialize */
151-
ArmDeInitialize();
152-
153-
/* Disable GIC */
154-
writel(0, GIC_DIST_CTRL);
155-
156-
/* Lets go */
157-
entry();
158-
159-
}
160-
161-
BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr)
16299
{
163100

164101
EFI_PHYSICAL_ADDRESS ElfEntryPoint;
@@ -222,7 +159,9 @@ BOOLEAN CheckElf64Header(Elf64_Ehdr * bl_elf_hdr)
222159
return TRUE;
223160
}
224161

225-
static BOOLEAN PCIExpressIsPhyReady(VOID)
162+
static BOOLEAN PCIExpressIsPhyReady(
163+
VOID
164+
)
226165
{
227166
if (readl(MSM_PCIE_PHY + PCIE_PHY_PCS_STATUS) & BIT(6))
228167
return FALSE;
@@ -326,7 +265,7 @@ EFI_STATUS efi_main(
326265
continue;
327266
}
328267

329-
// Read image and parse ELF32 file
268+
// Read image and parse ELF64 file
330269
Print(L"Opened payload image\n");
331270

332271
Status = PayloadFileProtocol->GetInfo(

0 commit comments

Comments
 (0)