thunks: Adjust build system for ARM thunk .h
"make headers" (which in turn invokes "make -C thunks/" should now build the include files via awk, avoiding the need for ruby. Signed-off-by: Bernhard Nortmann <bernhard.nortmann@web.de>
This commit is contained in:
parent
7ad5f454db
commit
55253760e5
5
Makefile
5
Makefile
@ -176,6 +176,11 @@ boot_head_sun5i.elf: boot_head.S boot_head.lds
|
||||
|
||||
sunxi-bootinfo: bootinfo.c
|
||||
|
||||
# "preprocessed" .h files for inclusion of ARM thunk code
|
||||
headers:
|
||||
make -C thunks/ CROSS_COMPILE=$(CROSS_COMPILE)
|
||||
|
||||
|
||||
# target tools
|
||||
TARGET_CFLAGS = $(DEFAULT_CFLAGS) -static $(CFLAGS)
|
||||
sunxi-meminfo: meminfo.c
|
||||
|
||||
32
thunks/Makefile
Normal file
32
thunks/Makefile
Normal file
@ -0,0 +1,32 @@
|
||||
#
|
||||
# build "preprocessed" .h files for inclusion of ARM scratch code
|
||||
#
|
||||
|
||||
SPL_THUNK := fel-to-spl-thunk.h
|
||||
THUNKS := sid_read_root.h
|
||||
|
||||
all: $(SPL_THUNK) $(THUNKS)
|
||||
# clean up object files afterwards
|
||||
rm -f *.o
|
||||
|
||||
# This empty prerequisite enforces a rebuild of all the headers on every run
|
||||
FORCE:
|
||||
|
||||
# If not specified explicitly: try to guess a suitable ARM toolchain prefix
|
||||
PATH_DIRS := $(shell echo $$PATH | sed -e 's/:/ /g')
|
||||
CROSS_COMPILE ?= $(shell find $(PATH_DIRS) -executable -name 'arm*-gcc' -printf '%f\t' | cut -f 1 | sed -e 's/-gcc/-/')
|
||||
|
||||
AS := $(CROSS_COMPILE)as
|
||||
OBJDUMP := $(CROSS_COMPILE)objdump
|
||||
|
||||
AWK_O_TO_H := awk -f objdump_to_h.awk
|
||||
|
||||
# The SPL thunk requires a different output format. The "style" variable for
|
||||
# awk controls this, and causes the htole32() conversion to be omitted.
|
||||
fel-to-spl-thunk.h: fel-to-spl-thunk.S FORCE
|
||||
$(AS) -o $(subst .S,.o,$<) $<
|
||||
$(OBJDUMP) -d $(subst .S,.o,$<) | $(AWK_O_TO_H) -v style=old > $@
|
||||
|
||||
$(THUNKS): %.h: %.S FORCE
|
||||
$(AS) -o $(subst .S,.o,$<) $<
|
||||
$(OBJDUMP) -d $(subst .S,.o,$<) | $(AWK_O_TO_H) > $@
|
||||
@ -1,4 +1,6 @@
|
||||
/* <entry_point>: */
|
||||
0xea000015, /* 0: b 5c <setup_stack> */
|
||||
/* <stack_begin>: */
|
||||
0xe1a00000, /* 4: nop */
|
||||
0xe1a00000, /* 8: nop */
|
||||
0xe1a00000, /* c: nop */
|
||||
@ -7,13 +9,17 @@
|
||||
0xe1a00000, /* 18: nop */
|
||||
0xe1a00000, /* 1c: nop */
|
||||
0xe1a00000, /* 20: nop */
|
||||
/* <stack_end>: */
|
||||
0xe1a00000, /* 24: nop */
|
||||
/* <swap_all_buffers>: */
|
||||
0xe28f40dc, /* 28: add r4, pc, #220 */
|
||||
/* <swap_next_buffer>: */
|
||||
0xe4940004, /* 2c: ldr r0, [r4], #4 */
|
||||
0xe4941004, /* 30: ldr r1, [r4], #4 */
|
||||
0xe4946004, /* 34: ldr r6, [r4], #4 */
|
||||
0xe3560000, /* 38: cmp r6, #0 */
|
||||
0x012fff1e, /* 3c: bxeq lr */
|
||||
/* <swap_next_word>: */
|
||||
0xe5902000, /* 40: ldr r2, [r0] */
|
||||
0xe5913000, /* 44: ldr r3, [r1] */
|
||||
0xe2566004, /* 48: subs r6, r6, #4 */
|
||||
@ -21,6 +27,7 @@
|
||||
0xe4803004, /* 50: str r3, [r0], #4 */
|
||||
0x1afffff9, /* 54: bne 40 <swap_next_word> */
|
||||
0xeafffff3, /* 58: b 2c <swap_next_buffer> */
|
||||
/* <setup_stack>: */
|
||||
0xe59f80a4, /* 5c: ldr r8, [pc, #164] */
|
||||
0xe24f0044, /* 60: sub r0, pc, #68 */
|
||||
0xe520d004, /* 64: str sp, [r0, #-4]! */
|
||||
@ -34,10 +41,12 @@
|
||||
0xe1120003, /* 84: tst r2, r3 */
|
||||
0x1a000012, /* 88: bne d8 <cache_is_unsupported> */
|
||||
0xebffffe5, /* 8c: bl 28 <swap_all_buffers> */
|
||||
/* <verify_checksum>: */
|
||||
0xe3067c39, /* 90: movw r7, #27705 */
|
||||
0xe3457f0a, /* 94: movt r7, #24330 */
|
||||
0xe1a00008, /* 98: mov r0, r8 */
|
||||
0xe5905010, /* 9c: ldr r5, [r0, #16] */
|
||||
/* <check_next_word>: */
|
||||
0xe4902004, /* a0: ldr r2, [r0], #4 */
|
||||
0xe2555004, /* a4: subs r5, r5, #4 */
|
||||
0xe0877002, /* a8: add r7, r7, r2 */
|
||||
@ -52,14 +61,18 @@
|
||||
0xf57ff06f, /* cc: isb sy */
|
||||
0xe12fff38, /* d0: blx r8 */
|
||||
0xea000006, /* d4: b f4 <return_to_fel> */
|
||||
/* <cache_is_unsupported>: */
|
||||
0xe3032f2e, /* d8: movw r2, #16174 */
|
||||
0xe3432f3f, /* dc: movt r2, #16191 */
|
||||
0xe5882008, /* e0: str r2, [r8, #8] */
|
||||
0xea000003, /* e4: b f8 <return_to_fel_noswap> */
|
||||
/* <checksum_is_bad>: */
|
||||
0xe304222e, /* e8: movw r2, #16942 */
|
||||
0xe3442441, /* ec: movt r2, #17473 */
|
||||
0xe5882008, /* f0: str r2, [r8, #8] */
|
||||
/* <return_to_fel>: */
|
||||
0xebffffcb, /* f4: bl 28 <swap_all_buffers> */
|
||||
/* <return_to_fel_noswap>: */
|
||||
0xe8bd4004, /* f8: pop {r2, lr} */
|
||||
0xe121f002, /* fc: msr CPSR_c, r2 */
|
||||
0xe59dd000, /* 100: ldr sp, [sp] */
|
||||
|
||||
33
thunks/objdump_to_h.awk
Normal file
33
thunks/objdump_to_h.awk
Normal file
@ -0,0 +1,33 @@
|
||||
# labels
|
||||
/[[:xdigit:]]+ <\w+>:/ {
|
||||
# (Note: using $0 instead of $2 would also include the address)
|
||||
if (style=="old")
|
||||
printf "\t/* %s */\n", $2
|
||||
else
|
||||
printf "\t\t/* %s */\n", $2
|
||||
}
|
||||
|
||||
# disassembly lines
|
||||
/[[:xdigit:]]+:/ {
|
||||
if (style=="old")
|
||||
printf "\t0x%s, /* %9s %-10s", $2, $1, $3
|
||||
else
|
||||
printf "\t\thtole32(0x%s), /* %5s %-5s", $2, $1, $3
|
||||
|
||||
for (i = 4; i <= NF; i++)
|
||||
if ($i == ";") {
|
||||
# strip comment (anything after and including ';')
|
||||
NF = i - 1
|
||||
break
|
||||
}
|
||||
# clear $1 to $3, which re-calculates $0 (= remainder of line)
|
||||
$3 = ""
|
||||
$2 = ""
|
||||
$1 = ""
|
||||
gsub("^\\s+", "") # strip leading whitespace
|
||||
|
||||
if (style=="old")
|
||||
printf " %-28s */\n", $0
|
||||
else
|
||||
printf " %-23s */\n", $0
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user