]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/contrib/dev/acpica/tables/tbxface.c
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / contrib / dev / acpica / tables / tbxface.c
1 /******************************************************************************
2  *
3  * Module Name: tbxface - Public interfaces to the ACPI subsystem
4  *                         ACPI table oriented interfaces
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2010, 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 __TBXFACE_C__
118
119 #include <contrib/dev/acpica/include/acpi.h>
120 #include <contrib/dev/acpica/include/accommon.h>
121 #include <contrib/dev/acpica/include/acnamesp.h>
122 #include <contrib/dev/acpica/include/actables.h>
123
124 #define _COMPONENT          ACPI_TABLES
125         ACPI_MODULE_NAME    ("tbxface")
126
127 /* Local prototypes */
128
129 static ACPI_STATUS
130 AcpiTbLoadNamespace (
131     void);
132
133
134 /*******************************************************************************
135  *
136  * FUNCTION:    AcpiAllocateRootTable
137  *
138  * PARAMETERS:  InitialTableCount   - Size of InitialTableArray, in number of
139  *                                    ACPI_TABLE_DESC structures
140  *
141  * RETURN:      Status
142  *
143  * DESCRIPTION: Allocate a root table array. Used by iASL compiler and
144  *              AcpiInitializeTables.
145  *
146  ******************************************************************************/
147
148 ACPI_STATUS
149 AcpiAllocateRootTable (
150     UINT32                  InitialTableCount)
151 {
152
153     AcpiGbl_RootTableList.Size = InitialTableCount;
154     AcpiGbl_RootTableList.Flags = ACPI_ROOT_ALLOW_RESIZE;
155
156     return (AcpiTbResizeRootTableList ());
157 }
158
159
160 /*******************************************************************************
161  *
162  * FUNCTION:    AcpiInitializeTables
163  *
164  * PARAMETERS:  InitialTableArray   - Pointer to an array of pre-allocated
165  *                                    ACPI_TABLE_DESC structures. If NULL, the
166  *                                    array is dynamically allocated.
167  *              InitialTableCount   - Size of InitialTableArray, in number of
168  *                                    ACPI_TABLE_DESC structures
169  *              AllowRealloc        - Flag to tell Table Manager if resize of
170  *                                    pre-allocated array is allowed. Ignored
171  *                                    if InitialTableArray is NULL.
172  *
173  * RETURN:      Status
174  *
175  * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
176  *
177  * NOTE:        Allows static allocation of the initial table array in order
178  *              to avoid the use of dynamic memory in confined environments
179  *              such as the kernel boot sequence where it may not be available.
180  *
181  *              If the host OS memory managers are initialized, use NULL for
182  *              InitialTableArray, and the table will be dynamically allocated.
183  *
184  ******************************************************************************/
185
186 ACPI_STATUS
187 AcpiInitializeTables (
188     ACPI_TABLE_DESC         *InitialTableArray,
189     UINT32                  InitialTableCount,
190     BOOLEAN                 AllowResize)
191 {
192     ACPI_PHYSICAL_ADDRESS   RsdpAddress;
193     ACPI_STATUS             Status;
194
195
196     ACPI_FUNCTION_TRACE (AcpiInitializeTables);
197
198
199     /*
200      * Set up the Root Table Array
201      * Allocate the table array if requested
202      */
203     if (!InitialTableArray)
204     {
205         Status = AcpiAllocateRootTable (InitialTableCount);
206         if (ACPI_FAILURE (Status))
207         {
208             return_ACPI_STATUS (Status);
209         }
210     }
211     else
212     {
213         /* Root Table Array has been statically allocated by the host */
214
215         ACPI_MEMSET (InitialTableArray, 0,
216             (ACPI_SIZE) InitialTableCount * sizeof (ACPI_TABLE_DESC));
217
218         AcpiGbl_RootTableList.Tables = InitialTableArray;
219         AcpiGbl_RootTableList.Size = InitialTableCount;
220         AcpiGbl_RootTableList.Flags = ACPI_ROOT_ORIGIN_UNKNOWN;
221         if (AllowResize)
222         {
223             AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ALLOW_RESIZE;
224         }
225     }
226
227     /* Get the address of the RSDP */
228
229     RsdpAddress = AcpiOsGetRootPointer ();
230     if (!RsdpAddress)
231     {
232         return_ACPI_STATUS (AE_NOT_FOUND);
233     }
234
235     /*
236      * Get the root table (RSDT or XSDT) and extract all entries to the local
237      * Root Table Array. This array contains the information of the RSDT/XSDT
238      * in a common, more useable format.
239      */
240     Status = AcpiTbParseRootTable (RsdpAddress);
241     return_ACPI_STATUS (Status);
242 }
243
244 ACPI_EXPORT_SYMBOL (AcpiInitializeTables)
245
246
247 /*******************************************************************************
248  *
249  * FUNCTION:    AcpiReallocateRootTable
250  *
251  * PARAMETERS:  None
252  *
253  * RETURN:      Status
254  *
255  * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
256  *              root list from the previously provided scratch area. Should
257  *              be called once dynamic memory allocation is available in the
258  *              kernel
259  *
260  ******************************************************************************/
261
262 ACPI_STATUS
263 AcpiReallocateRootTable (
264     void)
265 {
266     ACPI_TABLE_DESC         *Tables;
267     ACPI_SIZE               NewSize;
268     ACPI_SIZE               CurrentSize;
269
270
271     ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
272
273
274     /*
275      * Only reallocate the root table if the host provided a static buffer
276      * for the table array in the call to AcpiInitializeTables.
277      */
278     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
279     {
280         return_ACPI_STATUS (AE_SUPPORT);
281     }
282
283     /*
284      * Get the current size of the root table and add the default
285      * increment to create the new table size.
286      */
287     CurrentSize = (ACPI_SIZE)
288         AcpiGbl_RootTableList.Count * sizeof (ACPI_TABLE_DESC);
289
290     NewSize = CurrentSize +
291         (ACPI_ROOT_TABLE_SIZE_INCREMENT * sizeof (ACPI_TABLE_DESC));
292
293     /* Create new array and copy the old array */
294
295     Tables = ACPI_ALLOCATE_ZEROED (NewSize);
296     if (!Tables)
297     {
298         return_ACPI_STATUS (AE_NO_MEMORY);
299     }
300
301     ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, CurrentSize);
302
303     /*
304      * Update the root table descriptor. The new size will be the current
305      * number of tables plus the increment, independent of the reserved
306      * size of the original table list.
307      */
308     AcpiGbl_RootTableList.Tables = Tables;
309     AcpiGbl_RootTableList.Size =
310         AcpiGbl_RootTableList.Count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
311     AcpiGbl_RootTableList.Flags =
312         ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
313
314     return_ACPI_STATUS (AE_OK);
315 }
316
317 ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
318
319
320 /*******************************************************************************
321  *
322  * FUNCTION:    AcpiGetTableHeader
323  *
324  * PARAMETERS:  Signature           - ACPI signature of needed table
325  *              Instance            - Which instance (for SSDTs)
326  *              OutTableHeader      - The pointer to the table header to fill
327  *
328  * RETURN:      Status and pointer to mapped table header
329  *
330  * DESCRIPTION: Finds an ACPI table header.
331  *
332  * NOTE:        Caller is responsible in unmapping the header with
333  *              AcpiOsUnmapMemory
334  *
335  ******************************************************************************/
336
337 ACPI_STATUS
338 AcpiGetTableHeader (
339     char                    *Signature,
340     UINT32                  Instance,
341     ACPI_TABLE_HEADER       *OutTableHeader)
342 {
343     UINT32                  i;
344     UINT32                  j;
345     ACPI_TABLE_HEADER       *Header;
346
347
348     /* Parameter validation */
349
350     if (!Signature || !OutTableHeader)
351     {
352         return (AE_BAD_PARAMETER);
353     }
354
355     /* Walk the root table list */
356
357     for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++)
358     {
359         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
360                     Signature))
361         {
362             continue;
363         }
364
365         if (++j < Instance)
366         {
367             continue;
368         }
369
370         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
371         {
372             if ((AcpiGbl_RootTableList.Tables[i].Flags &
373                     ACPI_TABLE_ORIGIN_MASK) ==
374                 ACPI_TABLE_ORIGIN_MAPPED)
375             {
376                 Header = AcpiOsMapMemory (
377                             AcpiGbl_RootTableList.Tables[i].Address,
378                             sizeof (ACPI_TABLE_HEADER));
379                 if (!Header)
380                 {
381                     return AE_NO_MEMORY;
382                 }
383
384                 ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
385                 AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
386             }
387             else
388             {
389                 return AE_NOT_FOUND;
390             }
391         }
392         else
393         {
394             ACPI_MEMCPY (OutTableHeader,
395                 AcpiGbl_RootTableList.Tables[i].Pointer,
396                 sizeof(ACPI_TABLE_HEADER));
397         }
398
399         return (AE_OK);
400     }
401
402     return (AE_NOT_FOUND);
403 }
404
405 ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
406
407
408 /*******************************************************************************
409  *
410  * FUNCTION:    AcpiGetTable
411  *
412  * PARAMETERS:  Signature           - ACPI signature of needed table
413  *              Instance            - Which instance (for SSDTs)
414  *              OutTable            - Where the pointer to the table is returned
415  *
416  * RETURN:      Status and pointer to table
417  *
418  * DESCRIPTION: Finds and verifies an ACPI table.
419  *
420  ******************************************************************************/
421
422 ACPI_STATUS
423 AcpiGetTable (
424     char                    *Signature,
425     UINT32                  Instance,
426     ACPI_TABLE_HEADER       **OutTable)
427 {
428     UINT32                  i;
429     UINT32                  j;
430     ACPI_STATUS             Status;
431
432
433     /* Parameter validation */
434
435     if (!Signature || !OutTable)
436     {
437         return (AE_BAD_PARAMETER);
438     }
439
440     /* Walk the root table list */
441
442     for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++)
443     {
444         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
445                 Signature))
446         {
447             continue;
448         }
449
450         if (++j < Instance)
451         {
452             continue;
453         }
454
455         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
456         if (ACPI_SUCCESS (Status))
457         {
458             *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
459         }
460
461         return (Status);
462     }
463
464     return (AE_NOT_FOUND);
465 }
466
467 ACPI_EXPORT_SYMBOL (AcpiGetTable)
468
469
470 /*******************************************************************************
471  *
472  * FUNCTION:    AcpiGetTableByIndex
473  *
474  * PARAMETERS:  TableIndex          - Table index
475  *              Table               - Where the pointer to the table is returned
476  *
477  * RETURN:      Status and pointer to the table
478  *
479  * DESCRIPTION: Obtain a table by an index into the global table list.
480  *
481  ******************************************************************************/
482
483 ACPI_STATUS
484 AcpiGetTableByIndex (
485     UINT32                  TableIndex,
486     ACPI_TABLE_HEADER       **Table)
487 {
488     ACPI_STATUS             Status;
489
490
491     ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
492
493
494     /* Parameter validation */
495
496     if (!Table)
497     {
498         return_ACPI_STATUS (AE_BAD_PARAMETER);
499     }
500
501     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
502
503     /* Validate index */
504
505     if (TableIndex >= AcpiGbl_RootTableList.Count)
506     {
507         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
508         return_ACPI_STATUS (AE_BAD_PARAMETER);
509     }
510
511     if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
512     {
513         /* Table is not mapped, map it */
514
515         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
516         if (ACPI_FAILURE (Status))
517         {
518             (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
519             return_ACPI_STATUS (Status);
520         }
521     }
522
523     *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
524     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
525     return_ACPI_STATUS (AE_OK);
526 }
527
528 ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
529
530
531 /*******************************************************************************
532  *
533  * FUNCTION:    AcpiTbLoadNamespace
534  *
535  * PARAMETERS:  None
536  *
537  * RETURN:      Status
538  *
539  * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
540  *              the RSDT/XSDT.
541  *
542  ******************************************************************************/
543
544 static ACPI_STATUS
545 AcpiTbLoadNamespace (
546     void)
547 {
548     ACPI_STATUS             Status;
549     UINT32                  i;
550     ACPI_TABLE_HEADER       *NewDsdt;
551
552
553     ACPI_FUNCTION_TRACE (TbLoadNamespace);
554
555
556     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
557
558     /*
559      * Load the namespace. The DSDT is required, but any SSDT and
560      * PSDT tables are optional. Verify the DSDT.
561      */
562     if (!AcpiGbl_RootTableList.Count ||
563         !ACPI_COMPARE_NAME (
564             &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
565             ACPI_SIG_DSDT) ||
566          ACPI_FAILURE (AcpiTbVerifyTable (
567             &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
568     {
569         Status = AE_NO_ACPI_TABLES;
570         goto UnlockAndExit;
571     }
572
573     /*
574      * Save the DSDT pointer for simple access. This is the mapped memory
575      * address. We must take care here because the address of the .Tables
576      * array can change dynamically as tables are loaded at run-time. Note:
577      * .Pointer field is not validated until after call to AcpiTbVerifyTable.
578      */
579     AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
580
581     /*
582      * Optionally copy the entire DSDT to local memory (instead of simply
583      * mapping it.) There are some BIOSs that corrupt or replace the original
584      * DSDT, creating the need for this option. Default is FALSE, do not copy
585      * the DSDT.
586      */
587     if (AcpiGbl_CopyDsdtLocally)
588     {
589         NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
590         if (NewDsdt)
591         {
592             AcpiGbl_DSDT = NewDsdt;
593         }
594     }
595
596     /*
597      * Save the original DSDT header for detection of table corruption
598      * and/or replacement of the DSDT from outside the OS.
599      */
600     ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
601         sizeof (ACPI_TABLE_HEADER));
602
603     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
604
605     /* Load and parse tables */
606
607     Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
608     if (ACPI_FAILURE (Status))
609     {
610         return_ACPI_STATUS (Status);
611     }
612
613     /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
614
615     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
616     for (i = 2; i < AcpiGbl_RootTableList.Count; ++i)
617     {
618         if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
619                     ACPI_SIG_SSDT) &&
620              !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
621                     ACPI_SIG_PSDT)) ||
622              ACPI_FAILURE (AcpiTbVerifyTable (
623                 &AcpiGbl_RootTableList.Tables[i])))
624         {
625             continue;
626         }
627
628         /* Skip SSDT when DSDT is overriden */
629
630         if (ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
631                     ACPI_SIG_SSDT) &&
632             (AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Flags &
633                     ACPI_TABLE_ORIGIN_OVERRIDE))
634         {
635             continue;
636         }
637
638         /* Ignore errors while loading tables, get as many as possible */
639
640         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
641         (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
642         (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
643     }
644
645     ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
646
647 UnlockAndExit:
648     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
649     return_ACPI_STATUS (Status);
650 }
651
652
653 /*******************************************************************************
654  *
655  * FUNCTION:    AcpiLoadTables
656  *
657  * PARAMETERS:  None
658  *
659  * RETURN:      Status
660  *
661  * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
662  *
663  ******************************************************************************/
664
665 ACPI_STATUS
666 AcpiLoadTables (
667     void)
668 {
669     ACPI_STATUS             Status;
670
671
672     ACPI_FUNCTION_TRACE (AcpiLoadTables);
673
674
675     /* Load the namespace from the tables */
676
677     Status = AcpiTbLoadNamespace ();
678     if (ACPI_FAILURE (Status))
679     {
680         ACPI_EXCEPTION ((AE_INFO, Status,
681             "While loading namespace from ACPI tables"));
682     }
683
684     return_ACPI_STATUS (Status);
685 }
686
687 ACPI_EXPORT_SYMBOL (AcpiLoadTables)
688
689
690 /*******************************************************************************
691  *
692  * FUNCTION:    AcpiInstallTableHandler
693  *
694  * PARAMETERS:  Handler         - Table event handler
695  *              Context         - Value passed to the handler on each event
696  *
697  * RETURN:      Status
698  *
699  * DESCRIPTION: Install table event handler
700  *
701  ******************************************************************************/
702
703 ACPI_STATUS
704 AcpiInstallTableHandler (
705     ACPI_TABLE_HANDLER      Handler,
706     void                    *Context)
707 {
708     ACPI_STATUS             Status;
709
710
711     ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
712
713
714     if (!Handler)
715     {
716         return_ACPI_STATUS (AE_BAD_PARAMETER);
717     }
718
719     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
720     if (ACPI_FAILURE (Status))
721     {
722         return_ACPI_STATUS (Status);
723     }
724
725     /* Don't allow more than one handler */
726
727     if (AcpiGbl_TableHandler)
728     {
729         Status = AE_ALREADY_EXISTS;
730         goto Cleanup;
731     }
732
733     /* Install the handler */
734
735     AcpiGbl_TableHandler = Handler;
736     AcpiGbl_TableHandlerContext = Context;
737
738 Cleanup:
739     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
740     return_ACPI_STATUS (Status);
741 }
742
743 ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
744
745
746 /*******************************************************************************
747  *
748  * FUNCTION:    AcpiRemoveTableHandler
749  *
750  * PARAMETERS:  Handler         - Table event handler that was installed
751  *                                previously.
752  *
753  * RETURN:      Status
754  *
755  * DESCRIPTION: Remove table event handler
756  *
757  ******************************************************************************/
758
759 ACPI_STATUS
760 AcpiRemoveTableHandler (
761     ACPI_TABLE_HANDLER      Handler)
762 {
763     ACPI_STATUS             Status;
764
765
766     ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
767
768
769     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
770     if (ACPI_FAILURE (Status))
771     {
772         return_ACPI_STATUS (Status);
773     }
774
775     /* Make sure that the installed handler is the same */
776
777     if (!Handler ||
778         Handler != AcpiGbl_TableHandler)
779     {
780         Status = AE_BAD_PARAMETER;
781         goto Cleanup;
782     }
783
784     /* Remove the handler */
785
786     AcpiGbl_TableHandler = NULL;
787
788 Cleanup:
789     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
790     return_ACPI_STATUS (Status);
791 }
792
793 ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
794