decode.h revision 1.1.4.2 1 1.1.4.2 elad /* $NetBSD: decode.h,v 1.1.4.2 2006/04/19 02:33:08 elad Exp $ */
2 1.1.4.2 elad
3 1.1.4.2 elad /* Contributed to the NetBSD Foundation by Cherry G. Mathew <cherry (at) mahiti.org>
4 1.1.4.2 elad * This file contains prototypes to decode unwind descriptors.
5 1.1.4.2 elad */
6 1.1.4.2 elad
7 1.1.4.2 elad #define MAXSTATERECS 20 /* The maximum number of descriptor records per region */
8 1.1.4.2 elad
9 1.1.4.2 elad #define IS_R1(byte) (( (byte) & 0xc0) == 0)
10 1.1.4.2 elad #define IS_R2(byte) (((byte) & 0xf8) == 0x40)
11 1.1.4.2 elad #define IS_R3(byte) (((byte) & 0xfc) == 0x60)
12 1.1.4.2 elad #define IS_P1(byte) (((byte) & 0xe0) == 0x80)
13 1.1.4.2 elad #define IS_P2(byte) (((byte) & 0xf0) == 0xa0)
14 1.1.4.2 elad #define IS_P3(byte) (((byte) & 0xf8) == 0xb0)
15 1.1.4.2 elad #define IS_P4(byte) ((byte) == (char) 0xb8)
16 1.1.4.2 elad #define IS_P5(byte) ((byte) == (char) 0xb9)
17 1.1.4.2 elad #define IS_P6(byte) (((byte) & 0xe0) == 0xc0)
18 1.1.4.2 elad #define IS_P7(byte) (((byte) & 0xf0) == 0xe0)
19 1.1.4.2 elad #define IS_P8(byte) ((byte) == (char) 0xf0)
20 1.1.4.2 elad #define IS_P9(byte) ((byte) == (char) 0xf1)
21 1.1.4.2 elad #define IS_P10(byte) ((byte) ==(char) 0xff)
22 1.1.4.2 elad #define IS_B1(byte) (((byte) & 0xc0) == 0x80)
23 1.1.4.2 elad #define IS_B2(byte) (((byte) & 0xe0) == 0xc0)
24 1.1.4.2 elad #define IS_B3(byte) ((byte) == (char) 0xe0)
25 1.1.4.2 elad #define IS_B4(byte) (((byte) & 0xf7) == 0xf0)
26 1.1.4.2 elad #define IS_X1(byte) ((byte) == (char) 0xf9)
27 1.1.4.2 elad #define IS_X2(byte) ((byte) == (char) 0xfa)
28 1.1.4.2 elad #define IS_X3(byte) ((byte) == (char) 0xfb)
29 1.1.4.2 elad #define IS_X4(byte) ((byte) == (char) 0xfc)
30 1.1.4.2 elad
31 1.1.4.2 elad struct unwind_desc_R1 {
32 1.1.4.2 elad boolean_t r;
33 1.1.4.2 elad vsize_t rlen;
34 1.1.4.2 elad };
35 1.1.4.2 elad
36 1.1.4.2 elad struct unwind_desc_R2 {
37 1.1.4.2 elad u_int mask;
38 1.1.4.2 elad #define R2MASKRP 0x8
39 1.1.4.2 elad #define R2MASKPFS 0x4
40 1.1.4.2 elad #define R2MASKPSP 0x2
41 1.1.4.2 elad
42 1.1.4.2 elad u_int grsave;
43 1.1.4.2 elad vsize_t rlen;
44 1.1.4.2 elad };
45 1.1.4.2 elad
46 1.1.4.2 elad struct unwind_desc_R3 {
47 1.1.4.2 elad boolean_t r;
48 1.1.4.2 elad vsize_t rlen;
49 1.1.4.2 elad };
50 1.1.4.2 elad
51 1.1.4.2 elad struct unwind_desc_P1 {
52 1.1.4.2 elad u_int brmask;
53 1.1.4.2 elad };
54 1.1.4.2 elad
55 1.1.4.2 elad struct unwind_desc_P2 {
56 1.1.4.2 elad u_int brmask;
57 1.1.4.2 elad u_int gr;
58 1.1.4.2 elad };
59 1.1.4.2 elad
60 1.1.4.2 elad struct unwind_desc_P3 {
61 1.1.4.2 elad u_int r;
62 1.1.4.2 elad u_int grbr;
63 1.1.4.2 elad };
64 1.1.4.2 elad
65 1.1.4.2 elad struct unwind_desc_P4 {
66 1.1.4.2 elad vsize_t imask;
67 1.1.4.2 elad };
68 1.1.4.2 elad
69 1.1.4.2 elad struct unwind_desc_P5 {
70 1.1.4.2 elad u_int grmask;
71 1.1.4.2 elad u_int frmask;
72 1.1.4.2 elad };
73 1.1.4.2 elad
74 1.1.4.2 elad struct unwind_desc_P6 {
75 1.1.4.2 elad boolean_t r;
76 1.1.4.2 elad u_int rmask;
77 1.1.4.2 elad };
78 1.1.4.2 elad
79 1.1.4.2 elad struct unwind_desc_P7 {
80 1.1.4.2 elad u_int r;
81 1.1.4.2 elad vsize_t t;
82 1.1.4.2 elad vsize_t size;
83 1.1.4.2 elad };
84 1.1.4.2 elad
85 1.1.4.2 elad struct unwind_desc_P8 {
86 1.1.4.2 elad u_int r;
87 1.1.4.2 elad vsize_t t;
88 1.1.4.2 elad };
89 1.1.4.2 elad
90 1.1.4.2 elad struct unwind_desc_P9 {
91 1.1.4.2 elad u_int grmask;
92 1.1.4.2 elad u_int gr;
93 1.1.4.2 elad };
94 1.1.4.2 elad
95 1.1.4.2 elad struct unwind_desc_P10 {
96 1.1.4.2 elad u_int abi;
97 1.1.4.2 elad u_int context;
98 1.1.4.2 elad };
99 1.1.4.2 elad
100 1.1.4.2 elad struct unwind_desc_B1 {
101 1.1.4.2 elad boolean_t r;
102 1.1.4.2 elad u_int label;
103 1.1.4.2 elad };
104 1.1.4.2 elad
105 1.1.4.2 elad struct unwind_desc_B2 {
106 1.1.4.2 elad u_int ecount;
107 1.1.4.2 elad vsize_t t;
108 1.1.4.2 elad };
109 1.1.4.2 elad
110 1.1.4.2 elad struct unwind_desc_B3 {
111 1.1.4.2 elad vsize_t t;
112 1.1.4.2 elad vsize_t ecount;
113 1.1.4.2 elad };
114 1.1.4.2 elad
115 1.1.4.2 elad struct unwind_desc_B4 {
116 1.1.4.2 elad boolean_t r;
117 1.1.4.2 elad vsize_t label;
118 1.1.4.2 elad };
119 1.1.4.2 elad
120 1.1.4.2 elad struct unwind_desc_X1 {
121 1.1.4.2 elad boolean_t r;
122 1.1.4.2 elad boolean_t a;
123 1.1.4.2 elad boolean_t b;
124 1.1.4.2 elad u_int reg;
125 1.1.4.2 elad vsize_t t;
126 1.1.4.2 elad vsize_t offset;
127 1.1.4.2 elad };
128 1.1.4.2 elad
129 1.1.4.2 elad struct unwind_desc_X2 {
130 1.1.4.2 elad boolean_t x;
131 1.1.4.2 elad boolean_t a;
132 1.1.4.2 elad boolean_t b;
133 1.1.4.2 elad u_int reg;
134 1.1.4.2 elad boolean_t y;
135 1.1.4.2 elad u_int treg;
136 1.1.4.2 elad vsize_t t;
137 1.1.4.2 elad };
138 1.1.4.2 elad
139 1.1.4.2 elad
140 1.1.4.2 elad
141 1.1.4.2 elad struct unwind_desc_X3 {
142 1.1.4.2 elad boolean_t r;
143 1.1.4.2 elad u_int qp;
144 1.1.4.2 elad boolean_t a;
145 1.1.4.2 elad boolean_t b;
146 1.1.4.2 elad u_int reg;
147 1.1.4.2 elad vsize_t t;
148 1.1.4.2 elad vsize_t offset;
149 1.1.4.2 elad };
150 1.1.4.2 elad
151 1.1.4.2 elad struct unwind_desc_X4 {
152 1.1.4.2 elad u_int qp;
153 1.1.4.2 elad boolean_t x;
154 1.1.4.2 elad boolean_t a;
155 1.1.4.2 elad boolean_t b;
156 1.1.4.2 elad u_int reg;
157 1.1.4.2 elad boolean_t y;
158 1.1.4.2 elad u_int treg;
159 1.1.4.2 elad vsize_t t;
160 1.1.4.2 elad };
161 1.1.4.2 elad
162 1.1.4.2 elad union unwind_desc {
163 1.1.4.2 elad struct unwind_desc_R1 R1;
164 1.1.4.2 elad struct unwind_desc_R2 R2;
165 1.1.4.2 elad struct unwind_desc_R3 R3;
166 1.1.4.2 elad
167 1.1.4.2 elad struct unwind_desc_P1 P1;
168 1.1.4.2 elad struct unwind_desc_P2 P2;
169 1.1.4.2 elad struct unwind_desc_P3 P3;
170 1.1.4.2 elad struct unwind_desc_P4 P4;
171 1.1.4.2 elad struct unwind_desc_P5 P5;
172 1.1.4.2 elad struct unwind_desc_P6 P6;
173 1.1.4.2 elad struct unwind_desc_P7 P7;
174 1.1.4.2 elad struct unwind_desc_P8 P8;
175 1.1.4.2 elad struct unwind_desc_P9 P9;
176 1.1.4.2 elad struct unwind_desc_P10 P10;
177 1.1.4.2 elad
178 1.1.4.2 elad struct unwind_desc_B1 B1;
179 1.1.4.2 elad struct unwind_desc_B2 B2;
180 1.1.4.2 elad struct unwind_desc_B3 B3;
181 1.1.4.2 elad struct unwind_desc_B4 B4;
182 1.1.4.2 elad
183 1.1.4.2 elad struct unwind_desc_X1 X1;
184 1.1.4.2 elad struct unwind_desc_X2 X2;
185 1.1.4.2 elad struct unwind_desc_X3 X3;
186 1.1.4.2 elad struct unwind_desc_X4 X4;
187 1.1.4.2 elad };
188 1.1.4.2 elad
189 1.1.4.2 elad enum record_type {
190 1.1.4.2 elad R1, R2, R3,
191 1.1.4.2 elad P1, P2, P3, P4, P5, P6, P7, P8, P9, P10,
192 1.1.4.2 elad B1, B2, B3, B4,
193 1.1.4.2 elad X1, X2, X3, X4
194 1.1.4.2 elad };
195 1.1.4.2 elad
196 1.1.4.2 elad
197 1.1.4.2 elad /* A record chain is a decoded unwind descriptor.
198 1.1.4.2 elad * It is usefull for post processing unwind descriptors.
199 1.1.4.2 elad */
200 1.1.4.2 elad
201 1.1.4.2 elad struct recordchain {
202 1.1.4.2 elad enum record_type type;
203 1.1.4.2 elad union unwind_desc udesc;
204 1.1.4.2 elad };
205 1.1.4.2 elad
206 1.1.4.2 elad
207 1.1.4.2 elad
208 1.1.4.2 elad /* Decode Function prototypes. */
209 1.1.4.2 elad
210 1.1.4.2 elad char *
211 1.1.4.2 elad unwind_decode_ule128(char *buf, unsigned long *);
212 1.1.4.2 elad char *
213 1.1.4.2 elad unwind_decode_R1(char *buf, union unwind_desc *uwd);
214 1.1.4.2 elad char *
215 1.1.4.2 elad unwind_decode_R2(char *buf, union unwind_desc *uwd);
216 1.1.4.2 elad char *
217 1.1.4.2 elad unwind_decode_R3(char *buf, union unwind_desc *uwd);
218 1.1.4.2 elad char *
219 1.1.4.2 elad unwind_decode_P1(char *buf, union unwind_desc *uwd);
220 1.1.4.2 elad char *
221 1.1.4.2 elad unwind_decode_P2(char *buf, union unwind_desc *uwd);
222 1.1.4.2 elad char *
223 1.1.4.2 elad unwind_decode_P3(char *buf, union unwind_desc *uwd);
224 1.1.4.2 elad char *
225 1.1.4.2 elad unwind_decode_P4(char *buf, union unwind_desc *uwd, vsize_t len);
226 1.1.4.2 elad char *
227 1.1.4.2 elad unwind_decode_P5(char *buf, union unwind_desc *uwd);
228 1.1.4.2 elad char *
229 1.1.4.2 elad unwind_decode_P6(char *buf, union unwind_desc *uwd);
230 1.1.4.2 elad char *
231 1.1.4.2 elad unwind_decode_P7(char *buf, union unwind_desc *uwd);
232 1.1.4.2 elad char *
233 1.1.4.2 elad unwind_decode_P8(char *buf, union unwind_desc *uwd);
234 1.1.4.2 elad char *
235 1.1.4.2 elad unwind_decode_P9(char *buf, union unwind_desc *uwd);
236 1.1.4.2 elad char *
237 1.1.4.2 elad unwind_decode_P10(char *buf, union unwind_desc *uwd);
238 1.1.4.2 elad char *
239 1.1.4.2 elad unwind_decode_B1(char *buf, union unwind_desc *uwd);
240 1.1.4.2 elad char *
241 1.1.4.2 elad unwind_decode_B2(char *buf, union unwind_desc *uwd);
242 1.1.4.2 elad char *
243 1.1.4.2 elad unwind_decode_B3(char *buf, union unwind_desc *uwd);
244 1.1.4.2 elad char *
245 1.1.4.2 elad unwind_decode_B4(char *buf, union unwind_desc *uwd);
246 1.1.4.2 elad char *
247 1.1.4.2 elad unwind_decode_X1(char *buf, union unwind_desc *uwd);
248 1.1.4.2 elad char *
249 1.1.4.2 elad unwind_decode_X2(char *buf, union unwind_desc *uwd);
250 1.1.4.2 elad char *
251 1.1.4.2 elad unwind_decode_X3(char *buf, union unwind_desc *uwd);
252 1.1.4.2 elad char *
253 1.1.4.2 elad unwind_decode_X4(char *buf, union unwind_desc *uwd);
254 1.1.4.2 elad
255 1.1.4.2 elad
256 1.1.4.2 elad
257 1.1.4.2 elad
258 1.1.4.2 elad
259 1.1.4.2 elad
260