1e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu/*
2e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * Copyright (C) 2013 The Android Open Source Project
354a7494f17f80d6c548a58434bcb5579a26cc125Elliott Hughes * All rights reserved.
4e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *
5e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * Redistribution and use in source and binary forms, with or without
6e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * modification, are permitted provided that the following conditions
7e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * are met:
8e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *  * Redistributions of source code must retain the above copyright
9e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *    notice, this list of conditions and the following disclaimer.
10e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *  * Redistributions in binary form must reproduce the above copyright
11e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *    notice, this list of conditions and the following disclaimer in
12e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *    the documentation and/or other materials provided with the
13e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *    distribution.
14e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu *
15e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu * SUCH DAMAGE.
27e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu */
28e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu
29da9775509b74f1c54d9bdce3323702836315ef2bElliott Hughes#include <private/bionic_asm.h>
30e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu
31e210488e0d4082b9a0c55195c22191f29ed56bf8Serban ConstantinescuENTRY(syscall)
32e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    /* Move syscall No. from x0 to x8 */
33e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x8, x0
34e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    /* Move syscall parameters from x1 thru x6 to x0 thru x5 */
35e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x0, x1
36e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x1, x2
37e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x2, x3
38e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x3, x4
39e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x4, x5
40e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    mov     x5, x6
41e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    svc     #0
42e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu
43e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    /* check if syscall returned successfully */
44e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    cmn     x0, #(MAX_ERRNO + 1)
45e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    cneg    x0, x0, hi
467efad83d430f4d824f2aaa75edea5106f6ff8aaeElliott Hughes    b.hi    __set_errno_internal
47e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu
48e210488e0d4082b9a0c55195c22191f29ed56bf8Serban Constantinescu    ret
49e210488e0d4082b9a0c55195c22191f29ed56bf8Serban ConstantinescuEND(syscall)
50