OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgcc/] [config/] [xtensa/] [linux-unwind.h] - Blame information for rev 734

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 734 jeremybenn
/* DWARF2 EH unwinding support for Xtensa.
2
   Copyright (C) 2008, 2009 Free Software Foundation, Inc.
3
 
4
This file is part of GCC.
5
 
6
GCC is free software; you can redistribute it and/or modify
7
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 3, or (at your option)
9
any later version.
10
 
11
GCC is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
GNU General Public License for more details.
15
 
16
Under Section 7 of GPL version 3, you are granted additional
17
permissions described in the GCC Runtime Library Exception, version
18
3.1, as published by the Free Software Foundation.
19
 
20
You should have received a copy of the GNU General Public License and
21
a copy of the GCC Runtime Library Exception along with this program;
22
see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23
<http://www.gnu.org/licenses/>.  */
24
 
25
/* Do code reading to identify a signal frame, and set the frame
26
   state data appropriately.  See unwind-dw2-xtensa.c for the structs.
27
   Don't use this at all if inhibit_libc is used.  */
28
 
29
#ifndef inhibit_libc
30
 
31
#include <signal.h>
32
#include <sys/ucontext.h>
33
 
34
/* Encoded bytes for Xtensa instructions:
35
        movi a2, __NR_rt_sigreturn
36
        syscall
37
        entry (first byte only)
38
   Some of the bytes are endian-dependent.  */
39
 
40
#define MOVI_BYTE0 0x22
41
#define MOVI_BYTE2 225 /* __NR_rt_sigreturn */
42
#define SYSC_BYTE0 0
43
#define SYSC_BYTE2 0
44
 
45
#ifdef __XTENSA_EB__
46
#define MOVI_BYTE1 0x0a
47
#define SYSC_BYTE1 0x05
48
#define ENTRY_BYTE 0x6c
49
#else
50
#define MOVI_BYTE1 0xa0
51
#define SYSC_BYTE1 0x50
52
#define ENTRY_BYTE 0x36
53
#endif
54
 
55
#define MD_FALLBACK_FRAME_STATE_FOR xtensa_fallback_frame_state
56
 
57
static _Unwind_Reason_Code
58
xtensa_fallback_frame_state (struct _Unwind_Context *context,
59
                             _Unwind_FrameState *fs)
60
{
61
  unsigned char *pc = context->ra;
62
  struct sigcontext *sc;
63
 
64
  struct rt_sigframe {
65
    struct siginfo info;
66
    struct ucontext uc;
67
  } *rt_;
68
 
69
  /* movi a2, __NR_rt_sigreturn; syscall */
70
  if (pc[0] != MOVI_BYTE0
71
      || pc[1] != MOVI_BYTE1
72
      || pc[2] != MOVI_BYTE2
73
      || pc[3] != SYSC_BYTE0
74
      || pc[4] != SYSC_BYTE1
75
      || pc[5] != SYSC_BYTE2)
76
    return _URC_END_OF_STACK;
77
 
78
  rt_ = context->sp;
79
  sc = &rt_->uc.uc_mcontext;
80
  fs->signal_regs = (_Unwind_Word *) sc->sc_a;
81
 
82
  /* If the signal arrived just before an ENTRY instruction, find the return
83
     address and pretend the signal arrived before executing the CALL.  */
84
  if (*(unsigned char *) sc->sc_pc == ENTRY_BYTE)
85
   {
86
     unsigned callinc = (sc->sc_ps >> 16) & 3;
87
     fs->signal_ra = ((sc->sc_a[callinc << 2] & XTENSA_RA_FIELD_MASK)
88
                      | context->ra_high_bits) - 3;
89
   }
90
  else
91
    fs->signal_ra = sc->sc_pc;
92
 
93
  fs->signal_frame = 1;
94
  return _URC_NO_REASON;
95
}
96
 
97
#endif /* ifdef inhibit_libc  */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.