]>
Commit | Line | Data |
---|---|---|
a6eaba4d | 1 | /** @file\r |
ee4dc24f RN |
2 | SPCR table parser\r |
3 | \r | |
4 | Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | @par Reference(s):\r | |
14 | - Microsoft Serial Port Console Redirection Table\r | |
15 | Specification - Version 1.03 - August 10, 2015.\r | |
16 | **/\r | |
17 | \r | |
18 | #include <IndustryStandard/Acpi.h>\r | |
19 | #include <IndustryStandard/SerialPortConsoleRedirectionTable.h>\r | |
20 | #include <Library/UefiLib.h>\r | |
21 | #include "AcpiParser.h"\r | |
22 | #include "AcpiTableParser.h"\r | |
23 | \r | |
24 | // Local variables\r | |
25 | STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r | |
26 | \r | |
a6eaba4d DB |
27 | /**\r |
28 | This function validates the Interrupt Type.\r | |
ee4dc24f RN |
29 | \r |
30 | @param [in] Ptr Pointer to the start of the field data.\r | |
31 | @param [in] Context Pointer to context specific information e.g. this\r | |
32 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 33 | **/\r |
ee4dc24f RN |
34 | STATIC\r |
35 | VOID\r | |
36 | EFIAPI\r | |
37 | ValidateInterruptType (\r | |
38 | IN UINT8* Ptr,\r | |
39 | IN VOID* Context\r | |
40 | );\r | |
41 | \r | |
a6eaba4d DB |
42 | /**\r |
43 | This function validates the Irq.\r | |
ee4dc24f RN |
44 | \r |
45 | @param [in] Ptr Pointer to the start of the field data.\r | |
46 | @param [in] Context Pointer to context specific information e.g. this\r | |
47 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 48 | **/\r |
ee4dc24f RN |
49 | STATIC\r |
50 | VOID\r | |
51 | EFIAPI\r | |
52 | ValidateIrq (\r | |
53 | IN UINT8* Ptr,\r | |
54 | IN VOID* Context\r | |
55 | );\r | |
56 | \r | |
a6eaba4d DB |
57 | /**\r |
58 | An ACPI_PARSER array describing the ACPI SPCR Table.\r | |
59 | **/\r | |
ee4dc24f RN |
60 | STATIC CONST ACPI_PARSER SpcrParser[] = {\r |
61 | PARSE_ACPI_HEADER (&AcpiHdrInfo),\r | |
62 | {L"Interface Type", 1, 36, L"%d", NULL, NULL, NULL, NULL},\r | |
63 | {L"Reserved", 3, 37, L"%x %x %x", Dump3Chars, NULL, NULL, NULL},\r | |
64 | {L"Base Address", 12, 40, NULL, DumpGas, NULL, NULL, NULL},\r | |
65 | {L"Interrupt Type", 1, 52, L"%d", NULL, NULL, ValidateInterruptType, NULL},\r | |
66 | {L"IRQ", 1, 53, L"%d", NULL, NULL, ValidateIrq, NULL},\r | |
67 | {L"Global System Interrupt", 4, 54, L"0x%x", NULL, NULL, NULL, NULL},\r | |
68 | {L"Baud Rate", 1, 58, L"%d", NULL, NULL, NULL, NULL},\r | |
69 | {L"Parity", 1, 59, L"%d", NULL, NULL, NULL, NULL},\r | |
70 | {L"Stop Bits", 1, 60, L"%d", NULL, NULL, NULL, NULL},\r | |
71 | {L"Flow Control", 1, 61, L"0x%x", NULL, NULL, NULL, NULL},\r | |
72 | {L"Terminal Type", 1, 62, L"%d", NULL, NULL, NULL, NULL},\r | |
73 | {L"Reserved", 1, 63, L"%x", NULL, NULL, NULL, NULL},\r | |
74 | \r | |
75 | {L"PCI Device ID", 2, 64, L"0x%x", NULL, NULL, NULL, NULL},\r | |
76 | {L"PCI Vendor ID", 2, 66, L"0x%x", NULL, NULL, NULL, NULL},\r | |
77 | {L"PCI Bus Number", 1, 68, L"0x%x", NULL, NULL, NULL, NULL},\r | |
78 | {L"PCI Device Number", 1, 69, L"0x%x", NULL, NULL, NULL, NULL},\r | |
79 | {L"PCI Function Number", 1, 70, L"0x%x", NULL, NULL, NULL, NULL},\r | |
80 | {L"PCI Flags", 4, 71, L"0x%x", NULL, NULL, NULL, NULL},\r | |
81 | {L"PCI Segment", 1, 75, L"0x%x", NULL, NULL, NULL, NULL},\r | |
82 | {L"Reserved", 4, 76, L"%x", NULL, NULL, NULL, NULL}\r | |
83 | };\r | |
84 | \r | |
a6eaba4d DB |
85 | /**\r |
86 | This function validates the Interrupt Type.\r | |
ee4dc24f RN |
87 | \r |
88 | @param [in] Ptr Pointer to the start of the field data.\r | |
89 | @param [in] Context Pointer to context specific information e.g. this\r | |
90 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 91 | **/\r |
ee4dc24f RN |
92 | STATIC\r |
93 | VOID\r | |
94 | EFIAPI\r | |
95 | ValidateInterruptType (\r | |
96 | IN UINT8* Ptr,\r | |
97 | IN VOID* Context\r | |
98 | )\r | |
99 | {\r | |
100 | #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
101 | UINT8 InterruptType = *Ptr;\r | |
102 | if (InterruptType !=\r | |
103 | EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_INTERRUPT_TYPE_GIC) {\r | |
104 | IncrementErrorCount ();\r | |
105 | Print (\r | |
106 | L"\nERROR: InterruptType = %d. This must be 8 on ARM Platforms",\r | |
107 | InterruptType\r | |
108 | );\r | |
109 | }\r | |
110 | #endif\r | |
111 | }\r | |
112 | \r | |
a6eaba4d DB |
113 | /**\r |
114 | This function validates the Irq.\r | |
ee4dc24f RN |
115 | \r |
116 | @param [in] Ptr Pointer to the start of the field data.\r | |
117 | @param [in] Context Pointer to context specific information e.g. this\r | |
118 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 119 | **/\r |
ee4dc24f RN |
120 | STATIC\r |
121 | VOID\r | |
122 | EFIAPI\r | |
123 | ValidateIrq (\r | |
124 | IN UINT8* Ptr,\r | |
125 | IN VOID* Context\r | |
126 | )\r | |
127 | {\r | |
128 | #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
129 | UINT8 Irq = *Ptr;\r | |
130 | if (Irq != 0) {\r | |
131 | IncrementErrorCount ();\r | |
132 | Print (\r | |
133 | L"\nERROR: Irq = %d. This must be zero on ARM Platforms\n",\r | |
134 | Irq\r | |
135 | );\r | |
136 | }\r | |
137 | #endif\r | |
138 | }\r | |
139 | \r | |
a6eaba4d DB |
140 | /**\r |
141 | This function parses the ACPI SPCR table.\r | |
ee4dc24f RN |
142 | When trace is enabled this function parses the SPCR table and\r |
143 | traces the ACPI table fields.\r | |
144 | \r | |
145 | This function also performs validations of the ACPI table fields.\r | |
146 | \r | |
147 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
148 | @param [in] Ptr Pointer to the start of the buffer.\r | |
149 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
150 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 151 | **/\r |
ee4dc24f RN |
152 | VOID\r |
153 | EFIAPI\r | |
154 | ParseAcpiSpcr (\r | |
155 | IN BOOLEAN Trace,\r | |
156 | IN UINT8* Ptr,\r | |
157 | IN UINT32 AcpiTableLength,\r | |
158 | IN UINT8 AcpiTableRevision\r | |
159 | )\r | |
160 | {\r | |
161 | if (!Trace) {\r | |
162 | return;\r | |
163 | }\r | |
164 | \r | |
165 | // Dump the SPCR\r | |
166 | ParseAcpi (\r | |
167 | TRUE,\r | |
168 | 0,\r | |
169 | "SPCR",\r | |
170 | Ptr,\r | |
171 | AcpiTableLength,\r | |
172 | PARSER_PARAMS (SpcrParser)\r | |
173 | );\r | |
174 | }\r |