]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugPortDxe/DebugPort.h
apply for doxgen format.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugPortDxe / DebugPort.h
1 /** @file
2 Definitions and prototypes for DebugPort driver.
3
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
9
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.
12
13 **/
14
15 #ifndef __DEBUGPORT_H__
16 #define __DEBUGPORT_H__
17
18
19 #include <Uefi.h>
20
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>
26
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>
35
36 //
37 // Driver Binding Externs
38 //
39 extern EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding;
40 extern EFI_COMPONENT_NAME_PROTOCOL gDebugPortComponentName;
41 extern EFI_COMPONENT_NAME2_PROTOCOL gDebugPortComponentName2;
42
43 //
44 // local type definitions
45 //
46 #define DEBUGPORT_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')
47
48 //
49 // Device structure used by driver
50 //
51 typedef struct {
52 UINT32 Signature;
53 EFI_HANDLE DriverBindingHandle;
54 EFI_HANDLE DebugPortDeviceHandle;
55 VOID *DebugPortVariable;
56
57 EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface;
58 EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface;
59 EFI_DEVICE_PATH_PROTOCOL *DebugPortDevicePath;
60 EFI_DEBUGPORT_PROTOCOL DebugPortInterface;
61
62 EFI_HANDLE SerialIoDeviceHandle;
63 EFI_SERIAL_IO_PROTOCOL *SerialIoBinding;
64 UINT64 BaudRate;
65 UINT32 ReceiveFifoDepth;
66 UINT32 Timeout;
67 EFI_PARITY_TYPE Parity;
68 UINT8 DataBits;
69 EFI_STOP_BITS_TYPE StopBits;
70 } DEBUGPORT_DEVICE;
71
72 #define DEBUGPORT_DEVICE_FROM_THIS(a) CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)
73
74 #define EFI_ACPI_PC_COMPORT_HID EISA_PNP_ID (0x0500)
75 #define EFI_ACPI_16550UART_HID EISA_PNP_ID (0x0501)
76
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
83
84 #define DEBUGPORT_DRIVER_VERSION 1
85
86 #define EfiIsUartDevicePath(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)
87
88 //
89 // globals
90 //
91 extern DEBUGPORT_DEVICE *gDebugPortDevice;
92
93 //
94 // Driver binding interface functions...
95 //
96 EFI_STATUS
97 DebugPortEntryPoint (
98 IN EFI_HANDLE ImageHandle,
99 IN EFI_SYSTEM_TABLE *SystemTable
100 )
101 ;
102
103 EFI_STATUS
104 EFIAPI
105 DebugPortSupported (
106 IN EFI_DRIVER_BINDING_PROTOCOL *This,
107 IN EFI_HANDLE Controller,
108 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
109 )
110 ;
111
112 EFI_STATUS
113 EFIAPI
114 DebugPortStart (
115 IN EFI_DRIVER_BINDING_PROTOCOL *This,
116 IN EFI_HANDLE Controller,
117 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
118 )
119 ;
120
121 EFI_STATUS
122 EFIAPI
123 DebugPortStop (
124 IN EFI_DRIVER_BINDING_PROTOCOL *This,
125 IN EFI_HANDLE Controller,
126 IN UINTN NumberOfChildren,
127 IN EFI_HANDLE *ChildHandleBuffer
128 )
129 ;
130
131 //
132 // EFI Component Name Functions
133 //
134 /**
135 Retrieves a Unicode string that is the user readable name of the driver.
136
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.
143
144 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
145 EFI_COMPONENT_NAME_PROTOCOL instance.
146
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.
155
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.
160
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.
164
165 @retval EFI_INVALID_PARAMETER Language is NULL.
166
167 @retval EFI_INVALID_PARAMETER DriverName is NULL.
168
169 @retval EFI_UNSUPPORTED The driver specified by This does not support
170 the language specified by Language.
171
172 **/
173 EFI_STATUS
174 EFIAPI
175 DebugPortComponentNameGetDriverName (
176 IN EFI_COMPONENT_NAME_PROTOCOL *This,
177 IN CHAR8 *Language,
178 OUT CHAR16 **DriverName
179 );
180
181
182 /**
183 Retrieves a Unicode string that is the user readable name of the controller
184 that is being managed by a driver.
185
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.
194
195 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
196 EFI_COMPONENT_NAME_PROTOCOL instance.
197
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
201 returned.
202
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
210 child controller.
211
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.
220
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
226 specified by This.
227
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
231 DriverName.
232
233 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
234
235 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
236 EFI_HANDLE.
237
238 @retval EFI_INVALID_PARAMETER Language is NULL.
239
240 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
241
242 @retval EFI_UNSUPPORTED The driver specified by This is not currently
243 managing the controller specified by
244 ControllerHandle and ChildHandle.
245
246 @retval EFI_UNSUPPORTED The driver specified by This does not support
247 the language specified by Language.
248
249 **/
250 EFI_STATUS
251 EFIAPI
252 DebugPortComponentNameGetControllerName (
253 IN EFI_COMPONENT_NAME_PROTOCOL *This,
254 IN EFI_HANDLE ControllerHandle,
255 IN EFI_HANDLE ChildHandle OPTIONAL,
256 IN CHAR8 *Language,
257 OUT CHAR16 **ControllerName
258 );
259
260
261 //
262 // DebugPort member functions
263 //
264 EFI_STATUS
265 EFIAPI
266 DebugPortReset (
267 IN EFI_DEBUGPORT_PROTOCOL *This
268 )
269 ;
270
271 EFI_STATUS
272 EFIAPI
273 DebugPortRead (
274 IN EFI_DEBUGPORT_PROTOCOL *This,
275 IN UINT32 Timeout,
276 IN OUT UINTN *BufferSize,
277 IN VOID *Buffer
278 )
279 ;
280
281 EFI_STATUS
282 EFIAPI
283 DebugPortWrite (
284 IN EFI_DEBUGPORT_PROTOCOL *This,
285 IN UINT32 Timeout,
286 IN OUT UINTN *BufferSize,
287 OUT VOID *Buffer
288 )
289 ;
290
291 EFI_STATUS
292 EFIAPI
293 DebugPortPoll (
294 IN EFI_DEBUGPORT_PROTOCOL *This
295 )
296 ;
297
298 #endif