1/* 2 * Copyright (c) 2007, 2008, 2009, ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef __thumb2__ 11//normal arm instructions 12 .arm 13 .text 14 .globl syscall 15 16syscall: 17 // Save pointer to return structure (r0), callee-save 18 // registers (r4-r10,r12) that are cloberred. 19 clrex 20 mov r12, sp 21 push {r0, r4-r10, r11, r12, lr, pc} 22 ldmia r12, {r4-r10, r12} 23 ldr r0, [sp, #80] 24 ldr lr, =swi_done 25 swi #0 26swi_done: 27 // This is where we end up executing after the system call? 28 // This accesses the stack, which was restored in do_resume 29 pop {r3,r4-r10} // pop 7 registers 30 // r0,r1 contain return values, r3 points to return structure 31 str r0, [r3, #0] 32 str r1, [r3, #4] 33 pop {r11} 34 35 pop {r3} // Using r3 to tempararily hold the value of sp register 36 // Warning: Assuming that clobbering r3 is OK!! 37 pop {lr} // Return address where we have to return 38 mov sp, r3 // Restoring sp from r3 now. 39 mov pc, lr // return by loading pc 40 nop 41 nop 42 nop 43 nop 44 45 46#else //use only the thumb2 instruction set 47 .syntax unified 48 .text 49 .globl syscall 50syscall: 51 // Save pointer to return structure (r0), callee-save 52 // registers (r4-r10,r12) that are cloberred. 53 mov r12, sp 54 //pc can not be in the list, but it is also not restored -> ignore 55 push {r0, r4-r10, r11, r12, lr} 56 ldr r0, [sp, #76] 57 ldmia r12, {r4-r10, r12} 58 ldr lr, =swi_done 59 svc #0 60swi_done: 61 // This is where we end up executing after the system call? 62 // This accesses the stack, which was restored in do_resume 63 pop {r3,r4-r10} // pop 7 registers 64 // r0,r1 contain return values, r3 points to return structure 65 str r0, [r3, #0] 66 str r1, [r3, #4] 67 pop {r11} 68 69 pop {r3} // Using r3 to temporarily hold the value of sp register 70 // Warning: Assuming that clobbering r3 is OK! 71 pop {lr} // Return address where we have to return 72 mov sp, r3 // Restoring sp from r3 now. 73 bx lr // return by loading pc 74#endif 75