]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EmbeddedPkg/GdbStub/SerialIo.c
BaseTools/Capsule: Do not support -o with --dump-info
[mirror_edk2.git] / EmbeddedPkg / GdbStub / SerialIo.c
index ed062684434cc5c2eccfc988d4c1770bec62032d..32ceaf1233b9da97f304a320862dac91844287c7 100644 (file)
@@ -1,13 +1,13 @@
 /** @file\r
-  Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system \r
+  Serial IO Abstraction for GDB stub. This allows an EFI consoles that shows up on the system\r
   running GDB. One consle for error information and another console for user input/output.\r
-  \r
-  Basic packet format is $packet-data#checksum. So every comand has 4 bytes of overhead: $, \r
-  #, 0, 0. The 0 and 0 are the ascii characters for the checksum. \r
-  \r
+\r
+  Basic packet format is $packet-data#checksum. So every comand has 4 bytes of overhead: $,\r
+  #, 0, 0. The 0 and 0 are the ascii characters for the checksum.\r
+\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
@@ -22,7 +22,7 @@
 \r
 //\r
 // Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c\r
-// here we need to wait for the periodic callback to do this. \r
+// here we need to wait for the periodic callback to do this.\r
 //\r
 BOOLEAN gCtrlCBreakFlag = FALSE;\r
 \r
@@ -34,9 +34,9 @@ BOOLEAN gCtrlCBreakFlag = FALSE;
 BOOLEAN gProcessingFPacket = FALSE;\r
 \r
 /**\r
-  Process a control-C break message. \r
-  \r
-  Currently a place holder, remove the ASSERT when it gets implemented. \r
+  Process a control-C break message.\r
+\r
+  Currently a place holder, remove the ASSERT when it gets implemented.\r
 \r
   @param  ErrNo   Error infomration from the F reply packet or other source\r
 \r
@@ -62,55 +62,55 @@ GdbCtrlCBreakMessage (
   @param  Packet  Packet to parse like an F reply packet\r
   @param  ErrNo   Buffer to hold Count bytes that were read\r
 \r
-  @retval -1      Error, not a valid F reply packet \r
-  @retval other   Return the return code from the F reply packet \r
+  @retval -1      Error, not a valid F reply packet\r
+  @retval other   Return the return code from the F reply packet\r
 \r
 **/\r
 INTN\r
 GdbParseFReplyPacket (\r
   IN  CHAR8   *Packet,\r
-  OUT UINTN   *ErrNo   \r
+  OUT UINTN   *ErrNo\r
   )\r
 {\r
   INTN   RetCode;\r
-   \r
+\r
   if (Packet[0] != 'F') {\r
     // A valid responce would be an F packet\r
     return -1;\r
   }\r
-  \r
+\r
   RetCode = AsciiStrHexToUintn (&Packet[1]);\r
-  \r
-  // Find 1st comma \r
-  for (;*Packet != '\0' && *Packet != ',';  Packet++);  \r
+\r
+  // Find 1st comma\r
+  for (;*Packet != '\0' && *Packet != ',';  Packet++);\r
   if (*Packet == '\0') {\r
     *ErrNo = 0;\r
     return RetCode;\r
   }\r
-  \r
+\r
   *ErrNo = AsciiStrHexToUintn (++Packet);\r
 \r
-  // Find 2nd comma \r
-  for (;*Packet != '\0' && *Packet != ',';  Packet++);  \r
+  // Find 2nd comma\r
+  for (;*Packet != '\0' && *Packet != ',';  Packet++);\r
   if (*Packet == '\0') {\r
     return RetCode;\r
   }\r
-  \r
+\r
   if (*(++Packet) == 'C') {\r
-    GdbCtrlCBreakMessage (*ErrNo);  \r
+    GdbCtrlCBreakMessage (*ErrNo);\r
   }\r
-  \r
+\r
   return RetCode;\r
 }\r
 \r
 \r
 /**\r
-  Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates \r
+  Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates\r
   the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.\r
 \r
   @param  FileDescriptor   Device to talk to.\r
   @param  Buffer           Buffer to hold Count bytes that were read\r
-  @param  Count            Number of bytes to transfer. \r
+  @param  Count            Number of bytes to transfer.\r
 \r
   @retval -1               Error\r
   @retval {other}          Number of bytes read.\r
@@ -128,19 +128,19 @@ GdbRead (
   INTN    RetCode;\r
   UINTN   ErrNo;\r
   BOOLEAN ReceiveDone = FALSE;\r
-   \r
+\r
   // Send:\r
   // "Fread,XX,YYYYYYYY,XX\r
   //\r
   // XX - FileDescriptor in ASCII\r
-  // YYYYYYYY - Buffer address in ASCII \r
+  // YYYYYYYY - Buffer address in ASCII\r
   // XX - Count in ASCII\r
   // SS - check sum\r
   //\r
   Size = AsciiSPrint (Packet, sizeof (Packet), "Fread,%x,%x,%x", FileDescriptor, Buffer, Count);\r
   // Packet array is too small if you got this ASSERT\r
   ASSERT (Size < sizeof (Packet));\r
-  \r
+\r
   gProcessingFPacket = TRUE;\r
   SendPacket (Packet);\r
   Print ((CHAR16 *)L"Packet sent..\n");\r
@@ -175,25 +175,25 @@ GdbRead (
 \r
   RetCode = GdbParseFReplyPacket (Packet, &ErrNo);\r
   Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);\r
-  \r
+\r
   if (ErrNo > 0) {\r
     //Send error to the host if there is any.\r
     SendError ((UINT8)ErrNo);\r
   }\r
-  \r
+\r
   gProcessingFPacket = FALSE;\r
 \r
   return RetCode;\r
-}  \r
-  \r
+}\r
+\r
 \r
 /**\r
-  Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates \r
-  nothing was written. On error -1 is returned. \r
+  Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates\r
+  nothing was written. On error -1 is returned.\r
 \r
   @param  FileDescriptor   Device to talk to.\r
   @param  Buffer           Buffer to hold Count bytes that are to be written\r
-  @param  Count            Number of bytes to transfer. \r
+  @param  Count            Number of bytes to transfer.\r
 \r
   @retval -1               Error\r
   @retval {other}          Number of bytes written.\r
@@ -216,14 +216,14 @@ GdbWrite (
   // #Fwrite,XX,YYYYYYYY,XX$SS\r
   //\r
   // XX - FileDescriptor in ASCII\r
-  // YYYYYYYY - Buffer address in ASCII \r
+  // YYYYYYYY - Buffer address in ASCII\r
   // XX - Count in ASCII\r
   // SS - check sum\r
   //\r
   Size = AsciiSPrint (Packet, sizeof (Packet), "Fwrite,%x,%x,%x", FileDescriptor, Buffer, Count);\r
   // Packet array is too small if you got this ASSERT\r
   ASSERT (Size < sizeof (Packet));\r
-  \r
+\r
   SendPacket (Packet);\r
   Print ((CHAR16 *)L"Packet sent..\n");\r
 \r
@@ -235,7 +235,7 @@ GdbWrite (
     // Process GDB commands\r
     switch (Packet[0]) {\r
       //Read memory command.\r
-      //m addr,length. \r
+      //m addr,length.\r
       case    'm':\r
         ReadFromMemory (Packet);\r
         break;\r
@@ -243,13 +243,13 @@ GdbWrite (
       //Fretcode, errno, Ctrl-C flag\r
       //retcode - Count read\r
       case    'F':\r
-        //Once target receives F reply packet that means the previous \r
+        //Once target receives F reply packet that means the previous\r
         //transactions are finished.\r
         ReceiveDone = TRUE;\r
         break;\r
-      \r
+\r
       //Send empty buffer\r
-      default    :  \r
+      default    :\r
         SendNotSupported();\r
         break;\r
     }\r
@@ -262,7 +262,7 @@ GdbWrite (
   if (ErrNo > 0) {\r
     SendError((UINT8)ErrNo);\r
   }\r
\r
+\r
   return RetCode;\r
 }\r
 \r
@@ -271,7 +271,7 @@ GdbWrite (
   Reset the serial device.\r
 \r
   @param  This              Protocol instance pointer.\r
-                            \r
+\r
   @retval EFI_SUCCESS       The device was reset.\r
   @retval EFI_DEVICE_ERROR  The serial device could not be reset.\r
 \r
@@ -287,7 +287,7 @@ GdbSerialReset (
 \r
 \r
 /**\r
-  Sets the baud rate, receive FIFO depth, transmit/receice time out, parity, \r
+  Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,\r
   data buts, and stop bits on a serial device.\r
 \r
   @param  This             Protocol instance pointer.\r
@@ -355,7 +355,7 @@ GdbSerialSetControl (
 \r
   @param  This              Protocol instance pointer.\r
   @param  Control           A pointer to return the current Control signals from the serial device.\r
-                            \r
+\r
   @retval EFI_SUCCESS       The control bits were read from the serial device.\r
   @retval EFI_DEVICE_ERROR  The serial device is not functioning correctly.\r
 \r
@@ -396,16 +396,16 @@ GdbSerialWrite (
   UINTN            Return;\r
 \r
   SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);\r
-  \r
+\r
   Return = GdbWrite (SerialDev->OutFileDescriptor, Buffer, *BufferSize);\r
   if (Return == (UINTN)-1) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   if (Return != *BufferSize) {\r
     *BufferSize = Return;\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -435,27 +435,27 @@ GdbSerialRead (
   UINTN            Return;\r
 \r
   SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);\r
-  \r
+\r
   Return = GdbRead (SerialDev->InFileDescriptor, Buffer, *BufferSize);\r
   if (Return == (UINTN)-1) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
-  \r
+\r
   if (Return != *BufferSize) {\r
     *BufferSize = Return;\r
   }\r
-  \r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
 \r
-// \r
+//\r
 // Template used to initailize the GDB Serial IO protocols\r
 //\r
 GDB_SERIAL_DEV gdbSerialDevTemplate = {\r
   GDB_SERIAL_DEV_SIGNATURE,\r
   NULL,\r
-  \r
+\r
   { // SerialIo\r
     SERIAL_IO_INTERFACE_REVISION,\r
     GdbSerialReset,\r
@@ -504,7 +504,7 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
 \r
 /**\r
   Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.\r
-  \r
+\r
   These console show up on the remote system running GDB\r
 \r
 **/\r
@@ -520,21 +520,21 @@ GdbInitializeSerialConsole (
   // Use the template to make a copy of the Serial Console private data structure.\r
   StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV),  &gdbSerialDevTemplate);\r
   ASSERT (StdOutSerialDev != NULL);\r
-  \r
+\r
   // Fixup pointer after the copy\r
   StdOutSerialDev->SerialIo.Mode = &StdOutSerialDev->SerialMode;\r
-  \r
+\r
   StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV),  &gdbSerialDevTemplate);\r
   ASSERT (StdErrSerialDev != NULL);\r
 \r
   // Fixup pointer and modify stuff that is different for StdError\r
-  StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;  \r
+  StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;\r
   StdErrSerialDev->DevicePath.Index = 1;\r
   StdErrSerialDev->OutFileDescriptor = GDB_STDERR;\r
-  \r
+\r
   // Make a new handle with Serial IO protocol and its device path on it.\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &StdOutSerialDev->Handle, \r
+                  &StdOutSerialDev->Handle,\r
                   &gEfiSerialIoProtocolGuid,   &StdOutSerialDev->SerialIo,\r
                   &gEfiDevicePathProtocolGuid, &StdOutSerialDev->DevicePath,\r
                   NULL\r
@@ -543,7 +543,7 @@ GdbInitializeSerialConsole (
 \r
   // Make a new handle with Serial IO protocol and its device path on it.\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &StdErrSerialDev->Handle, \r
+                  &StdErrSerialDev->Handle,\r
                   &gEfiSerialIoProtocolGuid,   &StdErrSerialDev->SerialIo,\r
                   &gEfiDevicePathProtocolGuid, &StdErrSerialDev->DevicePath,\r
                   NULL\r