arm: Generate the kernel.bin file in zImage format.

This allows you to run the kernel using the bootz command, which can be
useful on a board where the manufacturer's u-boot does not support EFI.
The original behavior has not been changed, the zImage binary can still
be run by jumping to the beginning of the binary file.

MFC after:	2 weeks
This commit is contained in:
Michal Meloun
2025-05-04 13:29:57 +02:00
parent 642c0334f5
commit e4bfe8e966
2 changed files with 33 additions and 1 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ ${KERNEL_KO}.bin: ${FULLKERNEL}
--output-target=binary ${FULLKERNEL} ${.TARGET}.temp
@{ ${NM} ${FULLKERNEL} | \
LC_ALL=C \
${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7jump && \
${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7bootz && \
cat ${.TARGET}.temp; \
} > ${.TARGET}
@rm ${.TARGET}.temp
+32
View File
@@ -38,6 +38,7 @@ BEGIN {
# The type of header we're writing is set using -v hdrtype= on
# the command line, ensure we got a valid value for it.
if (hdrtype != "v7jump" &&
hdrtype != "v7bootz" &&
hdrtype != "v8jump" &&
hdrtype != "v8booti") {
print "arm_kernel_boothdr.awk: " \
@@ -107,6 +108,35 @@ function write_v7jump() {
write_le32(hexstr_to_num("ea000000") + (gStartOff / 4) - 2)
}
function write_v7bootz() {
# We are writing this struct...
#
# struct BootZ_header {
# uint32_t code0; /* Executable code */
# uint32_t dummy[8]; /* dummy */
# uint32_t magic; /* Magic number 0x016f2818*/
# uint32_t load_offset; /* Image load offset, LE */
# uint32_t image_size; /* Effective Image size, LE */
# };
#
# We write 'b _start' into code0. The image size is everything from
# the start of the loaded image to the offset given by the _end symbol.
write_v7jump() # code0
write_le32(0) # dummy[0]
write_le32(0) # dummy[1]
write_le32(0) # dummy[2]
write_le32(0) # dummy[3]
write_le32(0) # dummy[4]
write_le32(0) # dummy[5]
write_le32(0) # dummy[6]
write_le32(0) # dummy[7]
write_le32(hexstr_to_num("016f2818")) # magic marker
write_le32(0) # load_offset (0 -> auto)
write_le32(gEndOff) # image_size
}
function write_v8jump() {
# Write the machine code for "b _start"...
@@ -186,6 +216,8 @@ END {
if (gHdrType == "v7jump") {
write_v7jump()
} else if (gHdrType == "v7bootz") {
write_v7bootz()
} else if (gHdrType == "v8jump") {
write_v8jump()
} else if (gHdrType == "v8booti") {