syscall.S revision 851e68a2402fa414544e66650e09dfdaac813e51
1405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham/* 2645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman * Copyright (C) 2013 The Android Open Source Project 3405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * All rights reserved. 4405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * 5405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * Redistribution and use in source and binary forms, with or without 6405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * modification, are permitted provided that the following conditions 7405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * are met: 8405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * * Redistributions of source code must retain the above copyright 9405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * notice, this list of conditions and the following disclaimer. 10405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * * Redistributions in binary form must reproduce the above copyright 11405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * notice, this list of conditions and the following disclaimer in 12405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * the documentation and/or other materials provided with the 13405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * distribution. 14405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * 15405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 18405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 19405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 20405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 21405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 22405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 23405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 25405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham * SUCH DAMAGE. 27405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham */ 28405b8029a6888f386adf3512113a33546141d1c8Raghu Gandham 29851e68a2402fa414544e66650e09dfdaac813e51Elliott Hughes#include <private/bionic_asm.h> 30645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman 31645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) 32645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris DearmanFRAMESZ = MKFSIZ(6,0) 33645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#else 34645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris DearmanFRAMESZ = MKFSIZ(0,1) 35645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris DearmanFRAME_GP = FRAMESZ-1*REGSZ 36645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#endif 37645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman 38645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris DearmanLEAF(syscall,FRAMESZ) 39645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman PTR_SUBU sp, FRAMESZ # allocate stack frame 40645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman SETUP_GP64(FRAME_GP,syscall) 41645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman SAVE_GP(FRAME_GP) 42645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move v0, a0 # syscall number to v0 43645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a0, a1 # shift args down 44645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a1, a2 45645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a2, a3 46645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32) 47645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_L a3, FRAMESZ+4*REGSZ(sp) 48645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_L t0, FRAMESZ+5*REGSZ(sp) 49645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_L t1, FRAMESZ+6*REGSZ(sp) 50645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_S t0, 4*REGSZ(sp) 51645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_S t1, 5*REGSZ(sp) 52645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#else 53645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a3, a4 54645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a4, a5 55645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman REG_L a5, FRAMESZ(sp) 56645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman#endif 57645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman syscall 58645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman move a0, v0 59645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman bnez a3, 1f 60645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman RESTORE_GP64 61645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman PTR_ADDU sp, FRAMESZ 62645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman j ra 63645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman1: 64645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman LA t9,__set_errno 65645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman RESTORE_GP64 66645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman PTR_ADDU sp, FRAMESZ 67645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman j t9 68645d0312c2d6b6492cc4b3891bc1a91908dc24b7Chris Dearman END(syscall) 69