4 Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - ACPI 6.2 Specification - Errata A, September 2017
11 #include <IndustryStandard/Acpi.h>
12 #include <Library/PrintLib.h>
13 #include <Library/UefiLib.h>
14 #include "AcpiParser.h"
15 #include "AcpiTableParser.h"
18 STATIC CONST UINT64
* SlitSystemLocalityCount
;
19 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
22 An ACPI_PARSER array describing the ACPI SLIT table.
24 STATIC CONST ACPI_PARSER SlitParser
[] = {
25 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
26 {L
"Number of System Localities", 8, 36, L
"0x%lx", NULL
,
27 (VOID
**)&SlitSystemLocalityCount
, NULL
, NULL
}
31 Macro to get the value of a System Locality
33 #define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)
36 This function parses the ACPI SLIT table.
37 When trace is enabled this function parses the SLIT table and
38 traces the ACPI table fields.
40 This function also validates System Localities for the following:
41 - Diagonal elements have a normalized value of 10
42 - Relative distance from System Locality at i*N+j is same as
45 @param [in] Trace If TRUE, trace the ACPI fields.
46 @param [in] Ptr Pointer to the start of the buffer.
47 @param [in] AcpiTableLength Length of the ACPI table.
48 @param [in] AcpiTableRevision Revision of the ACPI table.
55 IN UINT32 AcpiTableLength
,
56 IN UINT8 AcpiTableRevision
64 CHAR16 Buffer
[80]; // Used for AsciiName param of ParseAcpi
76 PARSER_PARAMS (SlitParser
)
79 // Check if the values used to control the parsing logic have been
81 if (SlitSystemLocalityCount
== NULL
) {
82 IncrementErrorCount ();
84 L
"ERROR: Insufficient table length. AcpiTableLength = %d.\n",
91 Despite the 'Number of System Localities' being a 64-bit field in SLIT,
92 the maximum number of localities that can be represented in SLIT is limited
93 by the 'Length' field of the ACPI table.
95 Since the ACPI table length field is 32-bit wide. The maximum number of
96 localities that can be represented in SLIT can be calculated as:
98 MaxLocality = sqrt (MAX_UINT32 - sizeof (EFI_ACPI_6_3_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER))
102 if (*SlitSystemLocalityCount
> MAX_UINT16
) {
103 IncrementErrorCount ();
105 L
"ERROR: The Number of System Localities provided can't be represented " \
106 L
"in the SLIT table. SlitSystemLocalityCount = %ld. " \
107 L
"MaxLocalityCountAllowed = %d.\n",
108 *SlitSystemLocalityCount
,
114 LocalityCount
= (UINT32
)*SlitSystemLocalityCount
;
116 // Make sure system localities fit in the table buffer provided
117 if (Offset
+ (LocalityCount
* LocalityCount
) > AcpiTableLength
) {
118 IncrementErrorCount ();
120 L
"ERROR: Invalid Number of System Localities. " \
121 L
"SlitSystemLocalityCount = %ld. AcpiTableLength = %d.\n",
122 *SlitSystemLocalityCount
,
128 LocalityPtr
= Ptr
+ Offset
;
130 // We only print the Localities if the count is less than 16
131 // If the locality count is more than 16 then refer to the
133 if (LocalityCount
< 16) {
137 L
"Entry[0x%lx][0x%lx]",
141 PrintFieldName (0, Buffer
);
144 for (Index
= 0; Index
< LocalityCount
; Index
++) {
145 Print (L
" (%3d) ", Index
);
148 for (Count
= 0; Count
< LocalityCount
; Count
++) {
149 Print (L
" (%3d) ", Count
);
150 for (Index
= 0; Index
< LocalityCount
; Index
++) {
151 Print (L
" %3d ", SLIT_ELEMENT (LocalityPtr
, Count
, Index
));
158 for (Count
= 0; Count
< LocalityCount
; Count
++) {
159 for (Index
= 0; Index
< LocalityCount
; Index
++) {
160 // Element[x][x] must be equal to 10
161 if ((Count
== Index
) && (SLIT_ELEMENT (LocalityPtr
, Count
,Index
) != 10)) {
162 IncrementErrorCount ();
164 L
"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."
165 L
" Normalized Value is not 10\n",
168 SLIT_ELEMENT (LocalityPtr
, Count
, Index
)
171 // Element[i][j] must be equal to Element[j][i]
172 if (SLIT_ELEMENT (LocalityPtr
, Count
, Index
) !=
173 SLIT_ELEMENT (LocalityPtr
, Index
, Count
)) {
174 IncrementErrorCount ();
176 L
"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"
177 L
"Element[0x%lx][0x%lx] (%3d) do not match.\n",
180 SLIT_ELEMENT (LocalityPtr
, Count
, Index
),
183 SLIT_ELEMENT (LocalityPtr
, Index
, Count
)