2 Definitions and prototypes for DebugPort driver.
4 Copyright (c) 2006 - 2008, Intel Corporation. <BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __DEBUGPORT_H__
16 #define __DEBUGPORT_H__
21 #include <Protocol/DevicePath.h>
22 #include <Protocol/ComponentName.h>
23 #include <Protocol/DriverBinding.h>
24 #include <Protocol/SerialIo.h>
25 #include <Protocol/DebugPort.h>
27 #include <Library/DebugLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/UefiLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/UefiRuntimeServicesTableLib.h>
34 #include <Library/DevicePathLib.h>
37 // Driver Binding Externs
39 extern EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding
;
40 extern EFI_COMPONENT_NAME_PROTOCOL gDebugPortComponentName
;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gDebugPortComponentName2
;
44 // local type definitions
46 #define DEBUGPORT_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')
49 // Device structure used by driver
53 EFI_HANDLE DriverBindingHandle
;
54 EFI_HANDLE DebugPortDeviceHandle
;
55 VOID
*DebugPortVariable
;
57 EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface
;
58 EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface
;
59 EFI_DEVICE_PATH_PROTOCOL
*DebugPortDevicePath
;
60 EFI_DEBUGPORT_PROTOCOL DebugPortInterface
;
62 EFI_HANDLE SerialIoDeviceHandle
;
63 EFI_SERIAL_IO_PROTOCOL
*SerialIoBinding
;
65 UINT32 ReceiveFifoDepth
;
67 EFI_PARITY_TYPE Parity
;
69 EFI_STOP_BITS_TYPE StopBits
;
72 #define DEBUGPORT_DEVICE_FROM_THIS(a) CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)
74 #define EFI_ACPI_PC_COMPORT_HID EISA_PNP_ID (0x0500)
75 #define EFI_ACPI_16550UART_HID EISA_PNP_ID (0x0501)
77 #define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200
78 #define DEBUGPORT_UART_DEFAULT_PARITY 0
79 #define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16
80 #define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 // 5 ms
81 #define DEBUGPORT_UART_DEFAULT_DATA_BITS 8
82 #define DEBUGPORT_UART_DEFAULT_STOP_BITS 1
84 #define DEBUGPORT_DRIVER_VERSION 1
86 #define EfiIsUartDevicePath(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
91 extern DEBUGPORT_DEVICE
*gDebugPortDevice
;
94 // Driver binding interface functions...
98 IN EFI_HANDLE ImageHandle
,
99 IN EFI_SYSTEM_TABLE
*SystemTable
105 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
106 IN EFI_HANDLE Controller
,
107 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
113 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
114 IN EFI_HANDLE Controller
,
115 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
121 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
122 IN EFI_HANDLE Controller
,
123 IN UINTN NumberOfChildren
,
124 IN EFI_HANDLE
*ChildHandleBuffer
128 // EFI Component Name Functions
131 Retrieves a Unicode string that is the user readable name of the driver.
133 This function retrieves the user readable name of a driver in the form of a
134 Unicode string. If the driver specified by This has a user readable name in
135 the language specified by Language, then a pointer to the driver name is
136 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
137 by This does not support the language specified by Language,
138 then EFI_UNSUPPORTED is returned.
140 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
141 EFI_COMPONENT_NAME_PROTOCOL instance.
143 @param Language[in] A pointer to a Null-terminated ASCII string
144 array indicating the language. This is the
145 language of the driver name that the caller is
146 requesting, and it must match one of the
147 languages specified in SupportedLanguages. The
148 number of languages supported by a driver is up
149 to the driver writer. Language is specified
150 in RFC 3066 or ISO 639-2 language code format.
152 @param DriverName[out] A pointer to the Unicode string to return.
153 This Unicode string is the name of the
154 driver specified by This in the language
155 specified by Language.
157 @retval EFI_SUCCESS The Unicode string for the Driver specified by
158 This and the language specified by Language was
159 returned in DriverName.
161 @retval EFI_INVALID_PARAMETER Language is NULL.
163 @retval EFI_INVALID_PARAMETER DriverName is NULL.
165 @retval EFI_UNSUPPORTED The driver specified by This does not support
166 the language specified by Language.
171 DebugPortComponentNameGetDriverName (
172 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
174 OUT CHAR16
**DriverName
179 Retrieves a Unicode string that is the user readable name of the controller
180 that is being managed by a driver.
182 This function retrieves the user readable name of the controller specified by
183 ControllerHandle and ChildHandle in the form of a Unicode string. If the
184 driver specified by This has a user readable name in the language specified by
185 Language, then a pointer to the controller name is returned in ControllerName,
186 and EFI_SUCCESS is returned. If the driver specified by This is not currently
187 managing the controller specified by ControllerHandle and ChildHandle,
188 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
189 support the language specified by Language, then EFI_UNSUPPORTED is returned.
191 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
192 EFI_COMPONENT_NAME_PROTOCOL instance.
194 @param ControllerHandle[in] The handle of a controller that the driver
195 specified by This is managing. This handle
196 specifies the controller whose name is to be
199 @param ChildHandle[in] The handle of the child controller to retrieve
200 the name of. This is an optional parameter that
201 may be NULL. It will be NULL for device
202 drivers. It will also be NULL for a bus drivers
203 that wish to retrieve the name of the bus
204 controller. It will not be NULL for a bus
205 driver that wishes to retrieve the name of a
208 @param Language[in] A pointer to a Null-terminated ASCII string
209 array indicating the language. This is the
210 language of the driver name that the caller is
211 requesting, and it must match one of the
212 languages specified in SupportedLanguages. The
213 number of languages supported by a driver is up
214 to the driver writer. Language is specified in
215 RFC 3066 or ISO 639-2 language code format.
217 @param ControllerName[out] A pointer to the Unicode string to return.
218 This Unicode string is the name of the
219 controller specified by ControllerHandle and
220 ChildHandle in the language specified by
221 Language from the point of view of the driver
224 @retval EFI_SUCCESS The Unicode string for the user readable name in
225 the language specified by Language for the
226 driver specified by This was returned in
229 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
231 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
234 @retval EFI_INVALID_PARAMETER Language is NULL.
236 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
238 @retval EFI_UNSUPPORTED The driver specified by This is not currently
239 managing the controller specified by
240 ControllerHandle and ChildHandle.
242 @retval EFI_UNSUPPORTED The driver specified by This does not support
243 the language specified by Language.
248 DebugPortComponentNameGetControllerName (
249 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
250 IN EFI_HANDLE ControllerHandle
,
251 IN EFI_HANDLE ChildHandle OPTIONAL
,
253 OUT CHAR16
**ControllerName
258 // DebugPort member functions
263 IN EFI_DEBUGPORT_PROTOCOL
*This
269 IN EFI_DEBUGPORT_PROTOCOL
*This
,
271 IN OUT UINTN
*BufferSize
,
278 IN EFI_DEBUGPORT_PROTOCOL
*This
,
280 IN OUT UINTN
*BufferSize
,
287 IN EFI_DEBUGPORT_PROTOCOL
*This