summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBradley Morgan <brads@mainlining.org>2026-10-03 18:57:38 +0000
committerBradley Morgan <brads@mainlining.org>2026-10-03 18:57:38 +0000
commit00fc82f17cff9295387d516384ecdc443acb1b22 (patch)
tree798bef0185878286028fe0eaf7594616a66903e4 /test
parent7e8514efb64774b6a635b87ae945e519a7c38551 (diff)
tashaboot: arm64 bringup, semihosting payload loader
consoles on the pl011 the dtb points at, walks the memory node and chosen, loads an arm64 kernel Image over semihosting and jumps to it with the documented register state. string functions, printf and libfdt are vendored from lk (lk2nd) and u-boot so the libc surface is the one those projects already proved. built and booted on qemu virt, payload exits clean through semihosting.
Diffstat (limited to 'test')
-rw-r--r--test/payload.S52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/payload.S b/test/payload.S
new file mode 100644
index 0000000..d1891a2
--- /dev/null
+++ b/test/payload.S
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * payload.S - tiny arm64 image for testing tashaboot. carries the real
+ * Image header from Documentation/arch/arm64/booting.rst, prints one
+ * line on the virt uart, parks. built with the same conventions the
+ * kernel itself uses so the header math in tashaboot is exercised for
+ * real, not against a fake.
+ *
+ * Copyright (C) 2026 Bradley Morgan <brads@mainlining.org>
+ */
+
+#include <asm/linkage.h>
+
+/* the header the bootloader validates */
+#define ARM64_IMAGE_MAGIC 0x644d5241
+
+.section .text.head
+.globl _start
+_start:
+ /* code0/code1: branch over the header, like the kernel does */
+ b 1f
+ .long 0
+
+ /* text_offset, 0x80000 like every kernel since forever */
+ .quad 0x80000
+ /* image_size, filled at build time by scripts/mkpayload.sh */
+ .quad payload_end - _start
+ /* flags, bit 3 = anywhere in memory is fine */
+ .quad (1 << 3)
+ .quad 0
+ .quad 0
+ .quad 0
+ /* magic "ARM\x64" */
+ .long ARM64_IMAGE_MAGIC
+ .long 0
+1:
+ /* the payload entry: x0 = dtb from the bootloader */
+ ldr x1, =0x09000000 /* pl011 on qemu virt */
+ adr x2, msg
+2: ldrb w3, [x2], #1
+ cbz w3, 3f
+ str w3, [x1]
+ b 2b
+3: /* clean exit through semihosting, proof we got here */
+ mov x0, #0x18 /* SYS_EXIT */
+ ldr x1, =0x20026 /* ADP_Stopped_ApplicationExit */
+ hlt #0xF000
+ b 3b
+
+msg: .asciz "payload: alive, tashaboot jumped here\n"
+ .balign 8
+payload_end: