Line 5... |
Line 5... |
#define CONCAT2(a, b) a ## b
|
#define CONCAT2(a, b) a ## b
|
|
|
#ifdef __USER_LABEL_PREFIX__
|
#ifdef __USER_LABEL_PREFIX__
|
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
|
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
|
#else
|
#else
|
#define FUNCTION( name ) CONCAT ( _ , name)
|
#error __USER_LABEL_PREFIX is not defined
|
#endif
|
#endif
|
|
|
/* .text is used instead of .section .text so it works with arm-aout too. */
|
/* .text is used instead of .section .text so it works with arm-aout too. */
|
.text
|
.text
|
.code 32
|
.code 32
|
Line 25... |
Line 25... |
/* Start by setting up a stack */
|
/* Start by setting up a stack */
|
#ifdef ARM_RDP_MONITOR
|
#ifdef ARM_RDP_MONITOR
|
/* Issue Demon SWI to read stack info */
|
/* Issue Demon SWI to read stack info */
|
swi SWI_GetEnv /* Returns command line in r0 */
|
swi SWI_GetEnv /* Returns command line in r0 */
|
mov sp,r1 /* and the highest memory address in r1 */
|
mov sp,r1 /* and the highest memory address in r1 */
|
ldr sl, LC2 /* stack limit is at end of data */
|
ldr sl, .LC2 /* stack limit is at end of data */
|
add sl, sl, #256 /* allow slop for stack overflow handling */
|
add sl, sl, #256 /* allow slop for stack overflow handling */
|
/* and small frames */
|
/* and small frames */
|
#else
|
#else
|
#ifdef ARM_RDI_MONITOR
|
#ifdef ARM_RDI_MONITOR
|
/* Issue Angel SWI to read stack info */
|
/* Issue Angel SWI to read stack info */
|
mov r0, #AngelSWI_Reason_HeapInfo
|
mov r0, #AngelSWI_Reason_HeapInfo
|
adr r1, LC0 /* point at ptr to 4 words to receive data */
|
adr r1, .LC0 /* point at ptr to 4 words to receive data */
|
swi AngelSWI_ARM /* We are always in ARM mode for startup */
|
swi AngelSWI_ARM /* We are always in ARM mode for startup */
|
ldr r0, LC0 /* point at values read */
|
ldr r0, .LC0 /* point at values read */
|
ldr sp, [r0, #8]
|
ldr sp, [r0, #8]
|
ldr sl, [r0, #12]
|
ldr sl, [r0, #12]
|
add sl, sl, #256 /* allow slop for stack overflow handling */
|
add sl, sl, #256 /* allow slop for stack overflow handling */
|
/* and small frames */
|
/* and small frames */
|
#else
|
#else
|
/* Set up the stack pointer to a fixed value */
|
/* Set up the stack pointer to a fixed value */
|
ldr r3, LC0
|
ldr r3, .LC0
|
mov sp, r3
|
mov sp, r3
|
/* Setup a default stack-limit in-case the code has been
|
/* Setup a default stack-limit in-case the code has been
|
compiled with "-mapcs-stack-check". Hard-wiring this value
|
compiled with "-mapcs-stack-check". Hard-wiring this value
|
is not ideal, since there is currently no support for
|
is not ideal, since there is currently no support for
|
checking that the heap and stack have not collided, or that
|
checking that the heap and stack have not collided, or that
|
Line 57... |
Line 57... |
#endif
|
#endif
|
mov a2, #0 /* Second arg: fill value */
|
mov a2, #0 /* Second arg: fill value */
|
mov fp, a2 /* Null frame pointer */
|
mov fp, a2 /* Null frame pointer */
|
mov r7, a2 /* Null frame pointer for Thumb */
|
mov r7, a2 /* Null frame pointer for Thumb */
|
|
|
ldr a1, LC1 /* First arg: start of memory block */
|
ldr a1, .LC1 /* First arg: start of memory block */
|
ldr a3, LC2
|
ldr a3, .LC2
|
sub a3, a3, a1 /* Third arg: length of block */
|
sub a3, a3, a1 /* Third arg: length of block */
|
|
|
|
|
#ifdef __thumb__ /* Enter Thumb mode.... */
|
#ifdef __thumb__ /* Enter Thumb mode.... */
|
|
|
add a4, pc, #1 /* Get the address of the Thumb block */
|
add a4, pc, #1 /* Get the address of the Thumb block */
|
bx a4 /* Go there and start Thumb decoding */
|
bx a4 /* Go there and start Thumb decoding */
|
|
|
.code 16
|
.code 16
|
.global change_mode
|
.global __change_mode
|
change_mode:
|
.thumb_func
|
|
__change_mode:
|
#endif
|
#endif
|
|
|
bl FUNCTION (memset)
|
bl FUNCTION (memset)
|
#if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR)
|
#if !defined (ARM_RDP_MONITOR) && !defined (ARM_RDI_MONITOR)
|
mov r0, #0 /* no arguments */
|
mov r0, #0 /* no arguments */
|
Line 85... |
Line 86... |
#ifdef ARM_RDP_MONITOR
|
#ifdef ARM_RDP_MONITOR
|
swi SWI_GetEnv /* sets r0 to point to the command line */
|
swi SWI_GetEnv /* sets r0 to point to the command line */
|
mov r1, r0
|
mov r1, r0
|
#else
|
#else
|
mov r0, #AngelSWI_Reason_GetCmdLine
|
mov r0, #AngelSWI_Reason_GetCmdLine
|
adr r1, LC30 /* Space for command line */
|
adr r1, .LC30 /* Space for command line */
|
swi AngelSWI
|
swi AngelSWI
|
ldr r1, LC30
|
ldr r1, .LC30
|
#endif
|
#endif
|
/* Parse string at r1 */
|
/* Parse string at r1 */
|
mov r0, #0 /* count of arguments so far */
|
mov r0, #0 /* count of arguments so far */
|
LC10:
|
.LC10:
|
/* Skip leading blanks */
|
/* Skip leading blanks */
|
#ifdef __thumb__
|
#ifdef __thumb__
|
ldrb r3, [r1]
|
ldrb r3, [r1]
|
add r1, #1
|
add r1, #1
|
#else
|
#else
|
ldrb r3, [r1], #1
|
ldrb r3, [r1], #1
|
#endif
|
#endif
|
cmp r3, #0
|
cmp r3, #0
|
beq LC12
|
beq .LC12
|
cmp r3, #' '
|
cmp r3, #' '
|
beq LC10
|
beq .LC10
|
|
|
/* See whether we are scanning a string */
|
/* See whether we are scanning a string */
|
cmp r3, #'"'
|
cmp r3, #'"'
|
#ifdef __thumb__
|
#ifdef __thumb__
|
beq LC20
|
beq .LC20
|
cmp r3, #'\''
|
cmp r3, #'\''
|
bne LC21
|
bne .LC21
|
LC20:
|
.LC20:
|
mov r2, r3
|
mov r2, r3
|
b LC22
|
b .LC22
|
|
|
LC21:
|
.LC21:
|
mov r2, #' ' /* terminator type */
|
mov r2, #' ' /* terminator type */
|
sub r1, r1, #1 /* adjust back to point at start char */
|
sub r1, r1, #1 /* adjust back to point at start char */
|
LC22:
|
.LC22:
|
#else
|
#else
|
cmpne r3, #'\''
|
cmpne r3, #'\''
|
moveq r2, r3
|
moveq r2, r3
|
movne r2, #' ' /* terminator type */
|
movne r2, #' ' /* terminator type */
|
subne r1, r1, #1 /* adjust back to point at start char */
|
subne r1, r1, #1 /* adjust back to point at start char */
|
Line 132... |
Line 133... |
push {r1}
|
push {r1}
|
#else
|
#else
|
stmfd sp!, {r1}
|
stmfd sp!, {r1}
|
#endif
|
#endif
|
add r0, r0, #1
|
add r0, r0, #1
|
LC11:
|
.LC11:
|
#ifdef __thumb__
|
#ifdef __thumb__
|
ldrb r3, [r1]
|
ldrb r3, [r1]
|
add r1, #1
|
add r1, #1
|
#else
|
#else
|
ldrb r3, [r1], #1
|
ldrb r3, [r1], #1
|
#endif
|
#endif
|
cmp r3, #0
|
cmp r3, #0
|
beq LC12
|
beq .LC12
|
cmp r2, r3 /* reached terminator? */
|
cmp r2, r3 /* reached terminator? */
|
bne LC11
|
bne .LC11
|
mov r2, #0
|
mov r2, #0
|
sub r3, r1, #1
|
sub r3, r1, #1
|
strb r2, [r3] /* terminate the arg string */
|
strb r2, [r3] /* terminate the arg string */
|
b LC10
|
b .LC10
|
|
|
LC12:
|
.LC12:
|
mov r1, sp /* point at stacked arg pointers */
|
mov r1, sp /* point at stacked arg pointers */
|
/* We've now got the stacked args in order reverse the */
|
/* We've now got the stacked args in order reverse the */
|
#ifdef __thumb__
|
#ifdef __thumb__
|
mov r2, r0
|
mov r2, r0
|
lsl r2, #2
|
lsl r2, #2
|
add r2, sp
|
add r2, sp
|
mov r3, sp
|
mov r3, sp
|
LC15: cmp r2, r3
|
.LC15: cmp r2, r3
|
bls LC14
|
bls .LC14
|
sub r2, #4
|
sub r2, #4
|
ldr r4, [r2]
|
ldr r4, [r2]
|
ldr r5, [r3]
|
ldr r5, [r3]
|
str r5, [r2]
|
str r5, [r2]
|
str r4, [r3]
|
str r4, [r3]
|
add r3, #4
|
add r3, #4
|
b LC15
|
b .LC15
|
LC14:
|
.LC14:
|
#else
|
#else
|
add r2, sp, r0, LSL #2 /* End of args */
|
add r2, sp, r0, LSL #2 /* End of args */
|
mov r3, sp /* Start of args */
|
mov r3, sp /* Start of args */
|
LC13: cmp r2, r3
|
.LC13: cmp r2, r3
|
ldrhi r4,[r2, #-4] /* Reverse ends of list */
|
ldrhi r4,[r2, #-4] /* Reverse ends of list */
|
ldrhi r5, [r3]
|
ldrhi r5, [r3]
|
strhi r5, [r2, #-4]!
|
strhi r5, [r2, #-4]!
|
strhi r4, [r3], #4
|
strhi r4, [r3], #4
|
bhi LC13
|
bhi .LC13
|
#endif
|
#endif
|
|
|
#endif
|
#endif
|
bl FUNCTION (main)
|
bl FUNCTION (main)
|
|
|
Line 204... |
Line 205... |
|
|
/* For Thumb, constants must be after the code since only
|
/* For Thumb, constants must be after the code since only
|
positive offsets are supported for PC relative addresses. */
|
positive offsets are supported for PC relative addresses. */
|
|
|
.align 0
|
.align 0
|
LC0:
|
.LC0:
|
#ifdef ARM_RDI_MONITOR
|
#ifdef ARM_RDI_MONITOR
|
.word HeapBase
|
.word HeapBase
|
#else
|
#else
|
#ifndef ARM_RDP_MONITOR
|
#ifndef ARM_RDP_MONITOR
|
#ifdef __pe__
|
#ifdef __pe__
|
Line 216... |
Line 217... |
#else
|
#else
|
/* .word 0x80000 */ /* Top of RAM on the PIE board */
|
/* .word 0x80000 */ /* Top of RAM on the PIE board */
|
#endif
|
#endif
|
#endif
|
#endif
|
#endif
|
#endif
|
LC1:
|
.LC1:
|
.word __bss_start__
|
.word __bss_start__
|
LC2:
|
.LC2:
|
.word __bss_end__
|
.word __bss_end__
|
|
|
#ifdef ARM_RDI_MONITOR
|
#ifdef ARM_RDI_MONITOR
|
LC30: .word CommandLine
|
.LC30: .word CommandLine
|
|
|
/* Workspace for Angel calls. */
|
/* Workspace for Angel calls. */
|
.data
|
.data
|
/* Data returned by monitor SWI */
|
/* Data returned by monitor SWI */
|
HeapBase: .word 0
|
HeapBase: .word 0
|