Home | History | Annotate | Download | only in mips
      1 /* libunwind - a platform-independent unwind library
      2    Copyright (C) 2008 CodeSourcery
      3    Copyright (C) 2012 Tommi Rantala <tt.rantala (at) gmail.com>
      4 
      5 This file is part of libunwind.
      6 
      7 Permission is hereby granted, free of charge, to any person obtaining
      8 a copy of this software and associated documentation files (the
      9 "Software"), to deal in the Software without restriction, including
     10 without limitation the rights to use, copy, modify, merge, publish,
     11 distribute, sublicense, and/or sell copies of the Software, and to
     12 permit persons to whom the Software is furnished to do so, subject to
     13 the following conditions:
     14 
     15 The above copyright notice and this permission notice shall be
     16 included in all copies or substantial portions of the Software.
     17 
     18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
     19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
     20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
     21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
     22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
     23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
     24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
     25 
     26 #include "offsets.h"
     27 #include <endian.h>
     28 
     29 	.text
     30 
     31 #if _MIPS_SIM == _ABIO32
     32 # if __BYTE_ORDER == __BIG_ENDIAN
     33 #  define OFFSET 4
     34 # else
     35 #  define OFFSET 0
     36 # endif
     37 # define SREG(X) \
     38  sw $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X + OFFSET) ($4); \
     39  sra $1, $X, 31; \
     40  sw $1, (LINUX_UC_MCONTEXT_GREGS + 8 * X + 4 - OFFSET) ($4)
     41 /* Yes, we save the return address to PC. */
     42 # define SPC \
     43  sw $31, (LINUX_UC_MCONTEXT_PC + OFFSET) ($4); \
     44  sra $1, $31, 31; \
     45  sw $1, (LINUX_UC_MCONTEXT_PC + 4 - OFFSET) ($4)
     46 #else
     47 # define SREG(X) sd $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X) ($4)
     48 # define SPC sd $31, (LINUX_UC_MCONTEXT_PC) ($4)
     49 #endif
     50 
     51 	.global _Umips_getcontext
     52 	.type	_Umips_getcontext, %function
     53 	# This is a stub version of getcontext() for MIPS which only stores core
     54 	# registers.
     55 _Umips_getcontext:
     56 	.set noat
     57 	SREG (1)
     58 	SREG (0)
     59 	SREG (2)
     60 	SREG (3)
     61 	SREG (4)
     62 	SREG (5)
     63 	SREG (6)
     64 	SREG (7)
     65 	SREG (8)
     66 	SREG (9)
     67 	SREG (10)
     68 	SREG (11)
     69 	SREG (12)
     70 	SREG (13)
     71 	SREG (14)
     72 	SREG (15)
     73 	SREG (16)
     74 	SREG (17)
     75 	SREG (18)
     76 	SREG (19)
     77 	SREG (20)
     78 	SREG (21)
     79 	SREG (22)
     80 	SREG (23)
     81 	SREG (24)
     82 	SREG (25)
     83 	SREG (26)
     84 	SREG (27)
     85 	SREG (28)
     86 	SREG (29)
     87 	SREG (30)
     88 	SREG (31)
     89 	SPC
     90 	li	$2, 0
     91 	j $31
     92 
     93 	.size	_Umips_getcontext, .-_Umips_getcontext
     94