]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/tbxfroot.c
This commit was generated by cvs2svn to compensate for changes in r159952,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / tbxfroot.c
1 /******************************************************************************
2  *
3  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4  *              $Revision: 1.91 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, 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 <contrib/dev/acpica/acpi.h>
120 #include <contrib/dev/acpica/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 (AcpiTbGenerateChecksum (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         (AcpiTbGenerateChecksum (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_STRNCMP (Signature, DSDT_SIG, ACPI_NAME_SIZE))
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] && ACPI_STRNCMP (
256                         OemId, Table->OemId,
257                         sizeof (Table->OemId))) ||
258
259         (OemTableId[0] && ACPI_STRNCMP (
260                             OemTableId, Table->OemTableId,
261                             sizeof (Table->OemTableId))))
262     {
263         return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
264     }
265
266     ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n",
267         Table->Signature));
268
269     *TablePtr = Table;
270     return_ACPI_STATUS (AE_OK);
271 }
272
273
274 /*******************************************************************************
275  *
276  * FUNCTION:    AcpiGetFirmwareTable
277  *
278  * PARAMETERS:  Signature       - Any ACPI table signature
279  *              Instance        - the non zero instance of the table, allows
280  *                                support for multiple tables of the same type
281  *              Flags           - Physical/Virtual support
282  *              TablePointer    - Where a buffer containing the table is
283  *                                returned
284  *
285  * RETURN:      Status
286  *
287  * DESCRIPTION: This function is called to get an ACPI table. A buffer is
288  *              allocated for the table and returned in TablePointer.
289  *              This table will be a complete table including the header.
290  *
291  ******************************************************************************/
292
293 ACPI_STATUS
294 AcpiGetFirmwareTable (
295     ACPI_STRING             Signature,
296     UINT32                  Instance,
297     UINT32                  Flags,
298     ACPI_TABLE_HEADER       **TablePointer)
299 {
300     ACPI_STATUS             Status;
301     ACPI_POINTER            Address;
302     ACPI_TABLE_HEADER       *Header = NULL;
303     ACPI_TABLE_DESC         *TableInfo = NULL;
304     ACPI_TABLE_DESC         *RsdtInfo;
305     UINT32                  TableCount;
306     UINT32                  i;
307     UINT32                  j;
308
309
310     ACPI_FUNCTION_TRACE ("AcpiGetFirmwareTable");
311
312
313     /*
314      * Ensure that at least the table manager is initialized.  We don't
315      * require that the entire ACPI subsystem is up for this interface.
316      * If we have a buffer, we must have a length too
317      */
318     if ((Instance == 0)     ||
319         (!Signature)        ||
320         (!TablePointer))
321     {
322         return_ACPI_STATUS (AE_BAD_PARAMETER);
323     }
324
325     /* Ensure that we have a RSDP */
326
327     if (!AcpiGbl_RSDP)
328     {
329         /* Get the RSDP */
330
331         Status = AcpiOsGetRootPointer (Flags, &Address);
332         if (ACPI_FAILURE (Status))
333         {
334             ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n"));
335             return_ACPI_STATUS (AE_NO_ACPI_TABLES);
336         }
337
338         /* Map and validate the RSDP */
339
340         if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
341         {
342             Status = AcpiOsMapMemory (Address.Pointer.Physical,
343                         sizeof (RSDP_DESCRIPTOR), (void *) &AcpiGbl_RSDP);
344             if (ACPI_FAILURE (Status))
345             {
346                 return_ACPI_STATUS (Status);
347             }
348         }
349         else
350         {
351             AcpiGbl_RSDP = Address.Pointer.Logical;
352         }
353
354         /* The RDSP signature and checksum must both be correct */
355
356         Status = AcpiTbValidateRsdp (AcpiGbl_RSDP);
357         if (ACPI_FAILURE (Status))
358         {
359             return_ACPI_STATUS (Status);
360         }
361     }
362
363     /* Get the RSDT address via the RSDP */
364
365     AcpiTbGetRsdtAddress (&Address);
366     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
367         "RSDP located at %p, RSDT physical=%8.8X%8.8X\n",
368         AcpiGbl_RSDP,
369         ACPI_FORMAT_UINT64 (Address.Pointer.Value)));
370
371     /* Insert ProcessorMode flags */
372
373     Address.PointerType |= Flags;
374
375     /* Get and validate the RSDT */
376
377     RsdtInfo = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC));
378     if (!RsdtInfo)
379     {
380         return_ACPI_STATUS (AE_NO_MEMORY);
381     }
382
383     Status = AcpiTbGetTable (&Address, RsdtInfo);
384     if (ACPI_FAILURE (Status))
385     {
386         goto Cleanup;
387     }
388
389     Status = AcpiTbValidateRsdt (RsdtInfo->Pointer);
390     if (ACPI_FAILURE (Status))
391     {
392         goto Cleanup;
393     }
394
395     /* Allocate a scratch table header and table descriptor */
396
397     Header = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
398     if (!Header)
399     {
400         Status = AE_NO_MEMORY;
401         goto Cleanup;
402     }
403
404     TableInfo = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_DESC));
405     if (!TableInfo)
406     {
407         Status = AE_NO_MEMORY;
408         goto Cleanup;
409     }
410
411     /* Get the number of table pointers within the RSDT */
412
413     TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer);
414     Address.PointerType = AcpiGbl_TableFlags | Flags;
415
416     /*
417      * Search the RSDT/XSDT for the correct instance of the
418      * requested table
419      */
420     for (i = 0, j = 0; i < TableCount; i++)
421     {
422         /*
423          * Get the next table pointer, handle RSDT vs. XSDT
424          * RSDT pointers are 32 bits, XSDT pointers are 64 bits
425          */
426         if (AcpiGbl_RootTableType == ACPI_TABLE_TYPE_RSDT)
427         {
428             Address.Pointer.Value = (ACPI_CAST_PTR (
429                 RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i];
430         }
431         else
432         {
433             Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR (
434                 XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]);
435         }
436
437         /* Get the table header */
438
439         Status = AcpiTbGetTableHeader (&Address, Header);
440         if (ACPI_FAILURE (Status))
441         {
442             goto Cleanup;
443         }
444
445         /* Compare table signatures and table instance */
446
447         if (!ACPI_STRNCMP (Header->Signature, Signature, ACPI_NAME_SIZE))
448         {
449             /* An instance of the table was found */
450
451             j++;
452             if (j >= Instance)
453             {
454                 /* Found the correct instance, get the entire table */
455
456                 Status = AcpiTbGetTableBody (&Address, Header, TableInfo);
457                 if (ACPI_FAILURE (Status))
458                 {
459                     goto Cleanup;
460                 }
461
462                 *TablePointer = TableInfo->Pointer;
463                 goto Cleanup;
464             }
465         }
466     }
467
468     /* Did not find the table */
469
470     Status = AE_NOT_EXIST;
471
472
473 Cleanup:
474     if (RsdtInfo->Pointer)
475     {
476         AcpiOsUnmapMemory (RsdtInfo->Pointer,
477             (ACPI_SIZE) RsdtInfo->Pointer->Length);
478     }
479     ACPI_MEM_FREE (RsdtInfo);
480
481     if (Header)
482     {
483         ACPI_MEM_FREE (Header);
484     }
485     if (TableInfo)
486     {
487         ACPI_MEM_FREE (TableInfo);
488     }
489     return_ACPI_STATUS (Status);
490 }
491
492
493 /* TBD: Move to a new file */
494
495 #if ACPI_MACHINE_WIDTH != 16
496
497 /*******************************************************************************
498  *
499  * FUNCTION:    AcpiFindRootPointer
500  *
501  * PARAMETERS:  Flags                   - Logical/Physical addressing
502  *              RsdpAddress             - Where to place the RSDP address
503  *
504  * RETURN:      Status, Physical address of the RSDP
505  *
506  * DESCRIPTION: Find the RSDP
507  *
508  ******************************************************************************/
509
510 ACPI_STATUS
511 AcpiFindRootPointer (
512     UINT32                  Flags,
513     ACPI_POINTER            *RsdpAddress)
514 {
515     ACPI_TABLE_DESC         TableInfo;
516     ACPI_STATUS             Status;
517
518
519     ACPI_FUNCTION_TRACE ("AcpiFindRootPointer");
520
521
522     /* Get the RSDP */
523
524     Status = AcpiTbFindRsdp (&TableInfo, Flags);
525     if (ACPI_FAILURE (Status))
526     {
527         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
528             "RSDP structure not found, %s Flags=%X\n",
529             AcpiFormatException (Status), Flags));
530
531         return_ACPI_STATUS (AE_NO_ACPI_TABLES);
532     }
533
534     RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER;
535     RsdpAddress->Pointer.Physical = TableInfo.PhysicalAddress;
536     return_ACPI_STATUS (AE_OK);
537 }
538
539
540 /*******************************************************************************
541  *
542  * FUNCTION:    AcpiTbScanMemoryForRsdp
543  *
544  * PARAMETERS:  StartAddress        - Starting pointer for search
545  *              Length              - Maximum length to search
546  *
547  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
548  *
549  * DESCRIPTION: Search a block of memory for the RSDP signature
550  *
551  ******************************************************************************/
552
553 static UINT8 *
554 AcpiTbScanMemoryForRsdp (
555     UINT8                   *StartAddress,
556     UINT32                  Length)
557 {
558     ACPI_STATUS             Status;
559     UINT8                   *MemRover;
560     UINT8                   *EndAddress;
561
562
563     ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp");
564
565
566     EndAddress = StartAddress + Length;
567
568     /* Search from given start address for the requested length */
569
570     for (MemRover = StartAddress; MemRover < EndAddress;
571          MemRover += ACPI_RSDP_SCAN_STEP)
572     {
573         /* The RSDP signature and checksum must both be correct */
574
575         Status = AcpiTbValidateRsdp (ACPI_CAST_PTR (RSDP_DESCRIPTOR, MemRover));
576         if (ACPI_SUCCESS (Status))
577         {
578             /* Sig and checksum valid, we have found a real RSDP */
579
580             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
581                 "RSDP located at physical address %p\n", MemRover));
582             return_PTR (MemRover);
583         }
584
585         /* No sig match or bad checksum, keep searching */
586     }
587
588     /* Searched entire block, no RSDP was found */
589
590     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
591         "Searched entire block from %p, valid RSDP was not found\n",
592         StartAddress));
593     return_PTR (NULL);
594 }
595
596
597 /*******************************************************************************
598  *
599  * FUNCTION:    AcpiTbFindRsdp
600  *
601  * PARAMETERS:  TableInfo               - Where the table info is returned
602  *              Flags                   - Current memory mode (logical vs.
603  *                                        physical addressing)
604  *
605  * RETURN:      Status, RSDP physical address
606  *
607  * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
608  *              pointer structure.  If it is found, set *RSDP to point to it.
609  *
610  *              NOTE1: The RSDP must be either in the first 1K of the Extended
611  *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
612  *              Only a 32-bit physical address is necessary.
613  *
614  *              NOTE2: This function is always available, regardless of the
615  *              initialization state of the rest of ACPI.
616  *
617  ******************************************************************************/
618
619 static ACPI_STATUS
620 AcpiTbFindRsdp (
621     ACPI_TABLE_DESC         *TableInfo,
622     UINT32                  Flags)
623 {
624     UINT8                   *TablePtr;
625     UINT8                   *MemRover;
626     UINT32                  PhysicalAddress;
627     ACPI_STATUS             Status;
628
629
630     ACPI_FUNCTION_TRACE ("TbFindRsdp");
631
632
633     /*
634      * Scan supports either logical addressing or physical addressing
635      */
636     if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
637     {
638         /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
639
640         Status = AcpiOsMapMemory (
641                     (ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
642                     ACPI_EBDA_PTR_LENGTH, (void *) &TablePtr);
643         if (ACPI_FAILURE (Status))
644         {
645             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
646                 "Could not map memory at %8.8X for length %X\n",
647                 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
648
649             return_ACPI_STATUS (Status);
650         }
651
652         ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
653
654         /* Convert segment part to physical address */
655
656         PhysicalAddress <<= 4;
657         AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
658
659         /* EBDA present? */
660
661         if (PhysicalAddress > 0x400)
662         {
663             /*
664              * 1b) Search EBDA paragraphs (EBDA is required to be a
665              *     minimum of 1K length)
666              */
667             Status = AcpiOsMapMemory (
668                         (ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
669                         ACPI_EBDA_WINDOW_SIZE, (void *) &TablePtr);
670             if (ACPI_FAILURE (Status))
671             {
672                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
673                     "Could not map memory at %8.8X for length %X\n",
674                     PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
675
676                 return_ACPI_STATUS (Status);
677             }
678
679             MemRover = AcpiTbScanMemoryForRsdp (TablePtr,
680                             ACPI_EBDA_WINDOW_SIZE);
681             AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
682
683             if (MemRover)
684             {
685                 /* Return the physical address */
686
687                 PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr);
688
689                 TableInfo->PhysicalAddress =
690                     (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
691                 return_ACPI_STATUS (AE_OK);
692             }
693         }
694
695         /*
696          * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
697          */
698         Status = AcpiOsMapMemory (
699                     (ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
700                     ACPI_HI_RSDP_WINDOW_SIZE, (void *) &TablePtr);
701
702         if (ACPI_FAILURE (Status))
703         {
704             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
705                 "Could not map memory at %8.8X for length %X\n",
706                 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
707
708             return_ACPI_STATUS (Status);
709         }
710
711         MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
712         AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
713
714         if (MemRover)
715         {
716             /* Return the physical address */
717
718             PhysicalAddress =
719                 ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr);
720
721             TableInfo->PhysicalAddress =
722                 (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
723             return_ACPI_STATUS (AE_OK);
724         }
725     }
726
727     /*
728      * Physical addressing
729      */
730     else
731     {
732         /* 1a) Get the location of the EBDA */
733
734         ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION);
735         PhysicalAddress <<= 4;      /* Convert segment to physical address */
736
737         /* EBDA present? */
738
739         if (PhysicalAddress > 0x400)
740         {
741             /*
742              * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of
743              *     1K length)
744              */
745             MemRover = AcpiTbScanMemoryForRsdp (
746                             ACPI_PHYSADDR_TO_PTR (PhysicalAddress),
747                             ACPI_EBDA_WINDOW_SIZE);
748             if (MemRover)
749             {
750                 /* Return the physical address */
751
752                 TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
753                 return_ACPI_STATUS (AE_OK);
754             }
755         }
756
757         /* 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh */
758
759         MemRover = AcpiTbScanMemoryForRsdp (
760                         ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
761                         ACPI_HI_RSDP_WINDOW_SIZE);
762         if (MemRover)
763         {
764             /* Found it, return the physical address */
765
766             TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
767             return_ACPI_STATUS (AE_OK);
768         }
769     }
770
771     /* A valid RSDP was not found */
772
773     ACPI_REPORT_ERROR (("No valid RSDP was found\n"));
774     return_ACPI_STATUS (AE_NOT_FOUND);
775 }
776
777 #endif
778