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