diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-06 20:54:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-06 20:54:59 +0000 |
commit | 5332fb0e659549272ed5527c26964b22d31da3bc (patch) | |
tree | 89a4da9899c3fa1f260bd637bf9ab623d86b4844 | |
parent | 7c2ea5a1a560284b6d22a60d62ac943ec6144096 (diff) | |
download | px4-nuttx-5332fb0e659549272ed5527c26964b22d31da3bc.tar.gz px4-nuttx-5332fb0e659549272ed5527c26964b22d31da3bc.tar.bz2 px4-nuttx-5332fb0e659549272ed5527c26964b22d31da3bc.zip |
Correct some assembly language errors in the last checkin
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5714 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/arch/arm/src/armv6-m/up_svcall.c | 26 | ||||
-rw-r--r-- | nuttx/arch/arm/src/armv7-m/up_svcall.c | 24 |
2 files changed, 33 insertions, 17 deletions
diff --git a/nuttx/arch/arm/src/armv6-m/up_svcall.c b/nuttx/arch/arm/src/armv6-m/up_svcall.c index e8aa977bd..aac16d489 100644 --- a/nuttx/arch/arm/src/armv6-m/up_svcall.c +++ b/nuttx/arch/arm/src/armv6-m/up_svcall.c @@ -92,6 +92,16 @@ * Description: * Call the stub function corresponding to the system call. * + * R0 - Need not be preserved until after the stub is called. + * R1-R3 - Need to be preserved until the stub is called. The values of + * R0 and R1 returned by the stub must be preserved. + * R4-R11 must be preserved to support the expectations of the user-space + * callee + * R12 - Need not be preserved + * R13 - (stack pointer) + * R14 - Need not be preserved + * R15 - (PC) + * ****************************************************************************/ #ifdef CONFIG_NUTTX_KERNEL @@ -100,15 +110,13 @@ static void dispatch_syscall(void) { __asm__ __volatile__ ( - " push {r4-r6}\n" /* Save R4, R5 and R6 */ - " mov r6, r14\n" /* Save LR in R6 */ - " ldr r4, =g_stublookup\n" /* Get the base of the stub lookup table */ - " lsl r3, r0, #2\n" /* Get the offset of the stub for this syscall */ - " ldr r3, [r4, r3]\n" /* Load the entry of the stub for this syscall */ - " blx r3\n" /* Call the stub */ - " mov r14, r6\n" /* Restore R14 */ - " pop {r4-r6}\n" /* Restore R4, R5, and R6 */ - " mov r2, r0\n" /* Save the return value in R0 in R2 for now */ + " push {r4}\n" /* Save R4 */ + " ldr r4, =g_stublookup\n" /* R4=The base of the stub lookup table */ + " lsl r0, r0, #2\n" /* R0=Offset of the stub for this syscall */ + " ldr r4, [r4, r0]\n" /* R4=Address of the stub for this syscall */ + " blx r5\n" /* Call the stub (modifies R14) */ + " pop {r4}\n" /* Restore R4 */ + " mov r2, r0\n" /* R2=Saves return value in R0 */ " mov r0, #3\n" /* R0=SYS_syscall_return */ " svc 0" /* Return from the syscall */ ::: diff --git a/nuttx/arch/arm/src/armv7-m/up_svcall.c b/nuttx/arch/arm/src/armv7-m/up_svcall.c index 48ab00eba..078f85606 100644 --- a/nuttx/arch/arm/src/armv7-m/up_svcall.c +++ b/nuttx/arch/arm/src/armv7-m/up_svcall.c @@ -92,6 +92,18 @@ * Description: * Call the stub function corresponding to the system call. * + * Here we need to preserve registers: + * + * R0 - Need not be preserved until after the stub is called. + * R1-R3 - Need to be preserved until the stub is called. The values of + * R0 and R1 returned by the stub must be preserved. + * R4-R11 must be preserved to support the expectations of the user-space + * callee + * R12 - Need not be preserved + * R13 - (stack pointer) + * R14 - Need not be preserved + * R15 - (PC) + * ****************************************************************************/ #ifdef CONFIG_NUTTX_KERNEL @@ -100,14 +112,10 @@ static void dispatch_syscall(void) { __asm__ __volatile__ ( - " push {r4, r5}\n" /* Save R4 and R5 */ - " mov r5, r14\n" /* Save LR in R5 */ - " ldr r4, =g_stublookup\n" /* Get the base of the stub lookup table */ - " ldr r4, [r4, r0, lsl #2]\n" /* Load the entry of the stub for this syscall */ - " blx r4\n" /* Call the stub */ - " mov r14, r5\n" /* Restore R14 */ - " pop {r4, r5}\n" /* Restore R4 and R5 */ - " mov r2, r0\n" /* Save the return value in R0 in R2 for now */ + " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */ + " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */ + " blx ip\n" /* Call the stub (modifies R14)*/ + " mov r2, r0\n" /* R2=Saved return value in R0 */ " mov r0, #3\n" /* R0=SYS_syscall_return */ " svc 0" /* Return from the syscall */ ::: |