Skip to content

Commit e4bfe8e

Browse files
committed
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
1 parent 642c033 commit e4bfe8e

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

sys/conf/Makefile.arm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ ${KERNEL_KO}.bin: ${FULLKERNEL}
9393
--output-target=binary ${FULLKERNEL} ${.TARGET}.temp
9494
@{ ${NM} ${FULLKERNEL} | \
9595
LC_ALL=C \
96-
${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7jump && \
96+
${AWK} -f $S/tools/arm_kernel_boothdr.awk -v hdrtype=v7bootz && \
9797
cat ${.TARGET}.temp; \
9898
} > ${.TARGET}
9999
@rm ${.TARGET}.temp

sys/tools/arm_kernel_boothdr.awk

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ BEGIN {
3838
# The type of header we're writing is set using -v hdrtype= on
3939
# the command line, ensure we got a valid value for it.
4040
if (hdrtype != "v7jump" &&
41+
hdrtype != "v7bootz" &&
4142
hdrtype != "v8jump" &&
4243
hdrtype != "v8booti") {
4344
print "arm_kernel_boothdr.awk: " \
@@ -107,6 +108,35 @@ function write_v7jump() {
107108
write_le32(hexstr_to_num("ea000000") + (gStartOff / 4) - 2)
108109
}
109110

111+
function write_v7bootz() {
112+
113+
# We are writing this struct...
114+
#
115+
# struct BootZ_header {
116+
# uint32_t code0; /* Executable code */
117+
# uint32_t dummy[8]; /* dummy */
118+
# uint32_t magic; /* Magic number 0x016f2818*/
119+
# uint32_t load_offset; /* Image load offset, LE */
120+
# uint32_t image_size; /* Effective Image size, LE */
121+
# };
122+
#
123+
# We write 'b _start' into code0. The image size is everything from
124+
# the start of the loaded image to the offset given by the _end symbol.
125+
126+
write_v7jump() # code0
127+
write_le32(0) # dummy[0]
128+
write_le32(0) # dummy[1]
129+
write_le32(0) # dummy[2]
130+
write_le32(0) # dummy[3]
131+
write_le32(0) # dummy[4]
132+
write_le32(0) # dummy[5]
133+
write_le32(0) # dummy[6]
134+
write_le32(0) # dummy[7]
135+
write_le32(hexstr_to_num("016f2818")) # magic marker
136+
write_le32(0) # load_offset (0 -> auto)
137+
write_le32(gEndOff) # image_size
138+
}
139+
110140
function write_v8jump() {
111141

112142
# Write the machine code for "b _start"...
@@ -186,6 +216,8 @@ END {
186216

187217
if (gHdrType == "v7jump") {
188218
write_v7jump()
219+
} else if (gHdrType == "v7bootz") {
220+
write_v7bootz()
189221
} else if (gHdrType == "v8jump") {
190222
write_v8jump()
191223
} else if (gHdrType == "v8booti") {

0 commit comments

Comments
 (0)