mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-28 16:14:04 +02:00
Code scrub for DebugPortDxe.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6665 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
64735d2414
commit
2d285faad8
@ -29,19 +29,37 @@ EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
DEBUGPORT_DEVICE *gDebugPortDevice;
|
DEBUGPORT_DEVICE mDebugPortDevice = {
|
||||||
|
DEBUGPORT_DEVICE_SIGNATURE,
|
||||||
|
(EFI_HANDLE) 0,
|
||||||
|
(EFI_HANDLE) 0,
|
||||||
|
(VOID *) NULL,
|
||||||
|
(EFI_DEVICE_PATH_PROTOCOL *) NULL,
|
||||||
|
{
|
||||||
|
DebugPortReset,
|
||||||
|
DebugPortRead,
|
||||||
|
DebugPortWrite,
|
||||||
|
DebugPortPoll
|
||||||
|
},
|
||||||
|
(EFI_HANDLE) 0,
|
||||||
|
(EFI_SERIAL_IO_PROTOCOL *) NULL,
|
||||||
|
DEBUGPORT_UART_DEFAULT_BAUDRATE,
|
||||||
|
DEBUGPORT_UART_DEFAULT_FIFO_DEPTH,
|
||||||
|
DEBUGPORT_UART_DEFAULT_TIMEOUT,
|
||||||
|
(EFI_PARITY_TYPE) DEBUGPORT_UART_DEFAULT_PARITY,
|
||||||
|
DEBUGPORT_UART_DEFAULT_DATA_BITS,
|
||||||
|
(EFI_STOP_BITS_TYPE) DEBUGPORT_UART_DEFAULT_STOP_BITS
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Local worker function to obtain device path information from DebugPort variable.
|
Local worker function to obtain device path information from DebugPort variable.
|
||||||
|
|
||||||
Records requested settings in DebugPort device structure.
|
Records requested settings in DebugPort device structure.
|
||||||
|
|
||||||
@param DebugPortDevice Pointer to instance of dubug port device.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
GetDebugPortVariable (
|
GetDebugPortVariable (
|
||||||
DEBUGPORT_DEVICE *DebugPortDevice
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
UINTN DataSize;
|
UINTN DataSize;
|
||||||
@ -55,51 +73,51 @@ GetDebugPortVariable (
|
|||||||
&gEfiDebugPortVariableGuid,
|
&gEfiDebugPortVariableGuid,
|
||||||
NULL,
|
NULL,
|
||||||
&DataSize,
|
&DataSize,
|
||||||
DebugPortDevice->DebugPortVariable
|
mDebugPortDevice.DebugPortVariable
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Status == EFI_BUFFER_TOO_SMALL) {
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
||||||
if (gDebugPortDevice->DebugPortVariable != NULL) {
|
if (mDebugPortDevice.DebugPortVariable != NULL) {
|
||||||
FreePool (gDebugPortDevice->DebugPortVariable);
|
FreePool (mDebugPortDevice.DebugPortVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPortDevice->DebugPortVariable = AllocatePool (DataSize);
|
mDebugPortDevice.DebugPortVariable = AllocatePool (DataSize);
|
||||||
if (DebugPortDevice->DebugPortVariable != NULL) {
|
if (mDebugPortDevice.DebugPortVariable != NULL) {
|
||||||
gRT->GetVariable (
|
gRT->GetVariable (
|
||||||
(CHAR16 *) EFI_DEBUGPORT_VARIABLE_NAME,
|
(CHAR16 *) EFI_DEBUGPORT_VARIABLE_NAME,
|
||||||
&gEfiDebugPortVariableGuid,
|
&gEfiDebugPortVariableGuid,
|
||||||
NULL,
|
NULL,
|
||||||
&DataSize,
|
&DataSize,
|
||||||
DebugPortDevice->DebugPortVariable
|
mDebugPortDevice.DebugPortVariable
|
||||||
);
|
);
|
||||||
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) DebugPortDevice->DebugPortVariable;
|
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) mDebugPortDevice.DebugPortVariable;
|
||||||
while (!IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
|
while (!IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
|
||||||
DevicePath = NextDevicePathNode (DevicePath);
|
DevicePath = NextDevicePathNode (DevicePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsDevicePathEnd (DevicePath)) {
|
if (IsDevicePathEnd (DevicePath)) {
|
||||||
FreePool (gDebugPortDevice->DebugPortVariable);
|
FreePool (mDebugPortDevice.DebugPortVariable);
|
||||||
DebugPortDevice->DebugPortVariable = NULL;
|
mDebugPortDevice.DebugPortVariable = NULL;
|
||||||
} else {
|
} else {
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&DebugPortDevice->BaudRate,
|
&mDebugPortDevice.BaudRate,
|
||||||
&((UART_DEVICE_PATH *) DevicePath)->BaudRate,
|
&((UART_DEVICE_PATH *) DevicePath)->BaudRate,
|
||||||
sizeof (((UART_DEVICE_PATH *) DevicePath)->BaudRate)
|
sizeof (((UART_DEVICE_PATH *) DevicePath)->BaudRate)
|
||||||
);
|
);
|
||||||
DebugPortDevice->ReceiveFifoDepth = DEBUGPORT_UART_DEFAULT_FIFO_DEPTH;
|
mDebugPortDevice.ReceiveFifoDepth = DEBUGPORT_UART_DEFAULT_FIFO_DEPTH;
|
||||||
DebugPortDevice->Timeout = DEBUGPORT_UART_DEFAULT_TIMEOUT;
|
mDebugPortDevice.Timeout = DEBUGPORT_UART_DEFAULT_TIMEOUT;
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&DebugPortDevice->Parity,
|
&mDebugPortDevice.Parity,
|
||||||
&((UART_DEVICE_PATH *) DevicePath)->Parity,
|
&((UART_DEVICE_PATH *) DevicePath)->Parity,
|
||||||
sizeof (((UART_DEVICE_PATH *) DevicePath)->Parity)
|
sizeof (((UART_DEVICE_PATH *) DevicePath)->Parity)
|
||||||
);
|
);
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&DebugPortDevice->DataBits,
|
&mDebugPortDevice.DataBits,
|
||||||
&((UART_DEVICE_PATH *) DevicePath)->DataBits,
|
&((UART_DEVICE_PATH *) DevicePath)->DataBits,
|
||||||
sizeof (((UART_DEVICE_PATH *) DevicePath)->DataBits)
|
sizeof (((UART_DEVICE_PATH *) DevicePath)->DataBits)
|
||||||
);
|
);
|
||||||
CopyMem (
|
CopyMem (
|
||||||
&DebugPortDevice->StopBits,
|
&mDebugPortDevice.StopBits,
|
||||||
&((UART_DEVICE_PATH *) DevicePath)->StopBits,
|
&((UART_DEVICE_PATH *) DevicePath)->StopBits,
|
||||||
sizeof (((UART_DEVICE_PATH *) DevicePath)->StopBits)
|
sizeof (((UART_DEVICE_PATH *) DevicePath)->StopBits)
|
||||||
);
|
);
|
||||||
@ -108,11 +126,6 @@ GetDebugPortVariable (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// implementation code
|
|
||||||
//
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Debug Port Driver entry point.
|
Debug Port Driver entry point.
|
||||||
|
|
||||||
@ -149,29 +162,6 @@ InitializeDebugPortDriver (
|
|||||||
&gDebugPortComponentName2
|
&gDebugPortComponentName2
|
||||||
);
|
);
|
||||||
ASSERT_EFI_ERROR (Status);
|
ASSERT_EFI_ERROR (Status);
|
||||||
//
|
|
||||||
// Allocate and Initialize dev structure
|
|
||||||
//
|
|
||||||
gDebugPortDevice = AllocateZeroPool (sizeof (DEBUGPORT_DEVICE));
|
|
||||||
if (gDebugPortDevice == NULL) {
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// Fill in static and default pieces of device structure first.
|
|
||||||
//
|
|
||||||
gDebugPortDevice->Signature = DEBUGPORT_DEVICE_SIGNATURE;
|
|
||||||
|
|
||||||
gDebugPortDevice->DebugPortInterface.Reset = DebugPortReset;
|
|
||||||
gDebugPortDevice->DebugPortInterface.Read = DebugPortRead;
|
|
||||||
gDebugPortDevice->DebugPortInterface.Write = DebugPortWrite;
|
|
||||||
gDebugPortDevice->DebugPortInterface.Poll = DebugPortPoll;
|
|
||||||
|
|
||||||
gDebugPortDevice->BaudRate = DEBUGPORT_UART_DEFAULT_BAUDRATE;
|
|
||||||
gDebugPortDevice->ReceiveFifoDepth = DEBUGPORT_UART_DEFAULT_FIFO_DEPTH;
|
|
||||||
gDebugPortDevice->Timeout = DEBUGPORT_UART_DEFAULT_TIMEOUT;
|
|
||||||
gDebugPortDevice->Parity = (EFI_PARITY_TYPE) DEBUGPORT_UART_DEFAULT_PARITY;
|
|
||||||
gDebugPortDevice->DataBits = DEBUGPORT_UART_DEFAULT_DATA_BITS;
|
|
||||||
gDebugPortDevice->StopBits = (EFI_STOP_BITS_TYPE) DEBUGPORT_UART_DEFAULT_STOP_BITS;
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -214,6 +204,7 @@ DebugPortSupported (
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Check to see that there's not a debugport protocol already published
|
// Check to see that there's not a debugport protocol already published
|
||||||
|
// Question: Why do we prevent debugport protocol published on more one device?
|
||||||
//
|
//
|
||||||
if (gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **) &DebugPortInterface) != EFI_NOT_FOUND) {
|
if (gBS->LocateProtocol (&gEfiDebugPortProtocolGuid, NULL, (VOID **) &DebugPortInterface) != EFI_NOT_FOUND) {
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
@ -221,16 +212,16 @@ DebugPortSupported (
|
|||||||
//
|
//
|
||||||
// Read DebugPort variable to determine debug port selection and parameters
|
// Read DebugPort variable to determine debug port selection and parameters
|
||||||
//
|
//
|
||||||
GetDebugPortVariable (gDebugPortDevice);
|
GetDebugPortVariable ();
|
||||||
|
|
||||||
if (gDebugPortDevice->DebugPortVariable != NULL) {
|
if (mDebugPortDevice.DebugPortVariable != NULL) {
|
||||||
//
|
//
|
||||||
// There's a DEBUGPORT variable, so do LocateDevicePath and check to see if
|
// There's a DEBUGPORT variable, so do LocateDevicePath and check to see if
|
||||||
// the closest matching handle matches the controller handle, and if it does,
|
// the closest matching handle matches the controller handle, and if it does,
|
||||||
// check to see that the remaining device path has the DebugPort GUIDed messaging
|
// check to see that the remaining device path has the DebugPort GUIDed messaging
|
||||||
// device path only. Otherwise, it's a mismatch and EFI_UNSUPPORTED is returned.
|
// device path only. Otherwise, it's a mismatch and EFI_UNSUPPORTED is returned.
|
||||||
//
|
//
|
||||||
Dp1 = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) gDebugPortDevice->DebugPortVariable);
|
Dp1 = DuplicateDevicePath ((EFI_DEVICE_PATH_PROTOCOL *) mDebugPortDevice.DebugPortVariable);
|
||||||
if (Dp1 == NULL) {
|
if (Dp1 == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
@ -247,7 +238,11 @@ DebugPortSupported (
|
|||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status == EFI_SUCCESS && (Dp2->Type != 3 || Dp2->SubType != 10 || *((UINT16 *) Dp2->Length) != 20)) {
|
if (Status == EFI_SUCCESS &&
|
||||||
|
(Dp2->Type != MESSAGING_DEVICE_PATH ||
|
||||||
|
Dp2->SubType != MSG_VENDOR_DP ||
|
||||||
|
*((UINT16 *) Dp2->Length) != sizeof (VENDOR_DEVICE_PATH))) {
|
||||||
|
|
||||||
Status = EFI_UNSUPPORTED;
|
Status = EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +308,7 @@ DebugPortStart (
|
|||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
&gEfiSerialIoProtocolGuid,
|
&gEfiSerialIoProtocolGuid,
|
||||||
(VOID **) &gDebugPortDevice->SerialIoBinding,
|
(VOID **) &mDebugPortDevice.SerialIoBinding,
|
||||||
This->DriverBindingHandle,
|
This->DriverBindingHandle,
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
|
EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
|
||||||
@ -322,34 +317,34 @@ DebugPortStart (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
gDebugPortDevice->SerialIoDeviceHandle = ControllerHandle;
|
mDebugPortDevice.SerialIoDeviceHandle = ControllerHandle;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Initialize the Serial Io interface...
|
// Initialize the Serial Io interface...
|
||||||
//
|
//
|
||||||
Status = gDebugPortDevice->SerialIoBinding->SetAttributes (
|
Status = mDebugPortDevice.SerialIoBinding->SetAttributes (
|
||||||
gDebugPortDevice->SerialIoBinding,
|
mDebugPortDevice.SerialIoBinding,
|
||||||
gDebugPortDevice->BaudRate,
|
mDebugPortDevice.BaudRate,
|
||||||
gDebugPortDevice->ReceiveFifoDepth,
|
mDebugPortDevice.ReceiveFifoDepth,
|
||||||
gDebugPortDevice->Timeout,
|
mDebugPortDevice.Timeout,
|
||||||
gDebugPortDevice->Parity,
|
mDebugPortDevice.Parity,
|
||||||
gDebugPortDevice->DataBits,
|
mDebugPortDevice.DataBits,
|
||||||
gDebugPortDevice->StopBits
|
mDebugPortDevice.StopBits
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
gDebugPortDevice->BaudRate = 0;
|
mDebugPortDevice.BaudRate = 0;
|
||||||
gDebugPortDevice->Parity = DefaultParity;
|
mDebugPortDevice.Parity = DefaultParity;
|
||||||
gDebugPortDevice->DataBits = 0;
|
mDebugPortDevice.DataBits = 0;
|
||||||
gDebugPortDevice->StopBits = DefaultStopBits;
|
mDebugPortDevice.StopBits = DefaultStopBits;
|
||||||
gDebugPortDevice->ReceiveFifoDepth = 0;
|
mDebugPortDevice.ReceiveFifoDepth = 0;
|
||||||
Status = gDebugPortDevice->SerialIoBinding->SetAttributes (
|
Status = mDebugPortDevice.SerialIoBinding->SetAttributes (
|
||||||
gDebugPortDevice->SerialIoBinding,
|
mDebugPortDevice.SerialIoBinding,
|
||||||
gDebugPortDevice->BaudRate,
|
mDebugPortDevice.BaudRate,
|
||||||
gDebugPortDevice->ReceiveFifoDepth,
|
mDebugPortDevice.ReceiveFifoDepth,
|
||||||
gDebugPortDevice->Timeout,
|
mDebugPortDevice.Timeout,
|
||||||
gDebugPortDevice->Parity,
|
mDebugPortDevice.Parity,
|
||||||
gDebugPortDevice->DataBits,
|
mDebugPortDevice.DataBits,
|
||||||
gDebugPortDevice->StopBits
|
mDebugPortDevice.StopBits
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
@ -362,7 +357,7 @@ DebugPortStart (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gDebugPortDevice->SerialIoBinding->Reset (gDebugPortDevice->SerialIoBinding);
|
mDebugPortDevice.SerialIoBinding->Reset (mDebugPortDevice.SerialIoBinding);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create device path instance for DebugPort
|
// Create device path instance for DebugPort
|
||||||
@ -378,19 +373,19 @@ DebugPortStart (
|
|||||||
SetDevicePathEndNode (Dp1);
|
SetDevicePathEndNode (Dp1);
|
||||||
}
|
}
|
||||||
|
|
||||||
gDebugPortDevice->DebugPortDevicePath = AppendDevicePathNode (Dp1, (EFI_DEVICE_PATH_PROTOCOL *) &DebugPortDP);
|
mDebugPortDevice.DebugPortDevicePath = AppendDevicePathNode (Dp1, (EFI_DEVICE_PATH_PROTOCOL *) &DebugPortDP);
|
||||||
if (gDebugPortDevice->DebugPortDevicePath == NULL) {
|
if (mDebugPortDevice.DebugPortDevicePath == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// Publish DebugPort and Device Path protocols
|
// Publish DebugPort and Device Path protocols
|
||||||
//
|
//
|
||||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||||
&gDebugPortDevice->DebugPortDeviceHandle,
|
&mDebugPortDevice.DebugPortDeviceHandle,
|
||||||
&gEfiDevicePathProtocolGuid,
|
&gEfiDevicePathProtocolGuid,
|
||||||
gDebugPortDevice->DebugPortDevicePath,
|
mDebugPortDevice.DebugPortDevicePath,
|
||||||
&gEfiDebugPortProtocolGuid,
|
&gEfiDebugPortProtocolGuid,
|
||||||
&gDebugPortDevice->DebugPortInterface,
|
&mDebugPortDevice.DebugPortInterface,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -409,9 +404,9 @@ DebugPortStart (
|
|||||||
Status = gBS->OpenProtocol (
|
Status = gBS->OpenProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
&gEfiSerialIoProtocolGuid,
|
&gEfiSerialIoProtocolGuid,
|
||||||
(VOID **) &gDebugPortDevice->SerialIoBinding,
|
(VOID **) &mDebugPortDevice.SerialIoBinding,
|
||||||
This->DriverBindingHandle,
|
This->DriverBindingHandle,
|
||||||
gDebugPortDevice->DebugPortDeviceHandle,
|
mDebugPortDevice.DebugPortDeviceHandle,
|
||||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -421,7 +416,7 @@ DebugPortStart (
|
|||||||
|
|
||||||
BufferSize = 48;
|
BufferSize = 48;
|
||||||
DebugPortWrite (
|
DebugPortWrite (
|
||||||
&gDebugPortDevice->DebugPortInterface,
|
&mDebugPortDevice.DebugPortInterface,
|
||||||
0,
|
0,
|
||||||
&BufferSize,
|
&BufferSize,
|
||||||
"DebugPort driver failed to open child controller\n\n"
|
"DebugPort driver failed to open child controller\n\n"
|
||||||
@ -438,15 +433,16 @@ DebugPortStart (
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG_CODE_BEGIN ();
|
DEBUG_CODE_BEGIN ();
|
||||||
UINTN BufferSize;
|
UINTN BufferSize;
|
||||||
|
|
||||||
BufferSize = 38;
|
BufferSize = 38;
|
||||||
DebugPortWrite (
|
DebugPortWrite (
|
||||||
&gDebugPortDevice->DebugPortInterface,
|
&mDebugPortDevice.DebugPortInterface,
|
||||||
0,
|
0,
|
||||||
&BufferSize,
|
&BufferSize,
|
||||||
"Hello World from the DebugPort driver\n\n"
|
"Hello World from the DebugPort driver\n\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
DEBUG_CODE_END ();
|
DEBUG_CODE_END ();
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -488,7 +484,7 @@ DebugPortStop (
|
|||||||
ControllerHandle
|
ControllerHandle
|
||||||
);
|
);
|
||||||
|
|
||||||
gDebugPortDevice->SerialIoBinding = NULL;
|
mDebugPortDevice.SerialIoBinding = NULL;
|
||||||
|
|
||||||
gBS->CloseProtocol (
|
gBS->CloseProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
@ -497,7 +493,7 @@ DebugPortStop (
|
|||||||
ControllerHandle
|
ControllerHandle
|
||||||
);
|
);
|
||||||
|
|
||||||
FreePool (gDebugPortDevice->DebugPortDevicePath);
|
FreePool (mDebugPortDevice.DebugPortDevicePath);
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
@ -505,10 +501,10 @@ DebugPortStop (
|
|||||||
// Disconnect SerialIo child handle
|
// Disconnect SerialIo child handle
|
||||||
//
|
//
|
||||||
Status = gBS->CloseProtocol (
|
Status = gBS->CloseProtocol (
|
||||||
gDebugPortDevice->SerialIoDeviceHandle,
|
mDebugPortDevice.SerialIoDeviceHandle,
|
||||||
&gEfiSerialIoProtocolGuid,
|
&gEfiSerialIoProtocolGuid,
|
||||||
This->DriverBindingHandle,
|
This->DriverBindingHandle,
|
||||||
gDebugPortDevice->DebugPortDeviceHandle
|
mDebugPortDevice.DebugPortDeviceHandle
|
||||||
);
|
);
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
@ -518,11 +514,11 @@ DebugPortStop (
|
|||||||
// Unpublish our protocols (DevicePath, DebugPort)
|
// Unpublish our protocols (DevicePath, DebugPort)
|
||||||
//
|
//
|
||||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
Status = gBS->UninstallMultipleProtocolInterfaces (
|
||||||
gDebugPortDevice->DebugPortDeviceHandle,
|
mDebugPortDevice.DebugPortDeviceHandle,
|
||||||
&gEfiDevicePathProtocolGuid,
|
&gEfiDevicePathProtocolGuid,
|
||||||
gDebugPortDevice->DebugPortDevicePath,
|
mDebugPortDevice.DebugPortDevicePath,
|
||||||
&gEfiDebugPortProtocolGuid,
|
&gEfiDebugPortProtocolGuid,
|
||||||
&gDebugPortDevice->DebugPortInterface,
|
&mDebugPortDevice.DebugPortInterface,
|
||||||
NULL
|
NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -530,13 +526,13 @@ DebugPortStop (
|
|||||||
gBS->OpenProtocol (
|
gBS->OpenProtocol (
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
&gEfiSerialIoProtocolGuid,
|
&gEfiSerialIoProtocolGuid,
|
||||||
(VOID **) &gDebugPortDevice->SerialIoBinding,
|
(VOID **) &mDebugPortDevice.SerialIoBinding,
|
||||||
This->DriverBindingHandle,
|
This->DriverBindingHandle,
|
||||||
gDebugPortDevice->DebugPortDeviceHandle,
|
mDebugPortDevice.DebugPortDeviceHandle,
|
||||||
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
gDebugPortDevice->DebugPortDeviceHandle = NULL;
|
mDebugPortDevice.DebugPortDeviceHandle = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -604,6 +600,7 @@ DebugPortRead (
|
|||||||
DebugPortDevice = DEBUGPORT_DEVICE_FROM_THIS (This);
|
DebugPortDevice = DEBUGPORT_DEVICE_FROM_THIS (This);
|
||||||
BufferPtr = Buffer;
|
BufferPtr = Buffer;
|
||||||
LocalBufferSize = *BufferSize;
|
LocalBufferSize = *BufferSize;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Status = DebugPortDevice->SerialIoBinding->Read (
|
Status = DebugPortDevice->SerialIoBinding->Read (
|
||||||
DebugPortDevice->SerialIoBinding,
|
DebugPortDevice->SerialIoBinding,
|
||||||
@ -733,7 +730,6 @@ DebugPortPoll (
|
|||||||
|
|
||||||
@retval EFI_SUCCESS Unload Debug Port driver successfully.
|
@retval EFI_SUCCESS Unload Debug Port driver successfully.
|
||||||
@retval EFI_ABORTED Serial IO is still binding.
|
@retval EFI_ABORTED Serial IO is still binding.
|
||||||
@retval others Fails to unload Debug Port driver.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
@ -742,32 +738,16 @@ ImageUnloadHandler (
|
|||||||
EFI_HANDLE ImageHandle
|
EFI_HANDLE ImageHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
if (mDebugPortDevice.SerialIoBinding != NULL) {
|
||||||
|
|
||||||
if (gDebugPortDevice->SerialIoBinding != NULL) {
|
|
||||||
return EFI_ABORTED;
|
return EFI_ABORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = gBS->UninstallMultipleProtocolInterfaces (
|
|
||||||
ImageHandle,
|
|
||||||
&gEfiDriverBindingProtocolGuid,
|
|
||||||
&gDebugPortDevice->DriverBindingInterface,
|
|
||||||
&gEfiComponentNameProtocolGuid,
|
|
||||||
&gDebugPortDevice->ComponentNameInterface,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
//
|
//
|
||||||
// Clean up allocations
|
// Clean up allocations
|
||||||
//
|
//
|
||||||
if (gDebugPortDevice->DebugPortVariable != NULL) {
|
if (mDebugPortDevice.DebugPortVariable != NULL) {
|
||||||
FreePool (gDebugPortDevice->DebugPortVariable);
|
FreePool (mDebugPortDevice.DebugPortVariable);
|
||||||
}
|
}
|
||||||
|
|
||||||
FreePool (gDebugPortDevice);
|
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -54,8 +54,6 @@ typedef struct {
|
|||||||
EFI_HANDLE DebugPortDeviceHandle;
|
EFI_HANDLE DebugPortDeviceHandle;
|
||||||
VOID *DebugPortVariable;
|
VOID *DebugPortVariable;
|
||||||
|
|
||||||
EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface;
|
|
||||||
EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface;
|
|
||||||
EFI_DEVICE_PATH_PROTOCOL *DebugPortDevicePath;
|
EFI_DEVICE_PATH_PROTOCOL *DebugPortDevicePath;
|
||||||
EFI_DEBUGPORT_PROTOCOL DebugPortInterface;
|
EFI_DEBUGPORT_PROTOCOL DebugPortInterface;
|
||||||
|
|
||||||
@ -77,7 +75,7 @@ typedef struct {
|
|||||||
#define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200
|
#define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200
|
||||||
#define DEBUGPORT_UART_DEFAULT_PARITY 0
|
#define DEBUGPORT_UART_DEFAULT_PARITY 0
|
||||||
#define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16
|
#define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16
|
||||||
#define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 // 5 ms
|
#define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 ///< 5 ms
|
||||||
#define DEBUGPORT_UART_DEFAULT_DATA_BITS 8
|
#define DEBUGPORT_UART_DEFAULT_DATA_BITS 8
|
||||||
#define DEBUGPORT_UART_DEFAULT_STOP_BITS 1
|
#define DEBUGPORT_UART_DEFAULT_STOP_BITS 1
|
||||||
|
|
||||||
@ -85,11 +83,6 @@ typedef struct {
|
|||||||
|
|
||||||
#define IS_UART_DEVICEPATH(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
|
#define IS_UART_DEVICEPATH(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
|
||||||
|
|
||||||
//
|
|
||||||
// globals
|
|
||||||
//
|
|
||||||
extern DEBUGPORT_DEVICE *gDebugPortDevice;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Debug Port Driver entry pointo.
|
Debug Port Driver entry pointo.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user