]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
c7acdceb9473b8c77ec2ba48b1f6dc6837f72042
[mirror_edk2.git] / ShellPkg / Library / UefiShellAcpiViewCommandLib / Parsers / Rsdp / RsdpParser.c
1 /**
2 RSDP table parser
3
4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 @par Reference(s):
14 - ACPI 6.2 Specification - Errata A, September 2017
15 **/
16
17 #include <Library/UefiLib.h>
18 #include "AcpiParser.h"
19 #include "AcpiTableParser.h"
20
21 // Local Variables
22 STATIC CONST UINT64* XsdtAddress;
23
24 /** This function validates the RSDT Address.
25
26 @param [in] Ptr Pointer to the start of the field data.
27 @param [in] Context Pointer to context specific information e.g. this
28 could be a pointer to the ACPI table header.
29 */
30 STATIC
31 VOID
32 EFIAPI
33 ValidateRsdtAddress (
34 IN UINT8* Ptr,
35 IN VOID* Context
36 );
37
38 /** This function validates the XSDT Address.
39
40 @param [in] Ptr Pointer to the start of the field data.
41 @param [in] Context Pointer to context specific information e.g. this
42 could be a pointer to the ACPI table header.
43 */
44 STATIC
45 VOID
46 EFIAPI
47 ValidateXsdtAddress (
48 IN UINT8* Ptr,
49 IN VOID* Context
50 );
51
52 /** An array describing the ACPI RSDP Table.
53 */
54 STATIC CONST ACPI_PARSER RsdpParser[] = {
55 {L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL},
56 {L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},
57 {L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL},
58 {L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL},
59 {L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL},
60 {L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL},
61 {L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID**)&XsdtAddress,
62 ValidateXsdtAddress, NULL},
63 {L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL},
64 {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}
65 };
66
67 /** This function validates the RSDT Address.
68
69 @param [in] Ptr Pointer to the start of the field data.
70 @param [in] Context Pointer to context specific information e.g. this
71 could be a pointer to the ACPI table header.
72 */
73 STATIC
74 VOID
75 EFIAPI
76 ValidateRsdtAddress (
77 IN UINT8* Ptr,
78 IN VOID* Context
79 )
80 {
81 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
82 // Reference: Server Base Boot Requirements System Software on ARM Platforms
83 // Section: 4.2.1.1 RSDP
84 // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
85 // - Within the RSDP, the RsdtAddress field must be null (zero) and the
86 // XsdtAddresss MUST be a valid, non-null, 64-bit value.
87 UINT32 RsdtAddr = *(UINT32*)Ptr;
88 if (RsdtAddr != 0) {
89 IncrementErrorCount ();
90 Print (
91 L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",
92 RsdtAddr
93 );
94 }
95 #endif
96 }
97
98 /** This function validates the XSDT Address.
99
100 @param [in] Ptr Pointer to the start of the field data.
101 @param [in] Context Pointer to context specific information e.g. this
102 could be a pointer to the ACPI table header.
103 */
104 STATIC
105 VOID
106 EFIAPI
107 ValidateXsdtAddress (
108 IN UINT8* Ptr,
109 IN VOID* Context
110 )
111 {
112 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
113 // Reference: Server Base Boot Requirements System Software on ARM Platforms
114 // Section: 4.2.1.1 RSDP
115 // Root System Description Pointer (RSDP), ACPI ? 5.2.5.
116 // - Within the RSDP, the RsdtAddress field must be null (zero) and the
117 // XsdtAddresss MUST be a valid, non-null, 64-bit value.
118 UINT64 XsdtAddr = *(UINT64*)Ptr;
119 if (XsdtAddr == 0) {
120 IncrementErrorCount ();
121 Print (
122 L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",
123 XsdtAddr
124 );
125 }
126 #endif
127 }
128
129 /** This function parses the ACPI RSDP table.
130
131 This function invokes the parser for the XSDT table.
132 * Note - This function does not support parsing of RSDT table.
133
134 This function also performs a RAW dump of the ACPI table and
135 validates the checksum.
136
137 @param [in] Trace If TRUE, trace the ACPI fields.
138 @param [in] Ptr Pointer to the start of the buffer.
139 @param [in] AcpiTableLength Length of the ACPI table.
140 @param [in] AcpiTableRevision Revision of the ACPI table.
141 */
142 VOID
143 EFIAPI
144 ParseAcpiRsdp (
145 IN BOOLEAN Trace,
146 IN UINT8* Ptr,
147 IN UINT32 AcpiTableLength,
148 IN UINT8 AcpiTableRevision
149 )
150 {
151 if (Trace) {
152 DumpRaw (Ptr, AcpiTableLength);
153 VerifyChecksum (TRUE, Ptr, AcpiTableLength);
154 }
155
156 ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS (RsdpParser));
157
158 // This code currently supports parsing of XSDT table only
159 // and does not parse the RSDT table. Platforms provide the
160 // RSDT to enable compatibility with ACPI 1.0 operating systems.
161 // Therefore the RSDT should not be used on ARM platforms.
162 if ((*XsdtAddress) == 0) {
163 IncrementErrorCount ();
164 Print (L"ERROR: XSDT Pointer is not set.\n");
165 return;
166 }
167
168 ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress));
169 }