]>
Commit | Line | Data |
---|---|---|
fdd61615 SM |
1 | /** @file\r |
2 | DBG2 Table Generator\r | |
3 | \r | |
313d2ec9 PG |
4 | Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>\r |
5 | \r | |
9cd9bdc6 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
fdd61615 SM |
7 | \r |
8 | @par Reference(s):\r | |
9 | - Microsoft Debug Port Table 2 (DBG2) Specification - December 10, 2015.\r | |
10 | \r | |
11 | **/\r | |
12 | \r | |
13 | #include <IndustryStandard/DebugPort2Table.h>\r | |
14 | #include <Library/AcpiLib.h>\r | |
15 | #include <Library/DebugLib.h>\r | |
313d2ec9 | 16 | #include <Library/MemoryAllocationLib.h>\r |
fdd61615 SM |
17 | #include <Library/PL011UartLib.h>\r |
18 | #include <Protocol/AcpiTable.h>\r | |
19 | #include <Protocol/SerialIo.h>\r | |
20 | \r | |
21 | // Module specific include files.\r | |
22 | #include <AcpiTableGenerator.h>\r | |
23 | #include <ConfigurationManagerObject.h>\r | |
24 | #include <ConfigurationManagerHelper.h>\r | |
313d2ec9 | 25 | #include <Library/SsdtSerialPortFixupLib.h>\r |
fdd61615 SM |
26 | #include <Library/TableHelperLib.h>\r |
27 | #include <Protocol/ConfigurationManagerProtocol.h>\r | |
28 | \r | |
29 | /** ARM standard DBG2 Table Generator\r | |
30 | \r | |
31 | Constructs the DBG2 table for PL011 or SBSA UART peripherals.\r | |
32 | \r | |
33 | Requirements:\r | |
34 | The following Configuration Manager Object(s) are required by\r | |
35 | this Generator:\r | |
36 | - EArmObjSerialDebugPortInfo\r | |
37 | */\r | |
38 | \r | |
39 | #pragma pack(1)\r | |
40 | \r | |
41 | /** The number of debug ports represented by the Table.\r | |
42 | */\r | |
43 | #define DBG2_NUM_DEBUG_PORTS 1\r | |
44 | \r | |
45 | /** The number of Generic Address Registers\r | |
46 | presented in the debug device information.\r | |
47 | */\r | |
48 | #define DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS 1\r | |
49 | \r | |
313d2ec9 PG |
50 | /** The index for the debug port 0 in the Debug port information list.\r |
51 | */\r | |
52 | #define INDEX_DBG_PORT0 0\r | |
53 | \r | |
54 | /** A string representing the name of the debug port 0.\r | |
fdd61615 | 55 | */\r |
313d2ec9 | 56 | #define NAME_STR_DBG_PORT0 "COM0"\r |
fdd61615 | 57 | \r |
313d2ec9 | 58 | /** An UID representing the debug port 0.\r |
fdd61615 | 59 | */\r |
313d2ec9 | 60 | #define UID_DBG_PORT0 0\r |
fdd61615 SM |
61 | \r |
62 | /** The length of the namespace string.\r | |
63 | */\r | |
313d2ec9 | 64 | #define DBG2_NAMESPACESTRING_FIELD_SIZE sizeof (NAME_STR_DBG_PORT0)\r |
fdd61615 SM |
65 | \r |
66 | /** The PL011 UART address range length.\r | |
67 | */\r | |
68 | #define PL011_UART_LENGTH 0x1000\r | |
69 | \r | |
70 | /** A structure that provides the OS with the required information\r | |
71 | for initializing a debugger connection.\r | |
72 | */\r | |
73 | typedef struct {\r | |
74 | /// The debug device information for the platform\r | |
75 | EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT Dbg2Device;\r | |
76 | \r | |
77 | /// The base address register for the serial port\r | |
78 | EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister;\r | |
79 | \r | |
80 | /// The address size\r | |
81 | UINT32 AddressSize;\r | |
82 | \r | |
83 | /// The debug port name string\r | |
84 | UINT8 NameSpaceString[DBG2_NAMESPACESTRING_FIELD_SIZE];\r | |
85 | } DBG2_DEBUG_DEVICE_INFORMATION;\r | |
86 | \r | |
87 | /** A structure representing the information about the debug port(s)\r | |
88 | available on the platform.\r | |
89 | */\r | |
90 | typedef struct {\r | |
91 | /// The DBG2 table header\r | |
92 | EFI_ACPI_DEBUG_PORT_2_DESCRIPTION_TABLE Description;\r | |
93 | \r | |
94 | /// Debug port information list\r | |
95 | DBG2_DEBUG_DEVICE_INFORMATION Dbg2DeviceInfo[DBG2_NUM_DEBUG_PORTS];\r | |
96 | } DBG2_TABLE;\r | |
97 | \r | |
98 | /** A helper macro used for initializing the debug port device\r | |
99 | information structure.\r | |
100 | \r | |
fdd61615 SM |
101 | @param [in] SubType The DBG Port SubType.\r |
102 | @param [in] UartBase The UART port base address.\r | |
103 | @param [in] UartAddrLen The UART port address range length.\r | |
104 | @param [in] UartNameStr The UART port name string.\r | |
105 | **/\r | |
106 | #define DBG2_DEBUG_PORT_DDI( \\r | |
fdd61615 SM |
107 | SubType, \\r |
108 | UartBase, \\r | |
109 | UartAddrLen, \\r | |
110 | UartNameStr \\r | |
111 | ) { \\r | |
112 | { \\r | |
113 | /* UINT8 Revision */ \\r | |
114 | EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION, \\r | |
115 | /* UINT16 Length */ \\r | |
116 | sizeof (DBG2_DEBUG_DEVICE_INFORMATION), \\r | |
117 | /* UINT8 NumberofGenericAddressRegisters */ \\r | |
1018bd4c | 118 | DBG2_NUMBER_OF_GENERIC_ADDRESS_REGISTERS, \\r |
fdd61615 SM |
119 | /* UINT16 NameSpaceStringLength */ \\r |
120 | DBG2_NAMESPACESTRING_FIELD_SIZE, \\r | |
121 | /* UINT16 NameSpaceStringOffset */ \\r | |
122 | OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, NameSpaceString), \\r | |
123 | /* UINT16 OemDataLength */ \\r | |
124 | 0, \\r | |
125 | /* UINT16 OemDataOffset */ \\r | |
126 | 0, \\r | |
127 | /* UINT16 Port Type */ \\r | |
128 | EFI_ACPI_DBG2_PORT_TYPE_SERIAL, \\r | |
129 | /* UINT16 Port Subtype */ \\r | |
130 | SubType, \\r | |
131 | /* UINT8 Reserved[2] */ \\r | |
132 | {EFI_ACPI_RESERVED_BYTE, EFI_ACPI_RESERVED_BYTE}, \\r | |
133 | /* UINT16 BaseAddressRegister Offset */ \\r | |
134 | OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, BaseAddressRegister), \\r | |
135 | /* UINT16 AddressSize Offset */ \\r | |
136 | OFFSET_OF (DBG2_DEBUG_DEVICE_INFORMATION, AddressSize) \\r | |
137 | }, \\r | |
138 | /* EFI_ACPI_6_2_GENERIC_ADDRESS_STRUCTURE BaseAddressRegister */ \\r | |
139 | ARM_GAS32 (UartBase), \\r | |
140 | /* UINT32 AddressSize */ \\r | |
141 | UartAddrLen, \\r | |
142 | /* UINT8 NameSpaceString[MAX_DBG2_NAME_LEN] */ \\r | |
143 | UartNameStr \\r | |
144 | }\r | |
145 | \r | |
146 | /** The DBG2 Table template definition.\r | |
147 | \r | |
148 | Note: fields marked with "{Template}" will be set dynamically\r | |
149 | */\r | |
150 | STATIC\r | |
151 | DBG2_TABLE AcpiDbg2 = {\r | |
152 | {\r | |
153 | ACPI_HEADER (\r | |
154 | EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE,\r | |
155 | DBG2_TABLE,\r | |
156 | EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION\r | |
157 | ),\r | |
158 | OFFSET_OF (DBG2_TABLE, Dbg2DeviceInfo),\r | |
159 | DBG2_NUM_DEBUG_PORTS\r | |
160 | },\r | |
161 | {\r | |
162 | /*\r | |
163 | * Debug port 1\r | |
164 | */\r | |
165 | DBG2_DEBUG_PORT_DDI (\r | |
fdd61615 SM |
166 | 0, // {Template}: Serial Port Subtype\r |
167 | 0, // {Template}: Serial Port Base Address\r | |
168 | PL011_UART_LENGTH,\r | |
313d2ec9 | 169 | NAME_STR_DBG_PORT0\r |
fdd61615 SM |
170 | )\r |
171 | }\r | |
172 | };\r | |
173 | \r | |
174 | #pragma pack()\r | |
175 | \r | |
176 | /** This macro expands to a function that retrieves the Serial\r | |
177 | debug port information from the Configuration Manager\r | |
178 | */\r | |
179 | GET_OBJECT_LIST (\r | |
180 | EObjNameSpaceArm,\r | |
181 | EArmObjSerialDebugPortInfo,\r | |
182 | CM_ARM_SERIAL_PORT_INFO\r | |
183 | );\r | |
184 | \r | |
7c10e8ab | 185 | /** Initialize the PL011/SBSA UART with the parameters obtained from\r |
fdd61615 SM |
186 | the Configuration Manager.\r |
187 | \r | |
188 | @param [in] SerialPortInfo Pointer to the Serial Port Information.\r | |
189 | \r | |
190 | @retval EFI_SUCCESS Success.\r | |
191 | @retval EFI_INVALID_PARAMETER The parameters for serial port initialization\r | |
192 | are invalid.\r | |
193 | **/\r | |
194 | STATIC\r | |
195 | EFI_STATUS\r | |
196 | SetupDebugUart (\r | |
197 | IN CONST CM_ARM_SERIAL_PORT_INFO * CONST SerialPortInfo\r | |
198 | )\r | |
199 | {\r | |
200 | EFI_STATUS Status;\r | |
201 | UINT64 BaudRate;\r | |
202 | UINT32 ReceiveFifoDepth;\r | |
203 | EFI_PARITY_TYPE Parity;\r | |
204 | UINT8 DataBits;\r | |
205 | EFI_STOP_BITS_TYPE StopBits;\r | |
206 | \r | |
207 | ASSERT (SerialPortInfo != NULL);\r | |
208 | \r | |
209 | // Initialize the Serial Debug UART\r | |
210 | DEBUG ((DEBUG_INFO, "Initializing Serial Debug UART...\n"));\r | |
211 | ReceiveFifoDepth = 0; // Use the default value for FIFO depth\r | |
212 | Parity = (EFI_PARITY_TYPE)FixedPcdGet8 (PcdUartDefaultParity);\r | |
213 | DataBits = FixedPcdGet8 (PcdUartDefaultDataBits);\r | |
214 | StopBits = (EFI_STOP_BITS_TYPE)FixedPcdGet8 (PcdUartDefaultStopBits);\r | |
215 | \r | |
216 | BaudRate = SerialPortInfo->BaudRate;\r | |
217 | Status = PL011UartInitializePort (\r | |
218 | (UINTN)SerialPortInfo->BaseAddress,\r | |
219 | SerialPortInfo->Clock,\r | |
220 | &BaudRate,\r | |
221 | &ReceiveFifoDepth,\r | |
222 | &Parity,\r | |
223 | &DataBits,\r | |
224 | &StopBits\r | |
225 | );\r | |
226 | \r | |
fdd61615 SM |
227 | ASSERT_EFI_ERROR (Status);\r |
228 | return Status;\r | |
229 | }\r | |
230 | \r | |
313d2ec9 PG |
231 | /** Free any resources allocated for constructing the tables.\r |
232 | \r | |
233 | @param [in] This Pointer to the ACPI table generator.\r | |
234 | @param [in] AcpiTableInfo Pointer to the ACPI Table Info.\r | |
235 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
236 | Protocol Interface.\r | |
237 | @param [in, out] Table Pointer to an array of pointers\r | |
238 | to ACPI Table(s).\r | |
239 | @param [in] TableCount Number of ACPI table(s).\r | |
240 | \r | |
241 | @retval EFI_SUCCESS The resources were freed successfully.\r | |
242 | @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid.\r | |
243 | **/\r | |
244 | STATIC\r | |
245 | EFI_STATUS\r | |
246 | EFIAPI\r | |
247 | FreeDbg2TableEx (\r | |
248 | IN CONST ACPI_TABLE_GENERATOR * CONST This,\r | |
249 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,\r | |
250 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,\r | |
251 | IN OUT EFI_ACPI_DESCRIPTION_HEADER *** CONST Table,\r | |
252 | IN CONST UINTN TableCount\r | |
253 | )\r | |
254 | {\r | |
255 | EFI_STATUS Status;\r | |
256 | EFI_ACPI_DESCRIPTION_HEADER ** TableList;\r | |
257 | \r | |
258 | ASSERT (This != NULL);\r | |
259 | ASSERT (AcpiTableInfo != NULL);\r | |
260 | ASSERT (CfgMgrProtocol != NULL);\r | |
261 | ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);\r | |
262 | ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);\r | |
263 | \r | |
264 | if ((Table == NULL) ||\r | |
265 | (*Table == NULL) ||\r | |
266 | (TableCount != 2)) {\r | |
267 | DEBUG ((DEBUG_ERROR, "ERROR: DBG2: Invalid Table Pointer\n"));\r | |
268 | return EFI_INVALID_PARAMETER;\r | |
269 | }\r | |
270 | \r | |
271 | TableList = *Table;\r | |
272 | \r | |
273 | if ((TableList[1] == NULL) ||\r | |
274 | (TableList[1]->Signature !=\r | |
275 | EFI_ACPI_6_3_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE)) {\r | |
276 | DEBUG ((DEBUG_ERROR, "ERROR: DBG2: Invalid SSDT table pointer.\n"));\r | |
277 | return EFI_INVALID_PARAMETER;\r | |
278 | }\r | |
279 | \r | |
280 | // Only need to free the SSDT table at index 1. The DBG2 table is static.\r | |
281 | Status = FreeSsdtSerialPortTable (TableList[1]);\r | |
282 | ASSERT_EFI_ERROR (Status);\r | |
283 | \r | |
284 | // Free the table list.\r | |
285 | FreePool (*Table);\r | |
286 | \r | |
287 | return Status;\r | |
288 | }\r | |
fdd61615 | 289 | \r |
313d2ec9 | 290 | /** Construct the DBG2 ACPI table and its associated SSDT table.\r |
fdd61615 SM |
291 | \r |
292 | This function invokes the Configuration Manager protocol interface\r | |
293 | to get the required hardware information for generating the ACPI\r | |
294 | table.\r | |
295 | \r | |
296 | If this function allocates any resources then they must be freed\r | |
313d2ec9 PG |
297 | in the FreeXXXXTableResourcesEx function.\r |
298 | \r | |
299 | @param [in] This Pointer to the ACPI table generator.\r | |
300 | @param [in] AcpiTableInfo Pointer to the ACPI table information.\r | |
301 | @param [in] CfgMgrProtocol Pointer to the Configuration Manager\r | |
302 | Protocol interface.\r | |
303 | @param [out] Table Pointer to a list of generated ACPI table(s).\r | |
304 | @param [out] TableCount Number of generated ACPI table(s).\r | |
305 | \r | |
306 | @retval EFI_SUCCESS Table generated successfully.\r | |
307 | @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration\r | |
308 | Manager is less than the Object size for\r | |
309 | the requested object.\r | |
310 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
311 | @retval EFI_NOT_FOUND Could not find information.\r | |
312 | @retval EFI_OUT_OF_RESOURCES Could not allocate memory.\r | |
313 | @retval EFI_UNSUPPORTED Unsupported configuration.\r | |
fdd61615 SM |
314 | **/\r |
315 | STATIC\r | |
316 | EFI_STATUS\r | |
317 | EFIAPI\r | |
313d2ec9 PG |
318 | BuildDbg2TableEx (\r |
319 | IN CONST ACPI_TABLE_GENERATOR * This,\r | |
320 | IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo,\r | |
321 | IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol,\r | |
322 | OUT EFI_ACPI_DESCRIPTION_HEADER *** Table,\r | |
323 | OUT UINTN * CONST TableCount\r | |
fdd61615 SM |
324 | )\r |
325 | {\r | |
313d2ec9 PG |
326 | EFI_STATUS Status;\r |
327 | CM_ARM_SERIAL_PORT_INFO * SerialPortInfo;\r | |
328 | UINT32 SerialPortCount;\r | |
329 | EFI_ACPI_DESCRIPTION_HEADER ** TableList;\r | |
fdd61615 SM |
330 | \r |
331 | ASSERT (This != NULL);\r | |
332 | ASSERT (AcpiTableInfo != NULL);\r | |
333 | ASSERT (CfgMgrProtocol != NULL);\r | |
334 | ASSERT (Table != NULL);\r | |
313d2ec9 | 335 | ASSERT (TableCount != NULL);\r |
fdd61615 SM |
336 | ASSERT (AcpiTableInfo->TableGeneratorId == This->GeneratorID);\r |
337 | ASSERT (AcpiTableInfo->AcpiTableSignature == This->AcpiTableSignature);\r | |
338 | \r | |
339 | if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) ||\r | |
340 | (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) {\r | |
341 | DEBUG ((\r | |
342 | DEBUG_ERROR,\r | |
343 | "ERROR: DBG2: Requested table revision = %d, is not supported."\r | |
344 | "Supported table revision: Minimum = %d, Maximum = %d\n",\r | |
345 | AcpiTableInfo->AcpiTableRevision,\r | |
346 | This->MinAcpiTableRevision,\r | |
347 | This->AcpiTableRevision\r | |
348 | ));\r | |
349 | return EFI_INVALID_PARAMETER;\r | |
350 | }\r | |
351 | \r | |
352 | *Table = NULL;\r | |
353 | \r | |
354 | Status = GetEArmObjSerialDebugPortInfo (\r | |
355 | CfgMgrProtocol,\r | |
356 | CM_NULL_TOKEN,\r | |
357 | &SerialPortInfo,\r | |
313d2ec9 | 358 | &SerialPortCount\r |
fdd61615 SM |
359 | );\r |
360 | if (EFI_ERROR (Status)) {\r | |
361 | DEBUG ((\r | |
362 | DEBUG_ERROR,\r | |
363 | "ERROR: DBG2: Failed to get serial port information. Status = %r\n",\r | |
364 | Status\r | |
365 | ));\r | |
313d2ec9 | 366 | return Status;\r |
fdd61615 SM |
367 | }\r |
368 | \r | |
313d2ec9 | 369 | if (SerialPortCount == 0) {\r |
fdd61615 SM |
370 | DEBUG ((\r |
371 | DEBUG_ERROR,\r | |
313d2ec9 PG |
372 | "ERROR: DBG2: Serial port information not found. Status = %r\n",\r |
373 | EFI_NOT_FOUND\r | |
fdd61615 | 374 | ));\r |
313d2ec9 | 375 | return EFI_NOT_FOUND;\r |
fdd61615 SM |
376 | }\r |
377 | \r | |
313d2ec9 PG |
378 | // Only use the first DBG2 port information.\r |
379 | Status = ValidateSerialPortInfo (SerialPortInfo, 1);\r | |
380 | if (EFI_ERROR (Status)) {\r | |
fdd61615 SM |
381 | DEBUG ((\r |
382 | DEBUG_ERROR,\r | |
313d2ec9 PG |
383 | "ERROR: DBG2: Invalid serial port information. Status = %r\n",\r |
384 | Status\r | |
fdd61615 | 385 | ));\r |
313d2ec9 PG |
386 | return Status;\r |
387 | }\r | |
388 | \r | |
389 | // Allocate a table to store pointers to the DBG2 and SSDT tables.\r | |
390 | TableList = (EFI_ACPI_DESCRIPTION_HEADER**)\r | |
391 | AllocateZeroPool (sizeof (EFI_ACPI_DESCRIPTION_HEADER*) * 2);\r | |
392 | if (TableList == NULL) {\r | |
393 | Status = EFI_OUT_OF_RESOURCES;\r | |
394 | DEBUG ((\r | |
395 | DEBUG_ERROR,\r | |
396 | "ERROR: DBG2: Failed to allocate memory for Table List," \\r | |
397 | " Status = %r\n",\r | |
398 | Status\r | |
399 | ));\r | |
400 | return Status;\r | |
fdd61615 SM |
401 | }\r |
402 | \r | |
403 | Status = AddAcpiHeader (\r | |
404 | CfgMgrProtocol,\r | |
405 | This,\r | |
406 | (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2,\r | |
e12bdeb1 | 407 | AcpiTableInfo,\r |
fdd61615 SM |
408 | sizeof (DBG2_TABLE)\r |
409 | );\r | |
410 | if (EFI_ERROR (Status)) {\r | |
411 | DEBUG ((\r | |
412 | DEBUG_ERROR,\r | |
413 | "ERROR: DBG2: Failed to add ACPI header. Status = %r\n",\r | |
414 | Status\r | |
415 | ));\r | |
416 | goto error_handler;\r | |
417 | }\r | |
418 | \r | |
419 | // Update the base address\r | |
313d2ec9 | 420 | AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].BaseAddressRegister.Address =\r |
fdd61615 SM |
421 | SerialPortInfo->BaseAddress;\r |
422 | \r | |
423 | // Update the serial port subtype\r | |
313d2ec9 | 424 | AcpiDbg2.Dbg2DeviceInfo[INDEX_DBG_PORT0].Dbg2Device.PortSubtype =\r |
fdd61615 SM |
425 | SerialPortInfo->PortSubtype;\r |
426 | \r | |
7c10e8ab SM |
427 | if ((SerialPortInfo->PortSubtype ==\r |
428 | EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_PL011_UART) ||\r | |
429 | (SerialPortInfo->PortSubtype ==\r | |
430 | EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART_2X) ||\r | |
431 | (SerialPortInfo->PortSubtype ==\r | |
432 | EFI_ACPI_DBG2_PORT_SUBTYPE_SERIAL_ARM_SBSA_GENERIC_UART)) {\r | |
433 | // Initialize the serial port\r | |
434 | Status = SetupDebugUart (SerialPortInfo);\r | |
435 | if (EFI_ERROR (Status)) {\r | |
436 | DEBUG ((\r | |
437 | DEBUG_ERROR,\r | |
438 | "ERROR: DBG2: Failed to configure debug serial port. Status = %r\n",\r | |
439 | Status\r | |
440 | ));\r | |
441 | goto error_handler;\r | |
442 | }\r | |
fdd61615 SM |
443 | }\r |
444 | \r | |
313d2ec9 PG |
445 | TableList[0] = (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2;\r |
446 | \r | |
447 | // Build a SSDT table describing the serial port.\r | |
448 | Status = BuildSsdtSerialPortTable (\r | |
449 | AcpiTableInfo,\r | |
450 | SerialPortInfo,\r | |
451 | NAME_STR_DBG_PORT0,\r | |
452 | UID_DBG_PORT0,\r | |
453 | &TableList[1]\r | |
454 | );\r | |
455 | if (EFI_ERROR (Status)) {\r | |
456 | DEBUG ((\r | |
457 | DEBUG_ERROR,\r | |
458 | "ERROR: DBG2: Failed to build associated SSDT table. Status = %r\n",\r | |
459 | Status\r | |
460 | ));\r | |
461 | goto error_handler;\r | |
462 | }\r | |
463 | \r | |
464 | *TableCount = 2;\r | |
465 | *Table = TableList;\r | |
466 | \r | |
467 | return Status;\r | |
fdd61615 SM |
468 | \r |
469 | error_handler:\r | |
313d2ec9 PG |
470 | if (TableList != NULL) {\r |
471 | FreePool (TableList);\r | |
472 | }\r | |
473 | \r | |
fdd61615 SM |
474 | return Status;\r |
475 | }\r | |
476 | \r | |
477 | /** This macro defines the DBG2 Table Generator revision.\r | |
478 | */\r | |
479 | #define DBG2_GENERATOR_REVISION CREATE_REVISION (1, 0)\r | |
480 | \r | |
481 | /** The interface for the DBG2 Table Generator.\r | |
482 | */\r | |
483 | STATIC\r | |
484 | CONST\r | |
485 | ACPI_TABLE_GENERATOR Dbg2Generator = {\r | |
486 | // Generator ID\r | |
487 | CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdDbg2),\r | |
488 | // Generator Description\r | |
489 | L"ACPI.STD.DBG2.GENERATOR",\r | |
490 | // ACPI Table Signature\r | |
313d2ec9 | 491 | EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE,\r |
fdd61615 SM |
492 | // ACPI Table Revision supported by this Generator\r |
493 | EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,\r | |
494 | // Minimum supported ACPI Table Revision\r | |
495 | EFI_ACPI_DBG2_DEBUG_DEVICE_INFORMATION_STRUCT_REVISION,\r | |
496 | // Creator ID\r | |
497 | TABLE_GENERATOR_CREATOR_ID_ARM,\r | |
498 | // Creator Revision\r | |
499 | DBG2_GENERATOR_REVISION,\r | |
313d2ec9 | 500 | // Build table function. Use the extended version instead.\r |
fdd61615 | 501 | NULL,\r |
313d2ec9 | 502 | // Free table function. Use the extended version instead.\r |
fdd61615 | 503 | NULL,\r |
313d2ec9 PG |
504 | // Extended Build table function.\r |
505 | BuildDbg2TableEx,\r | |
506 | // Extended free function.\r | |
507 | FreeDbg2TableEx\r | |
fdd61615 SM |
508 | };\r |
509 | \r | |
510 | /** Register the Generator with the ACPI Table Factory.\r | |
511 | \r | |
512 | @param [in] ImageHandle The handle to the image.\r | |
513 | @param [in] SystemTable Pointer to the System Table.\r | |
514 | \r | |
515 | @retval EFI_SUCCESS The Generator is registered.\r | |
516 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
517 | @retval EFI_ALREADY_STARTED The Generator for the Table ID\r | |
518 | is already registered.\r | |
519 | **/\r | |
520 | EFI_STATUS\r | |
521 | EFIAPI\r | |
522 | AcpiDbg2LibConstructor (\r | |
43a0e08d SM |
523 | IN EFI_HANDLE ImageHandle,\r |
524 | IN EFI_SYSTEM_TABLE * SystemTable\r | |
fdd61615 SM |
525 | )\r |
526 | {\r | |
527 | EFI_STATUS Status;\r | |
528 | Status = RegisterAcpiTableGenerator (&Dbg2Generator);\r | |
529 | DEBUG ((DEBUG_INFO, "DBG2: Register Generator. Status = %r\n", Status));\r | |
530 | ASSERT_EFI_ERROR (Status);\r | |
fdd61615 SM |
531 | return Status;\r |
532 | }\r | |
533 | \r | |
534 | /** Deregister the Generator from the ACPI Table Factory.\r | |
535 | \r | |
536 | @param [in] ImageHandle The handle to the image.\r | |
537 | @param [in] SystemTable Pointer to the System Table.\r | |
538 | \r | |
539 | @retval EFI_SUCCESS The Generator is deregistered.\r | |
540 | @retval EFI_INVALID_PARAMETER A parameter is invalid.\r | |
541 | @retval EFI_NOT_FOUND The Generator is not registered.\r | |
542 | **/\r | |
543 | EFI_STATUS\r | |
544 | EFIAPI\r | |
545 | AcpiDbg2LibDestructor (\r | |
43a0e08d SM |
546 | IN EFI_HANDLE ImageHandle,\r |
547 | IN EFI_SYSTEM_TABLE * SystemTable\r | |
fdd61615 SM |
548 | )\r |
549 | {\r | |
550 | EFI_STATUS Status;\r | |
551 | Status = DeregisterAcpiTableGenerator (&Dbg2Generator);\r | |
552 | DEBUG ((DEBUG_INFO, "DBG2: Deregister Generator. Status = %r\n", Status));\r | |
553 | ASSERT_EFI_ERROR (Status);\r | |
554 | return Status;\r | |
555 | }\r |