21 DEBUGPORT_DRIVER_VERSION,
27 DEBUGPORT_DEVICE_SIGNATURE,
39 DEBUGPORT_UART_DEFAULT_BAUDRATE,
40 DEBUGPORT_UART_DEFAULT_FIFO_DEPTH,
43 DEBUGPORT_UART_DEFAULT_DATA_BITS,
62 GetVariable2 (EFI_DEBUGPORT_VARIABLE_NAME, &gEfiDebugPortVariableGuid, (VOID **)&DebugPortVariable, &DataSize);
63 if (DebugPortVariable ==
NULL) {
67 DevicePath = DebugPortVariable;
68 while (!
IsDevicePathEnd (DevicePath) && !IS_UART_DEVICEPATH (DevicePath)) {
77 &mDebugPortDevice.BaudRate,
81 mDebugPortDevice.ReceiveFifoDepth = DEBUGPORT_UART_DEFAULT_FIFO_DEPTH;
84 &mDebugPortDevice.Parity,
89 &mDebugPortDevice.DataBits,
94 &mDebugPortDevice.StopBits,
98 return DebugPortVariable;
132 &gDebugPortDriverBinding,
134 &gDebugPortComponentName,
135 &gDebugPortComponentName2
182 if (
gBS->LocateProtocol (&gEfiDebugPortProtocolGuid,
NULL, (VOID **)&DebugPortInterface) != EFI_NOT_FOUND) {
183 return EFI_UNSUPPORTED;
191 if (DebugPortVariable !=
NULL) {
198 DevicePath = DebugPortVariable;
199 Status =
gBS->LocateDevicePath (
200 &gEfiSerialIoProtocolGuid,
205 if ((Status ==
EFI_SUCCESS) && (TempHandle != ControllerHandle)) {
206 Status = EFI_UNSUPPORTED;
211 (DevicePath->
SubType != MSG_VENDOR_DP) ||
214 Status = EFI_UNSUPPORTED;
218 Status = EFI_UNSUPPORTED;
222 if (EFI_ERROR (Status)) {
227 Status =
gBS->OpenProtocol (
229 &gEfiSerialIoProtocolGuid,
231 This->DriverBindingHandle,
233 EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
235 if (EFI_ERROR (Status)) {
239 Status =
gBS->CloseProtocol (
241 &gEfiSerialIoProtocolGuid,
242 This->DriverBindingHandle,
276 Status =
gBS->OpenProtocol (
278 &gEfiSerialIoProtocolGuid,
279 (VOID **)&mDebugPortDevice.SerialIoBinding,
280 This->DriverBindingHandle,
282 EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
284 if (EFI_ERROR (Status)) {
288 mDebugPortDevice.SerialIoDeviceHandle = ControllerHandle;
293 Status = mDebugPortDevice.SerialIoBinding->SetAttributes (
294 mDebugPortDevice.SerialIoBinding,
295 mDebugPortDevice.BaudRate,
296 mDebugPortDevice.ReceiveFifoDepth,
297 mDebugPortDevice.Timeout,
298 mDebugPortDevice.Parity,
299 mDebugPortDevice.DataBits,
300 mDebugPortDevice.StopBits
302 if (EFI_ERROR (Status)) {
303 mDebugPortDevice.BaudRate = 0;
304 mDebugPortDevice.Parity = DefaultParity;
305 mDebugPortDevice.DataBits = 0;
306 mDebugPortDevice.StopBits = DefaultStopBits;
307 mDebugPortDevice.ReceiveFifoDepth = 0;
308 Status = mDebugPortDevice.SerialIoBinding->SetAttributes (
309 mDebugPortDevice.SerialIoBinding,
310 mDebugPortDevice.BaudRate,
311 mDebugPortDevice.ReceiveFifoDepth,
312 mDebugPortDevice.Timeout,
313 mDebugPortDevice.Parity,
314 mDebugPortDevice.DataBits,
315 mDebugPortDevice.StopBits
317 if (EFI_ERROR (Status)) {
320 &gEfiSerialIoProtocolGuid,
321 This->DriverBindingHandle,
328 mDebugPortDevice.SerialIoBinding->Reset (mDebugPortDevice.SerialIoBinding);
334 DebugPortDP.Header.
SubType = MSG_VENDOR_DP;
336 CopyGuid (&DebugPortDP.Guid, &gEfiDebugPortDevicePathGuid);
345 if (mDebugPortDevice.DebugPortDevicePath ==
NULL) {
346 return EFI_OUT_OF_RESOURCES;
352 Status =
gBS->InstallMultipleProtocolInterfaces (
353 &mDebugPortDevice.DebugPortDeviceHandle,
354 &gEfiDevicePathProtocolGuid,
355 mDebugPortDevice.DebugPortDevicePath,
356 &gEfiDebugPortProtocolGuid,
357 &mDebugPortDevice.DebugPortInterface,
361 if (EFI_ERROR (Status)) {
364 &gEfiSerialIoProtocolGuid,
365 This->DriverBindingHandle,
374 Status =
gBS->OpenProtocol (
376 &gEfiSerialIoProtocolGuid,
377 (VOID **)&mDebugPortDevice.SerialIoBinding,
378 This->DriverBindingHandle,
379 mDebugPortDevice.DebugPortDeviceHandle,
380 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
383 if (EFI_ERROR (Status)) {
386 &gEfiSerialIoProtocolGuid,
387 This->DriverBindingHandle,
421 if (NumberOfChildren == 0) {
427 &gEfiSerialIoProtocolGuid,
428 This->DriverBindingHandle,
432 mDebugPortDevice.SerialIoBinding =
NULL;
436 &gEfiDevicePathProtocolGuid,
437 This->DriverBindingHandle,
441 FreePool (mDebugPortDevice.DebugPortDevicePath);
448 Status =
gBS->CloseProtocol (
449 mDebugPortDevice.SerialIoDeviceHandle,
450 &gEfiSerialIoProtocolGuid,
451 This->DriverBindingHandle,
452 mDebugPortDevice.DebugPortDeviceHandle
455 if (EFI_ERROR (Status)) {
462 Status =
gBS->UninstallMultipleProtocolInterfaces (
463 mDebugPortDevice.DebugPortDeviceHandle,
464 &gEfiDevicePathProtocolGuid,
465 mDebugPortDevice.DebugPortDevicePath,
466 &gEfiDebugPortProtocolGuid,
467 &mDebugPortDevice.DebugPortInterface,
471 if (EFI_ERROR (Status)) {
474 &gEfiSerialIoProtocolGuid,
475 (VOID **)&mDebugPortDevice.SerialIoBinding,
476 This->DriverBindingHandle,
477 mDebugPortDevice.DebugPortDeviceHandle,
478 EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
481 mDebugPortDevice.DebugPortDeviceHandle =
NULL;
512 This->Read (This, 0, &BufferSize, &BitBucket);
542 UINTN LocalBufferSize;
546 DebugPortDevice = DEBUGPORT_DEVICE_FROM_THIS (This);
548 LocalBufferSize = *BufferSize;
551 Status = DebugPortDevice->SerialIoBinding->Read (
552 DebugPortDevice->SerialIoBinding,
556 if (Status == EFI_TIMEOUT) {
562 }
else if (EFI_ERROR (Status)) {
566 BufferPtr += LocalBufferSize;
567 LocalBufferSize = *BufferSize - (BufferPtr - (UINT8 *)Buffer);
568 }
while (LocalBufferSize != 0 && Timeout > 0);
570 *BufferSize = (
UINTN)BufferPtr - (
UINTN)Buffer;
603 UINT32 SerialControl;
606 DebugPortDevice = DEBUGPORT_DEVICE_FROM_THIS (This);
609 for (Position = 0; Position < *BufferSize && !EFI_ERROR (Status); Position += WriteSize) {
610 DebugPortDevice->SerialIoBinding->GetControl (
611 DebugPortDevice->SerialIoBinding,
614 if (*BufferSize - Position < 8) {
615 WriteSize = *BufferSize - Position;
618 Status = DebugPortDevice->SerialIoBinding->Write (
619 DebugPortDevice->SerialIoBinding,
621 &((UINT8 *)Buffer)[Position]
625 *BufferSize = Position;
649 UINT32 SerialControl;
652 DebugPortDevice = DEBUGPORT_DEVICE_FROM_THIS (This);
654 Status = DebugPortDevice->SerialIoBinding->GetControl (
655 DebugPortDevice->SerialIoBinding,
659 if (!EFI_ERROR (Status)) {
660 if ((SerialControl & EFI_SERIAL_INPUT_BUFFER_EMPTY) != 0) {
661 Status = EFI_NOT_READY;
689 VOID *ComponentName2;
691 if (mDebugPortDevice.SerialIoBinding !=
NULL) {
698 Status =
gBS->HandleProtocol (ImageHandle, &gEfiComponentNameProtocolGuid, &ComponentName);
699 if (EFI_ERROR (Status)) {
700 ComponentName =
NULL;
703 Status =
gBS->HandleProtocol (ImageHandle, &gEfiComponentName2ProtocolGuid, &ComponentName2);
704 if (EFI_ERROR (Status)) {
705 ComponentName2 =
NULL;
708 if (ComponentName ==
NULL) {
709 if (ComponentName2 ==
NULL) {
710 Status =
gBS->UninstallMultipleProtocolInterfaces (
712 &gEfiDriverBindingProtocolGuid,
713 &gDebugPortDriverBinding,
717 Status =
gBS->UninstallMultipleProtocolInterfaces (
719 &gEfiDriverBindingProtocolGuid,
720 &gDebugPortDriverBinding,
721 &gEfiComponentName2ProtocolGuid,
727 if (ComponentName2 ==
NULL) {
728 Status =
gBS->UninstallMultipleProtocolInterfaces (
730 &gEfiDriverBindingProtocolGuid,
731 &gDebugPortDriverBinding,
732 &gEfiComponentNameProtocolGuid,
737 Status =
gBS->UninstallMultipleProtocolInterfaces (
739 &gEfiDriverBindingProtocolGuid,
740 &gDebugPortDriverBinding,
741 &gEfiComponentNameProtocolGuid,
743 &gEfiComponentName2ProtocolGuid,
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
EFI_STATUS EFIAPI DebugPortReset(IN EFI_DEBUGPORT_PROTOCOL *This)
EFI_STATUS EFIAPI DebugPortStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI DebugPortStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI DebugPortSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE ControllerHandle, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI ImageUnloadHandler(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI DebugPortPoll(IN EFI_DEBUGPORT_PROTOCOL *This)
EFI_STATUS EFIAPI DebugPortRead(IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, IN VOID *Buffer)
EFI_STATUS EFIAPI InitializeDebugPortDriver(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI DebugPortWrite(IN EFI_DEBUGPORT_PROTOCOL *This, IN UINT32 Timeout, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
EFI_DEVICE_PATH_PROTOCOL * GetDebugPortVariable(VOID)
#define MESSAGING_DEVICE_PATH
UINT16 EFIAPI SetDevicePathNodeLength(IN OUT VOID *Node, IN UINTN Length)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI AppendDevicePathNode(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL)
BOOLEAN EFIAPI IsDevicePathEnd(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI NextDevicePathNode(IN CONST VOID *Node)
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
VOID EFIAPI SetDevicePathEndNode(OUT VOID *Node)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define DEBUGPORT_UART_DEFAULT_TIMEOUT
5 ms
#define ASSERT_EFI_ERROR(StatusParameter)
EFI_STATUS EFIAPI GetVariable2(IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)