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
;
46 extern EFI_COMPONENT_NAME2_PROTOCOL gDebugPortComponentName2
;
49 // local type definitions
51 #define DEBUGPORT_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')
54 // Device structure used by driver
58 EFI_HANDLE DriverBindingHandle
;
59 EFI_HANDLE DebugPortDeviceHandle
;
60 VOID
*DebugPortVariable
;
62 EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface
;
63 EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface
;
64 EFI_DEVICE_PATH_PROTOCOL
*DebugPortDevicePath
;
65 EFI_DEBUGPORT_PROTOCOL DebugPortInterface
;
67 EFI_HANDLE SerialIoDeviceHandle
;
68 EFI_SERIAL_IO_PROTOCOL
*SerialIoBinding
;
70 UINT32 ReceiveFifoDepth
;
72 EFI_PARITY_TYPE Parity
;
74 EFI_STOP_BITS_TYPE StopBits
;
77 #define DEBUGPORT_DEVICE_FROM_THIS(a) CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)
79 #define EFI_ACPI_PC_COMPORT_HID EISA_PNP_ID (0x0500)
80 #define EFI_ACPI_16550UART_HID EISA_PNP_ID (0x0501)
82 #define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200
83 #define DEBUGPORT_UART_DEFAULT_PARITY 0
84 #define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16
85 #define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 // 5 ms
86 #define DEBUGPORT_UART_DEFAULT_DATA_BITS 8
87 #define DEBUGPORT_UART_DEFAULT_STOP_BITS 1
89 #define DEBUGPORT_DRIVER_VERSION 1
91 #define EfiIsUartDevicePath(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
96 extern DEBUGPORT_DEVICE
*gDebugPortDevice
;
99 // Driver binding interface functions...
102 DebugPortEntryPoint (
103 IN EFI_HANDLE ImageHandle
,
104 IN EFI_SYSTEM_TABLE
*SystemTable
111 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
112 IN EFI_HANDLE Controller
,
113 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
120 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
121 IN EFI_HANDLE Controller
,
122 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
129 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
130 IN EFI_HANDLE Controller
,
131 IN UINTN NumberOfChildren
,
132 IN EFI_HANDLE
*ChildHandleBuffer
137 // EFI Component Name Functions
140 Retrieves a Unicode string that is the user readable name of the driver.
142 This function retrieves the user readable name of a driver in the form of a
143 Unicode string. If the driver specified by This has a user readable name in
144 the language specified by Language, then a pointer to the driver name is
145 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
146 by This does not support the language specified by Language,
147 then EFI_UNSUPPORTED is returned.
149 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
150 EFI_COMPONENT_NAME_PROTOCOL instance.
152 @param Language[in] A pointer to a Null-terminated ASCII string
153 array indicating the language. This is the
154 language of the driver name that the caller is
155 requesting, and it must match one of the
156 languages specified in SupportedLanguages. The
157 number of languages supported by a driver is up
158 to the driver writer. Language is specified
159 in RFC 3066 or ISO 639-2 language code format.
161 @param DriverName[out] A pointer to the Unicode string to return.
162 This Unicode string is the name of the
163 driver specified by This in the language
164 specified by Language.
166 @retval EFI_SUCCESS The Unicode string for the Driver specified by
167 This and the language specified by Language was
168 returned in DriverName.
170 @retval EFI_INVALID_PARAMETER Language is NULL.
172 @retval EFI_INVALID_PARAMETER DriverName is NULL.
174 @retval EFI_UNSUPPORTED The driver specified by This does not support
175 the language specified by Language.
180 DebugPortComponentNameGetDriverName (
181 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
183 OUT CHAR16
**DriverName
188 Retrieves a Unicode string that is the user readable name of the controller
189 that is being managed by a driver.
191 This function retrieves the user readable name of the controller specified by
192 ControllerHandle and ChildHandle in the form of a Unicode string. If the
193 driver specified by This has a user readable name in the language specified by
194 Language, then a pointer to the controller name is returned in ControllerName,
195 and EFI_SUCCESS is returned. If the driver specified by This is not currently
196 managing the controller specified by ControllerHandle and ChildHandle,
197 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
198 support the language specified by Language, then EFI_UNSUPPORTED is returned.
200 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
201 EFI_COMPONENT_NAME_PROTOCOL instance.
203 @param ControllerHandle[in] The handle of a controller that the driver
204 specified by This is managing. This handle
205 specifies the controller whose name is to be
208 @param ChildHandle[in] The handle of the child controller to retrieve
209 the name of. This is an optional parameter that
210 may be NULL. It will be NULL for device
211 drivers. It will also be NULL for a bus drivers
212 that wish to retrieve the name of the bus
213 controller. It will not be NULL for a bus
214 driver that wishes to retrieve the name of a
217 @param Language[in] A pointer to a Null-terminated ASCII string
218 array indicating the language. This is the
219 language of the driver name that the caller is
220 requesting, and it must match one of the
221 languages specified in SupportedLanguages. The
222 number of languages supported by a driver is up
223 to the driver writer. Language is specified in
224 RFC 3066 or ISO 639-2 language code format.
226 @param ControllerName[out] A pointer to the Unicode string to return.
227 This Unicode string is the name of the
228 controller specified by ControllerHandle and
229 ChildHandle in the language specified by
230 Language from the point of view of the driver
233 @retval EFI_SUCCESS The Unicode string for the user readable name in
234 the language specified by Language for the
235 driver specified by This was returned in
238 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
240 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
243 @retval EFI_INVALID_PARAMETER Language is NULL.
245 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
247 @retval EFI_UNSUPPORTED The driver specified by This is not currently
248 managing the controller specified by
249 ControllerHandle and ChildHandle.
251 @retval EFI_UNSUPPORTED The driver specified by This does not support
252 the language specified by Language.
257 DebugPortComponentNameGetControllerName (
258 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
259 IN EFI_HANDLE ControllerHandle
,
260 IN EFI_HANDLE ChildHandle OPTIONAL
,
262 OUT CHAR16
**ControllerName
267 // DebugPort member functions
272 IN EFI_DEBUGPORT_PROTOCOL
*This
279 IN EFI_DEBUGPORT_PROTOCOL
*This
,
281 IN OUT UINTN
*BufferSize
,
289 IN EFI_DEBUGPORT_PROTOCOL
*This
,
291 IN OUT UINTN
*BufferSize
,
299 IN EFI_DEBUGPORT_PROTOCOL
*This