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
106 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
107 IN EFI_HANDLE Controller
,
108 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
115 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
116 IN EFI_HANDLE Controller
,
117 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
124 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
125 IN EFI_HANDLE Controller
,
126 IN UINTN NumberOfChildren
,
127 IN EFI_HANDLE
*ChildHandleBuffer
132 // EFI Component Name Functions
135 Retrieves a Unicode string that is the user readable name of the driver.
137 This function retrieves the user readable name of a driver in the form of a
138 Unicode string. If the driver specified by This has a user readable name in
139 the language specified by Language, then a pointer to the driver name is
140 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
141 by This does not support the language specified by Language,
142 then EFI_UNSUPPORTED is returned.
144 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
145 EFI_COMPONENT_NAME_PROTOCOL instance.
147 @param Language[in] A pointer to a Null-terminated ASCII string
148 array indicating the language. This is the
149 language of the driver name that the caller is
150 requesting, and it must match one of the
151 languages specified in SupportedLanguages. The
152 number of languages supported by a driver is up
153 to the driver writer. Language is specified
154 in RFC 3066 or ISO 639-2 language code format.
156 @param DriverName[out] A pointer to the Unicode string to return.
157 This Unicode string is the name of the
158 driver specified by This in the language
159 specified by Language.
161 @retval EFI_SUCCESS The Unicode string for the Driver specified by
162 This and the language specified by Language was
163 returned in DriverName.
165 @retval EFI_INVALID_PARAMETER Language is NULL.
167 @retval EFI_INVALID_PARAMETER DriverName is NULL.
169 @retval EFI_UNSUPPORTED The driver specified by This does not support
170 the language specified by Language.
175 DebugPortComponentNameGetDriverName (
176 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
178 OUT CHAR16
**DriverName
183 Retrieves a Unicode string that is the user readable name of the controller
184 that is being managed by a driver.
186 This function retrieves the user readable name of the controller specified by
187 ControllerHandle and ChildHandle in the form of a Unicode string. If the
188 driver specified by This has a user readable name in the language specified by
189 Language, then a pointer to the controller name is returned in ControllerName,
190 and EFI_SUCCESS is returned. If the driver specified by This is not currently
191 managing the controller specified by ControllerHandle and ChildHandle,
192 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
193 support the language specified by Language, then EFI_UNSUPPORTED is returned.
195 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
196 EFI_COMPONENT_NAME_PROTOCOL instance.
198 @param ControllerHandle[in] The handle of a controller that the driver
199 specified by This is managing. This handle
200 specifies the controller whose name is to be
203 @param ChildHandle[in] The handle of the child controller to retrieve
204 the name of. This is an optional parameter that
205 may be NULL. It will be NULL for device
206 drivers. It will also be NULL for a bus drivers
207 that wish to retrieve the name of the bus
208 controller. It will not be NULL for a bus
209 driver that wishes to retrieve the name of a
212 @param Language[in] A pointer to a Null-terminated ASCII string
213 array indicating the language. This is the
214 language of the driver name that the caller is
215 requesting, and it must match one of the
216 languages specified in SupportedLanguages. The
217 number of languages supported by a driver is up
218 to the driver writer. Language is specified in
219 RFC 3066 or ISO 639-2 language code format.
221 @param ControllerName[out] A pointer to the Unicode string to return.
222 This Unicode string is the name of the
223 controller specified by ControllerHandle and
224 ChildHandle in the language specified by
225 Language from the point of view of the driver
228 @retval EFI_SUCCESS The Unicode string for the user readable name in
229 the language specified by Language for the
230 driver specified by This was returned in
233 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
235 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
238 @retval EFI_INVALID_PARAMETER Language is NULL.
240 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
242 @retval EFI_UNSUPPORTED The driver specified by This is not currently
243 managing the controller specified by
244 ControllerHandle and ChildHandle.
246 @retval EFI_UNSUPPORTED The driver specified by This does not support
247 the language specified by Language.
252 DebugPortComponentNameGetControllerName (
253 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
254 IN EFI_HANDLE ControllerHandle
,
255 IN EFI_HANDLE ChildHandle OPTIONAL
,
257 OUT CHAR16
**ControllerName
262 // DebugPort member functions
267 IN EFI_DEBUGPORT_PROTOCOL
*This
274 IN EFI_DEBUGPORT_PROTOCOL
*This
,
276 IN OUT UINTN
*BufferSize
,
284 IN EFI_DEBUGPORT_PROTOCOL
*This
,
286 IN OUT UINTN
*BufferSize
,
294 IN EFI_DEBUGPORT_PROTOCOL
*This