summaryrefslogtreecommitdiffstats
path: root/EmbeddedPkg/GdbStub/SerialIo.c
diff options
context:
space:
mode:
Diffstat (limited to 'EmbeddedPkg/GdbStub/SerialIo.c')
-rw-r--r--EmbeddedPkg/GdbStub/SerialIo.c159
1 files changed, 77 insertions, 82 deletions
diff --git a/EmbeddedPkg/GdbStub/SerialIo.c b/EmbeddedPkg/GdbStub/SerialIo.c
index 08d1763c30..9970ab687e 100644
--- a/EmbeddedPkg/GdbStub/SerialIo.c
+++ b/EmbeddedPkg/GdbStub/SerialIo.c
@@ -18,14 +18,14 @@
// Set TRUE if F Reply package signals a ctrl-c. We can not process the Ctrl-c
// here we need to wait for the periodic callback to do this.
//
-BOOLEAN gCtrlCBreakFlag = FALSE;
+BOOLEAN gCtrlCBreakFlag = FALSE;
//
// If the periodic callback is called while we are processing an F packet we need
// to let the callback know to not read from the serial stream as it could steal
// characters from the F response packet
//
-BOOLEAN gProcessingFPacket = FALSE;
+BOOLEAN gProcessingFPacket = FALSE;
/**
Process a control-C break message.
@@ -35,21 +35,19 @@ BOOLEAN gProcessingFPacket = FALSE;
@param ErrNo Error information from the F reply packet or other source
**/
-
VOID
GdbCtrlCBreakMessage (
- IN UINTN ErrNo
+ IN UINTN ErrNo
)
{
// See D.10.5 of gdb.pdf
// This should look like a break message. Should look like SIGINT
/* TODO: Make sure if we should do anything with ErrNo */
- //Turn on the global Ctrl-C flag.
+ // Turn on the global Ctrl-C flag.
gCtrlCBreakFlag = TRUE;
}
-
/**
Parse the F reply packet and extract the return value and an ErrNo if it exists.
@@ -62,11 +60,11 @@ GdbCtrlCBreakMessage (
**/
INTN
GdbParseFReplyPacket (
- IN CHAR8 *Packet,
- OUT UINTN *ErrNo
+ IN CHAR8 *Packet,
+ OUT UINTN *ErrNo
)
{
- INTN RetCode;
+ INTN RetCode;
if (Packet[0] != 'F') {
// A valid response would be an F packet
@@ -76,7 +74,9 @@ GdbParseFReplyPacket (
RetCode = AsciiStrHexToUintn (&Packet[1]);
// Find 1st comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
+ for ( ; *Packet != '\0' && *Packet != ','; Packet++) {
+ }
+
if (*Packet == '\0') {
*ErrNo = 0;
return RetCode;
@@ -85,7 +85,9 @@ GdbParseFReplyPacket (
*ErrNo = AsciiStrHexToUintn (++Packet);
// Find 2nd comma
- for (;*Packet != '\0' && *Packet != ','; Packet++);
+ for ( ; *Packet != '\0' && *Packet != ','; Packet++) {
+ }
+
if (*Packet == '\0') {
return RetCode;
}
@@ -97,7 +99,6 @@ GdbParseFReplyPacket (
return RetCode;
}
-
/**
Read data from a FileDescriptor. On success number of bytes read is returned. Zero indicates
the end of a file. On error -1 is returned. If count is zero, GdbRead returns zero.
@@ -112,16 +113,16 @@ GdbParseFReplyPacket (
**/
INTN
GdbRead (
- IN INTN FileDescriptor,
- OUT VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT VOID *Buffer,
+ IN UINTN Count
)
{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
+ CHAR8 Packet[128];
+ UINTN Size;
+ INTN RetCode;
+ UINTN ErrNo;
+ BOOLEAN ReceiveDone = FALSE;
// Send:
// "Fread,XX,YYYYYYYY,XX
@@ -146,23 +147,23 @@ GdbRead (
// Process GDB commands
switch (Packet[0]) {
- //Write memory command.
- //M addr,length:XX...
+ // Write memory command.
+ // M addr,length:XX...
case 'M':
WriteToMemory (Packet);
break;
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
+ // Fretcode, errno, Ctrl-C flag
+ // retcode - Count read
case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
+ // Once target receives F reply packet that means the previous
+ // transactions are finished.
ReceiveDone = TRUE;
break;
- //Send empty buffer
- default :
- SendNotSupported();
+ // Send empty buffer
+ default:
+ SendNotSupported ();
break;
}
} while (ReceiveDone == FALSE);
@@ -171,7 +172,7 @@ GdbRead (
Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
if (ErrNo > 0) {
- //Send error to the host if there is any.
+ // Send error to the host if there is any.
SendError ((UINT8)ErrNo);
}
@@ -180,7 +181,6 @@ GdbRead (
return RetCode;
}
-
/**
Write data to a FileDescriptor. On success number of bytes written is returned. Zero indicates
nothing was written. On error -1 is returned.
@@ -195,16 +195,16 @@ GdbRead (
**/
INTN
GdbWrite (
- IN INTN FileDescriptor,
- OUT CONST VOID *Buffer,
- IN UINTN Count
+ IN INTN FileDescriptor,
+ OUT CONST VOID *Buffer,
+ IN UINTN Count
)
{
- CHAR8 Packet[128];
- UINTN Size;
- INTN RetCode;
- UINTN ErrNo;
- BOOLEAN ReceiveDone = FALSE;
+ CHAR8 Packet[128];
+ UINTN Size;
+ INTN RetCode;
+ UINTN ErrNo;
+ BOOLEAN ReceiveDone = FALSE;
// Send:
// #Fwrite,XX,YYYYYYYY,XX$SS
@@ -228,23 +228,23 @@ GdbWrite (
// Process GDB commands
switch (Packet[0]) {
- //Read memory command.
- //m addr,length.
+ // Read memory command.
+ // m addr,length.
case 'm':
ReadFromMemory (Packet);
break;
- //Fretcode, errno, Ctrl-C flag
- //retcode - Count read
+ // Fretcode, errno, Ctrl-C flag
+ // retcode - Count read
case 'F':
- //Once target receives F reply packet that means the previous
- //transactions are finished.
+ // Once target receives F reply packet that means the previous
+ // transactions are finished.
ReceiveDone = TRUE;
break;
- //Send empty buffer
- default :
- SendNotSupported();
+ // Send empty buffer
+ default:
+ SendNotSupported ();
break;
}
} while (ReceiveDone == FALSE);
@@ -252,15 +252,14 @@ GdbWrite (
RetCode = GdbParseFReplyPacket (Packet, &ErrNo);
Print ((CHAR16 *)L"RetCode: %x..ErrNo: %x..\n", RetCode, ErrNo);
- //Send error to the host if there is any.
+ // Send error to the host if there is any.
if (ErrNo > 0) {
- SendError((UINT8)ErrNo);
+ SendError ((UINT8)ErrNo);
}
return RetCode;
}
-
/**
Reset the serial device.
@@ -279,7 +278,6 @@ GdbSerialReset (
return EFI_SUCCESS;
}
-
/**
Sets the baud rate, receive FIFO depth, transmit/receive time out, parity,
data buts, and stop bits on a serial device.
@@ -321,7 +319,6 @@ GdbSerialSetAttributes (
return EFI_UNSUPPORTED;
}
-
/**
Set the control bits on a serial device
@@ -343,7 +340,6 @@ GdbSerialSetControl (
return EFI_UNSUPPORTED;
}
-
/**
Retrieves the status of the control bits on a serial device
@@ -364,7 +360,6 @@ GdbSerialGetControl (
return EFI_UNSUPPORTED;
}
-
/**
Writes data to a serial device.
@@ -387,7 +382,7 @@ GdbSerialWrite (
)
{
GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
+ UINTN Return;
SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
@@ -416,7 +411,6 @@ GdbSerialWrite (
@retval EFI_TIMEOUT The data write was stopped due to a timeout.
**/
-
EFI_STATUS
EFIAPI
GdbSerialRead (
@@ -426,7 +420,7 @@ GdbSerialRead (
)
{
GDB_SERIAL_DEV *SerialDev;
- UINTN Return;
+ UINTN Return;
SerialDev = GDB_SERIAL_DEV_FROM_THIS (This);
@@ -442,11 +436,10 @@ GdbSerialRead (
return EFI_SUCCESS;
}
-
//
// Template used to initialize the GDB Serial IO protocols
//
-GDB_SERIAL_DEV gdbSerialDevTemplate = {
+GDB_SERIAL_DEV gdbSerialDevTemplate = {
GDB_SERIAL_DEV_SIGNATURE,
NULL,
@@ -460,14 +453,14 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
GdbSerialRead,
NULL
},
- { // SerialMode
- 0, // ControlMask
- 0, // Timeout
- 0, // BaudRate
- 1, // RceiveFifoDepth
- 0, // DataBits
- 0, // Parity
- 0 // StopBits
+ { // SerialMode
+ 0, // ControlMask
+ 0, // Timeout
+ 0, // BaudRate
+ 1, // RceiveFifoDepth
+ 0, // DataBits
+ 0, // Parity
+ 0 // StopBits
},
{
{
@@ -475,8 +468,8 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
HARDWARE_DEVICE_PATH,
HW_VENDOR_DP,
{
- (UINT8) (sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)) >> 8)
+ (UINT8)(sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)),
+ (UINT8)((sizeof (VENDOR_DEVICE_PATH) + sizeof (UINT32)) >> 8)
},
},
EFI_SERIAL_IO_PROTOCOL_GUID
@@ -486,8 +479,8 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL)),
- (UINT8) (sizeof (EFI_DEVICE_PATH_PROTOCOL) >> 8)
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
+ (UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL) >> 8)
}
},
},
@@ -495,7 +488,6 @@ GDB_SERIAL_DEV gdbSerialDevTemplate = {
GDB_STDOUT
};
-
/**
Make two serial consoles: 1) StdIn and StdOut via GDB. 2) StdErr via GDB.
@@ -512,25 +504,27 @@ GdbInitializeSerialConsole (
GDB_SERIAL_DEV *StdErrSerialDev;
// Use the template to make a copy of the Serial Console private data structure.
- StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
+ StdOutSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
ASSERT (StdOutSerialDev != NULL);
// Fixup pointer after the copy
StdOutSerialDev->SerialIo.Mode = &StdOutSerialDev->SerialMode;
- StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
+ StdErrSerialDev = AllocateCopyPool (sizeof (GDB_SERIAL_DEV), &gdbSerialDevTemplate);
ASSERT (StdErrSerialDev != NULL);
// Fixup pointer and modify stuff that is different for StdError
- StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;
- StdErrSerialDev->DevicePath.Index = 1;
+ StdErrSerialDev->SerialIo.Mode = &StdErrSerialDev->SerialMode;
+ StdErrSerialDev->DevicePath.Index = 1;
StdErrSerialDev->OutFileDescriptor = GDB_STDERR;
// Make a new handle with Serial IO protocol and its device path on it.
Status = gBS->InstallMultipleProtocolInterfaces (
&StdOutSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdOutSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdOutSerialDev->DevicePath,
+ &gEfiSerialIoProtocolGuid,
+ &StdOutSerialDev->SerialIo,
+ &gEfiDevicePathProtocolGuid,
+ &StdOutSerialDev->DevicePath,
NULL
);
ASSERT_EFI_ERROR (Status);
@@ -538,10 +532,11 @@ GdbInitializeSerialConsole (
// Make a new handle with Serial IO protocol and its device path on it.
Status = gBS->InstallMultipleProtocolInterfaces (
&StdErrSerialDev->Handle,
- &gEfiSerialIoProtocolGuid, &StdErrSerialDev->SerialIo,
- &gEfiDevicePathProtocolGuid, &StdErrSerialDev->DevicePath,
+ &gEfiSerialIoProtocolGuid,
+ &StdErrSerialDev->SerialIo,
+ &gEfiDevicePathProtocolGuid,
+ &StdErrSerialDev->DevicePath,
NULL
);
ASSERT_EFI_ERROR (Status);
}
-