]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EdbDisasmSupport.h
CommitLineData
e8a5ac7c 1/** @file\r
748edcd5 2\r
f42f22f5 3Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>\r
9d510e61 4SPDX-License-Identifier: BSD-2-Clause-Patent\r
748edcd5 5\r
748edcd5 6\r
e8a5ac7c 7**/\r
748edcd5
PB
8\r
9#ifndef _EFI_EDB_DISASM_SUPPORT_H_\r
10#define _EFI_EDB_DISASM_SUPPORT_H_\r
11\r
12#include <Uefi.h>\r
13\r
14#define EDB_BYTECODE_NUMBER_IN_LINE 5\r
15\r
16#ifdef EFI32\r
17#define EDB_PRINT_ADDRESS_FORMAT L"%08x: "\r
18#else\r
19// To use 012l instead of 016l because space is not enough\r
20#define EDB_PRINT_ADDRESS_FORMAT L"%012lx: "\r
21#endif\r
22\r
23#define OPCODE_MAX 0x40\r
24\r
25#define EDB_INSTRUCTION_NAME_MAX_LENGTH 10\r
26#define EDB_INSTRUCTION_NAME_MAX_SIZE (EDB_INSTRUCTION_NAME_MAX_LENGTH * sizeof(CHAR16))\r
27#define EDB_INSTRUCTION_CONTENT_MAX_LENGTH 30\r
28#define EDB_INSTRUCTION_CONTENT_MAX_SIZE (EDB_INSTRUCTION_CONTENT_MAX_LENGTH * sizeof(CHAR16))\r
29\r
d138a2e9
DB
30/**\r
31\r
32 Set offset for Instruction name and content.\r
33\r
34 @param InstructionNameOffset - Instruction name offset\r
35 @param InstructionContentOffset - Instruction content offset\r
36\r
37**/\r
748edcd5
PB
38VOID\r
39EdbSetOffset (\r
40 IN UINTN InstructionNameOffset,\r
41 IN UINTN InstructionContentOffset\r
42 );\r
43\r
d138a2e9
DB
44/**\r
45\r
46 Pre instruction string construction.\r
47\r
48 @return Instruction string\r
49\r
50**/\r
748edcd5
PB
51CHAR16 *\r
52EdbPreInstructionString (\r
53 VOID\r
54 );\r
55\r
d138a2e9
DB
56/**\r
57\r
58 Post instruction string construction.\r
59\r
60 @return Instruction string\r
61\r
62**/\r
748edcd5
PB
63CHAR16 *\r
64EdbPostInstructionString (\r
65 VOID\r
66 );\r
67\r
d138a2e9
DB
68/**\r
69\r
70 Print the instruction name.\r
71\r
72 @param Name - instruction name\r
73\r
74 @return Instruction name offset\r
75\r
76**/\r
748edcd5
PB
77UINTN\r
78EdbPrintInstructionName (\r
79 IN CHAR16 *Name\r
80 );\r
81\r
d138a2e9
DB
82/**\r
83\r
84 Get Sign, NaturalUnits, and ConstantUnits of the WORD data.\r
85\r
86 @param Data16 - WORD data\r
87 @param NaturalUnits - Natural Units of the WORD\r
88 @param ConstantUnits - Constant Units of the WORD\r
89\r
90 @return Sign value of WORD\r
91\r
92**/\r
748edcd5
PB
93BOOLEAN\r
94EdbGetNaturalIndex16 (\r
95 IN UINT16 Data16,\r
96 OUT UINTN *NaturalUnits,\r
97 OUT UINTN *ConstantUnits\r
98 );\r
99\r
d138a2e9
DB
100/**\r
101\r
102 Get Sign, NaturalUnits, and ConstantUnits of the DWORD data.\r
103\r
104 @param Data32 - DWORD data\r
105 @param NaturalUnits - Natural Units of the DWORD\r
106 @param ConstantUnits - Constant Units of the DWORD\r
107\r
108 @return Sign value of DWORD\r
109\r
110**/\r
748edcd5
PB
111BOOLEAN\r
112EdbGetNaturalIndex32 (\r
113 IN UINT32 Data32,\r
114 OUT UINTN *NaturalUnits,\r
115 OUT UINTN *ConstantUnits\r
116 );\r
117\r
d138a2e9
DB
118/**\r
119\r
120 Get Sign, NaturalUnits, and ConstantUnits of the QWORD data.\r
121\r
122 @param Data64 - QWORD data\r
123 @param NaturalUnits - Natural Units of the QWORD\r
124 @param ConstantUnits - Constant Units of the QWORD\r
125\r
126 @return Sign value of QWORD\r
127\r
128**/\r
748edcd5
PB
129BOOLEAN\r
130EdbGetNaturalIndex64 (\r
131 IN UINT64 Data64,\r
132 OUT UINT64 *NaturalUnits,\r
133 OUT UINT64 *ConstantUnits\r
134 );\r
135\r
d138a2e9
DB
136/**\r
137\r
138 Print the hexical WORD raw index data to instruction content.\r
139\r
140 @param Data16 - WORD data\r
141\r
142 @return Instruction content offset\r
143\r
144**/\r
748edcd5
PB
145UINTN\r
146EdbPrintRawIndexData16 (\r
147 IN UINT16 Data16\r
148 );\r
149\r
d138a2e9
DB
150/**\r
151\r
152 Print the hexical DWORD raw index data to instruction content.\r
153\r
154 @param Data32 - DWORD data\r
155\r
156 @return Instruction content offset\r
157\r
158**/\r
748edcd5
PB
159UINTN\r
160EdbPrintRawIndexData32 (\r
161 IN UINT32 Data32\r
162 );\r
163\r
d138a2e9
DB
164/**\r
165\r
166 Print the hexical QWORD raw index data to instruction content.\r
167\r
168 @param Data64 - QWORD data\r
169\r
170 @return Instruction content offset\r
171\r
172**/\r
748edcd5
PB
173UINTN\r
174EdbPrintRawIndexData64 (\r
175 IN UINT64 Data64\r
176 );\r
177\r
d138a2e9
DB
178/**\r
179\r
180 Print register 1 in operands.\r
181\r
182 @param Operands - instruction operands\r
183\r
184 @return Instruction content offset\r
185\r
186**/\r
748edcd5
PB
187UINTN\r
188EdbPrintRegister1 (\r
189 IN UINT8 Operands\r
190 );\r
191\r
d138a2e9
DB
192/**\r
193\r
194 Print register 2 in operands.\r
195\r
196 @param Operands - instruction operands\r
197\r
198 @return Instruction content offset\r
199\r
200**/\r
748edcd5
PB
201UINTN\r
202EdbPrintRegister2 (\r
203 IN UINT8 Operands\r
204 );\r
205\r
d138a2e9
DB
206/**\r
207\r
208 Print dedicated register 1 in operands.\r
209\r
210 @param Operands - instruction operands\r
211\r
212 @return Instruction content offset\r
213\r
214**/\r
748edcd5
PB
215UINTN\r
216EdbPrintDedicatedRegister1 (\r
217 IN UINT8 Operands\r
218 );\r
219\r
d138a2e9
DB
220/**\r
221\r
222 Print dedicated register 2 in operands.\r
223\r
224 @param Operands - instruction operands\r
225\r
226 @return Instruction content offset\r
227\r
228**/\r
748edcd5
PB
229UINTN\r
230EdbPrintDedicatedRegister2 (\r
231 IN UINT8 Operands\r
232 );\r
233\r
d138a2e9
DB
234/**\r
235\r
236 Print the hexical UINTN index data to instruction content.\r
237\r
238 @param Sign - Signed bit of UINTN data\r
239 @param NaturalUnits - natural units of UINTN data\r
240 @param ConstantUnits - natural units of UINTN data\r
241\r
242 @return Instruction content offset\r
243\r
244**/\r
748edcd5
PB
245UINTN\r
246EdbPrintIndexData (\r
247 IN BOOLEAN Sign,\r
248 IN UINTN NaturalUnits,\r
249 IN UINTN ConstantUnits\r
250 );\r
251\r
d138a2e9
DB
252/**\r
253\r
254 Print the hexical QWORD index data to instruction content.\r
255\r
256 @param Sign - Signed bit of QWORD data\r
257 @param NaturalUnits - natural units of QWORD data\r
258 @param ConstantUnits - natural units of QWORD data\r
259\r
260 @return Instruction content offset\r
261\r
262**/\r
748edcd5
PB
263UINTN\r
264EdbPrintIndexData64 (\r
265 IN BOOLEAN Sign,\r
266 IN UINT64 NaturalUnits,\r
267 IN UINT64 ConstantUnits\r
268 );\r
269\r
d138a2e9
DB
270/**\r
271\r
272 Print the hexical BYTE immediate data to instruction content.\r
273\r
274 @param Data - BYTE data\r
275\r
276 @return Instruction content offset\r
277\r
278**/\r
748edcd5
PB
279UINTN\r
280EdbPrintImmData8 (\r
281 IN UINT8 Data\r
282 );\r
283\r
d138a2e9
DB
284/**\r
285\r
286 Print the hexical WORD immediate data to instruction content.\r
287\r
288 @param Data - WORD data\r
289\r
290 @return Instruction content offset\r
291\r
292**/\r
748edcd5
PB
293UINTN\r
294EdbPrintImmData16 (\r
295 IN UINT16 Data\r
296 );\r
297\r
d138a2e9
DB
298/**\r
299\r
300 Print the hexical DWORD immediate data to instruction content.\r
301\r
302 @param Data - DWORD data\r
303\r
304 @return Instruction content offset\r
305\r
306**/\r
748edcd5
PB
307UINTN\r
308EdbPrintImmData32 (\r
309 IN UINT32 Data\r
310 );\r
311\r
d138a2e9
DB
312/**\r
313\r
314 Print the hexical QWORD immediate data to instruction content.\r
315\r
316 @param Data - QWORD data\r
317\r
318 @return Instruction content offset\r
319\r
320**/\r
748edcd5
PB
321UINTN\r
322EdbPrintImmData64 (\r
323 IN UINT64 Data\r
324 );\r
325\r
d138a2e9
DB
326/**\r
327\r
328 Print the decimal UINTN immediate data to instruction content.\r
329\r
330 @param Data - UINTN data\r
331\r
332 @return Instruction content offset\r
333\r
334**/\r
748edcd5
PB
335UINTN\r
336EdbPrintImmDatan (\r
337 IN UINTN Data\r
338 );\r
339\r
d138a2e9
DB
340/**\r
341\r
342 Print the decimal QWORD immediate data to instruction content.\r
343\r
344 @param Data64 - QWORD data\r
345\r
346 @return Instruction content offset\r
347\r
348**/\r
748edcd5
PB
349UINTN\r
350EdbPrintImmData64n (\r
351 IN UINT64 Data64\r
352 );\r
353\r
d138a2e9
DB
354/**\r
355\r
356 Print the hexical BYTE to instruction content.\r
357\r
358 @param Data8 - BYTE data\r
359\r
360 @return Instruction content offset\r
361\r
362**/\r
748edcd5
PB
363UINTN\r
364EdbPrintData8 (\r
365 IN UINT8 Data8\r
366 );\r
367\r
d138a2e9
DB
368/**\r
369\r
370 Print the hexical WORD to instruction content.\r
371\r
372 @param Data16 - WORD data\r
373\r
374 @return Instruction content offset\r
375\r
376**/\r
748edcd5
PB
377UINTN\r
378EdbPrintData16 (\r
379 IN UINT16 Data16\r
380 );\r
381\r
d138a2e9
DB
382/**\r
383\r
384 Print the hexical DWORD to instruction content.\r
385\r
386 @param Data32 - DWORD data\r
387\r
388 @return Instruction content offset\r
389\r
390**/\r
748edcd5
PB
391UINTN\r
392EdbPrintData32 (\r
393 IN UINT32 Data32\r
394 );\r
395\r
d138a2e9
DB
396/**\r
397\r
398 Print the hexical QWORD to instruction content.\r
399\r
400 @param Data64 - QWORD data\r
401\r
402 @return Instruction content offset\r
403\r
404**/\r
748edcd5
PB
405UINTN\r
406EdbPrintData64 (\r
407 IN UINT64 Data64\r
408 );\r
409\r
d138a2e9
DB
410/**\r
411\r
412 Print the decimal unsigned UINTN to instruction content.\r
413\r
414 @param Data - unsigned UINTN data\r
415\r
416 @return Instruction content offset\r
417\r
418**/\r
748edcd5
PB
419UINTN\r
420EdbPrintDatan (\r
421 IN UINTN Data\r
422 );\r
423\r
d138a2e9
DB
424/**\r
425\r
426 Print the decimal unsigned QWORD to instruction content.\r
427\r
428 @param Data64 - unsigned QWORD data\r
429\r
430 @return Instruction content offset\r
431\r
432**/\r
748edcd5
PB
433UINTN\r
434EdbPrintData64n (\r
435 IN UINT64 Data64\r
436 );\r
437\r
d138a2e9
DB
438/**\r
439\r
440 Print the decimal signed BYTE to instruction content.\r
441\r
442 @param Data8 - signed BYTE data\r
443\r
444 @return Instruction content offset\r
445\r
446**/\r
748edcd5
PB
447UINTN\r
448EdbPrintData8s (\r
449 IN UINT8 Data8\r
450 );\r
451\r
d138a2e9
DB
452/**\r
453\r
454 Print the decimal signed WORD to instruction content.\r
455\r
456 @param Data16 - signed WORD data\r
457\r
458 @return Instruction content offset\r
459\r
460**/\r
748edcd5
PB
461UINTN\r
462EdbPrintData16s (\r
463 IN UINT16 Data16\r
464 );\r
465\r
d138a2e9
DB
466/**\r
467\r
468 Print the decimal signed DWORD to instruction content.\r
469\r
470 @param Data32 - signed DWORD data\r
471\r
472 @return Instruction content offset\r
473\r
474**/\r
748edcd5
PB
475UINTN\r
476EdbPrintData32s (\r
477 IN UINT32 Data32\r
478 );\r
479\r
d138a2e9
DB
480/**\r
481\r
482 Print the decimal signed QWORD to instruction content.\r
483\r
484 @param Data64 - signed QWORD data\r
485\r
486 @return Instruction content offset\r
487\r
488**/\r
748edcd5
PB
489UINTN\r
490EdbPrintData64s (\r
491 IN UINT64 Data64\r
492 );\r
493\r
d138a2e9
DB
494/**\r
495\r
496 Print the comma to instruction content.\r
497\r
498 @return Instruction content offset\r
499\r
500**/\r
748edcd5
PB
501UINTN\r
502EdbPrintComma (\r
503 VOID\r
504 );\r
505\r
d138a2e9
DB
506/**\r
507\r
508 Find the symbol string according to address, then print it.\r
509\r
510 @param Address - instruction address\r
511\r
512 @retval 1 - symbol string is found and printed\r
513 @retval 0 - symbol string not found\r
514\r
515**/\r
748edcd5
PB
516UINTN\r
517EdbFindAndPrintSymbol (\r
518 IN UINTN Address\r
519 );\r
520\r
d138a2e9
DB
521/**\r
522\r
523 Print the EBC byte code.\r
524\r
525 @param InstructionAddress - instruction address\r
526 @param InstructionNumber - instruction number\r
527\r
528**/\r
748edcd5
PB
529VOID\r
530EdbPrintRaw (\r
531 IN EFI_PHYSICAL_ADDRESS InstructionAddress,\r
532 IN UINTN InstructionNumber\r
533 );\r
534\r
d138a2e9
DB
535/**\r
536\r
537 Print the EBC asm code.\r
538\r
539 @param DebuggerPrivate - EBC Debugger private data structure\r
540 @param SystemContext - EBC system context.\r
541\r
542 @retval EFI_SUCCESS - show disasm successfully\r
543\r
544**/\r
748edcd5
PB
545EFI_STATUS\r
546EdbShowDisasm (\r
547 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,\r
548 IN EFI_SYSTEM_CONTEXT SystemContext\r
549 );\r
550\r
d138a2e9
DB
551/**\r
552\r
24648548 553 Get register value according to the system context, and register index.\r
d138a2e9
DB
554\r
555 @param SystemContext - EBC system context.\r
556 @param Index - EBC register index\r
557\r
558 @return register value\r
559\r
560**/\r
748edcd5
PB
561UINT64\r
562GetRegisterValue (\r
563 IN EFI_SYSTEM_CONTEXT SystemContext,\r
564 IN UINT8 Index\r
565 );\r
566\r
567#endif\r