]>
Commit | Line | Data |
---|---|---|
a6eaba4d | 1 | /** @file\r |
ee4dc24f RN |
2 | SLIT 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 | - ACPI 6.2 Specification - Errata A, September 2017\r | |
15 | **/\r | |
16 | \r | |
17 | #include <IndustryStandard/Acpi.h>\r | |
18 | #include <Library/PrintLib.h>\r | |
19 | #include <Library/UefiLib.h>\r | |
20 | #include "AcpiParser.h"\r | |
21 | #include "AcpiTableParser.h"\r | |
22 | \r | |
23 | // Local Variables\r | |
24 | STATIC CONST UINT64* SlitSystemLocalityCount;\r | |
25 | STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r | |
26 | \r | |
a6eaba4d DB |
27 | /**\r |
28 | An ACPI_PARSER array describing the ACPI SLIT table.\r | |
29 | **/\r | |
ee4dc24f RN |
30 | STATIC CONST ACPI_PARSER SlitParser[] = {\r |
31 | PARSE_ACPI_HEADER (&AcpiHdrInfo),\r | |
32 | {L"Number of System Localities", 8, 36, L"0x%lx", NULL,\r | |
33 | (VOID**)&SlitSystemLocalityCount, NULL, NULL}\r | |
34 | };\r | |
35 | \r | |
a6eaba4d DB |
36 | /**\r |
37 | Macro to get the value of a System Locality\r | |
38 | **/\r | |
ee4dc24f RN |
39 | #define SLIT_ELEMENT(Ptr, i, j) *(Ptr + (i * LocalityCount) + j)\r |
40 | \r | |
a6eaba4d DB |
41 | /**\r |
42 | This function parses the ACPI SLIT table.\r | |
ee4dc24f RN |
43 | When trace is enabled this function parses the SLIT table and\r |
44 | traces the ACPI table fields.\r | |
45 | \r | |
46 | This function also validates System Localities for the following:\r | |
47 | - Diagonal elements have a normalized value of 10\r | |
48 | - Relative distance from System Locality at i*N+j is same as\r | |
49 | j*N+i\r | |
50 | \r | |
51 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
52 | @param [in] Ptr Pointer to the start of the buffer.\r | |
53 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
54 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 55 | **/\r |
ee4dc24f RN |
56 | VOID\r |
57 | EFIAPI\r | |
58 | ParseAcpiSlit (\r | |
59 | IN BOOLEAN Trace,\r | |
60 | IN UINT8* Ptr,\r | |
61 | IN UINT32 AcpiTableLength,\r | |
62 | IN UINT8 AcpiTableRevision\r | |
63 | )\r | |
64 | {\r | |
65 | UINT32 Offset;\r | |
f75c7478 DB |
66 | UINT64 Count;\r |
67 | UINT64 Index;\r | |
ee4dc24f RN |
68 | UINT64 LocalityCount;\r |
69 | UINT8* LocalityPtr;\r | |
70 | CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi\r | |
71 | \r | |
72 | if (!Trace) {\r | |
73 | return;\r | |
74 | }\r | |
75 | \r | |
76 | Offset = ParseAcpi (\r | |
77 | TRUE,\r | |
78 | 0,\r | |
79 | "SLIT",\r | |
80 | Ptr,\r | |
81 | AcpiTableLength,\r | |
82 | PARSER_PARAMS (SlitParser)\r | |
83 | );\r | |
84 | LocalityPtr = Ptr + Offset;\r | |
85 | \r | |
86 | LocalityCount = *SlitSystemLocalityCount;\r | |
87 | // We only print the Localities if the count is less than 16\r | |
88 | // If the locality count is more than 16 then refer to the\r | |
89 | // raw data dump.\r | |
90 | if (LocalityCount < 16) {\r | |
91 | UnicodeSPrint (\r | |
92 | Buffer,\r | |
93 | sizeof (Buffer),\r | |
94 | L"Entry[0x%lx][0x%lx]",\r | |
95 | LocalityCount,\r | |
96 | LocalityCount\r | |
97 | );\r | |
98 | PrintFieldName (0, Buffer);\r | |
99 | Print (L"\n");\r | |
100 | Print (L" ");\r | |
f75c7478 DB |
101 | for (Index = 0; Index < LocalityCount; Index++) {\r |
102 | Print (L" (%3d) ", Index);\r | |
ee4dc24f RN |
103 | }\r |
104 | Print (L"\n");\r | |
f75c7478 DB |
105 | for (Count = 0; Count< LocalityCount; Count++) {\r |
106 | Print (L" (%3d) ", Count);\r | |
107 | for (Index = 0; Index < LocalityCount; Index++) {\r | |
108 | Print (L" %3d ", SLIT_ELEMENT (LocalityPtr, Count, Index));\r | |
ee4dc24f RN |
109 | }\r |
110 | Print (L"\n");\r | |
111 | }\r | |
112 | }\r | |
113 | \r | |
114 | // Validate\r | |
f75c7478 DB |
115 | for (Count = 0; Count < LocalityCount; Count++) {\r |
116 | for (Index = 0; Index < LocalityCount; Index++) {\r | |
ee4dc24f | 117 | // Element[x][x] must be equal to 10\r |
f75c7478 | 118 | if ((Count == Index) && (SLIT_ELEMENT (LocalityPtr, Count,Index) != 10)) {\r |
ee4dc24f RN |
119 | IncrementErrorCount ();\r |
120 | Print (\r | |
121 | L"ERROR: Diagonal Element[0x%lx][0x%lx] (%3d)."\r | |
122 | " Normalized Value is not 10\n",\r | |
f75c7478 DB |
123 | Count,\r |
124 | Index,\r | |
125 | SLIT_ELEMENT (LocalityPtr, Count, Index)\r | |
ee4dc24f RN |
126 | );\r |
127 | }\r | |
128 | // Element[i][j] must be equal to Element[j][i]\r | |
f75c7478 DB |
129 | if (SLIT_ELEMENT (LocalityPtr, Count, Index) !=\r |
130 | SLIT_ELEMENT (LocalityPtr, Index, Count)) {\r | |
ee4dc24f RN |
131 | IncrementErrorCount ();\r |
132 | Print (\r | |
133 | L"ERROR: Relative distances for Element[0x%lx][0x%lx] (%3d) and \n"\r | |
134 | "Element[0x%lx][0x%lx] (%3d) do not match.\n",\r | |
f75c7478 DB |
135 | Count,\r |
136 | Index,\r | |
137 | SLIT_ELEMENT (LocalityPtr, Count, Index),\r | |
138 | Index,\r | |
139 | Count,\r | |
140 | SLIT_ELEMENT (LocalityPtr, Index, Count)\r | |
ee4dc24f RN |
141 | );\r |
142 | }\r | |
143 | }\r | |
144 | }\r | |
145 | }\r |