]>
Commit | Line | Data |
---|---|---|
a6eaba4d | 1 | /** @file\r |
ee4dc24f RN |
2 | SPCR table parser\r |
3 | \r | |
cca8826c | 4 | Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r |
56ba3746 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
ee4dc24f RN |
6 | \r |
7 | @par Reference(s):\r | |
8 | - Microsoft Serial Port Console Redirection Table\r | |
9 | Specification - Version 1.03 - August 10, 2015.\r | |
10 | **/\r | |
11 | \r | |
12 | #include <IndustryStandard/Acpi.h>\r | |
13 | #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>\r | |
14 | #include <Library/UefiLib.h>\r | |
15 | #include "AcpiParser.h"\r | |
16 | #include "AcpiTableParser.h"\r | |
17 | \r | |
18 | // Local variables\r | |
19 | STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r | |
20 | \r | |
a6eaba4d DB |
21 | /**\r |
22 | This function validates the Interrupt Type.\r | |
ee4dc24f RN |
23 | \r |
24 | @param [in] Ptr Pointer to the start of the field data.\r | |
25 | @param [in] Context Pointer to context specific information e.g. this\r | |
26 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 27 | **/\r |
ee4dc24f RN |
28 | STATIC\r |
29 | VOID\r | |
30 | EFIAPI\r | |
31 | ValidateInterruptType (\r | |
32 | IN UINT8* Ptr,\r | |
33 | IN VOID* Context\r | |
34 | )\r | |
35 | {\r | |
36 | #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
f75c7478 DB |
37 | UINT8 InterruptType;\r |
38 | \r | |
39 | InterruptType = *Ptr;\r | |
40 | \r | |
ee4dc24f RN |
41 | if (InterruptType !=\r |
42 | EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {\r | |
43 | IncrementErrorCount ();\r | |
44 | Print (\r | |
45 | L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",\r | |
46 | InterruptType\r | |
47 | );\r | |
48 | }\r | |
49 | #endif\r | |
50 | }\r | |
51 | \r | |
a6eaba4d DB |
52 | /**\r |
53 | This function validates the Irq.\r | |
ee4dc24f RN |
54 | \r |
55 | @param [in] Ptr Pointer to the start of the field data.\r | |
56 | @param [in] Context Pointer to context specific information e.g. this\r | |
57 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 58 | **/\r |
ee4dc24f RN |
59 | STATIC\r |
60 | VOID\r | |
61 | EFIAPI\r | |
62 | ValidateIrq (\r | |
63 | IN UINT8* Ptr,\r | |
64 | IN VOID* Context\r | |
65 | )\r | |
66 | {\r | |
67 | #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
f75c7478 DB |
68 | UINT8 Irq;\r |
69 | \r | |
70 | Irq = *Ptr;\r | |
71 | \r | |
ee4dc24f RN |
72 | if (Irq != 0) {\r |
73 | IncrementErrorCount ();\r | |
74 | Print (\r | |
75 | L"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",\r | |
76 | Irq\r | |
77 | );\r | |
78 | }\r | |
79 | #endif\r | |
80 | }\r | |
81 | \r | |
cca8826c KK |
82 | /**\r |
83 | An ACPI_PARSER array describing the ACPI SPCR Table.\r | |
84 | **/\r | |
85 | STATIC CONST ACPI_PARSER SpcrParser[] = {\r | |
86 | PARSE_ACPI_HEADER (&AcpiHdrInfo),\r | |
87 | {L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL},\r | |
88 | {L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},\r | |
89 | {L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL},\r | |
90 | {L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL},\r | |
91 | {L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL},\r | |
92 | {L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL},\r | |
93 | {L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL},\r | |
94 | {L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL},\r | |
95 | {L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL},\r | |
96 | {L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL},\r | |
97 | {L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL},\r | |
98 | {L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL},\r | |
99 | \r | |
100 | {L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL},\r | |
101 | {L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL},\r | |
102 | {L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL},\r | |
103 | {L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL},\r | |
104 | {L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL},\r | |
105 | {L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL},\r | |
106 | {L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL},\r | |
107 | {L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL}\r | |
108 | };\r | |
109 | \r | |
a6eaba4d DB |
110 | /**\r |
111 | This function parses the ACPI SPCR table.\r | |
ee4dc24f RN |
112 | When trace is enabled this function parses the SPCR table and\r |
113 | traces the ACPI table fields.\r | |
114 | \r | |
115 | This function also performs validations of the ACPI table fields.\r | |
116 | \r | |
117 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
118 | @param [in] Ptr Pointer to the start of the buffer.\r | |
119 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
120 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 121 | **/\r |
ee4dc24f RN |
122 | VOID\r |
123 | EFIAPI\r | |
124 | ParseAcpiSpcr (\r | |
125 | IN BOOLEAN Trace,\r | |
126 | IN UINT8* Ptr,\r | |
127 | IN UINT32 AcpiTableLength,\r | |
128 | IN UINT8 AcpiTableRevision\r | |
129 | )\r | |
130 | {\r | |
131 | if (!Trace) {\r | |
132 | return;\r | |
133 | }\r | |
134 | \r | |
135 | // Dump the SPCR\r | |
136 | ParseAcpi (\r | |
137 | TRUE,\r | |
138 | 0,\r | |
139 | "SPCR",\r | |
140 | Ptr,\r | |
141 | AcpiTableLength,\r | |
142 | PARSER_PARAMS (SpcrParser)\r | |
143 | );\r | |
144 | }\r |