From ad5a2be4c18cd0f22d66faf38959e6da41ec2d59 Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Tue, 24 Jun 2025 10:07:29 -0500 Subject: [PATCH] bsps/aarch64/start: Add support for Image protocol This adds support for a the Image header protocol similar to the zImage protocol that Linux kernels use to describe their expectations of the system configuration. --- bsps/aarch64/shared/start/start.S | 23 +++++++++++++++++++++++ spec/build/bsps/aarch64/optimghdr.yml | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 spec/build/bsps/aarch64/optimghdr.yml diff --git a/bsps/aarch64/shared/start/start.S b/bsps/aarch64/shared/start/start.S index 0a89d85035..60484e09bf 100644 --- a/bsps/aarch64/shared/start/start.S +++ b/bsps/aarch64/shared/start/start.S @@ -37,12 +37,35 @@ #include #include +#include #include /* Global symbols */ .globl _start .section ".bsp_start_text", "ax" +#ifdef BSP_START_IMAGE_HEADER + /* + * This format is defined by: + * https://www.kernel.org/doc/Documentation/arm64/booting.txt + */ + mov x0, x0 + b _start + /* + * This must be defined by the BSP as different environments may not treat it + * the same. Xen treats it as an offset from 0x40000000 while QEMU treats it + * as an absolute offset (RAM origin + load offset). + */ + .dword BSP_START_IMAGE_HEADER_LOAD_OFFSET + .dword 0 /* image size */ + .dword 0 /* kernel flags, LE, page size unspecified, place near RAM start */ + .dword 0 /* reserved 2 */ + .dword 0 /* reserved 3 */ + .dword 0 /* reserved 4 */ + .word 0x644d5241 /* magic, ascii ['A', 'R', 'M', 64] LE */ + .word 0 /* reserved 5, PE COFF offset */ +#endif /* BSP_START_IMAGE_HEADER */ + /* Start entry */ _start: diff --git a/spec/build/bsps/aarch64/optimghdr.yml b/spec/build/bsps/aarch64/optimghdr.yml new file mode 100644 index 0000000000..76f241862a --- /dev/null +++ b/spec/build/bsps/aarch64/optimghdr.yml @@ -0,0 +1,16 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-boolean: null +- define-condition: null +build-type: option +copyrights: +- Copyright (C) 2025 On-Line Applications Research (OAR) +default: +- enabled-by: true + value: true +description: | + include zImage boot header +enabled-by: true +links: [] +name: BSP_START_IMAGE_HEADER +type: build