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 
     28 	.text
     29 
     30 #if _MIPS_SIM == _ABIO32
     31 # if defined(__MIPSEB__)
     32 #  define OFFSET 4
     33 # else
     34 #  define OFFSET 0
     35 # endif
     36 # define SREG(X) \
     37  sw $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X + OFFSET) ($4); \
     38  sra $1, $X, 31; \
     39  sw $1, (LINUX_UC_MCONTEXT_GREGS + 8 * X + 4 - OFFSET) ($4)
     40 /* Yes, we save the return address to PC. */
     41 # define SPC \
     42  sw $31, (LINUX_UC_MCONTEXT_PC + OFFSET) ($4); \
     43  sra $1, $31, 31; \
     44  sw $1, (LINUX_UC_MCONTEXT_PC + 4 - OFFSET) ($4)
     45 #else
     46 # define SREG(X) sd $X, (LINUX_UC_MCONTEXT_GREGS + 8 * X) ($4)
     47 # define SPC sd $31, (LINUX_UC_MCONTEXT_PC) ($4)
     48 #endif
     49 
     50 	.global _Umips_getcontext
     51 	.type	_Umips_getcontext, %function
     52 	# This is a stub version of getcontext() for MIPS which only stores core
     53 	# registers.
     54 _Umips_getcontext:
     55 	.set noat
     56 	SREG (0)
     57 	SREG (1)
     58 	SREG (2)
     59 	SREG (3)
     60 	SREG (4)
     61 	SREG (5)
     62 	SREG (6)
     63 	SREG (7)
     64 	SREG (8)
     65 	SREG (9)
     66 	SREG (10)
     67 	SREG (11)
     68 	SREG (12)
     69 	SREG (13)
     70 	SREG (14)
     71 	SREG (15)
     72 	SREG (16)
     73 	SREG (17)
     74 	SREG (18)
     75 	SREG (19)
     76 	SREG (20)
     77 	SREG (21)
     78 	SREG (22)
     79 	SREG (23)
     80 	SREG (24)
     81 	SREG (25)
     82 	SREG (26)
     83 	SREG (27)
     84 	SREG (28)
     85 	SREG (29)
     86 	SREG (30)
     87 	SREG (31)
     88 	SPC
     89 	li	$2, 0
     90 	j $31
     91 
     92 	.size	_Umips_getcontext, .-_Umips_getcontext
     93