]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/DebugPortDxe/DebugPort.h
clean up the un-suitable ';' location when declaring the functions.
[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 EFI_STATUS
103 EFIAPI
104 DebugPortSupported (
105 IN EFI_DRIVER_BINDING_PROTOCOL *This,
106 IN EFI_HANDLE Controller,
107 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
108 );
109
110 EFI_STATUS
111 EFIAPI
112 DebugPortStart (
113 IN EFI_DRIVER_BINDING_PROTOCOL *This,
114 IN EFI_HANDLE Controller,
115 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
116 );
117
118 EFI_STATUS
119 EFIAPI
120 DebugPortStop (
121 IN EFI_DRIVER_BINDING_PROTOCOL *This,
122 IN EFI_HANDLE Controller,
123 IN UINTN NumberOfChildren,
124 IN EFI_HANDLE *ChildHandleBuffer
125 );
126
127 //
128 // EFI Component Name Functions
129 //
130 /**
131 Retrieves a Unicode string that is the user readable name of the driver.
132
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.
139
140 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
141 EFI_COMPONENT_NAME_PROTOCOL instance.
142
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.
151
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.
156
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.
160
161 @retval EFI_INVALID_PARAMETER Language is NULL.
162
163 @retval EFI_INVALID_PARAMETER DriverName is NULL.
164
165 @retval EFI_UNSUPPORTED The driver specified by This does not support
166 the language specified by Language.
167
168 **/
169 EFI_STATUS
170 EFIAPI
171 DebugPortComponentNameGetDriverName (
172 IN EFI_COMPONENT_NAME_PROTOCOL *This,
173 IN CHAR8 *Language,
174 OUT CHAR16 **DriverName
175 );
176
177
178 /**
179 Retrieves a Unicode string that is the user readable name of the controller
180 that is being managed by a driver.
181
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.
190
191 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
192 EFI_COMPONENT_NAME_PROTOCOL instance.
193
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
197 returned.
198
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
206 child controller.
207
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.
216
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
222 specified by This.
223
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
227 DriverName.
228
229 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
230
231 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
232 EFI_HANDLE.
233
234 @retval EFI_INVALID_PARAMETER Language is NULL.
235
236 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
237
238 @retval EFI_UNSUPPORTED The driver specified by This is not currently
239 managing the controller specified by
240 ControllerHandle and ChildHandle.
241
242 @retval EFI_UNSUPPORTED The driver specified by This does not support
243 the language specified by Language.
244
245 **/
246 EFI_STATUS
247 EFIAPI
248 DebugPortComponentNameGetControllerName (
249 IN EFI_COMPONENT_NAME_PROTOCOL *This,
250 IN EFI_HANDLE ControllerHandle,
251 IN EFI_HANDLE ChildHandle OPTIONAL,
252 IN CHAR8 *Language,
253 OUT CHAR16 **ControllerName
254 );
255
256
257 //
258 // DebugPort member functions
259 //
260 EFI_STATUS
261 EFIAPI
262 DebugPortReset (
263 IN EFI_DEBUGPORT_PROTOCOL *This
264 );
265
266 EFI_STATUS
267 EFIAPI
268 DebugPortRead (
269 IN EFI_DEBUGPORT_PROTOCOL *This,
270 IN UINT32 Timeout,
271 IN OUT UINTN *BufferSize,
272 IN VOID *Buffer
273 );
274
275 EFI_STATUS
276 EFIAPI
277 DebugPortWrite (
278 IN EFI_DEBUGPORT_PROTOCOL *This,
279 IN UINT32 Timeout,
280 IN OUT UINTN *BufferSize,
281 OUT VOID *Buffer
282 );
283
284 EFI_STATUS
285 EFIAPI
286 DebugPortPoll (
287 IN EFI_DEBUGPORT_PROTOCOL *This
288 );
289
290 #endif