]>
Commit | Line | Data |
---|---|---|
5ba3f43e A |
1 | /* |
2 | * Copyright (c) 2007 Apple Inc. All rights reserved. | |
3 | */ | |
4 | /* | |
5 | * CDDL HEADER START | |
6 | * | |
7 | * The contents of this file are subject to the terms of the | |
8 | * Common Development and Distribution License, Version 1.0 only | |
9 | * (the "License"). You may not use this file except in compliance | |
10 | * with the License. | |
11 | * | |
12 | * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE | |
13 | * or http://www.opensolaris.org/os/licensing. | |
14 | * See the License for the specific language governing permissions | |
15 | * and limitations under the License. | |
16 | * | |
17 | * When distributing Covered Code, include this CDDL HEADER in each | |
18 | * file and include the License file at usr/src/OPENSOLARIS.LICENSE. | |
19 | * If applicable, add the following below this CDDL HEADER, with the | |
20 | * fields enclosed by brackets "[]" replaced with your own identifying | |
21 | * information: Portions Copyright [yyyy] [name of copyright owner] | |
22 | * | |
23 | * CDDL HEADER END | |
24 | */ | |
25 | /* | |
26 | * Copyright 2004 Sun Microsystems, Inc. All rights reserved. | |
27 | * Use is subject to license terms. | |
28 | */ | |
29 | ||
0a7de745 A |
30 | #ifndef _FASTTRAP_ISA_H |
31 | #define _FASTTRAP_ISA_H | |
5ba3f43e | 32 | |
5ba3f43e A |
33 | #include <sys/types.h> |
34 | #include <stdint.h> | |
35 | ||
0a7de745 | 36 | #ifdef __cplusplus |
5ba3f43e A |
37 | extern "C" { |
38 | #endif | |
39 | ||
40 | typedef union { | |
41 | uint32_t instr32; | |
42 | struct { | |
43 | uint16_t instr1; | |
44 | uint16_t instr2; | |
45 | } instr16; | |
46 | } fasttrap_instr_t; | |
47 | ||
48 | typedef struct fasttrap_machtp { | |
49 | fasttrap_instr_t ftmt_instr; /* original instruction */ | |
50 | ||
0a7de745 | 51 | uint8_t ftmt_fntype; /* One of the FASTTRAP_FN* constants defined below */ |
5ba3f43e | 52 | /* Once the tracepoint is initialized, fntype will be FN_DONE_INIT and thumb will be 0 for ARM, 1 for Thumb */ |
0a7de745 | 53 | uint8_t ftmt_thumb; |
5ba3f43e | 54 | |
0a7de745 A |
55 | uint8_t ftmt_type; |
56 | uint8_t ftmt_installed:1; | |
57 | uint8_t ftmt_retired:1; | |
5ba3f43e A |
58 | } fasttrap_machtp_t; |
59 | ||
0a7de745 A |
60 | #define ftt_instr ftt_mtp.ftmt_instr.instr32 |
61 | #define ftt_instr1 ftt_mtp.ftmt_instr.instr16.instr1 | |
62 | #define ftt_instr2 ftt_mtp.ftmt_instr.instr16.instr2 | |
63 | #define ftt_fntype ftt_mtp.ftmt_fntype | |
64 | #define ftt_thumb ftt_mtp.ftmt_thumb | |
65 | #define ftt_type ftt_mtp.ftmt_type | |
66 | #define ftt_installed ftt_mtp.ftmt_installed | |
67 | #define ftt_retired ftt_mtp.ftmt_retired | |
68 | ||
69 | #define FASTTRAP_T_INV 1 | |
70 | #define FASTTRAP_T_COMMON 2 | |
71 | #define FASTTRAP_T_BLX 3 | |
72 | #define FASTTRAP_T_B_COND 4 | |
73 | #define FASTTRAP_T_B_UNCOND 5 | |
74 | #define FASTTRAP_T_BX_REG 6 | |
75 | #define FASTTRAP_T_PUSH_LR 7 | |
76 | #define FASTTRAP_T_POP_PC 8 | |
77 | #define FASTTRAP_T_STM_LR 9 | |
78 | #define FASTTRAP_T_LDM_PC 10 | |
79 | #define FASTTRAP_T_CPY_PC 11 | |
80 | #define FASTTRAP_T_MOV_PC_REG 12 | |
81 | #define FASTTRAP_T_LDR_PC_IMMED 13 | |
82 | #define FASTTRAP_T_VLDR_PC_IMMED 14 | |
83 | #define FASTTRAP_T_CB_N_Z 15 | |
5ba3f43e | 84 | #if defined(__arm64__) |
0a7de745 A |
85 | #define FASTTRAP_T_ARM64_STANDARD_FUNCTION_ENTRY 16 /* stp fp, lr, [sp, #-16]! */ |
86 | #define FASTTRAP_T_ARM64_LDR_S_PC_REL 17 | |
87 | #define FASTTRAP_T_ARM64_LDR_W_PC_REL 18 | |
88 | #define FASTTRAP_T_ARM64_LDR_D_PC_REL 19 | |
89 | #define FASTTRAP_T_ARM64_LDR_X_PC_REL 20 | |
90 | #define FASTTRAP_T_ARM64_LDR_Q_PC_REL 21 | |
91 | #define FASTTRAP_T_ARM64_LDRSW_PC_REL 22 | |
92 | #define FASTTRAP_T_ARM64_B_COND 23 | |
93 | #define FASTTRAP_T_ARM64_CBNZ_W 24 | |
94 | #define FASTTRAP_T_ARM64_CBNZ_X 25 | |
95 | #define FASTTRAP_T_ARM64_CBZ_W 26 | |
96 | #define FASTTRAP_T_ARM64_CBZ_X 27 | |
97 | #define FASTTRAP_T_ARM64_TBNZ 28 | |
98 | #define FASTTRAP_T_ARM64_TBZ 29 | |
99 | #define FASTTRAP_T_ARM64_B 30 | |
100 | #define FASTTRAP_T_ARM64_BL 31 | |
101 | #define FASTTRAP_T_ARM64_BLR 32 | |
102 | #define FASTTRAP_T_ARM64_BR 33 | |
103 | #define FASTTRAP_T_ARM64_RET 34 | |
104 | #define FASTTRAP_T_ARM64_ADRP 35 | |
105 | #define FASTTRAP_T_ARM64_ADR 36 | |
106 | #define FASTTRAP_T_ARM64_PRFM 37 | |
107 | #define FASTTRAP_T_ARM64_EXCLUSIVE_MEM 38 | |
108 | #define FASTTRAP_T_ARM64_RETAB 39 | |
5ba3f43e A |
109 | #endif |
110 | ||
0a7de745 | 111 | #if defined (__arm__) |
5ba3f43e A |
112 | #define FASTTRAP_ARM_INSTR 0xe7ffdefc |
113 | #define FASTTRAP_THUMB_INSTR 0xdefc | |
114 | #define FASTTRAP_ARM_RET_INSTR 0xe7ffdefb | |
115 | #define FASTTRAP_THUMB_RET_INSTR 0xdefb | |
0a7de745 | 116 | |
5ba3f43e A |
117 | #elif defined (__arm64__) |
118 | #define FASTTRAP_ARM32_INSTR 0xe7ffdefc | |
119 | #define FASTTRAP_THUMB32_INSTR 0xdefc | |
120 | #define FASTTRAP_ARM64_INSTR 0xe7eeee7e | |
121 | ||
122 | #define FASTTRAP_ARM32_RET_INSTR 0xe7ffdefb | |
123 | #define FASTTRAP_THUMB32_RET_INSTR 0xdefb | |
124 | #define FASTTRAP_ARM64_RET_INSTR 0xe7eeee7d | |
0a7de745 | 125 | #endif |
5ba3f43e A |
126 | |
127 | #define FASTTRAP_FN_DONE_INIT 255 | |
128 | #define FASTTRAP_FN_UNKNOWN 0 | |
129 | #define FASTTRAP_FN_ARM 1 | |
130 | #define FASTTRAP_FN_THUMB 2 | |
131 | #define FASTTRAP_FN_USDT 3 | |
d9a64523 A |
132 | #define FASTTRAP_FN_ARM64 4 |
133 | #define FASTTRAP_FN_ARM64_32 5 | |
5ba3f43e A |
134 | |
135 | #define ARM_RM(x) ((x) & 0xF) | |
136 | #define ARM_RS(x) (((x) >> 8) & 0xF) | |
137 | #define ARM_RD(x) (((x) >> 12) & 0xF) | |
138 | #define ARM_RN(x) (((x) >> 16) & 0xF) | |
139 | #define ARM_CONDCODE(x) ((x) >> 28) | |
140 | ||
141 | #define THUMB16_HRM(x) (((x) >> 3) & 0xF) | |
142 | #define THUMB16_HRD(x) (((x) & 0x7) | ((((x) >> 4) & 0x8))) | |
143 | ||
0a7de745 A |
144 | #define THUMB32_RM(x, y) ((y) & 0xF) |
145 | #define THUMB32_RD(x, y) (((y) >> 8) & 0xF) | |
146 | #define THUMB32_RT(x, y) (((y) >> 12) & 0xF) | |
147 | #define THUMB32_RN(x, y) ((x) & 0xF) | |
5ba3f43e A |
148 | |
149 | #define REG_SP 13 | |
150 | #define REG_LR 14 | |
151 | #define REG_PC 15 | |
152 | ||
0a7de745 A |
153 | #define FASTTRAP_RETURN_AFRAMES 6 |
154 | #define FASTTRAP_ENTRY_AFRAMES 5 | |
155 | #define FASTTRAP_OFFSET_AFRAMES 5 | |
5ba3f43e A |
156 | |
157 | #if defined(__arm64__) | |
0a7de745 | 158 | #define FASTTRAP_ARM64_OP_VALUE_FUNC_ENTRY 0xa9bf7bfd /* stp fp, lr, [sp, #-16]! */ |
5ba3f43e | 159 | |
0a7de745 A |
160 | #define FASTTRAP_ARM64_OP_MASK_LDR_S_PC_REL 0xff000000 /* Bits to check for ldr St, label */ |
161 | #define FASTTRAP_ARM64_OP_VALUE_LDR_S_PC_REL 0x1c000000 /* Value to find */ | |
5ba3f43e | 162 | |
0a7de745 A |
163 | #define FASTTRAP_ARM64_OP_MASK_LDR_W_PC_REL 0xff000000 /* Bits to check for ldr Wt, label */ |
164 | #define FASTTRAP_ARM64_OP_VALUE_LDR_W_PC_REL 0x18000000 /* Value to find */ | |
5ba3f43e | 165 | |
0a7de745 A |
166 | #define FASTTRAP_ARM64_OP_MASK_LDR_D_PC_REL 0xff000000 /* Bits to check for ldr Dt, label */ |
167 | #define FASTTRAP_ARM64_OP_VALUE_LDR_D_PC_REL 0x5c000000 /* Value to find */ | |
5ba3f43e | 168 | |
0a7de745 A |
169 | #define FASTTRAP_ARM64_OP_MASK_LDR_X_PC_REL 0xff000000 /* Bits to check for ldr Xt, label */ |
170 | #define FASTTRAP_ARM64_OP_VALUE_LDR_X_PC_REL 0x58000000 /* Value to find */ | |
5ba3f43e | 171 | |
0a7de745 A |
172 | #define FASTTRAP_ARM64_OP_MASK_LDR_Q_PC_REL 0xff000000 /* Bits to check for ldr Qt, label */ |
173 | #define FASTTRAP_ARM64_OP_VALUE_LDR_Q_PC_REL 0x9c000000 /* Value to find */ | |
5ba3f43e | 174 | |
0a7de745 A |
175 | #define FASTTRAP_ARM64_OP_MASK_LRDSW_PC_REL 0xff000000 /* Bits to check for ldrsw <reg>, label */ |
176 | #define FASTTRAP_ARM64_OP_VALUE_LRDSW_PC_REL 0x98000000 /* Value to find */ | |
5ba3f43e | 177 | |
0a7de745 A |
178 | #define FASTTRAP_ARM64_OP_MASK_B_COND_PC_REL 0xff000010 /* Bits to check for b.cond label */ |
179 | #define FASTTRAP_ARM64_OP_VALUE_B_COND_PC_REL 0x54000000 /* Value to find */ | |
5ba3f43e | 180 | |
0a7de745 A |
181 | #define FASTTRAP_ARM64_OP_MASK_CBNZ_W_PC_REL 0xff000000 /* Bits to check for cbnz Wt, _label */ |
182 | #define FASTTRAP_ARM64_OP_VALUE_CBNZ_W_PC_REL 0x35000000 /* Value to find */ | |
5ba3f43e | 183 | |
0a7de745 A |
184 | #define FASTTRAP_ARM64_OP_MASK_CBNZ_X_PC_REL 0xff000000 /* Bits to check for cbnz Xt, _label */ |
185 | #define FASTTRAP_ARM64_OP_VALUE_CBNZ_X_PC_REL 0xb5000000 /* Value to find */ | |
5ba3f43e | 186 | |
0a7de745 A |
187 | #define FASTTRAP_ARM64_OP_MASK_CBZ_W_PC_REL 0xff000000 /* Bits to check for cbz Wt, _label */ |
188 | #define FASTTRAP_ARM64_OP_VALUE_CBZ_W_PC_REL 0x34000000 /* Value to find */ | |
5ba3f43e | 189 | |
0a7de745 A |
190 | #define FASTTRAP_ARM64_OP_MASK_CBZ_X_PC_REL 0xff000000 /* Bits to check for cbz Xt, _label */ |
191 | #define FASTTRAP_ARM64_OP_VALUE_CBZ_X_PC_REL 0xb4000000 /* Value to find */ | |
5ba3f43e | 192 | |
0a7de745 A |
193 | #define FASTTRAP_ARM64_OP_MASK_TBNZ_PC_REL 0x7f000000 /* Bits to check for tbnz Xt, _label */ |
194 | #define FASTTRAP_ARM64_OP_VALUE_TBNZ_PC_REL 0x37000000 /* Value to find */ | |
5ba3f43e | 195 | |
0a7de745 A |
196 | #define FASTTRAP_ARM64_OP_MASK_TBZ_PC_REL 0x7f000000 /* Bits to check for tbz Xt, _label */ |
197 | #define FASTTRAP_ARM64_OP_VALUE_TBZ_PC_REL 0x36000000 /* Value to find */ | |
5ba3f43e | 198 | |
0a7de745 A |
199 | #define FASTTRAP_ARM64_OP_MASK_B_PC_REL 0xfc000000 /* Bits to check for b _label */ |
200 | #define FASTTRAP_ARM64_OP_VALUE_B_PC_REL 0x14000000 /* Value to find */ | |
5ba3f43e | 201 | |
0a7de745 A |
202 | #define FASTTRAP_ARM64_OP_MASK_BL_PC_REL 0xfc000000 /* Bits to check for bl _label */ |
203 | #define FASTTRAP_ARM64_OP_VALUE_BL_PC_REL 0x94000000 /* Value to find */ | |
5ba3f43e | 204 | |
0a7de745 A |
205 | #define FASTTRAP_ARM64_OP_MASK_BLR 0xfffffe1f /* Bits to check for blr Xt */ |
206 | #define FASTTRAP_ARM64_OP_VALUE_BLR 0xd63f0000 /* Value to find */ | |
5ba3f43e | 207 | |
0a7de745 A |
208 | #define FASTTRAP_ARM64_OP_MASK_BR 0xfffffe1f /* Bits to check for br Xt */ |
209 | #define FASTTRAP_ARM64_OP_VALUE_BR 0xd61f0000 /* Value to find */ | |
5ba3f43e | 210 | |
0a7de745 A |
211 | #define FASTTRAP_ARM64_OP_MASK_RET 0xfffffc1f /* Bits to check for ret Rt */ |
212 | #define FASTTRAP_ARM64_OP_VALUE_RET 0xd65f0000 /* Value to find */ | |
5ba3f43e | 213 | |
0a7de745 A |
214 | #define FASTTRAP_ARM64_OP_MASK_ADRP 0x9f000000 /* Bits to check for adrp Xt, label*/ |
215 | #define FASTTRAP_ARM64_OP_VALUE_ADRP 0x90000000 /* Value to find */ | |
5ba3f43e | 216 | |
0a7de745 A |
217 | #define FASTTRAP_ARM64_OP_MASK_ADR 0x9f000000 /* Bits to check for adr Xt, label*/ |
218 | #define FASTTRAP_ARM64_OP_VALUE_ADR 0x10000000 /* Value to find */ | |
5ba3f43e | 219 | |
0a7de745 A |
220 | #define FASTTRAP_ARM64_OP_MASK_PRFM 0xff000000 /* Bits to check for adr Xt, label*/ |
221 | #define FASTTRAP_ARM64_OP_VALUE_PRFM 0xd8000000 /* Value to find */ | |
5ba3f43e | 222 | |
0a7de745 A |
223 | #define FASTTRAP_ARM64_OP_MASK_EXCL_MEM 0x3f000000 /* Bits to check for exclusive memory operation */ |
224 | #define FASTTRAP_ARM64_OP_VALUE_EXCL_MEM 0x08000000 /* Value to find */ | |
d9a64523 | 225 | |
0a7de745 A |
226 | #define FASTTRAP_ARM64_OP_MASK_RETAB 0xfffffc1f /* Bits to check for retab Rt */ |
227 | #define FASTTRAP_ARM64_OP_VALUE_RETAB 0xd65f0c1f /* Value to find */ | |
5ba3f43e A |
228 | #endif /* defined(__arm64__) */ |
229 | ||
0a7de745 | 230 | #ifdef __cplusplus |
5ba3f43e A |
231 | } |
232 | #endif | |
233 | ||
0a7de745 | 234 | #endif /* _FASTTRAP_ISA_H */ |