From 33deaa128a4ea4ca856121b9f3a2b1185aefd5f6 Mon Sep 17 00:00:00 2001 From: Gustave Monce Date: Sun, 11 Sep 2022 21:21:56 +0200 Subject: [PATCH] BootShim: Publish code for LinuxLoader and XBL Reload [skip ci] --- BootShim/BootShim.Zeta.LinuxLoader.S | 47 ++++++++++++++++++ BootShim/BootShim.Zeta.XBLReload.S | 74 ++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 BootShim/BootShim.Zeta.LinuxLoader.S create mode 100644 BootShim/BootShim.Zeta.XBLReload.S diff --git a/BootShim/BootShim.Zeta.LinuxLoader.S b/BootShim/BootShim.Zeta.LinuxLoader.S new file mode 100644 index 00000000..2d1e72be --- /dev/null +++ b/BootShim/BootShim.Zeta.LinuxLoader.S @@ -0,0 +1,47 @@ +_Head: + /* Set _Entry address */ + adr x1, _Payload + + /* Jump to the real code */ + b _Start + + /* Fake Linux kernel header */ + + /* Text Offset */ + .quad 0x9F000000 + +_StackSize: + /* Image Size */ + .quad 0x01DF5200 + + /* Flags */ + .quad 0 + + /* Reserved */ + .quad 0 + + /* Reserved */ + .quad 0 + + /* Reserved */ + .quad 0 + + /* ARM64 Magic */ + .ascii "ARM\x64" + + /* Reserved */ + .long 0 + +_Start: + /* Location of the device tree for said kernel image */ + ldr x0, _StackSize + add x0, x0, x1 + + /* Reserved */ + mov x1, #0 + +.text +.align 4 + +_Payload: + /* Your code will get ran right after this binary */ \ No newline at end of file diff --git a/BootShim/BootShim.Zeta.XBLReload.S b/BootShim/BootShim.Zeta.XBLReload.S new file mode 100644 index 00000000..b453fd83 --- /dev/null +++ b/BootShim/BootShim.Zeta.XBLReload.S @@ -0,0 +1,74 @@ +_Head: + /* Set _Entry address */ + adr x1, #0xA0 + + /* Jump to the real code */ + b _Start + + /* Fake Linux kernel header */ + +_StackBase: + /* Text Offset */ + .quad 0x9FC00000 + +_StackSize: + /* Image Size */ + .quad 0x00300000 + +_Test1: + /* Flags */ + .quad 0x9B800000 + +_Test2: + /* Reserved */ + .quad 0x03C00000 + + /* Reserved */ + .quad 0 + + /* Reserved */ + .quad 0 + + /* ARM64 Magic */ + .ascii "ARM\x64" + + /* Reserved */ + .long 0 + +_Start: + mov x4, x1 + ldr x5, _StackBase + cmp x4, x5 + beq _Entry + ldr x6, _StackSize + +_CopyLoop: + ldp x2, x3, [x4], #16 + stp x2, x3, [x5], #16 + subs x6, x6, #16 + b.ne _CopyLoop + + nop + ldr x8, _Test1 + ldr x9, _Test2 +_Cleanup: + mov x2, #0 + mov x3, #0 + stp xzr, xzr, [x8], #16 + subs x9, x9, #16 + b.ne _Cleanup + nop + nop + nop + nop + + ldr x5, _StackBase + +_Entry: + br x5 + +dead: + /* We should never get here */ + b dead + + /* Your code will get ran right after this binary */ \ No newline at end of file