1 /******************************************************************************
2 *
3 * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2011, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __TBXFROOT_C__
45
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "actables.h"
49
50
51 #define _COMPONENT ACPI_TABLES
52 ACPI_MODULE_NAME ("tbxfroot")
53
54 /* Local prototypes */
55
56 static UINT8 *
57 AcpiTbScanMemoryForRsdp (
58 UINT8 *StartAddress,
59 UINT32 Length);
60
61 static ACPI_STATUS
62 AcpiTbValidateRsdp (
63 ACPI_TABLE_RSDP *Rsdp);
64
65
66 /*******************************************************************************
67 *
68 * FUNCTION: AcpiTbValidateRsdp
69 *
70 * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
71 *
72 * RETURN: Status
73 *
74 * DESCRIPTION: Validate the RSDP (ptr)
75 *
76 ******************************************************************************/
77
78 static ACPI_STATUS
79 AcpiTbValidateRsdp (
80 ACPI_TABLE_RSDP *Rsdp)
81 {
82 ACPI_FUNCTION_ENTRY ();
83
84
85 /*
86 * The signature and checksum must both be correct
87 *
88 * Note: Sometimes there exists more than one RSDP in memory; the valid
89 * RSDP has a valid checksum, all others have an invalid checksum.
90 */
91 if (ACPI_STRNCMP ((char *) Rsdp, ACPI_SIG_RSDP,
92 sizeof (ACPI_SIG_RSDP)-1) != 0)
93 {
94 /* Nope, BAD Signature */
95
96 return (AE_BAD_SIGNATURE);
97 }
98
99 /* Check the standard checksum */
100
101 if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
102 {
103 return (AE_BAD_CHECKSUM);
104 }
105
106 /* Check extended checksum if table version >= 2 */
107
108 if ((Rsdp->Revision >= 2) &&
109 (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
110 {
111 return (AE_BAD_CHECKSUM);
112 }
217
218 return_ACPI_STATUS (AE_NO_MEMORY);
219 }
220
221 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
222 AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
223
224 if (MemRover)
225 {
226 /* Return the physical address */
227
228 PhysicalAddress = (UINT32)
229 (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
230
231 *TableAddress = PhysicalAddress;
232 return_ACPI_STATUS (AE_OK);
233 }
234
235 /* A valid RSDP was not found */
236
237 ACPI_ERROR ((AE_INFO, "A valid RSDP was not found"));
238 return_ACPI_STATUS (AE_NOT_FOUND);
239 }
240
241 ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
242
243
244 /*******************************************************************************
245 *
246 * FUNCTION: AcpiTbScanMemoryForRsdp
247 *
248 * PARAMETERS: StartAddress - Starting pointer for search
249 * Length - Maximum length to search
250 *
251 * RETURN: Pointer to the RSDP if found, otherwise NULL.
252 *
253 * DESCRIPTION: Search a block of memory for the RSDP signature
254 *
255 ******************************************************************************/
256
257 static UINT8 *
258 AcpiTbScanMemoryForRsdp (
259 UINT8 *StartAddress,
260 UINT32 Length)
261 {
262 ACPI_STATUS Status;
263 UINT8 *MemRover;
264 UINT8 *EndAddress;
265
266
267 ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
268
269
270 EndAddress = StartAddress + Length;
271
272 /* Search from given start address for the requested length */
273
274 for (MemRover = StartAddress; MemRover < EndAddress;
275 MemRover += ACPI_RSDP_SCAN_STEP)
276 {
277 /* The RSDP signature and checksum must both be correct */
279 Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
280 if (ACPI_SUCCESS (Status))
281 {
282 /* Sig and checksum valid, we have found a real RSDP */
283
284 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
285 "RSDP located at physical address %p\n", MemRover));
286 return_PTR (MemRover);
287 }
288
289 /* No sig match or bad checksum, keep searching */
290 }
291
292 /* Searched entire block, no RSDP was found */
293
294 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
295 "Searched entire block from %p, valid RSDP was not found\n",
296 StartAddress));
297 return_PTR (NULL);
298 }
299
|
1 /******************************************************************************
2 *
3 * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __TBXFROOT_C__
45
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "actables.h"
49
50
51 #define _COMPONENT ACPI_TABLES
52 ACPI_MODULE_NAME ("tbxfroot")
53
54
55 /*******************************************************************************
56 *
57 * FUNCTION: AcpiTbValidateRsdp
58 *
59 * PARAMETERS: Rsdp - Pointer to unvalidated RSDP
60 *
61 * RETURN: Status
62 *
63 * DESCRIPTION: Validate the RSDP (ptr)
64 *
65 ******************************************************************************/
66
67 ACPI_STATUS
68 AcpiTbValidateRsdp (
69 ACPI_TABLE_RSDP *Rsdp)
70 {
71
72 /*
73 * The signature and checksum must both be correct
74 *
75 * Note: Sometimes there exists more than one RSDP in memory; the valid
76 * RSDP has a valid checksum, all others have an invalid checksum.
77 */
78 if (!ACPI_VALIDATE_RSDP_SIG (Rsdp->Signature))
79 {
80 /* Nope, BAD Signature */
81
82 return (AE_BAD_SIGNATURE);
83 }
84
85 /* Check the standard checksum */
86
87 if (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
88 {
89 return (AE_BAD_CHECKSUM);
90 }
91
92 /* Check extended checksum if table version >= 2 */
93
94 if ((Rsdp->Revision >= 2) &&
95 (AcpiTbChecksum ((UINT8 *) Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
96 {
97 return (AE_BAD_CHECKSUM);
98 }
203
204 return_ACPI_STATUS (AE_NO_MEMORY);
205 }
206
207 MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
208 AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
209
210 if (MemRover)
211 {
212 /* Return the physical address */
213
214 PhysicalAddress = (UINT32)
215 (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
216
217 *TableAddress = PhysicalAddress;
218 return_ACPI_STATUS (AE_OK);
219 }
220
221 /* A valid RSDP was not found */
222
223 ACPI_BIOS_ERROR ((AE_INFO, "A valid RSDP was not found"));
224 return_ACPI_STATUS (AE_NOT_FOUND);
225 }
226
227 ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
228
229
230 /*******************************************************************************
231 *
232 * FUNCTION: AcpiTbScanMemoryForRsdp
233 *
234 * PARAMETERS: StartAddress - Starting pointer for search
235 * Length - Maximum length to search
236 *
237 * RETURN: Pointer to the RSDP if found, otherwise NULL.
238 *
239 * DESCRIPTION: Search a block of memory for the RSDP signature
240 *
241 ******************************************************************************/
242
243 UINT8 *
244 AcpiTbScanMemoryForRsdp (
245 UINT8 *StartAddress,
246 UINT32 Length)
247 {
248 ACPI_STATUS Status;
249 UINT8 *MemRover;
250 UINT8 *EndAddress;
251
252
253 ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
254
255
256 EndAddress = StartAddress + Length;
257
258 /* Search from given start address for the requested length */
259
260 for (MemRover = StartAddress; MemRover < EndAddress;
261 MemRover += ACPI_RSDP_SCAN_STEP)
262 {
263 /* The RSDP signature and checksum must both be correct */
265 Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (ACPI_TABLE_RSDP, MemRover));
266 if (ACPI_SUCCESS (Status))
267 {
268 /* Sig and checksum valid, we have found a real RSDP */
269
270 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
271 "RSDP located at physical address %p\n", MemRover));
272 return_PTR (MemRover);
273 }
274
275 /* No sig match or bad checksum, keep searching */
276 }
277
278 /* Searched entire block, no RSDP was found */
279
280 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
281 "Searched entire block from %p, valid RSDP was not found\n",
282 StartAddress));
283 return_PTR (NULL);
284 }
|