.extern patch_channel
.extern dbg_device
/*
-
- r0 - physical address of syspage
- r1 - virtual address of syspage
- r2 - offset from start of syspage to start of the callout routine
- r3 - offset from start of syspage to read/write data used by callout
-
/
patch_debug:
stmdb sp!,{r4,lr}
add r4, r0, r2 / address of callout routine */
ldr r0, Lpatch_channel
ldr r1, Ldbg_device
ldr r0, [r0]
add r1, r1, r0, lsl #3
ldr r1, [r1, #DDI_BASE]
mov r0, #SAM9261S_DBGU_SIZE
bl callout_io_map
/* Patch the callout routine */
CALLOUT_PATCH r4, r0, r1, r2, ip
ldmia sp!,{r4,pc}
Lpatch_channel: .word patch_channel
Ldbg_device: .word dbg_device
CALLOUT_START(display_char_sam9261s, 0, patch_debug)
mov ip, #0x000000ff
orr ip, ip, #0x0000ff00
orr ip, ip, #0x00ff0000
orr ip, ip, #0xff000000
0: ldr r3, [ip, #SAM9261S_DBGU_SR]
tst r3, #0x02 /* TX Ready */
beq 0b
str r1, [ip, #SAM9261S_DBGU_THR]
mov pc, lr
CALLOUT_END(display_char_sam9261s)
CALLOUT_START(poll_key_sam9261s, 0, patch_debug)
mov ip, #0x000000ff
orr ip, ip, #0x0000ff00
orr ip, ip, #0x00ff0000
orr ip, ip, #0xff000000
1: ldr r3, [ip, #SAM9261S_DBGU_SR]
tst r3, #0x01 /* RX Ready */
ldrne r0, [ip, #SAM9261S_DBGU_RHR]
mvneq r0, #1
mov pc, lr
CALLOUT_END(poll_key_sam9261s)
CALLOUT_START(break_detect_sam9261s, 0, patch_debug)
mov ip, #0x000000ff
orr ip, ip, #0x0000ff00
orr ip, ip, #0x00ff0000
orr ip, ip, #0xff000000
mov r0, #0
mov pc, lr
CALLOUT_END(break_detect_sam9261s)
全部的代码就是这些了。