iPXE
DebugSupport.h
Go to the documentation of this file.
00001 /** @file
00002   DebugSupport protocol and supporting definitions as defined in the UEFI2.4
00003   specification.
00004 
00005   The DebugSupport protocol is used by source level debuggers to abstract the
00006   processor and handle context save and restore operations.
00007 
00008 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00009 Portions copyright (c) 2011 - 2013, ARM Ltd. All rights reserved.<BR>
00010 
00011 This program and the accompanying materials are licensed and made available under
00012 the terms and conditions of the BSD License that accompanies this distribution.
00013 The full text of the license may be found at
00014 http://opensource.org/licenses/bsd-license.php.
00015 
00016 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00017 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00018 
00019 **/
00020 
00021 #ifndef __DEBUG_SUPPORT_H__
00022 #define __DEBUG_SUPPORT_H__
00023 
00024 FILE_LICENCE ( BSD3 );
00025 
00026 #include <ipxe/efi/IndustryStandard/PeImage.h>
00027 
00028 typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL EFI_DEBUG_SUPPORT_PROTOCOL;
00029 
00030 ///
00031 /// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25}.
00032 ///
00033 #define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
00034   { \
00035     0x2755590C, 0x6F3C, 0x42FA, {0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 } \
00036   }
00037 
00038 ///
00039 /// Processor exception to be hooked.
00040 /// All exception types for IA32, X64, Itanium and EBC processors are defined.
00041 ///
00042 typedef INTN  EFI_EXCEPTION_TYPE;
00043 
00044 ///
00045 ///  IA-32 processor exception types.
00046 ///
00047 #define EXCEPT_IA32_DIVIDE_ERROR    0
00048 #define EXCEPT_IA32_DEBUG           1
00049 #define EXCEPT_IA32_NMI             2
00050 #define EXCEPT_IA32_BREAKPOINT      3
00051 #define EXCEPT_IA32_OVERFLOW        4
00052 #define EXCEPT_IA32_BOUND           5
00053 #define EXCEPT_IA32_INVALID_OPCODE  6
00054 #define EXCEPT_IA32_DOUBLE_FAULT    8
00055 #define EXCEPT_IA32_INVALID_TSS     10
00056 #define EXCEPT_IA32_SEG_NOT_PRESENT 11
00057 #define EXCEPT_IA32_STACK_FAULT     12
00058 #define EXCEPT_IA32_GP_FAULT        13
00059 #define EXCEPT_IA32_PAGE_FAULT      14
00060 #define EXCEPT_IA32_FP_ERROR        16
00061 #define EXCEPT_IA32_ALIGNMENT_CHECK 17
00062 #define EXCEPT_IA32_MACHINE_CHECK   18
00063 #define EXCEPT_IA32_SIMD            19
00064 
00065 ///
00066 /// FXSAVE_STATE.
00067 /// FP / MMX / XMM registers (see fxrstor instruction definition).
00068 ///
00069 typedef struct {
00070   UINT16  Fcw;
00071   UINT16  Fsw;
00072   UINT16  Ftw;
00073   UINT16  Opcode;
00074   UINT32  Eip;
00075   UINT16  Cs;
00076   UINT16  Reserved1;
00077   UINT32  DataOffset;
00078   UINT16  Ds;
00079   UINT8   Reserved2[10];
00080   UINT8   St0Mm0[10], Reserved3[6];
00081   UINT8   St1Mm1[10], Reserved4[6];
00082   UINT8   St2Mm2[10], Reserved5[6];
00083   UINT8   St3Mm3[10], Reserved6[6];
00084   UINT8   St4Mm4[10], Reserved7[6];
00085   UINT8   St5Mm5[10], Reserved8[6];
00086   UINT8   St6Mm6[10], Reserved9[6];
00087   UINT8   St7Mm7[10], Reserved10[6];
00088   UINT8   Xmm0[16];
00089   UINT8   Xmm1[16];
00090   UINT8   Xmm2[16];
00091   UINT8   Xmm3[16];
00092   UINT8   Xmm4[16];
00093   UINT8   Xmm5[16];
00094   UINT8   Xmm6[16];
00095   UINT8   Xmm7[16];
00096   UINT8   Reserved11[14 * 16];
00097 } EFI_FX_SAVE_STATE_IA32;
00098 
00099 ///
00100 ///  IA-32 processor context definition.
00101 ///
00102 typedef struct {
00103   UINT32                 ExceptionData;
00104   EFI_FX_SAVE_STATE_IA32 FxSaveState;
00105   UINT32                 Dr0;
00106   UINT32                 Dr1;
00107   UINT32                 Dr2;
00108   UINT32                 Dr3;
00109   UINT32                 Dr6;
00110   UINT32                 Dr7;
00111   UINT32                 Cr0;
00112   UINT32                 Cr1;  /* Reserved */
00113   UINT32                 Cr2;
00114   UINT32                 Cr3;
00115   UINT32                 Cr4;
00116   UINT32                 Eflags;
00117   UINT32                 Ldtr;
00118   UINT32                 Tr;
00119   UINT32                 Gdtr[2];
00120   UINT32                 Idtr[2];
00121   UINT32                 Eip;
00122   UINT32                 Gs;
00123   UINT32                 Fs;
00124   UINT32                 Es;
00125   UINT32                 Ds;
00126   UINT32                 Cs;
00127   UINT32                 Ss;
00128   UINT32                 Edi;
00129   UINT32                 Esi;
00130   UINT32                 Ebp;
00131   UINT32                 Esp;
00132   UINT32                 Ebx;
00133   UINT32                 Edx;
00134   UINT32                 Ecx;
00135   UINT32                 Eax;
00136 } EFI_SYSTEM_CONTEXT_IA32;
00137 
00138 ///
00139 ///  x64 processor exception types.
00140 ///
00141 #define EXCEPT_X64_DIVIDE_ERROR    0
00142 #define EXCEPT_X64_DEBUG           1
00143 #define EXCEPT_X64_NMI             2
00144 #define EXCEPT_X64_BREAKPOINT      3
00145 #define EXCEPT_X64_OVERFLOW        4
00146 #define EXCEPT_X64_BOUND           5
00147 #define EXCEPT_X64_INVALID_OPCODE  6
00148 #define EXCEPT_X64_DOUBLE_FAULT    8
00149 #define EXCEPT_X64_INVALID_TSS     10
00150 #define EXCEPT_X64_SEG_NOT_PRESENT 11
00151 #define EXCEPT_X64_STACK_FAULT     12
00152 #define EXCEPT_X64_GP_FAULT        13
00153 #define EXCEPT_X64_PAGE_FAULT      14
00154 #define EXCEPT_X64_FP_ERROR        16
00155 #define EXCEPT_X64_ALIGNMENT_CHECK 17
00156 #define EXCEPT_X64_MACHINE_CHECK   18
00157 #define EXCEPT_X64_SIMD            19
00158 
00159 ///
00160 /// FXSAVE_STATE.
00161 /// FP / MMX / XMM registers (see fxrstor instruction definition).
00162 ///
00163 typedef struct {
00164   UINT16  Fcw;
00165   UINT16  Fsw;
00166   UINT16  Ftw;
00167   UINT16  Opcode;
00168   UINT64  Rip;
00169   UINT64  DataOffset;
00170   UINT8   Reserved1[8];
00171   UINT8   St0Mm0[10], Reserved2[6];
00172   UINT8   St1Mm1[10], Reserved3[6];
00173   UINT8   St2Mm2[10], Reserved4[6];
00174   UINT8   St3Mm3[10], Reserved5[6];
00175   UINT8   St4Mm4[10], Reserved6[6];
00176   UINT8   St5Mm5[10], Reserved7[6];
00177   UINT8   St6Mm6[10], Reserved8[6];
00178   UINT8   St7Mm7[10], Reserved9[6];
00179   UINT8   Xmm0[16];
00180   UINT8   Xmm1[16];
00181   UINT8   Xmm2[16];
00182   UINT8   Xmm3[16];
00183   UINT8   Xmm4[16];
00184   UINT8   Xmm5[16];
00185   UINT8   Xmm6[16];
00186   UINT8   Xmm7[16];
00187   //
00188   // NOTE: UEFI 2.0 spec definition as follows.
00189   //
00190   UINT8   Reserved11[14 * 16];
00191 } EFI_FX_SAVE_STATE_X64;
00192 
00193 ///
00194 ///  x64 processor context definition.
00195 ///
00196 typedef struct {
00197   UINT64                ExceptionData;
00198   EFI_FX_SAVE_STATE_X64 FxSaveState;
00199   UINT64                Dr0;
00200   UINT64                Dr1;
00201   UINT64                Dr2;
00202   UINT64                Dr3;
00203   UINT64                Dr6;
00204   UINT64                Dr7;
00205   UINT64                Cr0;
00206   UINT64                Cr1;  /* Reserved */
00207   UINT64                Cr2;
00208   UINT64                Cr3;
00209   UINT64                Cr4;
00210   UINT64                Cr8;
00211   UINT64                Rflags;
00212   UINT64                Ldtr;
00213   UINT64                Tr;
00214   UINT64                Gdtr[2];
00215   UINT64                Idtr[2];
00216   UINT64                Rip;
00217   UINT64                Gs;
00218   UINT64                Fs;
00219   UINT64                Es;
00220   UINT64                Ds;
00221   UINT64                Cs;
00222   UINT64                Ss;
00223   UINT64                Rdi;
00224   UINT64                Rsi;
00225   UINT64                Rbp;
00226   UINT64                Rsp;
00227   UINT64                Rbx;
00228   UINT64                Rdx;
00229   UINT64                Rcx;
00230   UINT64                Rax;
00231   UINT64                R8;
00232   UINT64                R9;
00233   UINT64                R10;
00234   UINT64                R11;
00235   UINT64                R12;
00236   UINT64                R13;
00237   UINT64                R14;
00238   UINT64                R15;
00239 } EFI_SYSTEM_CONTEXT_X64;
00240 
00241 ///
00242 ///  Itanium Processor Family Exception types.
00243 ///
00244 #define EXCEPT_IPF_VHTP_TRANSLATION       0
00245 #define EXCEPT_IPF_INSTRUCTION_TLB        1
00246 #define EXCEPT_IPF_DATA_TLB               2
00247 #define EXCEPT_IPF_ALT_INSTRUCTION_TLB    3
00248 #define EXCEPT_IPF_ALT_DATA_TLB           4
00249 #define EXCEPT_IPF_DATA_NESTED_TLB        5
00250 #define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6
00251 #define EXCEPT_IPF_DATA_KEY_MISSED        7
00252 #define EXCEPT_IPF_DIRTY_BIT              8
00253 #define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9
00254 #define EXCEPT_IPF_DATA_ACCESS_BIT        10
00255 #define EXCEPT_IPF_BREAKPOINT             11
00256 #define EXCEPT_IPF_EXTERNAL_INTERRUPT     12
00257 //
00258 // 13 - 19 reserved
00259 //
00260 #define EXCEPT_IPF_PAGE_NOT_PRESENT           20
00261 #define EXCEPT_IPF_KEY_PERMISSION             21
00262 #define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS  22
00263 #define EXCEPT_IPF_DATA_ACCESS_RIGHTS         23
00264 #define EXCEPT_IPF_GENERAL_EXCEPTION          24
00265 #define EXCEPT_IPF_DISABLED_FP_REGISTER       25
00266 #define EXCEPT_IPF_NAT_CONSUMPTION            26
00267 #define EXCEPT_IPF_SPECULATION                27
00268 //
00269 // 28 reserved
00270 //
00271 #define EXCEPT_IPF_DEBUG                          29
00272 #define EXCEPT_IPF_UNALIGNED_REFERENCE            30
00273 #define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE     31
00274 #define EXCEPT_IPF_FP_FAULT                       32
00275 #define EXCEPT_IPF_FP_TRAP                        33
00276 #define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP  34
00277 #define EXCEPT_IPF_TAKEN_BRANCH                   35
00278 #define EXCEPT_IPF_SINGLE_STEP                    36
00279 //
00280 // 37 - 44 reserved
00281 //
00282 #define EXCEPT_IPF_IA32_EXCEPTION 45
00283 #define EXCEPT_IPF_IA32_INTERCEPT 46
00284 #define EXCEPT_IPF_IA32_INTERRUPT 47
00285 
00286 ///
00287 ///  IPF processor context definition.
00288 ///
00289 typedef struct {
00290   //
00291   // The first reserved field is necessary to preserve alignment for the correct
00292   // bits in UNAT and to insure F2 is 16 byte aligned.
00293   //
00294   UINT64  Reserved;
00295   UINT64  R1;
00296   UINT64  R2;
00297   UINT64  R3;
00298   UINT64  R4;
00299   UINT64  R5;
00300   UINT64  R6;
00301   UINT64  R7;
00302   UINT64  R8;
00303   UINT64  R9;
00304   UINT64  R10;
00305   UINT64  R11;
00306   UINT64  R12;
00307   UINT64  R13;
00308   UINT64  R14;
00309   UINT64  R15;
00310   UINT64  R16;
00311   UINT64  R17;
00312   UINT64  R18;
00313   UINT64  R19;
00314   UINT64  R20;
00315   UINT64  R21;
00316   UINT64  R22;
00317   UINT64  R23;
00318   UINT64  R24;
00319   UINT64  R25;
00320   UINT64  R26;
00321   UINT64  R27;
00322   UINT64  R28;
00323   UINT64  R29;
00324   UINT64  R30;
00325   UINT64  R31;
00326 
00327   UINT64  F2[2];
00328   UINT64  F3[2];
00329   UINT64  F4[2];
00330   UINT64  F5[2];
00331   UINT64  F6[2];
00332   UINT64  F7[2];
00333   UINT64  F8[2];
00334   UINT64  F9[2];
00335   UINT64  F10[2];
00336   UINT64  F11[2];
00337   UINT64  F12[2];
00338   UINT64  F13[2];
00339   UINT64  F14[2];
00340   UINT64  F15[2];
00341   UINT64  F16[2];
00342   UINT64  F17[2];
00343   UINT64  F18[2];
00344   UINT64  F19[2];
00345   UINT64  F20[2];
00346   UINT64  F21[2];
00347   UINT64  F22[2];
00348   UINT64  F23[2];
00349   UINT64  F24[2];
00350   UINT64  F25[2];
00351   UINT64  F26[2];
00352   UINT64  F27[2];
00353   UINT64  F28[2];
00354   UINT64  F29[2];
00355   UINT64  F30[2];
00356   UINT64  F31[2];
00357 
00358   UINT64  Pr;
00359 
00360   UINT64  B0;
00361   UINT64  B1;
00362   UINT64  B2;
00363   UINT64  B3;
00364   UINT64  B4;
00365   UINT64  B5;
00366   UINT64  B6;
00367   UINT64  B7;
00368 
00369   //
00370   // application registers
00371   //
00372   UINT64  ArRsc;
00373   UINT64  ArBsp;
00374   UINT64  ArBspstore;
00375   UINT64  ArRnat;
00376 
00377   UINT64  ArFcr;
00378 
00379   UINT64  ArEflag;
00380   UINT64  ArCsd;
00381   UINT64  ArSsd;
00382   UINT64  ArCflg;
00383   UINT64  ArFsr;
00384   UINT64  ArFir;
00385   UINT64  ArFdr;
00386 
00387   UINT64  ArCcv;
00388 
00389   UINT64  ArUnat;
00390 
00391   UINT64  ArFpsr;
00392 
00393   UINT64  ArPfs;
00394   UINT64  ArLc;
00395   UINT64  ArEc;
00396 
00397   //
00398   // control registers
00399   //
00400   UINT64  CrDcr;
00401   UINT64  CrItm;
00402   UINT64  CrIva;
00403   UINT64  CrPta;
00404   UINT64  CrIpsr;
00405   UINT64  CrIsr;
00406   UINT64  CrIip;
00407   UINT64  CrIfa;
00408   UINT64  CrItir;
00409   UINT64  CrIipa;
00410   UINT64  CrIfs;
00411   UINT64  CrIim;
00412   UINT64  CrIha;
00413 
00414   //
00415   // debug registers
00416   //
00417   UINT64  Dbr0;
00418   UINT64  Dbr1;
00419   UINT64  Dbr2;
00420   UINT64  Dbr3;
00421   UINT64  Dbr4;
00422   UINT64  Dbr5;
00423   UINT64  Dbr6;
00424   UINT64  Dbr7;
00425 
00426   UINT64  Ibr0;
00427   UINT64  Ibr1;
00428   UINT64  Ibr2;
00429   UINT64  Ibr3;
00430   UINT64  Ibr4;
00431   UINT64  Ibr5;
00432   UINT64  Ibr6;
00433   UINT64  Ibr7;
00434 
00435   //
00436   // virtual registers - nat bits for R1-R31
00437   //
00438   UINT64  IntNat;
00439 
00440 } EFI_SYSTEM_CONTEXT_IPF;
00441 
00442 ///
00443 ///  EBC processor exception types.
00444 ///
00445 #define EXCEPT_EBC_UNDEFINED            0
00446 #define EXCEPT_EBC_DIVIDE_ERROR         1
00447 #define EXCEPT_EBC_DEBUG                2
00448 #define EXCEPT_EBC_BREAKPOINT           3
00449 #define EXCEPT_EBC_OVERFLOW             4
00450 #define EXCEPT_EBC_INVALID_OPCODE       5   ///< Opcode out of range.
00451 #define EXCEPT_EBC_STACK_FAULT          6
00452 #define EXCEPT_EBC_ALIGNMENT_CHECK      7
00453 #define EXCEPT_EBC_INSTRUCTION_ENCODING 8   ///< Malformed instruction.
00454 #define EXCEPT_EBC_BAD_BREAK            9   ///< BREAK 0 or undefined BREAK.
00455 #define EXCEPT_EBC_STEP                 10  ///< To support debug stepping.
00456 ///
00457 /// For coding convenience, define the maximum valid EBC exception.
00458 ///
00459 #define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP
00460 
00461 ///
00462 ///  EBC processor context definition.
00463 ///
00464 typedef struct {
00465   UINT64  R0;
00466   UINT64  R1;
00467   UINT64  R2;
00468   UINT64  R3;
00469   UINT64  R4;
00470   UINT64  R5;
00471   UINT64  R6;
00472   UINT64  R7;
00473   UINT64  Flags;
00474   UINT64  ControlFlags;
00475   UINT64  Ip;
00476 } EFI_SYSTEM_CONTEXT_EBC;
00477 
00478 
00479 
00480 ///
00481 ///  ARM processor exception types.
00482 ///
00483 #define EXCEPT_ARM_RESET                    0
00484 #define EXCEPT_ARM_UNDEFINED_INSTRUCTION    1
00485 #define EXCEPT_ARM_SOFTWARE_INTERRUPT       2
00486 #define EXCEPT_ARM_PREFETCH_ABORT           3
00487 #define EXCEPT_ARM_DATA_ABORT               4
00488 #define EXCEPT_ARM_RESERVED                 5
00489 #define EXCEPT_ARM_IRQ                      6
00490 #define EXCEPT_ARM_FIQ                      7
00491 
00492 ///
00493 /// For coding convenience, define the maximum valid ARM exception.
00494 ///
00495 #define MAX_ARM_EXCEPTION EXCEPT_ARM_FIQ
00496 
00497 ///
00498 ///  ARM processor context definition.
00499 ///
00500 typedef struct {
00501   UINT32  R0;
00502   UINT32  R1;
00503   UINT32  R2;
00504   UINT32  R3;
00505   UINT32  R4;
00506   UINT32  R5;
00507   UINT32  R6;
00508   UINT32  R7;
00509   UINT32  R8;
00510   UINT32  R9;
00511   UINT32  R10;
00512   UINT32  R11;
00513   UINT32  R12;
00514   UINT32  SP;
00515   UINT32  LR;
00516   UINT32  PC;
00517   UINT32  CPSR;
00518   UINT32  DFSR;
00519   UINT32  DFAR;
00520   UINT32  IFSR;
00521   UINT32  IFAR;
00522 } EFI_SYSTEM_CONTEXT_ARM;
00523 
00524 
00525 ///
00526 ///  AARCH64 processor exception types.
00527 ///
00528 #define EXCEPT_AARCH64_SYNCHRONOUS_EXCEPTIONS    0
00529 #define EXCEPT_AARCH64_IRQ                       1
00530 #define EXCEPT_AARCH64_FIQ                       2
00531 #define EXCEPT_AARCH64_SERROR                    3
00532 
00533 ///
00534 /// For coding convenience, define the maximum valid ARM exception.
00535 ///
00536 #define MAX_AARCH64_EXCEPTION EXCEPT_AARCH64_SERROR
00537 
00538 typedef struct {
00539   // General Purpose Registers
00540   UINT64  X0;
00541   UINT64  X1;
00542   UINT64  X2;
00543   UINT64  X3;
00544   UINT64  X4;
00545   UINT64  X5;
00546   UINT64  X6;
00547   UINT64  X7;
00548   UINT64  X8;
00549   UINT64  X9;
00550   UINT64  X10;
00551   UINT64  X11;
00552   UINT64  X12;
00553   UINT64  X13;
00554   UINT64  X14;
00555   UINT64  X15;
00556   UINT64  X16;
00557   UINT64  X17;
00558   UINT64  X18;
00559   UINT64  X19;
00560   UINT64  X20;
00561   UINT64  X21;
00562   UINT64  X22;
00563   UINT64  X23;
00564   UINT64  X24;
00565   UINT64  X25;
00566   UINT64  X26;
00567   UINT64  X27;
00568   UINT64  X28;
00569   UINT64  FP;   // x29 - Frame pointer
00570   UINT64  LR;   // x30 - Link Register
00571   UINT64  SP;   // x31 - Stack pointer
00572 
00573   // FP/SIMD Registers
00574   UINT64  V0[2];
00575   UINT64  V1[2];
00576   UINT64  V2[2];
00577   UINT64  V3[2];
00578   UINT64  V4[2];
00579   UINT64  V5[2];
00580   UINT64  V6[2];
00581   UINT64  V7[2];
00582   UINT64  V8[2];
00583   UINT64  V9[2];
00584   UINT64  V10[2];
00585   UINT64  V11[2];
00586   UINT64  V12[2];
00587   UINT64  V13[2];
00588   UINT64  V14[2];
00589   UINT64  V15[2];
00590   UINT64  V16[2];
00591   UINT64  V17[2];
00592   UINT64  V18[2];
00593   UINT64  V19[2];
00594   UINT64  V20[2];
00595   UINT64  V21[2];
00596   UINT64  V22[2];
00597   UINT64  V23[2];
00598   UINT64  V24[2];
00599   UINT64  V25[2];
00600   UINT64  V26[2];
00601   UINT64  V27[2];
00602   UINT64  V28[2];
00603   UINT64  V29[2];
00604   UINT64  V30[2];
00605   UINT64  V31[2];
00606 
00607   UINT64  ELR;  // Exception Link Register
00608   UINT64  SPSR; // Saved Processor Status Register
00609   UINT64  FPSR; // Floating Point Status Register
00610   UINT64  ESR;  // Exception syndrome register
00611   UINT64  FAR;  // Fault Address Register
00612 } EFI_SYSTEM_CONTEXT_AARCH64;
00613 
00614 
00615 ///
00616 /// Universal EFI_SYSTEM_CONTEXT definition.
00617 ///
00618 typedef union {
00619   EFI_SYSTEM_CONTEXT_EBC  *SystemContextEbc;
00620   EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;
00621   EFI_SYSTEM_CONTEXT_X64  *SystemContextX64;
00622   EFI_SYSTEM_CONTEXT_IPF  *SystemContextIpf;
00623   EFI_SYSTEM_CONTEXT_ARM  *SystemContextArm;
00624   EFI_SYSTEM_CONTEXT_AARCH64  *SystemContextAArch64;
00625 } EFI_SYSTEM_CONTEXT;
00626 
00627 //
00628 // DebugSupport callback function prototypes
00629 //
00630 
00631 /**
00632   Registers and enables an exception callback function for the specified exception.
00633 
00634   @param  ExceptionType         Exception types in EBC, IA-32, x64, or IPF.
00635   @param  SystemContext         Exception content.
00636 
00637 **/
00638 typedef
00639 VOID
00640 (EFIAPI *EFI_EXCEPTION_CALLBACK)(
00641   IN     EFI_EXCEPTION_TYPE               ExceptionType,
00642   IN OUT EFI_SYSTEM_CONTEXT               SystemContext
00643   );
00644 
00645 /**
00646   Registers and enables the on-target debug agent's periodic entry point.
00647 
00648   @param  SystemContext         Exception content.
00649 
00650 **/
00651 typedef
00652 VOID
00653 (EFIAPI *EFI_PERIODIC_CALLBACK)(
00654   IN OUT EFI_SYSTEM_CONTEXT               SystemContext
00655   );
00656 
00657 ///
00658 /// Machine type definition
00659 ///
00660 typedef enum {
00661   IsaIa32 = IMAGE_FILE_MACHINE_I386,           ///< 0x014C
00662   IsaX64  = IMAGE_FILE_MACHINE_X64,            ///< 0x8664
00663   IsaIpf  = IMAGE_FILE_MACHINE_IA64,           ///< 0x0200
00664   IsaEbc  = IMAGE_FILE_MACHINE_EBC,            ///< 0x0EBC
00665   IsaArm  = IMAGE_FILE_MACHINE_ARMTHUMB_MIXED, ///< 0x01c2
00666   IsaAArch64  = IMAGE_FILE_MACHINE_ARM64       ///< 0xAA64
00667 } EFI_INSTRUCTION_SET_ARCHITECTURE;
00668 
00669 
00670 //
00671 // DebugSupport member function definitions
00672 //
00673 
00674 /**
00675   Returns the maximum value that may be used for the ProcessorIndex parameter in
00676   RegisterPeriodicCallback() and RegisterExceptionCallback().
00677 
00678   @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
00679   @param  MaxProcessorIndex     Pointer to a caller-allocated UINTN in which the maximum supported
00680                                 processor index is returned.
00681 
00682   @retval EFI_SUCCESS           The function completed successfully.
00683 
00684 **/
00685 typedef
00686 EFI_STATUS
00687 (EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX)(
00688   IN EFI_DEBUG_SUPPORT_PROTOCOL          *This,
00689   OUT UINTN                              *MaxProcessorIndex
00690   );
00691 
00692 /**
00693   Registers a function to be called back periodically in interrupt context.
00694 
00695   @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
00696   @param  ProcessorIndex        Specifies which processor the callback function applies to.
00697   @param  PeriodicCallback      A pointer to a function of type PERIODIC_CALLBACK that is the main
00698                                 periodic entry point of the debug agent.
00699 
00700   @retval EFI_SUCCESS           The function completed successfully.
00701   @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback
00702                                 function was previously registered.
00703   @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback
00704                                 function.
00705 
00706 **/
00707 typedef
00708 EFI_STATUS
00709 (EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK)(
00710   IN EFI_DEBUG_SUPPORT_PROTOCOL          *This,
00711   IN UINTN                               ProcessorIndex,
00712   IN EFI_PERIODIC_CALLBACK               PeriodicCallback
00713   );
00714 
00715 /**
00716   Registers a function to be called when a given processor exception occurs.
00717 
00718   @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
00719   @param  ProcessorIndex        Specifies which processor the callback function applies to.
00720   @param  ExceptionCallback     A pointer to a function of type EXCEPTION_CALLBACK that is called
00721                                 when the processor exception specified by ExceptionType occurs.
00722   @param  ExceptionType         Specifies which processor exception to hook.
00723 
00724   @retval EFI_SUCCESS           The function completed successfully.
00725   @retval EFI_ALREADY_STARTED   Non-NULL PeriodicCallback parameter when a callback
00726                                 function was previously registered.
00727   @retval EFI_OUT_OF_RESOURCES  System has insufficient memory resources to register new callback
00728                                 function.
00729 
00730 **/
00731 typedef
00732 EFI_STATUS
00733 (EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK)(
00734   IN EFI_DEBUG_SUPPORT_PROTOCOL          *This,
00735   IN UINTN                               ProcessorIndex,
00736   IN EFI_EXCEPTION_CALLBACK              ExceptionCallback,
00737   IN EFI_EXCEPTION_TYPE                  ExceptionType
00738   );
00739 
00740 /**
00741   Invalidates processor instruction cache for a memory range. Subsequent execution in this range
00742   causes a fresh memory fetch to retrieve code to be executed.
00743 
00744   @param  This                  A pointer to the EFI_DEBUG_SUPPORT_PROTOCOL instance.
00745   @param  ProcessorIndex        Specifies which processor's instruction cache is to be invalidated.
00746   @param  Start                 Specifies the physical base of the memory range to be invalidated.
00747   @param  Length                Specifies the minimum number of bytes in the processor's instruction
00748                                 cache to invalidate.
00749 
00750   @retval EFI_SUCCESS           The function completed successfully.
00751 
00752 **/
00753 typedef
00754 EFI_STATUS
00755 (EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE)(
00756   IN EFI_DEBUG_SUPPORT_PROTOCOL          *This,
00757   IN UINTN                               ProcessorIndex,
00758   IN VOID                                *Start,
00759   IN UINT64                              Length
00760   );
00761 
00762 ///
00763 /// This protocol provides the services to allow the debug agent to register
00764 /// callback functions that are called either periodically or when specific
00765 /// processor exceptions occur.
00766 ///
00767 struct _EFI_DEBUG_SUPPORT_PROTOCOL {
00768   ///
00769   /// Declares the processor architecture for this instance of the EFI Debug Support protocol.
00770   ///
00771   EFI_INSTRUCTION_SET_ARCHITECTURE  Isa;
00772   EFI_GET_MAXIMUM_PROCESSOR_INDEX   GetMaximumProcessorIndex;
00773   EFI_REGISTER_PERIODIC_CALLBACK    RegisterPeriodicCallback;
00774   EFI_REGISTER_EXCEPTION_CALLBACK   RegisterExceptionCallback;
00775   EFI_INVALIDATE_INSTRUCTION_CACHE  InvalidateInstructionCache;
00776 };
00777 
00778 extern EFI_GUID gEfiDebugSupportProtocolGuid;
00779 
00780 #endif