]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/contrib/dev/acpica/tbxfroot.c
This commit was generated by cvs2svn to compensate for changes in r146897,
[FreeBSD/FreeBSD.git] / sys / contrib / dev / acpica / tbxfroot.c
1 /******************************************************************************
2  *
3  * Module Name: tbxfroot - Find the root ACPI table (RSDT)
4  *              $Revision: 79 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2004, 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
127 /*******************************************************************************
128  *
129  * FUNCTION:    AcpiTbFindTable
130  *
131  * PARAMETERS:  Signature           - String with ACPI table signature
132  *              OemId               - String with the table OEM ID
133  *              OemTableId          - String with the OEM Table ID.
134  *
135  * RETURN:      Status
136  *
137  * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the
138  *              Signature, OEM ID and OEM Table ID.
139  *
140  ******************************************************************************/
141
142 ACPI_STATUS
143 AcpiTbFindTable (
144     char                    *Signature,
145     char                    *OemId,
146     char                    *OemTableId,
147     ACPI_TABLE_HEADER       **TablePtr)
148 {
149     ACPI_STATUS             Status;
150     ACPI_TABLE_HEADER       *Table;
151
152
153     ACPI_FUNCTION_TRACE ("TbFindTable");
154
155
156     /* Validate string lengths */
157
158     if ((ACPI_STRLEN (Signature)  > ACPI_NAME_SIZE) ||
159         (ACPI_STRLEN (OemId)      > sizeof (Table->OemId)) ||
160         (ACPI_STRLEN (OemTableId) > sizeof (Table->OemTableId)))
161     {
162         return_ACPI_STATUS (AE_AML_STRING_LIMIT);
163     }
164
165     if (!ACPI_STRNCMP (Signature, DSDT_SIG, ACPI_NAME_SIZE))
166     {
167         /*
168          * The DSDT pointer is contained in the FADT, not the RSDT.
169          * This code should suffice, because the only code that would perform
170          * a "find" on the DSDT is the DataTableRegion() AML opcode -- in
171          * which case, the DSDT is guaranteed to be already loaded.
172          * If this becomes insufficient, the FADT will have to be found first.
173          */
174         if (!AcpiGbl_DSDT)
175         {
176             return_ACPI_STATUS (AE_NO_ACPI_TABLES);
177         }
178
179         Table = AcpiGbl_DSDT;
180     }
181     else
182     {
183         /* Find the table */
184
185         Status = AcpiGetFirmwareTable (Signature, 1,
186                             ACPI_LOGICAL_ADDRESSING, &Table);
187         if (ACPI_FAILURE (Status))
188         {
189             return_ACPI_STATUS (Status);
190         }
191     }
192
193     /* Check OemId and OemTableId */
194
195     if ((OemId[0]      && ACPI_STRCMP (OemId, Table->OemId)) ||
196         (OemTableId[0] && ACPI_STRCMP (OemTableId, Table->OemTableId)))
197     {
198         return_ACPI_STATUS (AE_AML_NAME_NOT_FOUND);
199     }
200
201     ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Found table [%4.4s]\n", Table->Signature));
202     *TablePtr = Table;
203     return_ACPI_STATUS (AE_OK);
204 }
205
206
207 /*******************************************************************************
208  *
209  * FUNCTION:    AcpiGetFirmwareTable
210  *
211  * PARAMETERS:  Signature       - Any ACPI table signature
212  *              Instance        - the non zero instance of the table, allows
213  *                                support for multiple tables of the same type
214  *              Flags           - Physical/Virtual support
215  *              TablePointer    - Where a buffer containing the table is
216  *                                returned
217  *
218  * RETURN:      Status
219  *
220  * DESCRIPTION: This function is called to get an ACPI table. A buffer is
221  *              allocated for the table and returned in TablePointer.
222  *              This table will be a complete table including the header.
223  *
224  ******************************************************************************/
225
226 ACPI_STATUS
227 AcpiGetFirmwareTable (
228     ACPI_STRING             Signature,
229     UINT32                  Instance,
230     UINT32                  Flags,
231     ACPI_TABLE_HEADER       **TablePointer)
232 {
233     ACPI_STATUS             Status;
234     ACPI_POINTER            Address;
235     ACPI_TABLE_HEADER       *Header = NULL;
236     ACPI_TABLE_DESC         *TableInfo = NULL;
237     ACPI_TABLE_DESC         *RsdtInfo;
238     UINT32                  TableCount;
239     UINT32                  i;
240     UINT32                  j;
241
242
243     ACPI_FUNCTION_TRACE ("AcpiGetFirmwareTable");
244
245
246     /*
247      * Ensure that at least the table manager is initialized.  We don't
248      * require that the entire ACPI subsystem is up for this interface.
249      * If we have a buffer, we must have a length too
250      */
251     if ((Instance == 0)     ||
252         (!Signature)        ||
253         (!TablePointer))
254     {
255         return_ACPI_STATUS (AE_BAD_PARAMETER);
256     }
257
258     /* Ensure that we have a RSDP */
259
260     if (!AcpiGbl_RSDP)
261     {
262         /* Get the RSDP */
263
264         Status = AcpiOsGetRootPointer (Flags, &Address);
265         if (ACPI_FAILURE (Status))
266         {
267             ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "RSDP not found\n"));
268             return_ACPI_STATUS (AE_NO_ACPI_TABLES);
269         }
270
271         /* Map and validate the RSDP */
272
273         if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
274         {
275             Status = AcpiOsMapMemory (Address.Pointer.Physical, sizeof (RSDP_DESCRIPTOR),
276                                         (void *) &AcpiGbl_RSDP);
277             if (ACPI_FAILURE (Status))
278             {
279                 return_ACPI_STATUS (Status);
280             }
281         }
282         else
283         {
284             AcpiGbl_RSDP = Address.Pointer.Logical;
285         }
286
287         /* The signature and checksum must both be correct */
288
289         if (ACPI_STRNCMP ((char *) AcpiGbl_RSDP, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0)
290         {
291             /* Nope, BAD Signature */
292
293             return_ACPI_STATUS (AE_BAD_SIGNATURE);
294         }
295
296         if (AcpiTbChecksum (AcpiGbl_RSDP, ACPI_RSDP_CHECKSUM_LENGTH) != 0)
297         {
298             /* Nope, BAD Checksum */
299
300             return_ACPI_STATUS (AE_BAD_CHECKSUM);
301         }
302     }
303
304     /* Get the RSDT address via the RSDP */
305
306     AcpiTbGetRsdtAddress (&Address);
307     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
308         "RSDP located at %p, RSDT physical=%8.8X%8.8X \n",
309         AcpiGbl_RSDP,
310         ACPI_FORMAT_UINT64 (Address.Pointer.Value)));
311
312     /* Insert ProcessorMode flags */
313
314     Address.PointerType |= Flags;
315
316     /* Get and validate the RSDT */
317
318     RsdtInfo = ACPI_MEM_CALLOCATE (sizeof (ACPI_TABLE_DESC));
319     if (!RsdtInfo)
320     {
321         return_ACPI_STATUS (AE_NO_MEMORY);
322     }
323
324     Status = AcpiTbGetTable (&Address, RsdtInfo);
325     if (ACPI_FAILURE (Status))
326     {
327         goto Cleanup;
328     }
329
330     Status = AcpiTbValidateRsdt (RsdtInfo->Pointer);
331     if (ACPI_FAILURE (Status))
332     {
333         goto Cleanup;
334     }
335
336     /* Allocate a scratch table header and table descriptor */
337
338     Header = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_HEADER));
339     if (!Header)
340     {
341         Status = AE_NO_MEMORY;
342         goto Cleanup;
343     }
344
345     TableInfo = ACPI_MEM_ALLOCATE (sizeof (ACPI_TABLE_DESC));
346     if (!TableInfo)
347     {
348         Status = AE_NO_MEMORY;
349         goto Cleanup;
350     }
351
352     /* Get the number of table pointers within the RSDT */
353
354     TableCount = AcpiTbGetTableCount (AcpiGbl_RSDP, RsdtInfo->Pointer);
355     Address.PointerType = AcpiGbl_TableFlags | Flags;
356
357     /*
358      * Search the RSDT/XSDT for the correct instance of the
359      * requested table
360      */
361     for (i = 0, j = 0; i < TableCount; i++)
362     {
363         /* Get the next table pointer, handle RSDT vs. XSDT */
364
365         if (AcpiGbl_RSDP->Revision < 2)
366         {
367             Address.Pointer.Value = (ACPI_CAST_PTR (
368                 RSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i];
369         }
370         else
371         {
372             Address.Pointer.Value = ACPI_GET_ADDRESS ((ACPI_CAST_PTR (
373                 XSDT_DESCRIPTOR, RsdtInfo->Pointer))->TableOffsetEntry[i]);
374         }
375
376         /* Get the table header */
377
378         Status = AcpiTbGetTableHeader (&Address, Header);
379         if (ACPI_FAILURE (Status))
380         {
381             goto Cleanup;
382         }
383
384         /* Compare table signatures and table instance */
385
386         if (!ACPI_STRNCMP (Header->Signature, Signature, ACPI_NAME_SIZE))
387         {
388             /* An instance of the table was found */
389
390             j++;
391             if (j >= Instance)
392             {
393                 /* Found the correct instance, get the entire table */
394
395                 Status = AcpiTbGetTableBody (&Address, Header, TableInfo);
396                 if (ACPI_FAILURE (Status))
397                 {
398                     goto Cleanup;
399                 }
400
401                 *TablePointer = TableInfo->Pointer;
402                 goto Cleanup;
403             }
404         }
405     }
406
407     /* Did not find the table */
408
409     Status = AE_NOT_EXIST;
410
411
412 Cleanup:
413     AcpiOsUnmapMemory (RsdtInfo->Pointer, (ACPI_SIZE) RsdtInfo->Pointer->Length);
414     ACPI_MEM_FREE (RsdtInfo);
415
416     if (Header)
417     {
418         ACPI_MEM_FREE (Header);
419     }
420     if (TableInfo)
421     {
422         ACPI_MEM_FREE (TableInfo);
423     }
424     return_ACPI_STATUS (Status);
425 }
426
427
428 /* TBD: Move to a new file */
429
430 #if ACPI_MACHINE_WIDTH != 16
431
432 /*******************************************************************************
433  *
434  * FUNCTION:    AcpiFindRootPointer
435  *
436  * PARAMETERS:  **RsdpAddress           - Where to place the RSDP address
437  *              Flags                   - Logical/Physical addressing
438  *
439  * RETURN:      Status, Physical address of the RSDP
440  *
441  * DESCRIPTION: Find the RSDP
442  *
443  ******************************************************************************/
444
445 ACPI_STATUS
446 AcpiFindRootPointer (
447     UINT32                  Flags,
448     ACPI_POINTER            *RsdpAddress)
449 {
450     ACPI_TABLE_DESC         TableInfo;
451     ACPI_STATUS             Status;
452
453
454     ACPI_FUNCTION_TRACE ("AcpiFindRootPointer");
455
456
457     /* Get the RSDP */
458
459     Status = AcpiTbFindRsdp (&TableInfo, Flags);
460     if (ACPI_FAILURE (Status))
461     {
462         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "RSDP structure not found, %s Flags=%X\n",
463             AcpiFormatException (Status), Flags));
464         return_ACPI_STATUS (AE_NO_ACPI_TABLES);
465     }
466
467     RsdpAddress->PointerType = ACPI_PHYSICAL_POINTER;
468     RsdpAddress->Pointer.Physical = TableInfo.PhysicalAddress;
469     return_ACPI_STATUS (AE_OK);
470 }
471
472
473 /*******************************************************************************
474  *
475  * FUNCTION:    AcpiTbScanMemoryForRsdp
476  *
477  * PARAMETERS:  StartAddress        - Starting pointer for search
478  *              Length              - Maximum length to search
479  *
480  * RETURN:      Pointer to the RSDP if found, otherwise NULL.
481  *
482  * DESCRIPTION: Search a block of memory for the RSDP signature
483  *
484  ******************************************************************************/
485
486 UINT8 *
487 AcpiTbScanMemoryForRsdp (
488     UINT8                   *StartAddress,
489     UINT32                  Length)
490 {
491     UINT8                   *MemRover;
492     UINT8                   *EndAddress;
493     UINT8                   Checksum;
494
495
496     ACPI_FUNCTION_TRACE ("TbScanMemoryForRsdp");
497
498
499     EndAddress = StartAddress + Length;
500
501     /* Search from given start address for the requested length */
502
503     for (MemRover = StartAddress; MemRover < EndAddress;
504          MemRover += ACPI_RSDP_SCAN_STEP)
505     {
506         /* The signature and checksum must both be correct */
507
508         if (ACPI_STRNCMP ((char *) MemRover, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0)
509         {
510             /* No signature match, keep looking */
511
512             continue;
513         }
514
515         /* Signature matches, check the appropriate checksum */
516
517         if (((RSDP_DESCRIPTOR *) MemRover)->Revision < 2)
518         {
519             /* ACPI version 1.0 */
520
521             Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_CHECKSUM_LENGTH);
522         }
523         else
524         {
525             /* Post ACPI 1.0, use ExtendedChecksum */
526
527             Checksum = AcpiTbChecksum (MemRover, ACPI_RSDP_XCHECKSUM_LENGTH);
528         }
529
530         if (Checksum == 0)
531         {
532             /* Checksum valid, we have found a valid RSDP */
533
534             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
535                 "RSDP located at physical address %p\n", MemRover));
536             return_PTR (MemRover);
537         }
538
539         ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
540             "Found an RSDP at physical address %p, but it has a bad checksum\n",
541             MemRover));
542     }
543
544     /* Searched entire block, no RSDP was found */
545
546     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
547         "Searched entire block, no valid RSDP was found.\n"));
548     return_PTR (NULL);
549 }
550
551
552 /*******************************************************************************
553  *
554  * FUNCTION:    AcpiTbFindRsdp
555  *
556  * PARAMETERS:  *TableInfo              - Where the table info is returned
557  *              Flags                   - Current memory mode (logical vs.
558  *                                        physical addressing)
559  *
560  * RETURN:      Status, RSDP physical address
561  *
562  * DESCRIPTION: Search lower 1Mbyte of memory for the root system descriptor
563  *              pointer structure.  If it is found, set *RSDP to point to it.
564  *
565  *              NOTE1: The RSDP must be either in the first 1K of the Extended
566  *              BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.)
567  *              Only a 32-bit physical address is necessary.
568  *
569  *              NOTE2: This function is always available, regardless of the
570  *              initialization state of the rest of ACPI.
571  *
572  ******************************************************************************/
573
574 ACPI_STATUS
575 AcpiTbFindRsdp (
576     ACPI_TABLE_DESC         *TableInfo,
577     UINT32                  Flags)
578 {
579     UINT8                   *TablePtr;
580     UINT8                   *MemRover;
581     UINT32                  PhysicalAddress;
582     ACPI_STATUS             Status;
583
584
585     ACPI_FUNCTION_TRACE ("TbFindRsdp");
586
587
588     /*
589      * Scan supports either 1) Logical addressing or 2) Physical addressing
590      */
591     if ((Flags & ACPI_MEMORY_MODE) == ACPI_LOGICAL_ADDRESSING)
592     {
593         /*
594          * 1a) Get the location of the EBDA
595          */
596         Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_EBDA_PTR_LOCATION,
597                                     ACPI_EBDA_PTR_LENGTH,
598                                     (void *) &TablePtr);
599         if (ACPI_FAILURE (Status))
600         {
601             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
602                 ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH));
603             return_ACPI_STATUS (Status);
604         }
605
606         ACPI_MOVE_16_TO_32 (&PhysicalAddress, TablePtr);
607         PhysicalAddress <<= 4;                  /* Convert segment to physical address */
608         AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_PTR_LENGTH);
609
610         /* EBDA present? */
611
612         if (PhysicalAddress > 0x400)
613         {
614             /*
615              * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length)
616              */
617             Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) PhysicalAddress,
618                                         ACPI_EBDA_WINDOW_SIZE,
619                                         (void *) &TablePtr);
620             if (ACPI_FAILURE (Status))
621             {
622                 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
623                     PhysicalAddress, ACPI_EBDA_WINDOW_SIZE));
624                 return_ACPI_STATUS (Status);
625             }
626
627             MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_EBDA_WINDOW_SIZE);
628             AcpiOsUnmapMemory (TablePtr, ACPI_EBDA_WINDOW_SIZE);
629
630             if (MemRover)
631             {
632                 /* Found it, return the physical address */
633
634                 PhysicalAddress += ACPI_PTR_DIFF (MemRover, TablePtr);
635
636                 TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
637                 return_ACPI_STATUS (AE_OK);
638             }
639         }
640
641         /*
642          * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
643          */
644         Status = AcpiOsMapMemory ((ACPI_PHYSICAL_ADDRESS) ACPI_HI_RSDP_WINDOW_BASE,
645                                     ACPI_HI_RSDP_WINDOW_SIZE,
646                                     (void *) &TablePtr);
647         if (ACPI_FAILURE (Status))
648         {
649             ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not map memory at %8.8X for length %X\n",
650                 ACPI_HI_RSDP_WINDOW_BASE, ACPI_HI_RSDP_WINDOW_SIZE));
651             return_ACPI_STATUS (Status);
652         }
653
654         MemRover = AcpiTbScanMemoryForRsdp (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
655         AcpiOsUnmapMemory (TablePtr, ACPI_HI_RSDP_WINDOW_SIZE);
656
657         if (MemRover)
658         {
659             /* Found it, return the physical address */
660
661             PhysicalAddress = ACPI_HI_RSDP_WINDOW_BASE + ACPI_PTR_DIFF (MemRover, TablePtr);
662
663             TableInfo->PhysicalAddress = (ACPI_PHYSICAL_ADDRESS) PhysicalAddress;
664             return_ACPI_STATUS (AE_OK);
665         }
666     }
667
668     /*
669      * Physical addressing
670      */
671     else
672     {
673         /*
674          * 1a) Get the location of the EBDA
675          */
676         ACPI_MOVE_16_TO_32 (&PhysicalAddress, ACPI_EBDA_PTR_LOCATION);
677         PhysicalAddress <<= 4;      /* Convert segment to physical address */
678
679         /* EBDA present? */
680
681         if (PhysicalAddress > 0x400)
682         {
683             /*
684              * 1b) Search EBDA paragraphs (EBDA is required to be a minimum of 1K length)
685              */
686             MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (PhysicalAddress),
687                             ACPI_EBDA_WINDOW_SIZE);
688             if (MemRover)
689             {
690                 /* Found it, return the physical address */
691
692                 TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
693                 return_ACPI_STATUS (AE_OK);
694             }
695         }
696
697         /*
698          * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh
699          */
700         MemRover = AcpiTbScanMemoryForRsdp (ACPI_PHYSADDR_TO_PTR (ACPI_HI_RSDP_WINDOW_BASE),
701                         ACPI_HI_RSDP_WINDOW_SIZE);
702         if (MemRover)
703         {
704             /* Found it, return the physical address */
705
706             TableInfo->PhysicalAddress = ACPI_TO_INTEGER (MemRover);
707             return_ACPI_STATUS (AE_OK);
708         }
709     }
710
711     /* RSDP signature was not found */
712
713     return_ACPI_STATUS (AE_NOT_FOUND);
714 }
715
716 #endif
717