3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Definitions and prototypes for DebugPort driver
20 #ifndef __DEBUGPORT_H__
21 #define __DEBUGPORT_H__
26 #include <Protocol/DevicePath.h>
27 #include <Protocol/ComponentName.h>
28 #include <Protocol/DriverBinding.h>
29 #include <Protocol/SerialIo.h>
30 #include <Protocol/DebugPort.h>
32 #include <Library/DebugLib.h>
33 #include <Library/UefiDriverEntryPoint.h>
34 #include <Library/UefiLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/UefiRuntimeServicesTableLib.h>
39 #include <Library/DevicePathLib.h>
42 // Driver Binding Externs
44 extern EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding
;
45 extern EFI_COMPONENT_NAME_PROTOCOL gDebugPortComponentName
;
48 // local type definitions
50 #define DEBUGPORT_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')
53 // Device structure used by driver
57 EFI_HANDLE DriverBindingHandle
;
58 EFI_HANDLE DebugPortDeviceHandle
;
59 VOID
*DebugPortVariable
;
61 EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface
;
62 EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface
;
63 EFI_DEVICE_PATH_PROTOCOL
*DebugPortDevicePath
;
64 EFI_DEBUGPORT_PROTOCOL DebugPortInterface
;
66 EFI_HANDLE SerialIoDeviceHandle
;
67 EFI_SERIAL_IO_PROTOCOL
*SerialIoBinding
;
69 UINT32 ReceiveFifoDepth
;
71 EFI_PARITY_TYPE Parity
;
73 EFI_STOP_BITS_TYPE StopBits
;
76 #define DEBUGPORT_DEVICE_FROM_THIS(a) CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)
78 #define EFI_ACPI_PC_COMPORT_HID EISA_PNP_ID (0x0500)
79 #define EFI_ACPI_16550UART_HID EISA_PNP_ID (0x0501)
81 #define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200
82 #define DEBUGPORT_UART_DEFAULT_PARITY 0
83 #define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16
84 #define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 // 5 ms
85 #define DEBUGPORT_UART_DEFAULT_DATA_BITS 8
86 #define DEBUGPORT_UART_DEFAULT_STOP_BITS 1
88 #define DEBUGPORT_DRIVER_VERSION 1
90 #define EfiIsUartDevicePath(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
95 extern DEBUGPORT_DEVICE
*gDebugPortDevice
;
98 // Driver binding interface functions...
101 DebugPortEntryPoint (
102 IN EFI_HANDLE ImageHandle
,
103 IN EFI_SYSTEM_TABLE
*SystemTable
110 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
111 IN EFI_HANDLE Controller
,
112 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
119 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
120 IN EFI_HANDLE Controller
,
121 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
128 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
129 IN EFI_HANDLE Controller
,
130 IN UINTN NumberOfChildren
,
131 IN EFI_HANDLE
*ChildHandleBuffer
136 // EFI Component Name Functions
140 DebugPortComponentNameGetDriverName (
141 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
143 OUT CHAR16
**DriverName
149 DebugPortComponentNameGetControllerName (
150 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
151 IN EFI_HANDLE ControllerHandle
,
152 IN EFI_HANDLE ChildHandle OPTIONAL
,
154 OUT CHAR16
**ControllerName
159 // DebugPort member functions
164 IN EFI_DEBUGPORT_PROTOCOL
*This
171 IN EFI_DEBUGPORT_PROTOCOL
*This
,
173 IN OUT UINTN
*BufferSize
,
181 IN EFI_DEBUGPORT_PROTOCOL
*This
,
183 IN OUT UINTN
*BufferSize
,
191 IN EFI_DEBUGPORT_PROTOCOL
*This