1/* 2 * Copyright (c) 2015, Linaro Limited 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright notice, 10 * this list of conditions and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29#include <tee_syscall_numbers.h> 30#include <asm.S> 31 32#if defined(CFG_UNWIND) 33#define UNWIND(...) __VA_ARGS__ 34#else 35#define UNWIND(...) 36#endif 37 38 .section .text 39 .balign 4 40 .code 32 41 42 .macro UTEE_SYSCALL name, scn, num_args 43 FUNC \name , : 44 45UNWIND( .fnstart) 46 push {r5-r7,lr} 47UNWIND( .save {r5-r7,lr}) 48 mov r7, #(\scn) 49 .if \num_args > TEE_SVC_MAX_ARGS 50 .error "Too many arguments for syscall" 51 .endif 52 .if \num_args <= 4 53 @ No arguments passed on stack 54 mov r6, #0 55 .else 56 @ Tell number of arguments passed on the stack 57 mov r6, #(\num_args - 4) 58 @ Point just before the push (4 registers) above on the first argument 59 add r5, sp, #(4 * 4) 60 .endif 61 svc #0 62 pop {r5-r7,pc} 63UNWIND( .fnend) 64 END_FUNC \name 65 .endm 66 67 FUNC utee_panic, : 68UNWIND( .fnstart) 69 push {r0-r11, lr} 70UNWIND( .save {r0-r11, lr}) 71 mov lr, pc 72 push {lr} 73UNWIND( .save {lr}) 74 mov r1, sp 75 bl __utee_panic 76 /* Not reached */ 77UNWIND( .fnend) 78 END_FUNC utee_panic 79 80#include "utee_syscalls_asm.S" 81