c9a028cc18
This tool is a scriptable (lua) tool to patch binaries, it supports: - raw binary - ELF - SB(v1/v2) It also contains some basic routines to parse and generate useful arm/thumb code like jump or register load/store. This is very useful to take a firmware and patch an interrupt vector or some code to jump to an extra payload added to the binary. Examples are provided for several STMP based target which the payload is expected to be hwstub, and also for the Sansa View. A typical patcher usually requires three elements: - the lua patcher itself - the payload (hwstub for example) - (optional) a small stub either to jump properly to the payload or determine under which circumstance to do the jump (hold a key for example) Change-Id: I6d36020a3bc9e636615ac8221b7591ade5f251e3
87 lines
No EOL
2 KiB
ArmAsm
87 lines
No EOL
2 KiB
ArmAsm
.text
|
|
.global _start
|
|
_start:
|
|
b exec
|
|
branch_addr:
|
|
.word kill
|
|
hw_power_sts:
|
|
#if defined(CREATIVE_ZEN)
|
|
.word 0x800440b0 /* STMP3700 */
|
|
#else
|
|
.word 0x800440c0 /* IMX233 */
|
|
#endif
|
|
hw_pinctrl_din0:
|
|
.word 0x80018600
|
|
hw_pinctrl_din1:
|
|
.word 0x80018610
|
|
hw_pinctrl_din2:
|
|
.word 0x80018620
|
|
kill:
|
|
ldr pc, branch_addr
|
|
exec:
|
|
#if defined(SANSA_FUZEPLUS)
|
|
/* check PSWITCH=1 (power button pressed) */
|
|
ldr r0, hw_power_sts
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #20
|
|
and r0, #3
|
|
cmp r0, #1
|
|
bne ret
|
|
/* check B1P30=0 (volume down pressed) */
|
|
ldr r0, hw_pinctrl_din1
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #30
|
|
ands r0, #1
|
|
beq kill
|
|
#elif defined(CREATIVE_ZENXFI3)
|
|
/* check PSWITCH=1 (power button pressed) */
|
|
ldr r0, hw_power_sts
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #20
|
|
and r0, #3
|
|
cmp r0, #1
|
|
bne ret
|
|
/* check B2P07=0 (volume down pressed) */
|
|
ldr r0, hw_pinctrl_din2
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #7
|
|
ands r0, #1
|
|
beq kill
|
|
#elif defined(CREATIVE_ZENXFI2)
|
|
/* check B0P11=0 (power button pressed) and B0P14 (select button pressed) */
|
|
ldr r0, hw_pinctrl_din0
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #11
|
|
tst r0, #1
|
|
bne ret
|
|
mov r0, r0, lsr #3
|
|
tst r0, #1
|
|
beq kill
|
|
#elif defined(CREATIVE_ZEN)
|
|
/* check PSWITCH=1 (power button pressed) */
|
|
ldr r0, hw_power_sts
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #18
|
|
and r0, #3
|
|
cmp r0, #0
|
|
bne kill
|
|
#elif defined(SONY_NWZ)
|
|
/* check PSWITCH=3 (power button pressed) */
|
|
ldr r0, hw_power_sts
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #20
|
|
and r0, #3
|
|
cmp r0, #3
|
|
beq kill
|
|
#elif defined(CREATIVE_ZENXFISTYLE)
|
|
/* check PSWITCH=1 (power button pressed) */
|
|
ldr r0, hw_power_sts
|
|
ldr r0, [r0]
|
|
mov r0, r0, lsr #20
|
|
and r0, #3
|
|
cmp r0, #1
|
|
beq kill
|
|
#else
|
|
#error implement me
|
|
#endif
|
|
ret: |