xref: /titanic_41/usr/src/uts/intel/io/acpica/tables/tbxface.c (revision c39526b769298791ff5b0b6c5e761f49aabaeb4e)
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 - 2009, 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 "acpi.h"
120 #include "accommon.h"
121 #include "acnamesp.h"
122 #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 
269 
270     ACPI_FUNCTION_TRACE (AcpiReallocateRootTable);
271 
272 
273     /*
274      * Only reallocate the root table if the host provided a static buffer
275      * for the table array in the call to AcpiInitializeTables.
276      */
277     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
278     {
279         return_ACPI_STATUS (AE_SUPPORT);
280     }
281 
282     NewSize = ((ACPI_SIZE) AcpiGbl_RootTableList.Count +
283                     ACPI_ROOT_TABLE_SIZE_INCREMENT) *
284                 sizeof (ACPI_TABLE_DESC);
285 
286     /* Create new array and copy the old array */
287 
288     Tables = ACPI_ALLOCATE_ZEROED (NewSize);
289     if (!Tables)
290     {
291         return_ACPI_STATUS (AE_NO_MEMORY);
292     }
293 
294     ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables, NewSize);
295 
296     AcpiGbl_RootTableList.Size = AcpiGbl_RootTableList.Count;
297     AcpiGbl_RootTableList.Tables = Tables;
298     AcpiGbl_RootTableList.Flags =
299         ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
300 
301     return_ACPI_STATUS (AE_OK);
302 }
303 
304 ACPI_EXPORT_SYMBOL (AcpiReallocateRootTable)
305 
306 
307 /*******************************************************************************
308  *
309  * FUNCTION:    AcpiGetTableHeader
310  *
311  * PARAMETERS:  Signature           - ACPI signature of needed table
312  *              Instance            - Which instance (for SSDTs)
313  *              OutTableHeader      - The pointer to the table header to fill
314  *
315  * RETURN:      Status and pointer to mapped table header
316  *
317  * DESCRIPTION: Finds an ACPI table header.
318  *
319  * NOTE:        Caller is responsible in unmapping the header with
320  *              AcpiOsUnmapMemory
321  *
322  ******************************************************************************/
323 
324 ACPI_STATUS
325 AcpiGetTableHeader (
326     char                    *Signature,
327     UINT32                  Instance,
328     ACPI_TABLE_HEADER       *OutTableHeader)
329 {
330     UINT32                  i;
331     UINT32                  j;
332     ACPI_TABLE_HEADER       *Header;
333 
334 
335     /* Parameter validation */
336 
337     if (!Signature || !OutTableHeader)
338     {
339         return (AE_BAD_PARAMETER);
340     }
341 
342     /* Walk the root table list */
343 
344     for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++)
345     {
346         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
347                     Signature))
348         {
349             continue;
350         }
351 
352         if (++j < Instance)
353         {
354             continue;
355         }
356 
357         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
358         {
359             if ((AcpiGbl_RootTableList.Tables[i].Flags &
360                     ACPI_TABLE_ORIGIN_MASK) ==
361                 ACPI_TABLE_ORIGIN_MAPPED)
362             {
363                 Header = AcpiOsMapMemory (
364                             AcpiGbl_RootTableList.Tables[i].Address,
365                             sizeof (ACPI_TABLE_HEADER));
366                 if (!Header)
367                 {
368                     return AE_NO_MEMORY;
369                 }
370 
371                 ACPI_MEMCPY (OutTableHeader, Header, sizeof(ACPI_TABLE_HEADER));
372                 AcpiOsUnmapMemory (Header, sizeof(ACPI_TABLE_HEADER));
373             }
374             else
375             {
376                 return AE_NOT_FOUND;
377             }
378         }
379         else
380         {
381             ACPI_MEMCPY (OutTableHeader,
382                 AcpiGbl_RootTableList.Tables[i].Pointer,
383                 sizeof(ACPI_TABLE_HEADER));
384         }
385 
386         return (AE_OK);
387     }
388 
389     return (AE_NOT_FOUND);
390 }
391 
392 ACPI_EXPORT_SYMBOL (AcpiGetTableHeader)
393 
394 
395 /*******************************************************************************
396  *
397  * FUNCTION:    AcpiGetTable
398  *
399  * PARAMETERS:  Signature           - ACPI signature of needed table
400  *              Instance            - Which instance (for SSDTs)
401  *              OutTable            - Where the pointer to the table is returned
402  *
403  * RETURN:      Status and pointer to table
404  *
405  * DESCRIPTION: Finds and verifies an ACPI table.
406  *
407  ******************************************************************************/
408 
409 ACPI_STATUS
410 AcpiGetTable (
411     char                    *Signature,
412     UINT32                  Instance,
413     ACPI_TABLE_HEADER       **OutTable)
414 {
415     UINT32                  i;
416     UINT32                  j;
417     ACPI_STATUS             Status;
418 
419 
420     /* Parameter validation */
421 
422     if (!Signature || !OutTable)
423     {
424         return (AE_BAD_PARAMETER);
425     }
426 
427     /* Walk the root table list */
428 
429     for (i = 0, j = 0; i < AcpiGbl_RootTableList.Count; i++)
430     {
431         if (!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
432                 Signature))
433         {
434             continue;
435         }
436 
437         if (++j < Instance)
438         {
439             continue;
440         }
441 
442         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
443         if (ACPI_SUCCESS (Status))
444         {
445             *OutTable = AcpiGbl_RootTableList.Tables[i].Pointer;
446         }
447 
448         return (Status);
449     }
450 
451     return (AE_NOT_FOUND);
452 }
453 
454 ACPI_EXPORT_SYMBOL (AcpiGetTable)
455 
456 
457 /*******************************************************************************
458  *
459  * FUNCTION:    AcpiGetTableByIndex
460  *
461  * PARAMETERS:  TableIndex          - Table index
462  *              Table               - Where the pointer to the table is returned
463  *
464  * RETURN:      Status and pointer to the table
465  *
466  * DESCRIPTION: Obtain a table by an index into the global table list.
467  *
468  ******************************************************************************/
469 
470 ACPI_STATUS
471 AcpiGetTableByIndex (
472     UINT32                  TableIndex,
473     ACPI_TABLE_HEADER       **Table)
474 {
475     ACPI_STATUS             Status;
476 
477 
478     ACPI_FUNCTION_TRACE (AcpiGetTableByIndex);
479 
480 
481     /* Parameter validation */
482 
483     if (!Table)
484     {
485         return_ACPI_STATUS (AE_BAD_PARAMETER);
486     }
487 
488     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
489 
490     /* Validate index */
491 
492     if (TableIndex >= AcpiGbl_RootTableList.Count)
493     {
494         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
495         return_ACPI_STATUS (AE_BAD_PARAMETER);
496     }
497 
498     if (!AcpiGbl_RootTableList.Tables[TableIndex].Pointer)
499     {
500         /* Table is not mapped, map it */
501 
502         Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[TableIndex]);
503         if (ACPI_FAILURE (Status))
504         {
505             (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
506             return_ACPI_STATUS (Status);
507         }
508     }
509 
510     *Table = AcpiGbl_RootTableList.Tables[TableIndex].Pointer;
511     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
512     return_ACPI_STATUS (AE_OK);
513 }
514 
515 ACPI_EXPORT_SYMBOL (AcpiGetTableByIndex)
516 
517 
518 /*******************************************************************************
519  *
520  * FUNCTION:    AcpiTbLoadNamespace
521  *
522  * PARAMETERS:  None
523  *
524  * RETURN:      Status
525  *
526  * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
527  *              the RSDT/XSDT.
528  *
529  ******************************************************************************/
530 
531 static ACPI_STATUS
532 AcpiTbLoadNamespace (
533     void)
534 {
535     ACPI_STATUS             Status;
536     UINT32                  i;
537 
538 
539     ACPI_FUNCTION_TRACE (TbLoadNamespace);
540 
541 
542     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
543 
544     /*
545      * Load the namespace. The DSDT is required, but any SSDT and PSDT tables
546      * are optional.
547      */
548     if (!AcpiGbl_RootTableList.Count ||
549         !ACPI_COMPARE_NAME (
550             &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
551             ACPI_SIG_DSDT) ||
552         ACPI_FAILURE (AcpiTbVerifyTable (
553             &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
554     {
555         Status = AE_NO_ACPI_TABLES;
556         goto UnlockAndExit;
557     }
558 
559     /* A valid DSDT is required */
560 
561     Status = AcpiTbVerifyTable (
562         &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT]);
563     if (ACPI_FAILURE (Status))
564     {
565         Status = AE_NO_ACPI_TABLES;
566         goto UnlockAndExit;
567     }
568 
569     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
570 
571     /* Load and parse tables */
572 
573     Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
574     if (ACPI_FAILURE (Status))
575     {
576         return_ACPI_STATUS (Status);
577     }
578 
579     /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
580 
581     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
582     for (i = 0; i < AcpiGbl_RootTableList.Count; ++i)
583     {
584         if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
585                     ACPI_SIG_SSDT) &&
586              !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
587                     ACPI_SIG_PSDT)) ||
588              ACPI_FAILURE (AcpiTbVerifyTable (
589                 &AcpiGbl_RootTableList.Tables[i])))
590         {
591             continue;
592         }
593 
594         /* Ignore errors while loading tables, get as many as possible */
595 
596         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
597         (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
598         (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
599     }
600 
601     ACPI_DEBUG_PRINT ((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
602 
603 UnlockAndExit:
604     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
605     return_ACPI_STATUS (Status);
606 }
607 
608 
609 /*******************************************************************************
610  *
611  * FUNCTION:    AcpiLoadTables
612  *
613  * PARAMETERS:  None
614  *
615  * RETURN:      Status
616  *
617  * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
618  *
619  ******************************************************************************/
620 
621 ACPI_STATUS
622 AcpiLoadTables (
623     void)
624 {
625     ACPI_STATUS             Status;
626 
627 
628     ACPI_FUNCTION_TRACE (AcpiLoadTables);
629 
630 
631     /* Load the namespace from the tables */
632 
633     Status = AcpiTbLoadNamespace ();
634     if (ACPI_FAILURE (Status))
635     {
636         ACPI_EXCEPTION ((AE_INFO, Status,
637             "While loading namespace from ACPI tables"));
638     }
639 
640     return_ACPI_STATUS (Status);
641 }
642 
643 ACPI_EXPORT_SYMBOL (AcpiLoadTables)
644 
645 
646 /*******************************************************************************
647  *
648  * FUNCTION:    AcpiInstallTableHandler
649  *
650  * PARAMETERS:  Handler         - Table event handler
651  *              Context         - Value passed to the handler on each event
652  *
653  * RETURN:      Status
654  *
655  * DESCRIPTION: Install table event handler
656  *
657  ******************************************************************************/
658 
659 ACPI_STATUS
660 AcpiInstallTableHandler (
661     ACPI_TABLE_HANDLER      Handler,
662     void                    *Context)
663 {
664     ACPI_STATUS             Status;
665 
666 
667     ACPI_FUNCTION_TRACE (AcpiInstallTableHandler);
668 
669 
670     if (!Handler)
671     {
672         return_ACPI_STATUS (AE_BAD_PARAMETER);
673     }
674 
675     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
676     if (ACPI_FAILURE (Status))
677     {
678         return_ACPI_STATUS (Status);
679     }
680 
681     /* Don't allow more than one handler */
682 
683     if (AcpiGbl_TableHandler)
684     {
685         Status = AE_ALREADY_EXISTS;
686         goto Cleanup;
687     }
688 
689     /* Install the handler */
690 
691     AcpiGbl_TableHandler = Handler;
692     AcpiGbl_TableHandlerContext = Context;
693 
694 Cleanup:
695     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
696     return_ACPI_STATUS (Status);
697 }
698 
699 ACPI_EXPORT_SYMBOL (AcpiInstallTableHandler)
700 
701 
702 /*******************************************************************************
703  *
704  * FUNCTION:    AcpiRemoveTableHandler
705  *
706  * PARAMETERS:  Handler         - Table event handler that was installed
707  *                                previously.
708  *
709  * RETURN:      Status
710  *
711  * DESCRIPTION: Remove table event handler
712  *
713  ******************************************************************************/
714 
715 ACPI_STATUS
716 AcpiRemoveTableHandler (
717     ACPI_TABLE_HANDLER      Handler)
718 {
719     ACPI_STATUS             Status;
720 
721 
722     ACPI_FUNCTION_TRACE (AcpiRemoveTableHandler);
723 
724 
725     Status = AcpiUtAcquireMutex (ACPI_MTX_EVENTS);
726     if (ACPI_FAILURE (Status))
727     {
728         return_ACPI_STATUS (Status);
729     }
730 
731     /* Make sure that the installed handler is the same */
732 
733     if (!Handler ||
734         Handler != AcpiGbl_TableHandler)
735     {
736         Status = AE_BAD_PARAMETER;
737         goto Cleanup;
738     }
739 
740     /* Remove the handler */
741 
742     AcpiGbl_TableHandler = NULL;
743 
744 Cleanup:
745     (void) AcpiUtReleaseMutex (ACPI_MTX_EVENTS);
746     return_ACPI_STATUS (Status);
747 }
748 
749 ACPI_EXPORT_SYMBOL (AcpiRemoveTableHandler)
750 
751