blob: 91f70015b178f457430ea778590aa4e6113583fc [file] [log] [blame]
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -07001/* libunwind - a platform-independent unwind library
2 Copyright (C) 2008 CodeSourcery
3
4This file is part of libunwind.
5
6Permission is hereby granted, free of charge, to any person obtaining
7a copy of this software and associated documentation files (the
8"Software"), to deal in the Software without restriction, including
9without limitation the rights to use, copy, modify, merge, publish,
10distribute, sublicense, and/or sell copies of the Software, and to
11permit persons to whom the Software is furnished to do so, subject to
12the following conditions:
13
14The above copyright notice and this permission notice shall be
15included in all copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
24
25#ifndef LIBUNWIND_H
26#define LIBUNWIND_H
27
28#if defined(__cplusplus) || defined(c_plusplus)
29extern "C" {
30#endif
31
32#include <inttypes.h>
33#include <ucontext.h>
34
35#ifdef mips
36# undef mips
37#endif
38
39#define UNW_TARGET mips
40#define UNW_TARGET_MIPS 1
41
42#define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
43
44/* This needs to be big enough to accommodate "struct cursor", while
45 leaving some slack for future expansion. Changing this value will
46 require recompiling all users of this library. Stack allocation is
47 relatively cheap and unwind-state copying is relatively rare, so we
48 want to err on making it rather too big than too small. */
49
50/* FIXME for MIPS. Too big? What do other things use for similar tasks? */
51#define UNW_TDEP_CURSOR_LEN 4096
52
53/* The size of a "word" varies on MIPS. This type is used for memory
54 addresses and register values. To allow a single library to support
55 multiple ABIs, and to support N32 at all, we must use a 64-bit type
56 even when addresses are only 32 bits. */
57typedef uint64_t unw_word_t;
58typedef int32_t unw_sword_t;
59
60/* FIXME: MIPS ABIs. */
61typedef long double unw_tdep_fpreg_t;
62
63typedef enum
64 {
65 UNW_MIPS_R0,
66 UNW_MIPS_R1,
67 UNW_MIPS_R2,
68 UNW_MIPS_R3,
69 UNW_MIPS_R4,
70 UNW_MIPS_R5,
71 UNW_MIPS_R6,
72 UNW_MIPS_R7,
73 UNW_MIPS_R8,
74 UNW_MIPS_R9,
75 UNW_MIPS_R10,
76 UNW_MIPS_R11,
77 UNW_MIPS_R12,
78 UNW_MIPS_R13,
79 UNW_MIPS_R14,
80 UNW_MIPS_R15,
81 UNW_MIPS_R16,
82 UNW_MIPS_R17,
83 UNW_MIPS_R18,
84 UNW_MIPS_R19,
85 UNW_MIPS_R20,
86 UNW_MIPS_R21,
87 UNW_MIPS_R22,
88 UNW_MIPS_R23,
89 UNW_MIPS_R24,
90 UNW_MIPS_R25,
91 UNW_MIPS_R26,
92 UNW_MIPS_R27,
93 UNW_MIPS_R28,
94 UNW_MIPS_R29,
95 UNW_MIPS_R30,
96 UNW_MIPS_R31,
97
98 /* FIXME: Other registers! */
99
100 /* For MIPS, the CFA is the value of SP (r29) at the call site in the
101 previous frame. */
102 UNW_MIPS_CFA,
103
104 UNW_TDEP_LAST_REG = UNW_MIPS_R31,
105
106 UNW_TDEP_IP = UNW_MIPS_R31,
107 UNW_TDEP_SP = UNW_MIPS_R29,
108 UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */
109 }
110mips_regnum_t;
111
112typedef enum
113 {
114 UNW_MIPS_ABI_O32,
115 UNW_MIPS_ABI_N32,
116 UNW_MIPS_ABI_N64
117 }
118mips_abi_t;
119
120#define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */
121
122typedef struct unw_tdep_save_loc
123 {
124 /* Additional target-dependent info on a save location. */
125 }
126unw_tdep_save_loc_t;
127
128/* On x86, we can directly use ucontext_t as the unwind context. FIXME for
129 MIPS. */
130typedef ucontext_t unw_tdep_context_t;
131
132#include "libunwind-dynamic.h"
133
134typedef struct
135 {
136 /* no mips-specific auxiliary proc-info */
137 }
138unw_tdep_proc_info_t;
139
140#include "libunwind-common.h"
141
142/* There is no getcontext() on MIPS. Use a stub version which only saves GP
143 registers. FIXME: Not ideal, may not be sufficient for all libunwind
144 use cases. */
145#define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
146extern int unw_tdep_getcontext (ucontext_t *uc);
147
148#define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
149extern int unw_tdep_is_fpreg (int);
150
Daniel Jacobowitz3842dac2008-02-04 17:16:37 -0700151#if defined(__cplusplus) || defined(c_plusplus)
152}
153#endif
154
155#endif /* LIBUNWIND_H */