]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/Library/GdbDebugAgent/Ia32/Processor.c
ARM Packages: Removed trailing spaces
[mirror_edk2.git] / EmbeddedPkg / Library / GdbDebugAgent / Ia32 / Processor.c
index 4e4350a0f25c0adfdbbdfa4a49ac1b48bb04e26d..c5a421c69e658270d20a829797e0dd3874a1cd56 100755 (executable)
@@ -2,7 +2,7 @@
   Processor specific parts of the GDB stub\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
-  \r
+\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,7 +20,7 @@
 // {EFI mapping, GDB mapping}\r
 //\r
 EFI_EXCEPTION_TYPE_ENTRY gExceptionType[] = {\r
-  { EXCEPT_IA32_DIVIDE_ERROR,     GDB_SIGFPE  }, \r
+  { EXCEPT_IA32_DIVIDE_ERROR,     GDB_SIGFPE  },\r
   { EXCEPT_IA32_DEBUG,            GDB_SIGTRAP },\r
   { EXCEPT_IA32_NMI,              GDB_SIGEMT  },\r
   { EXCEPT_IA32_BREAKPOINT,       GDB_SIGTRAP },\r
@@ -62,7 +62,7 @@ UINTN gRegisterOffsets[] = {
 \r
 \r
 //Debug only..\r
-VOID \r
+VOID\r
 PrintReg (\r
   IN EFI_SYSTEM_CONTEXT SystemContext\r
   )\r
@@ -80,7 +80,7 @@ PrintReg (
 }\r
 \r
 //Debug only..\r
-VOID \r
+VOID\r
 PrintDRreg (\r
   IN EFI_SYSTEM_CONTEXT SystemContext\r
   )\r
@@ -96,8 +96,8 @@ PrintDRreg (
 \r
 /**\r
  Return the number of entries in the gExceptionType[]\r
\r
- @retval  UINTN, the number of entries in the gExceptionType[] array.    \r
+\r
+ @retval  UINTN, the number of entries in the gExceptionType[] array.\r
  **/\r
 UINTN\r
 MaxEfiException (\r
@@ -109,9 +109,9 @@ MaxEfiException (
 \r
 \r
 /**\r
-  Check to see if the ISA is supported. \r
+  Check to see if the ISA is supported.\r
   ISA = Instruction Set Architecture\r
\r
+\r
   @retval TRUE if Isa is supported,\r
       FALSE otherwise.\r
 **/\r
@@ -128,14 +128,14 @@ CheckIsa (
  This takes in the register number and the System Context, and returns a pointer to the RegNumber-th register in gdb ordering\r
  It is, by default, set to find the register pointer of the IA32 member\r
 \r
- @param   SystemContext     Register content at time of the exception \r
+ @param   SystemContext     Register content at time of the exception\r
  @param   RegNumber       The register to which we want to find a pointer\r
  @retval  the pointer to the RegNumber-th pointer\r
  **/\r
 UINTN *\r
 FindPointerToRegister(\r
   IN  EFI_SYSTEM_CONTEXT  SystemContext,\r
-  IN  UINTN               RegNumber  \r
+  IN  UINTN               RegNumber\r
   )\r
 {\r
   UINT8 *TempPtr;\r
@@ -160,7 +160,7 @@ BasicReadRegister (
   )\r
 {\r
   UINTN RegSize;\r
-  \r
+\r
   RegSize = 0;\r
   while (RegSize < REG_SIZE) {\r
     *OutBufPtr++ = mHexToStr[((*FindPointerToRegister(SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];\r
@@ -171,8 +171,8 @@ BasicReadRegister (
 }\r
 \r
 \r
-/** ‘p n’ \r
- Reads the n-th register's value into an output buffer and sends it as a packet \r
+/** ‘p n’\r
+ Reads the n-th register's value into an output buffer and sends it as a packet\r
 \r
  @param   SystemContext   Register content at time of the exception\r
  @param   InBuffer      Pointer to the input buffer received from gdb server\r
@@ -187,7 +187,7 @@ ReadNthRegister (
   UINTN RegNumber;\r
   CHAR8 OutBuffer[9]; // 1 reg=8 hex chars, and the end '\0' (escape seq)\r
   CHAR8 *OutBufPtr;   // pointer to the output buffer\r
-  \r
+\r
   RegNumber = AsciiStrHexToUintn (&InBuffer[1]);\r
 \r
   if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {\r
@@ -203,14 +203,14 @@ ReadNthRegister (
 }\r
 \r
 \r
-/** ‘g’ \r
- Reads the general registers into an output buffer  and sends it as a packet \r
+/** ‘g’\r
+ Reads the general registers into an output buffer  and sends it as a packet\r
 \r
  @param   SystemContext     Register content at time of the exception\r
  **/\r
 VOID\r
 EFIAPI\r
-ReadGeneralRegisters (  \r
+ReadGeneralRegisters (\r
   IN  EFI_SYSTEM_CONTEXT      SystemContext\r
   )\r
 {\r
@@ -219,7 +219,7 @@ ReadGeneralRegisters (
   CHAR8 *OutBufPtr;   // pointer to the output buffer\r
 \r
   OutBufPtr = OutBuffer;\r
-  for(i = 0 ; i < sizeof (gRegisterOffsets)/sizeof (UINTN) ; i++) {  // there are only 16 registers to read   \r
+  for(i = 0 ; i < sizeof (gRegisterOffsets)/sizeof (UINTN) ; i++) {  // there are only 16 registers to read\r
     OutBufPtr = BasicReadRegister(SystemContext, i, OutBufPtr);\r
   }\r
 \r
@@ -246,26 +246,26 @@ BasicWriteRegister (
   UINTN RegSize;\r
   UINTN TempValue; // the value transferred from a hex char\r
   UINT32 NewValue; // the new value of the RegNumber-th Register\r
-  \r
+\r
   NewValue = 0;\r
   RegSize = 0;\r
   while (RegSize < REG_SIZE) {\r
     TempValue = HexCharToInt(*InBufPtr++);\r
-    \r
+\r
    if (TempValue < 0) {\r
-      SendError (GDB_EBADMEMDATA); \r
+      SendError (GDB_EBADMEMDATA);\r
       return NULL;\r
     }\r
 \r
     NewValue += (TempValue << (RegSize+4));\r
     TempValue = HexCharToInt(*InBufPtr++);\r
-    \r
+\r
     if (TempValue < 0) {\r
-      SendError (GDB_EBADMEMDATA); \r
+      SendError (GDB_EBADMEMDATA);\r
       return NULL;\r
     }\r
-    \r
-    NewValue += (TempValue << RegSize); \r
+\r
+    NewValue += (TempValue << RegSize);\r
     RegSize = RegSize + 8;\r
   }\r
   *(FindPointerToRegister(SystemContext, RegNumber)) = NewValue;\r
@@ -290,19 +290,19 @@ WriteNthRegister (
   CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE];  // put the 'n..' part of the message into this array\r
   CHAR8 *RegNumBufPtr;\r
   CHAR8 *InBufPtr; // pointer to the input buffer\r
-  \r
+\r
   // find the register number to write\r
   InBufPtr = &InBuffer[1];\r
   RegNumBufPtr = RegNumBuffer;\r
   while (*InBufPtr != '=') {\r
     *RegNumBufPtr++ = *InBufPtr++;\r
-  } \r
+  }\r
   *RegNumBufPtr = '\0';\r
-  RegNumber = AsciiStrHexToUintn (RegNumBuffer); \r
+  RegNumber = AsciiStrHexToUintn (RegNumBuffer);\r
 \r
   // check if this is a valid Register Number\r
   if ((RegNumber < 0) || (RegNumber >= sizeof (gRegisterOffsets)/sizeof (UINTN))) {\r
-       SendError (GDB_EINVALIDREGNUM); \r
+       SendError (GDB_EINVALIDREGNUM);\r
     return;\r
   }\r
   InBufPtr++;  // skips the '=' character\r
@@ -327,16 +327,16 @@ WriteGeneralRegisters (
   UINTN  i;\r
   CHAR8 *InBufPtr; /// pointer to the input buffer\r
 \r
-  // check to see if the buffer is the right size which is \r
-  // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129 \r
+  // check to see if the buffer is the right size which is\r
+  // 1 (for 'G') + 16 (for 16 registers) * 8 ( for 8 hex chars each) = 129\r
   if (AsciiStrLen(InBuffer) != 129) { // 16 regs, 8 hex chars each, and the end '\0' (escape seq)\r
-       //Bad message. Message is not the right length \r
-    SendError (GDB_EBADBUFSIZE); \r
+       //Bad message. Message is not the right length\r
+    SendError (GDB_EBADBUFSIZE);\r
     return;\r
   }\r
 \r
   InBufPtr = &InBuffer[1];\r
-  \r
+\r
   // Read the new values for the registers from the input buffer to an array, NewValueArray.\r
   // The values in the array are in the gdb ordering\r
   for(i=0; i < sizeof (gRegisterOffsets)/sizeof (UINTN); i++) {  // there are only 16 registers to write\r
@@ -346,11 +346,11 @@ WriteGeneralRegisters (
   SendSuccess();\r
 }\r
 \r
-/** ‘c [addr ]’ \r
- Continue. addr is Address to resume. If addr is omitted, resume at current \r
+/** ‘c [addr ]’\r
+ Continue. addr is Address to resume. If addr is omitted, resume at current\r
  Address.\r
\r
- @param   SystemContext     Register content at time of the exception  \r
+\r
+ @param   SystemContext     Register content at time of the exception\r
  **/\r
 VOID\r
 EFIAPI\r
@@ -361,15 +361,15 @@ ContinueAtAddress (
 {\r
   if (PacketData[1] != '\0') {\r
     SystemContext.SystemContextIa32->Eip = AsciiStrHexToUintn (&PacketData[1]);\r
-  } \r
+  }\r
 }\r
 \r
 \r
 /** ‘s [addr ]’\r
- Single step. addr is the Address at which to resume. If addr is omitted, resume \r
+ Single step. addr is the Address at which to resume. If addr is omitted, resume\r
  at same Address.\r
\r
- @param   SystemContext     Register content at time of the exception  \r
+\r
+ @param   SystemContext     Register content at time of the exception\r
  **/\r
 VOID\r
 EFIAPI\r
@@ -421,9 +421,9 @@ GetBreakpointDataAddress (
 \r
   @param  SystemContext  Register content at time of the exception\r
 \r
-  @retval {1-4}          Currently detected breakpoint value   \r
+  @retval {1-4}          Currently detected breakpoint value\r
   @retval 0              No breakpoint detected.\r
\r
+\r
 **/\r
 UINTN\r
 GetBreakpointDetected (\r
@@ -444,7 +444,7 @@ GetBreakpointDetected (
   } else if (Dr6.Bits.B3 == 1) {\r
     BreakpointNumber = 4;\r
   } else {\r
-    BreakpointNumber = 0;  //No breakpoint detected \r
+    BreakpointNumber = 0;  //No breakpoint detected\r
   }\r
 \r
   return BreakpointNumber;\r
@@ -454,13 +454,13 @@ GetBreakpointDetected (
 /**\r
   Returns Breakpoint type (InstructionExecution, DataWrite, DataRead or DataReadWrite)\r
   based on the Breakpoint number\r
-  \r
+\r
   @param  SystemContext        Register content at time of the exception\r
   @param  BreakpointNumber     Breakpoint number\r
-  \r
+\r
   @retval BREAK_TYPE           Breakpoint type value read from register DR7 RWn field\r
                                For unknown value, it returns NotSupported.\r
-  \r
+\r
 **/\r
 BREAK_TYPE\r
 GetBreakpointType (\r
@@ -474,22 +474,22 @@ GetBreakpointType (
   Dr7.UintN = SystemContext.SystemContextIa32->Dr7;\r
 \r
   if (BreakpointNumber == 1) {\r
-    Type = (BREAK_TYPE) Dr7.Bits.RW0;  \r
+    Type = (BREAK_TYPE) Dr7.Bits.RW0;\r
   } else if (BreakpointNumber == 2) {\r
-    Type = (BREAK_TYPE) Dr7.Bits.RW1;  \r
+    Type = (BREAK_TYPE) Dr7.Bits.RW1;\r
   } else if (BreakpointNumber == 3) {\r
-    Type = (BREAK_TYPE) Dr7.Bits.RW2;  \r
+    Type = (BREAK_TYPE) Dr7.Bits.RW2;\r
   } else if (BreakpointNumber == 4) {\r
-    Type = (BREAK_TYPE) Dr7.Bits.RW3;  \r
+    Type = (BREAK_TYPE) Dr7.Bits.RW3;\r
   }\r
 \r
   return Type;\r
 }\r
 \r
 \r
-/** \r
+/**\r
   Parses Length and returns the length which DR7 LENn field accepts.\r
-  For example: If we receive 1-Byte length then we should return 0. \r
+  For example: If we receive 1-Byte length then we should return 0.\r
                Zero gets written to DR7 LENn field.\r
 \r
   @param  Length  Breakpoint length in Bytes (1 byte, 2 byte, 4 byte)\r
@@ -502,7 +502,7 @@ ConvertLengthData (
   IN     UINTN   Length\r
   )\r
 {\r
-  if (Length == 1) {         //1-Byte length \r
+  if (Length == 1) {         //1-Byte length\r
     return 0;\r
   } else if (Length == 2) {  //2-Byte length\r
     return 1;\r
@@ -515,8 +515,8 @@ ConvertLengthData (
 \r
 \r
 /**\r
-  Finds the next free debug register. If all the registers are occupied then \r
-  EFI_OUT_OF_RESOURCES is returned.  \r
+  Finds the next free debug register. If all the registers are occupied then\r
+  EFI_OUT_OF_RESOURCES is returned.\r
 \r
   @param  SystemContext   Register content at time of the exception\r
   @param  Register        Register value (0 - 3 for the first free debug register)\r
@@ -553,11 +553,11 @@ FindNextFreeDebugRegister (
 /**\r
   Enables the debug register. Writes Address value to appropriate DR0-3 register.\r
   Sets LENn, Gn, RWn bits in DR7 register.\r
\r
+\r
   @param  SystemContext   Register content at time of the exception\r
-  @param  Register        Register value (0 - 3) \r
+  @param  Register        Register value (0 - 3)\r
   @param  Address         Breakpoint address value\r
-  @param  Type            Breakpoint type (Instruction, Data write, Data read \r
+  @param  Type            Breakpoint type (Instruction, Data write, Data read\r
                           or write etc.)\r
 \r
   @retval EFI_STATUS      Appropriate status value.\r
@@ -577,15 +577,15 @@ EnableDebugRegister (
   //Convert length data\r
   Length = ConvertLengthData (Length);\r
 \r
-  //For Instruction execution, length should be 0 \r
+  //For Instruction execution, length should be 0\r
   //(Ref. Intel reference manual 18.2.4)\r
   if ((Type == 0) && (Length != 0)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
\r
+\r
   //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle\r
   //software breakpoint. We should send empty packet in both these cases.\r
-  if ((Type == (BREAK_TYPE)DataRead) || \r
+  if ((Type == (BREAK_TYPE)DataRead) ||\r
       (Type == (BREAK_TYPE)SoftwareBreakpoint)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
@@ -617,7 +617,7 @@ EnableDebugRegister (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  //Update Dr7 with appropriate Gn, RWn and LENn bits \r
+  //Update Dr7 with appropriate Gn, RWn and LENn bits\r
   SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;\r
 \r
   return EFI_SUCCESS;\r
@@ -633,7 +633,7 @@ EnableDebugRegister (
   @param  SystemContext  Register content at time of the exception\r
   @param  Address        Breakpoint address value\r
   @param  Length         Breakpoint length value\r
-  @param  Type           Breakpoint type (Instruction, Data write, \r
+  @param  Type           Breakpoint type (Instruction, Data write,\r
                          Data read or write etc.)\r
   @param  Register       Register value to be returned\r
 \r
@@ -653,7 +653,7 @@ FindMatchingDebugRegister (
 \r
   //Hardware doesn't support ReadWatch (z3 packet) type. GDB can handle\r
   //software breakpoint. We should send empty packet in both these cases.\r
-  if ((Type == (BREAK_TYPE)DataRead) || \r
+  if ((Type == (BREAK_TYPE)DataRead) ||\r
       (Type == (BREAK_TYPE)SoftwareBreakpoint)) {\r
     return EFI_UNSUPPORTED;\r
   }\r
@@ -663,24 +663,24 @@ FindMatchingDebugRegister (
 \r
   Dr7.UintN = SystemContext.SystemContextIa32->Dr7;\r
 \r
-  if ((Dr7.Bits.G0 == 1) && \r
+  if ((Dr7.Bits.G0 == 1) &&\r
       (Dr7.Bits.LEN0 == Length) &&\r
-      (Dr7.Bits.RW0 == Type) && \r
+      (Dr7.Bits.RW0 == Type) &&\r
       (Address == SystemContext.SystemContextIa32->Dr0)) {\r
     *Register = 0;\r
-  } else if ((Dr7.Bits.G1 == 1) && \r
+  } else if ((Dr7.Bits.G1 == 1) &&\r
              (Dr7.Bits.LEN1 == Length) &&\r
-             (Dr7.Bits.RW1 == Type) && \r
+             (Dr7.Bits.RW1 == Type) &&\r
              (Address == SystemContext.SystemContextIa32->Dr1)) {\r
     *Register = 1;\r
-  } else if ((Dr7.Bits.G2 == 1) && \r
+  } else if ((Dr7.Bits.G2 == 1) &&\r
              (Dr7.Bits.LEN2 == Length) &&\r
-             (Dr7.Bits.RW2 == Type) && \r
+             (Dr7.Bits.RW2 == Type) &&\r
              (Address == SystemContext.SystemContextIa32->Dr2)) {\r
     *Register = 2;\r
-  } else if ((Dr7.Bits.G3 == 1) && \r
+  } else if ((Dr7.Bits.G3 == 1) &&\r
              (Dr7.Bits.LEN3 == Length) &&\r
-             (Dr7.Bits.RW3 == Type) && \r
+             (Dr7.Bits.RW3 == Type) &&\r
              (Address == SystemContext.SystemContextIa32->Dr3)) {\r
     *Register = 3;\r
   } else {\r
@@ -704,12 +704,12 @@ FindMatchingDebugRegister (
 EFI_STATUS\r
 DisableDebugRegister (\r
  IN  EFI_SYSTEM_CONTEXT  SystemContext,\r
- IN  UINTN               Register  \r
+ IN  UINTN               Register\r
  )\r
 {\r
   IA32_DR7  Dr7;\r
   UINTN Address = 0;\r
\r
+\r
   //Read DR7 register so appropriate Gn, RWn and LENn bits can be turned off.\r
   Dr7.UintN = SystemContext.SystemContextIa32->Dr7;\r
 \r
@@ -863,15 +863,15 @@ RemoveBreakPoint (
   }\r
 \r
   switch (Type) {\r
-  \r
+\r
     case    0:   //Software breakpoint\r
       BreakType = SoftwareBreakpoint;\r
       break;\r
-      \r
+\r
     case    1:   //Hardware breakpoint\r
       BreakType = InstructionExecution;\r
       break;\r
-      \r
+\r
     case    2:   //Write watchpoint\r
       BreakType = DataWrite;\r
       break;\r