xref: /titanic_41/usr/src/uts/intel/io/acpica/tables/tbxfroot.c (revision 2449e17f82f6097fd2c665b64723e31ceecbeca6)
1 /******************************************************************************
2  *
3  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4  *              $Revision: 1.102 $
5  *
6  *****************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
17  * 2.1. This is your license from Intel Corp. under its intellectual property
18  * rights.  You may have additional license terms from the party that provided
19  * you this software, covering your right to use that party's intellectual
20  * property rights.
21  *
22  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23  * copy of the source code appearing in this file ("Covered Code") an
24  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25  * base code distributed originally by Intel ("Original Intel Code") to copy,
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code.  No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision.  In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change.  Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee.  Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution.  In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government.  In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #define __TBXFROOT_C__
118 
119 #include "acpi.h"
120 #include "actables.h"
121 
122 
123 #define _COMPONENT          ACPI_TABLES
124         ACPI_MODULE_NAME    ("tbxfroot")
125 
126 /* Local prototypes */
127 
128 static ACPI_STATUS
129 AcpiTbFindRsdp (
130     ACPI_TABLE_DESC         *TableInfo,
131     UINT32                  Flags);
132 
133 static UINT8 *
134 AcpiTbScanMemoryForRsdp (
135     UINT8                   *StartAddress,
136     UINT32                  Length);
137 
138 
139 /*******************************************************************************
140  *
141  * FUNCTION:    AcpiTbValidateRsdp
142  *
143  * PARAMETERS:  Rsdp        - Pointer to unvalidated RSDP
144  *
145  * RETURN:      Status
146  *
147  * DESCRIPTION: Validate the RSDP (ptr)
148  *
149  ******************************************************************************/
150 
151 ACPI_STATUS
152 AcpiTbValidateRsdp (
153     RSDP_DESCRIPTOR         *Rsdp)
154 {
155     ACPI_FUNCTION_ENTRY ();
156 
157 
158     /*
159      *  The signature and checksum must both be correct
160      */
161     if (ACPI_STRNCMP ((char *) Rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0)
162     {
163         /* Nope, BAD Signature */
164 
165         return (AE_BAD_SIGNATURE);
166     }
167 
168     /* Check the standard checksum */
169 
170     if (AcpiTbSumTable (Rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
171     {
172         return (AE_BAD_CHECKSUM);
173     }
174 
175     /* Check extended checksum if table version >= 2 */
176 
177     if ((Rsdp->Revision >= 2) &&
178         (AcpiTbSumTable (Rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0))
179     {
180         return (AE_BAD_CHECKSUM);
181     }
182 
183     return (AE_OK);
184 }
185 
186 
187 /*******************************************************************************
188  *
189  * FUNCTION:    AcpiTbFindTable
190  *
191  * PARAMETERS:  Signature           - String with ACPI table signature
192  *              OemId               - String with the table OEM ID
193  *              OemTableId          - String with the OEM Table ID
194  *              TablePtr            - Where the table pointer is returned
195  *
196  * RETURN:      Status
197  *
198  * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
199  *              Signature, OEM ID and OEM Table ID.
200  *
201  ******************************************************************************/
202 
203 ACPI_STATUS
204 AcpiTbFindTable (
205     char                    *Signature,
206     char                    *OemId,
207     char                    *OemTableId,
208     ACPI_TABLE_HEADER       **TablePtr)
209 {
210     ACPI_STATUS             Status;
211     ACPI_TABLE_HEADER       *Table;
212 
213 
214     ACPI_FUNCTION_TRACE (TbFindTable);
215 
216 
217     /* Validate string lengths */
218 
219     if ((ACPI_STRLEN (Signature)  > ACPI_NAME_SIZE) ||
220         (ACPI_STRLEN (OemId)      > sizeof (Table->OemId)) ||
221         (ACPI_STRLEN (OemTableId) > sizeof (Table->OemTableId)))
222     {
223         return_ACPI_STATUS (AE_AML_STRING_LIMIT);
224     }
225 
226     if (ACPI_COMPARE_NAME (Signature, DSDT_SIG))
227     {
228         /*
229          * The DSDT pointer is contained in the FADT, not the RSDT.
230          * This code should suffice, because the only code that would perform
231          * a "find" on the DSDT is the DataTableRegion() AML opcode -- in
232          * which case, the DSDT is guaranteed to be already loaded.
233          * If this becomes insufficient, the FADT will have to be found first.
234          */
235         if (!AcpiGbl_DSDT)
236         {
237             return_ACPI_STATUS (AE_NO_ACPI_TABLES);
238         }
239         Table = AcpiGbl_DSDT;
240     }
241     else
242     {
243         /* Find the table */
244 
245         Status = AcpiGetFirmwareTable (Signature, 1,
246                     ACPI_LOGICAL_ADDRESSING, &Table);
247         if (ACPI_FAILURE (Status))
248         {
249             return_ACPI_STATUS (Status);
250         }
251     }
252 
253     /* Check OemId and OemTableId */
254 
255     if ((OemId[0] &&
256         ACPI_STRNCMP (
257             OemId, Table->OemId,
258             sizeof (Table->OemId))) ||
259 
260         (OemTableId[0] &&
261         ACPI_STRNCMP (
262             OemTableId, Table->OemTableId,
263             sizeof (Table->OemTableId))))
264     {
265         return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
266     }
267 
268     ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
269         Table->Signature));
270 
271     *TablePtr = Table;
272     return_ACPI_STATUS (AE_OK);
273 }
274 
275 
276 /*******************************************************************************
277  *
278  * FUNCTION:    AcpiGetFirmwareTable
279  *
280  * PARAMETERS:  Signature       - Any ACPI table signature
281  *              Instance        - the non zero instance of the table, allows
282  *                                support for multiple tables of the same type
283  *              Flags           - Physical/Virtual support
284  *              TablePointer    - Where a buffer containing the table is
285  *                                returned
286  *
287  * RETURN:      Status
288  *
289  * DESCRIPTION: This function is called to get an ACPI table. A buffer is
290  *              allocated for the table and returned in TablePointer.
291  *              This table will be a complete table including the header.
292  *
293  ******************************************************************************/
294 
295 ACPI_STATUS
296 AcpiGetFirmwareTable (
297     ACPI_STRING             Signature,
298     UINT32                  Instance,
299     UINT32                  Flags,
300     ACPI_TABLE_HEADER       **TablePointer)
301 {
302     ACPI_STATUS             Status;
303     ACPI_POINTER            Address;
304     ACPI_TABLE_HEADER       *Header = NULL;
305     ACPI_TABLE_DESC         *TableInfo = NULL;
306     ACPI_TABLE_DESC         *RsdtInfo;
307     UINT32                  TableCount;
308     UINT32                  i;
309     UINT32                  j;
310 
311 
312     ACPI_FUNCTION_TRACE (AcpiGetFirmwareTable);
313 
314 
315     /*
316      * Ensure that at least the table manager is initialized.  We don't
317      * require that the entire ACPI subsystem is up for this interface.
318      * If we have a buffer, we must have a length too
319      */
320     if ((Instance == 0)     ||
321         (!Signature)        ||
322         (!TablePointer))
323     {
324         return_ACPI_STATUS (AE_BAD_PARAMETER);
325     }
326 
327     /* Ensure that we have a RSDP */
328 
329     if (!AcpiGbl_RSDP)
330     {
331         /* Get the RSDP */
332 
333         Status = AcpiOsGetRootPointer (Flags, &Address);
334         if (ACPI_FAILURE (Status))
335         {
336             ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n"));
337             return_ACPI_STATUS (AE_NO_ACPI_TABLES);
338         }
339 
340         /* Map and validate the RSDP */
341 
342         if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
343         {
344             Status = AcpiOsMapMemory (Address.Pointer.Physical,
345                         sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP);
346             if (ACPI_FAILURE (Status))
347             {
348                 return_ACPI_STATUS (Status);
349             }
350         }
351         else
352         {
353             AcpiGbl_RSDP = Address.Pointer.Logical;
354         }
355 
356         /* The RDSP signature and checksum must both be correct */
357 
358         Status = AcpiTbValidateRsdp (AcpiGbl_RSDP);
359         if (ACPI_FAILURE (Status))
360         {
361             return_ACPI_STATUS (Status);
362         }
363     }
364 
365     /* Get the RSDT address via the RSDP */
366 
367     AcpiTbGetRsdtAddress (&Address);
368     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
369         "RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
370         AcpiGbl_RSDP,
371         ACPI_FORMAT_UINT64 (Address.Pointer.Value)));
372 
373     /* Insert ProcessorMode flags */
374 
375     Address.PointerType |= Flags;
376 
377     /* Get and validate the RSDT */
378 
379     RsdtInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_TABLE_DESC));
380     if (!RsdtInfo)
381     {
382         return_ACPI_STATUS (AE_NO_MEMORY);
383     }
384 
385     Status = AcpiTbGetTable (&Address, RsdtInfo);
386     if (ACPI_FAILURE (Status))
387     {
388         goto Cleanup;
389     }
390 
391     Status = AcpiTbValidateRsdt (RsdtInfo->Pointer);
392     if (ACPI_FAILURE (Status))
393     {
394         goto Cleanup;
395     }
396 
397     /* Allocate a scratch table header and table descriptor */
398 
399     Header = ACPI_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
400     if (!Header)
401     {
402         Status = AE_NO_MEMORY;
403         goto Cleanup;
404     }
405 
406     TableInfo = ACPI_ALLOCATE (sizeof (ACPI_TABLE_DESC));
407     if (!TableInfo)
408     {
409         Status = AE_NO_MEMORY;
410         goto Cleanup;
411     }
412 
413     /* Get the number of table pointers within the RSDT */
414 
415     TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer);
416     Address.PointerType = AcpiGbl_TableFlags | Flags;
417 
418     /*
419      * Search the RSDT/XSDT for the correct instance of the
420      * requested table
421      */
422     for (i = 0, j = 0; i < TableCount; i++)
423     {
424         /*
425          * Get the next table pointer, handle RSDT vs. XSDT
426          * RSDT pointers are 32 bits, XSDT pointers are 64 bits
427          */
428         if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT)
429         {
430             Address.Pointer.Value = (ACPI_CAST_PTR (
431                 RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i];
432         }
433         else
434         {
435             Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR (
436                 XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]);
437         }
438 
439         /* Get the table header */
440 
441         Status = AcpiTbGetTableHeader (&Address, Header);
442         if (ACPI_FAILURE (Status))
443         {
444             goto Cleanup;
445         }
446 
447         /* Compare table signatures and table instance */
448 
449         if (ACPI_COMPARE_NAME (Header->Signature, Signature))
450         {
451             /* An instance of the table was found */
452 
453             j++;
454             if (j >= Instance)
455             {
456                 /* Found the correct instance, get the entire table */
457 
458                 Status = AcpiTbGetTableBody (&Address, Header, TableInfo);
459                 if (ACPI_FAILURE (Status))
460                 {
461                     goto Cleanup;
462                 }
463 
464                 *TablePointer = TableInfo->Pointer;
465                 goto Cleanup;
466             }
467         }
468     }
469 
470     /* Did not find the table */
471 
472     Status = AE_NOT_EXIST;
473 
474 
475 Cleanup:
476     if (RsdtInfo->Pointer)
477     {
478         AcpiOsUnmapMemory (RsdtInfo->Pointer,
479             (ACPI_SIZE) RsdtInfo->Pointer->Length);
480     }
481     ACPI_FREE (RsdtInfo);
482 
483     if (Header)
484     {
485         ACPI_FREE (Header);
486     }
487     if (TableInfo)
488     {
489         ACPI_FREE (TableInfo);
490     }
491     return_ACPI_STATUS (Status);
492 }
493 
494 ACPI_EXPORT_SYMBOL (AcpiGetFirmwareTable)
495 
496 
497 /* TBD: Move to a new file */
498 
499 #if ACPI_MACHINE_WIDTH != 16
500 
501 /*******************************************************************************
502  *
503  * FUNCTION:    AcpiFindRootPointer
504  *
505  * PARAMETERS:  Flags                   - Logical/Physical addressing
506  *              RsdpAddress             - Where to place the RSDP address
507  *
508  * RETURN:      Status, Physical address of the RSDP
509  *
510  * DESCRIPTION: Find the RSDP
511  *
512  ******************************************************************************/
513 
514 ACPI_STATUS
515 AcpiFindRootPointer (
516     UINT32                  Flags,
517     ACPI_POINTER            *RsdpAddress)
518 {
519     ACPI_TABLE_DESC         TableInfo;
520     ACPI_STATUS             Status;
521 
522 
523     ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
524 
525 
526     /* Get the RSDP */
527 
528     Status = AcpiTbFindRsdp (&TableInfo, Flags);
529     if (ACPI_FAILURE (Status))
530     {
531         ACPI_EXCEPTION ((AE_INFO, Status,
532             "RSDP structure not found - Flags=%X", Flags));
533 
534         return_ACPI_STATUS (AE_NO_ACPI_TABLES);
535     }
536 
537     RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER;
538     RsdpAddress->Pointer.Physical = TableInfo.PhysicalAddress;
539     return_ACPI_STATUS (AE_OK);
540 }
541 
542 ACPI_EXPORT_SYMBOL (AcpiFindRootPointer)
543 
544 
545 /*******************************************************************************
546  *
547  * FUNCTION:    AcpiTbScanMemoryForRsdp
548  *
549  * PARAMETERS:  StartAddress        - Starting pointer for search
550  *              Length              - Maximum length to search
551  *
552  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
553  *
554  * DESCRIPTION: Search a block of memory for the RSDP signature
555  *
556  ******************************************************************************/
557 
558 static UINT8 *
559 AcpiTbScanMemoryForRsdp (
560     UINT8                   *StartAddress,
561     UINT32                  Length)
562 {
563     ACPI_STATUS             Status;
564     UINT8                   *MemRover;
565     UINT8                   *EndAddress;
566 
567 
568     ACPI_FUNCTION_TRACE (TbScanMemoryForRsdp);
569 
570 
571     EndAddress = StartAddress + Length;
572 
573     /* Search from given start address for the requested length */
574 
575     for (MemRover = StartAddress; MemRover < EndAddress;
576          MemRover += ACPI_RSDP_SCAN_STEP)
577     {
578         /* The RSDP signature and checksum must both be correct */
579 
580         Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (RSDP_DESCRIPTOR, MemRover));
581         if (ACPI_SUCCESS (Status))
582         {
583             /* Sig and checksum valid, we have found a real RSDP */
584 
585             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
586                 "RSDP located at physical address %p\n", MemRover));
587             return_PTR (MemRover);
588         }
589 
590         /* No sig match or bad checksum, keep searching */
591     }
592 
593     /* Searched entire block, no RSDP was found */
594 
595     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
596         "Searched entire block from %p, valid RSDP was not found\n",
597         StartAddress));
598     return_PTR (NULL);
599 }
600 
601 
602 /*******************************************************************************
603  *
604  * FUNCTION:    AcpiTbFindRsdp
605  *
606  * PARAMETERS:  TableInfo               - Where the table info is returned
607  *              Flags                   - Current memory mode (logical vs.
608  *                                        physical addressing)
609  *
610  * RETURN:      Status, RSDP physical address
611  *
612  * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
613  *              pointer structure.  If it is found, set *RSDP to point to it.
614  *
615  *              NOTE1: The RSDP must be either in the first 1K of the Extended
616  *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
617  *              Only a 32-bit physical address is necessary.
618  *
619  *              NOTE2: This function is always available, regardless of the
620  *              initialization state of the rest of ACPI.
621  *
622  ******************************************************************************/
623 
624 static ACPI_STATUS
625 AcpiTbFindRsdp (
626     ACPI_TABLE_DESC         *TableInfo,
627     UINT32                  Flags)
628 {
629     UINT8                   *TablePtr;
630     UINT8                   *MemRover;
631     UINT32                  PhysicalAddress;
632     ACPI_STATUS             Status;
633 
634 
635     ACPI_FUNCTION_TRACE (TbFindRsdp);
636 
637 
638     /*
639      * Scan supports either logical addressing or physical addressing
640      */
641     if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
642     {
643         /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
644 
645         Status = AcpiOsMapMemory (
646                     (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
647                     ACPI_EBDA_PTR_LENGTH, (void *) &TablePtr);
648         if (ACPI_FAILURE (Status))
649         {
650             ACPI_ERROR ((AE_INFO,
651                 "Could not map memory at %8.8X for length %X",
652                 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
653 
654             return_ACPI_STATUS (Status);
655         }
656 
657         ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
658 
659         /* Convert segment part to physical address */
660 
661         PhysicalAddress <<= 4;
662         AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
663 
664         /* EBDA present? */
665 
666         if (PhysicalAddress > 0x400)
667         {
668             /*
669              * 1b) Search EBDA paragraphs (EBDA is required to be a
670              *     minimum of 1K length)
671              */
672             Status = AcpiOsMapMemory (
673                         (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
674                         ACPI_EBDA_WINDOW_SIZE, (void *) &TablePtr);
675             if (ACPI_FAILURE (Status))
676             {
677                 ACPI_ERROR ((AE_INFO,
678                     "Could not map memory at %8.8X for length %X",
679                     PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
680 
681                 return_ACPI_STATUS (Status);
682             }
683 
684             MemRover = AcpiTbScanMemoryForRsdp (TablePtr,
685                             ACPI_EBDA_WINDOW_SIZE);
686             AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
687 
688             if (MemRover)
689             {
690                 /* Return the physical address */
691 
692                 PhysicalAddress += (UINT32) ACPI_PTR_DIFF (MemRover, TablePtr);
693 
694                 TableInfo->PhysicalAddress =
695                     (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
696                 return_ACPI_STATUS (AE_OK);
697             }
698         }
699 
700         /*
701          * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
702          */
703         Status = AcpiOsMapMemory (
704                     (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
705                     ACPI_HI_RSDP_WINDOW_SIZE, (void *) &TablePtr);
706 
707         if (ACPI_FAILURE (Status))
708         {
709             ACPI_ERROR ((AE_INFO,
710                 "Could not map memory at %8.8X for length %X",
711                 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
712 
713             return_ACPI_STATUS (Status);
714         }
715 
716         MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
717         AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
718 
719         if (MemRover)
720         {
721             /* Return the physical address */
722 
723             PhysicalAddress = (UINT32)
724                 (ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr));
725 
726             TableInfo->PhysicalAddress =
727                 (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
728             return_ACPI_STATUS (AE_OK);
729         }
730     }
731 
732     /*
733      * Physical addressing
734      */
735     else
736     {
737         /* 1a) Get the location of the EBDA */
738 
739         ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION);
740         PhysicalAddress <<= 4;      /* Convert segment to physical address */
741 
742         /* EBDA present? */
743 
744         if (PhysicalAddress > 0x400)
745         {
746             /*
747              * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of
748              *     1K length)
749              */
750             MemRover = AcpiTbScanMemoryForRsdp (
751                             ACPI_PHYSADDR_TO_PTR (PhysicalAddress),
752                             ACPI_EBDA_WINDOW_SIZE);
753             if (MemRover)
754             {
755                 /* Return the physical address */
756 
757                 TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
758                 return_ACPI_STATUS (AE_OK);
759             }
760         }
761 
762         /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
763 
764         MemRover = AcpiTbScanMemoryForRsdp (
765                         ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
766                         ACPI_HI_RSDP_WINDOW_SIZE);
767         if (MemRover)
768         {
769             /* Found it, return the physical address */
770 
771             TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
772             return_ACPI_STATUS (AE_OK);
773         }
774     }
775 
776     /* A valid RSDP was not found */
777 
778     ACPI_ERROR ((AE_INFO, "No valid RSDP was found"));
779     return_ACPI_STATUS (AE_NOT_FOUND);
780 }
781 
782 #endif
783 
784