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