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