]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/DebugPortDxe/DebugPort.h
Add some function/header comments.
[mirror_edk2.git] / MdeModulePkg / Universal / DebugPortDxe / DebugPort.h
CommitLineData
c1f23d63 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13 DebugPort.h\r
14\r
15Abstract:\r
16 Definitions and prototypes for DebugPort driver\r
17\r
18--*/\r
19\r
20#ifndef __DEBUGPORT_H__\r
21#define __DEBUGPORT_H__\r
22\r
ed7748fe 23\r
c1f23d63 24#include <Uefi.h>\r
ed7748fe 25\r
c1f23d63 26#include <Protocol/DevicePath.h>\r
27#include <Protocol/ComponentName.h>\r
28#include <Protocol/DriverBinding.h>\r
29#include <Protocol/SerialIo.h>\r
30#include <Protocol/DebugPort.h>\r
ed7748fe 31\r
c1f23d63 32#include <Library/DebugLib.h>\r
33#include <Library/UefiDriverEntryPoint.h>\r
34#include <Library/UefiLib.h>\r
35#include <Library/BaseMemoryLib.h>\r
36#include <Library/MemoryAllocationLib.h>\r
37#include <Library/UefiBootServicesTableLib.h>\r
38#include <Library/UefiRuntimeServicesTableLib.h>\r
39#include <Library/DevicePathLib.h>\r
40\r
41//\r
42// Driver Binding Externs\r
43//\r
19f97f7e 44extern EFI_DRIVER_BINDING_PROTOCOL gDebugPortDriverBinding;\r
45extern EFI_COMPONENT_NAME_PROTOCOL gDebugPortComponentName;\r
46extern EFI_COMPONENT_NAME2_PROTOCOL gDebugPortComponentName2;\r
c1f23d63 47\r
48//\r
49// local type definitions\r
50//\r
51#define DEBUGPORT_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('D', 'B', 'G', 'P')\r
52\r
53//\r
54// Device structure used by driver\r
55//\r
56typedef struct {\r
57 UINT32 Signature;\r
58 EFI_HANDLE DriverBindingHandle;\r
59 EFI_HANDLE DebugPortDeviceHandle;\r
60 VOID *DebugPortVariable;\r
61\r
62 EFI_DRIVER_BINDING_PROTOCOL DriverBindingInterface;\r
63 EFI_COMPONENT_NAME_PROTOCOL ComponentNameInterface;\r
64 EFI_DEVICE_PATH_PROTOCOL *DebugPortDevicePath;\r
65 EFI_DEBUGPORT_PROTOCOL DebugPortInterface;\r
66\r
67 EFI_HANDLE SerialIoDeviceHandle;\r
68 EFI_SERIAL_IO_PROTOCOL *SerialIoBinding;\r
69 UINT64 BaudRate;\r
70 UINT32 ReceiveFifoDepth;\r
71 UINT32 Timeout;\r
72 EFI_PARITY_TYPE Parity;\r
73 UINT8 DataBits;\r
74 EFI_STOP_BITS_TYPE StopBits;\r
75} DEBUGPORT_DEVICE;\r
76\r
77#define DEBUGPORT_DEVICE_FROM_THIS(a) CR (a, DEBUGPORT_DEVICE, DebugPortInterface, DEBUGPORT_DEVICE_SIGNATURE)\r
78\r
79#define EFI_ACPI_PC_COMPORT_HID EISA_PNP_ID (0x0500)\r
80#define EFI_ACPI_16550UART_HID EISA_PNP_ID (0x0501)\r
81\r
82#define DEBUGPORT_UART_DEFAULT_BAUDRATE 115200\r
83#define DEBUGPORT_UART_DEFAULT_PARITY 0\r
84#define DEBUGPORT_UART_DEFAULT_FIFO_DEPTH 16\r
85#define DEBUGPORT_UART_DEFAULT_TIMEOUT 50000 // 5 ms\r
86#define DEBUGPORT_UART_DEFAULT_DATA_BITS 8\r
87#define DEBUGPORT_UART_DEFAULT_STOP_BITS 1\r
88\r
89#define DEBUGPORT_DRIVER_VERSION 1\r
90\r
91#define EfiIsUartDevicePath(dp) (DevicePathType (dp) == MESSAGING_DEVICE_PATH && DevicePathSubType (dp) == MSG_UART_DP)\r
92\r
93//\r
94// globals\r
95//\r
19f97f7e 96extern DEBUGPORT_DEVICE *gDebugPortDevice;\r
c1f23d63 97\r
98//\r
99// Driver binding interface functions...\r
100//\r
101EFI_STATUS\r
102DebugPortEntryPoint (\r
103 IN EFI_HANDLE ImageHandle,\r
104 IN EFI_SYSTEM_TABLE *SystemTable\r
105 )\r
106;\r
107\r
108EFI_STATUS\r
109EFIAPI\r
110DebugPortSupported (\r
111 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
112 IN EFI_HANDLE Controller,\r
113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
114 )\r
115;\r
116\r
117EFI_STATUS\r
118EFIAPI\r
119DebugPortStart (\r
120 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
121 IN EFI_HANDLE Controller,\r
122 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
123 )\r
124;\r
125\r
126EFI_STATUS\r
127EFIAPI\r
128DebugPortStop (\r
129 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
130 IN EFI_HANDLE Controller,\r
131 IN UINTN NumberOfChildren,\r
132 IN EFI_HANDLE *ChildHandleBuffer\r
133 )\r
134;\r
135\r
136//\r
137// EFI Component Name Functions\r
138//\r
19f97f7e 139/**\r
140 Retrieves a Unicode string that is the user readable name of the driver.\r
141\r
142 This function retrieves the user readable name of a driver in the form of a\r
143 Unicode string. If the driver specified by This has a user readable name in\r
144 the language specified by Language, then a pointer to the driver name is\r
145 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
146 by This does not support the language specified by Language,\r
147 then EFI_UNSUPPORTED is returned.\r
148\r
149 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
150 EFI_COMPONENT_NAME_PROTOCOL instance.\r
151\r
152 @param Language[in] A pointer to a Null-terminated ASCII string\r
153 array indicating the language. This is the\r
154 language of the driver name that the caller is\r
155 requesting, and it must match one of the\r
156 languages specified in SupportedLanguages. The\r
157 number of languages supported by a driver is up\r
158 to the driver writer. Language is specified\r
159 in RFC 3066 or ISO 639-2 language code format.\r
160\r
161 @param DriverName[out] A pointer to the Unicode string to return.\r
162 This Unicode string is the name of the\r
163 driver specified by This in the language\r
164 specified by Language.\r
165\r
166 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
167 This and the language specified by Language was\r
168 returned in DriverName.\r
169\r
170 @retval EFI_INVALID_PARAMETER Language is NULL.\r
171\r
172 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
173\r
174 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
175 the language specified by Language.\r
176\r
177**/\r
c1f23d63 178EFI_STATUS\r
179EFIAPI\r
180DebugPortComponentNameGetDriverName (\r
19f97f7e 181 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
182 IN CHAR8 *Language,\r
183 OUT CHAR16 **DriverName\r
184 );\r
185\r
186\r
187/**\r
188 Retrieves a Unicode string that is the user readable name of the controller\r
189 that is being managed by a driver.\r
190\r
191 This function retrieves the user readable name of the controller specified by\r
192 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
193 driver specified by This has a user readable name in the language specified by\r
194 Language, then a pointer to the controller name is returned in ControllerName,\r
195 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
196 managing the controller specified by ControllerHandle and ChildHandle,\r
197 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
198 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
199\r
200 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
201 EFI_COMPONENT_NAME_PROTOCOL instance.\r
c1f23d63 202\r
19f97f7e 203 @param ControllerHandle[in] The handle of a controller that the driver\r
204 specified by This is managing. This handle\r
205 specifies the controller whose name is to be\r
206 returned.\r
207\r
208 @param ChildHandle[in] The handle of the child controller to retrieve\r
209 the name of. This is an optional parameter that\r
210 may be NULL. It will be NULL for device\r
211 drivers. It will also be NULL for a bus drivers\r
212 that wish to retrieve the name of the bus\r
213 controller. It will not be NULL for a bus\r
214 driver that wishes to retrieve the name of a\r
215 child controller.\r
216\r
217 @param Language[in] A pointer to a Null-terminated ASCII string\r
218 array indicating the language. This is the\r
219 language of the driver name that the caller is\r
220 requesting, and it must match one of the\r
221 languages specified in SupportedLanguages. The\r
222 number of languages supported by a driver is up\r
223 to the driver writer. Language is specified in\r
224 RFC 3066 or ISO 639-2 language code format.\r
225\r
226 @param ControllerName[out] A pointer to the Unicode string to return.\r
227 This Unicode string is the name of the\r
228 controller specified by ControllerHandle and\r
229 ChildHandle in the language specified by\r
230 Language from the point of view of the driver\r
231 specified by This.\r
232\r
233 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
234 the language specified by Language for the\r
235 driver specified by This was returned in\r
236 DriverName.\r
237\r
238 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
239\r
240 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
241 EFI_HANDLE.\r
242\r
243 @retval EFI_INVALID_PARAMETER Language is NULL.\r
244\r
245 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
246\r
247 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
248 managing the controller specified by\r
249 ControllerHandle and ChildHandle.\r
250\r
251 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
252 the language specified by Language.\r
253\r
254**/\r
c1f23d63 255EFI_STATUS\r
256EFIAPI\r
257DebugPortComponentNameGetControllerName (\r
19f97f7e 258 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
259 IN EFI_HANDLE ControllerHandle,\r
260 IN EFI_HANDLE ChildHandle OPTIONAL,\r
261 IN CHAR8 *Language,\r
262 OUT CHAR16 **ControllerName\r
263 );\r
264\r
c1f23d63 265\r
266//\r
267// DebugPort member functions\r
268//\r
269EFI_STATUS\r
270EFIAPI\r
271DebugPortReset (\r
272 IN EFI_DEBUGPORT_PROTOCOL *This\r
273 )\r
274;\r
275\r
276EFI_STATUS\r
277EFIAPI\r
278DebugPortRead (\r
279 IN EFI_DEBUGPORT_PROTOCOL *This,\r
280 IN UINT32 Timeout,\r
281 IN OUT UINTN *BufferSize,\r
282 IN VOID *Buffer\r
283 )\r
284;\r
285\r
286EFI_STATUS\r
287EFIAPI\r
288DebugPortWrite (\r
289 IN EFI_DEBUGPORT_PROTOCOL *This,\r
290 IN UINT32 Timeout,\r
291 IN OUT UINTN *BufferSize,\r
292 OUT VOID *Buffer\r
293 )\r
294;\r
295\r
296EFI_STATUS\r
297EFIAPI\r
298DebugPortPoll (\r
299 IN EFI_DEBUGPORT_PROTOCOL *This\r
300 )\r
301;\r
302\r
303#endif\r