xref: /titanic_50/usr/src/uts/intel/io/acpica/tables/tbinstal.c (revision 42e43e9829853ed82c9a4e268b0b15ea58be81fb)
1 /******************************************************************************
2  *
3  * Module Name: tbinstal - ACPI table installation and removal
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights.  You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25  * make derivatives, distribute, use and display any portion of the Covered
26  * Code in any form, with the right to sublicense such rights; and
27  *
28  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29  * license (with the right to sublicense), under only those claims of Intel
30  * patents that are infringed by the Original Intel Code, to make, use, sell,
31  * offer to sell, and import the Covered Code and derivative works thereof
32  * solely to the minimum extent necessary to exercise the above copyright
33  * license, and in no event shall the patent license extend to any additions
34  * to or modifications of the Original Intel Code.  No other license or right
35  * is granted directly or by implication, estoppel or otherwise;
36  *
37  * The above copyright and patent license is granted only if the following
38  * conditions are met:
39  *
40  * 3. Conditions
41  *
42  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43  * Redistribution of source code of any substantial portion of the Covered
44  * Code or modification with rights to further distribute source must include
45  * the above Copyright Notice, the above License, this list of Conditions,
46  * and the following Disclaimer and Export Compliance provision.  In addition,
47  * Licensee must cause all Covered Code to which Licensee contributes to
48  * contain a file documenting the changes Licensee made to create that Covered
49  * Code and the date of any change.  Licensee must include in that file the
50  * documentation of any changes made by any predecessor Licensee.  Licensee
51  * must include a prominent statement that the modification is derived,
52  * directly or indirectly, from Original Intel Code.
53  *
54  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55  * Redistribution of source code of any substantial portion of the Covered
56  * Code or modification without rights to further distribute source must
57  * include the following Disclaimer and Export Compliance provision in the
58  * documentation and/or other materials provided with distribution.  In
59  * addition, Licensee may not authorize further sublicense of source of any
60  * portion of the Covered Code, and must include terms to the effect that the
61  * license from Licensee to its licensee is limited to the intellectual
62  * property embodied in the software Licensee provides to its licensee, and
63  * not to intellectual property embodied in modifications its licensee may
64  * make.
65  *
66  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67  * substantial portion of the Covered Code or modification must reproduce the
68  * above Copyright Notice, and the following Disclaimer and Export Compliance
69  * provision in the documentation and/or other materials provided with the
70  * distribution.
71  *
72  * 3.4. Intel retains all right, title, and interest in and to the Original
73  * Intel Code.
74  *
75  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76  * Intel shall be used in advertising or otherwise to promote the sale, use or
77  * other dealings in products derived from or relating to the Covered Code
78  * without prior written authorization from Intel.
79  *
80  * 4. Disclaimer and Export Compliance
81  *
82  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88  * PARTICULAR PURPOSE.
89  *
90  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97  * LIMITED REMEDY.
98  *
99  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100  * software or system incorporating such software without first obtaining any
101  * required license or other approval from the U. S. Department of Commerce or
102  * any other agency or department of the United States Government.  In the
103  * event Licensee exports any such software from the United States or
104  * re-exports any such software from a foreign destination, Licensee shall
105  * ensure that the distribution and export/re-export of the software is in
106  * compliance with all laws, regulations, orders, or other restrictions of the
107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108  * any of its subsidiaries will export/re-export any technical data, process,
109  * software, or service, directly or indirectly, to any country for which the
110  * United States government or any agency thereof requires an export license,
111  * other governmental approval, or letter of assurance, without first obtaining
112  * such license, approval or letter.
113  *
114  *****************************************************************************/
115 
116 
117 #define __TBINSTAL_C__
118 
119 #include "acpi.h"
120 #include "accommon.h"
121 #include "acnamesp.h"
122 #include "actables.h"
123 
124 
125 #define _COMPONENT          ACPI_TABLES
126         ACPI_MODULE_NAME    ("tbinstal")
127 
128 
129 /******************************************************************************
130  *
131  * FUNCTION:    AcpiTbVerifyTable
132  *
133  * PARAMETERS:  TableDesc           - table
134  *
135  * RETURN:      Status
136  *
137  * DESCRIPTION: this function is called to verify and map table
138  *
139  *****************************************************************************/
140 
141 ACPI_STATUS
142 AcpiTbVerifyTable (
143     ACPI_TABLE_DESC         *TableDesc)
144 {
145     ACPI_STATUS             Status = AE_OK;
146 
147 
148     ACPI_FUNCTION_TRACE (TbVerifyTable);
149 
150 
151     /* Map the table if necessary */
152 
153     if (!TableDesc->Pointer)
154     {
155         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
156             ACPI_TABLE_ORIGIN_MAPPED)
157         {
158             TableDesc->Pointer = AcpiOsMapMemory (
159                 TableDesc->Address, TableDesc->Length);
160         }
161 
162         if (!TableDesc->Pointer)
163         {
164             return_ACPI_STATUS (AE_NO_MEMORY);
165         }
166     }
167 
168     /* FACS is the odd table, has no standard ACPI header and no checksum */
169 
170     if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
171     {
172         /* Always calculate checksum, ignore bad checksum if requested */
173 
174         Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
175     }
176 
177     return_ACPI_STATUS (Status);
178 }
179 
180 
181 /*******************************************************************************
182  *
183  * FUNCTION:    AcpiTbAddTable
184  *
185  * PARAMETERS:  TableDesc           - Table descriptor
186  *              TableIndex          - Where the table index is returned
187  *
188  * RETURN:      Status
189  *
190  * DESCRIPTION: This function is called to add an ACPI table. It is used to
191  *              dynamically load tables via the Load and LoadTable AML
192  *              operators.
193  *
194  ******************************************************************************/
195 
196 ACPI_STATUS
197 AcpiTbAddTable (
198     ACPI_TABLE_DESC         *TableDesc,
199     UINT32                  *TableIndex)
200 {
201     UINT32                  i;
202     ACPI_STATUS             Status = AE_OK;
203     ACPI_TABLE_HEADER       *OverrideTable = NULL;
204 
205 
206     ACPI_FUNCTION_TRACE (TbAddTable);
207 
208 
209     if (!TableDesc->Pointer)
210     {
211         Status = AcpiTbVerifyTable (TableDesc);
212         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
213         {
214             return_ACPI_STATUS (Status);
215         }
216     }
217 
218     /*
219      * Originally, we checked the table signature for "SSDT" or "PSDT" here.
220      * Next, we added support for OEMx tables, signature "OEM".
221      * Valid tables were encountered with a null signature, so we've just
222      * given up on validating the signature, since it seems to be a waste
223      * of code. The original code was removed (05/2008).
224      */
225 
226     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
227 
228     /* Check if table is already registered */
229 
230     for (i = 0; i < AcpiGbl_RootTableList.Count; ++i)
231     {
232         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
233         {
234             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
235             if (ACPI_FAILURE (Status) ||
236                 !AcpiGbl_RootTableList.Tables[i].Pointer)
237             {
238                 continue;
239             }
240         }
241 
242         /*
243          * Check for a table match on the entire table length,
244          * not just the header.
245          */
246         if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
247         {
248             continue;
249         }
250 
251         if (ACPI_MEMCMP (TableDesc->Pointer,
252                 AcpiGbl_RootTableList.Tables[i].Pointer,
253                 AcpiGbl_RootTableList.Tables[i].Length))
254         {
255             continue;
256         }
257 
258         /*
259          * Note: the current mechanism does not unregister a table if it is
260          * dynamically unloaded. The related namespace entries are deleted,
261          * but the table remains in the root table list.
262          *
263          * The assumption here is that the number of different tables that
264          * will be loaded is actually small, and there is minimal overhead
265          * in just keeping the table in case it is needed again.
266          *
267          * If this assumption changes in the future (perhaps on large
268          * machines with many table load/unload operations), tables will
269          * need to be unregistered when they are unloaded, and slots in the
270          * root table list should be reused when empty.
271          */
272 
273         /*
274          * Table is already registered.
275          * We can delete the table that was passed as a parameter.
276          */
277         AcpiTbDeleteTable (TableDesc);
278         *TableIndex = i;
279 
280         if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
281         {
282             /* Table is still loaded, this is an error */
283 
284             Status = AE_ALREADY_EXISTS;
285             goto Release;
286         }
287         else
288         {
289             /* Table was unloaded, allow it to be reloaded */
290 
291             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
292             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
293             Status = AE_OK;
294             goto PrintHeader;
295         }
296     }
297 
298     /*
299      * ACPI Table Override:
300      * Allow the host to override dynamically loaded tables.
301      */
302     Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
303     if (ACPI_SUCCESS (Status) && OverrideTable)
304     {
305         ACPI_INFO ((AE_INFO,
306             "%4.4s @ 0x%p Table override, replaced with:",
307             TableDesc->Pointer->Signature,
308             ACPI_CAST_PTR (void, TableDesc->Address)));
309 
310         /* We can delete the table that was passed as a parameter */
311 
312         AcpiTbDeleteTable (TableDesc);
313 
314         /* Setup descriptor for the new table */
315 
316         TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
317         TableDesc->Pointer = OverrideTable;
318         TableDesc->Length = OverrideTable->Length;
319         TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
320     }
321 
322     /* Add the table to the global root table list */
323 
324     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
325                 TableDesc->Length, TableDesc->Flags, TableIndex);
326     if (ACPI_FAILURE (Status))
327     {
328         goto Release;
329     }
330 
331 PrintHeader:
332     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
333 
334 Release:
335     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
336     return_ACPI_STATUS (Status);
337 }
338 
339 
340 /*******************************************************************************
341  *
342  * FUNCTION:    AcpiTbResizeRootTableList
343  *
344  * PARAMETERS:  None
345  *
346  * RETURN:      Status
347  *
348  * DESCRIPTION: Expand the size of global table array
349  *
350  ******************************************************************************/
351 
352 ACPI_STATUS
353 AcpiTbResizeRootTableList (
354     void)
355 {
356     ACPI_TABLE_DESC         *Tables;
357 
358 
359     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
360 
361 
362     /* AllowResize flag is a parameter to AcpiInitializeTables */
363 
364     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
365     {
366         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
367         return_ACPI_STATUS (AE_SUPPORT);
368     }
369 
370     /* Increase the Table Array size */
371 
372     Tables = ACPI_ALLOCATE_ZEROED (
373         ((ACPI_SIZE) AcpiGbl_RootTableList.Size +
374             ACPI_ROOT_TABLE_SIZE_INCREMENT) *
375         sizeof (ACPI_TABLE_DESC));
376     if (!Tables)
377     {
378         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
379         return_ACPI_STATUS (AE_NO_MEMORY);
380     }
381 
382     /* Copy and free the previous table array */
383 
384     if (AcpiGbl_RootTableList.Tables)
385     {
386         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
387             (ACPI_SIZE) AcpiGbl_RootTableList.Size * sizeof (ACPI_TABLE_DESC));
388 
389         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
390         {
391             ACPI_FREE (AcpiGbl_RootTableList.Tables);
392         }
393     }
394 
395     AcpiGbl_RootTableList.Tables = Tables;
396     AcpiGbl_RootTableList.Size += ACPI_ROOT_TABLE_SIZE_INCREMENT;
397     AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
398 
399     return_ACPI_STATUS (AE_OK);
400 }
401 
402 
403 /*******************************************************************************
404  *
405  * FUNCTION:    AcpiTbStoreTable
406  *
407  * PARAMETERS:  Address             - Table address
408  *              Table               - Table header
409  *              Length              - Table length
410  *              Flags               - flags
411  *
412  * RETURN:      Status and table index.
413  *
414  * DESCRIPTION: Add an ACPI table to the global table list
415  *
416  ******************************************************************************/
417 
418 ACPI_STATUS
419 AcpiTbStoreTable (
420     ACPI_PHYSICAL_ADDRESS   Address,
421     ACPI_TABLE_HEADER       *Table,
422     UINT32                  Length,
423     UINT8                   Flags,
424     UINT32                  *TableIndex)
425 {
426     ACPI_STATUS             Status = AE_OK;
427 
428 
429     /* Ensure that there is room for the table in the Root Table List */
430 
431     if (AcpiGbl_RootTableList.Count >= AcpiGbl_RootTableList.Size)
432     {
433         Status = AcpiTbResizeRootTableList();
434         if (ACPI_FAILURE (Status))
435         {
436             return (Status);
437         }
438     }
439 
440     /* Initialize added table */
441 
442     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Address = Address;
443     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Pointer = Table;
444     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Length = Length;
445     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].OwnerId = 0;
446     AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Flags = Flags;
447 
448     ACPI_MOVE_32_TO_32 (
449         &(AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.Count].Signature),
450         Table->Signature);
451 
452     *TableIndex = AcpiGbl_RootTableList.Count;
453     AcpiGbl_RootTableList.Count++;
454     return (Status);
455 }
456 
457 
458 /*******************************************************************************
459  *
460  * FUNCTION:    AcpiTbDeleteTable
461  *
462  * PARAMETERS:  TableIndex          - Table index
463  *
464  * RETURN:      None
465  *
466  * DESCRIPTION: Delete one internal ACPI table
467  *
468  ******************************************************************************/
469 
470 void
471 AcpiTbDeleteTable (
472     ACPI_TABLE_DESC         *TableDesc)
473 {
474 
475     /* Table must be mapped or allocated */
476 
477     if (!TableDesc->Pointer)
478     {
479         return;
480     }
481 
482     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
483     {
484     case ACPI_TABLE_ORIGIN_MAPPED:
485         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
486         break;
487 
488     case ACPI_TABLE_ORIGIN_ALLOCATED:
489         ACPI_FREE (TableDesc->Pointer);
490         break;
491 
492     default:
493         break;
494     }
495 
496     TableDesc->Pointer = NULL;
497 }
498 
499 
500 /*******************************************************************************
501  *
502  * FUNCTION:    AcpiTbTerminate
503  *
504  * PARAMETERS:  None
505  *
506  * RETURN:      None
507  *
508  * DESCRIPTION: Delete all internal ACPI tables
509  *
510  ******************************************************************************/
511 
512 void
513 AcpiTbTerminate (
514     void)
515 {
516     UINT32                  i;
517 
518 
519     ACPI_FUNCTION_TRACE (TbTerminate);
520 
521 
522     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
523 
524     /* Delete the individual tables */
525 
526     for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
527     {
528         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
529     }
530 
531     /*
532      * Delete the root table array if allocated locally. Array cannot be
533      * mapped, so we don't need to check for that flag.
534      */
535     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
536     {
537         ACPI_FREE (AcpiGbl_RootTableList.Tables);
538     }
539 
540     AcpiGbl_RootTableList.Tables = NULL;
541     AcpiGbl_RootTableList.Flags = 0;
542     AcpiGbl_RootTableList.Count = 0;
543 
544     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
545     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
546 }
547 
548 
549 /*******************************************************************************
550  *
551  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
552  *
553  * PARAMETERS:  TableIndex          - Table index
554  *
555  * RETURN:      Status
556  *
557  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
558  *
559  ******************************************************************************/
560 
561 ACPI_STATUS
562 AcpiTbDeleteNamespaceByOwner (
563     UINT32                  TableIndex)
564 {
565     ACPI_OWNER_ID           OwnerId;
566     ACPI_STATUS             Status;
567 
568 
569     ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
570 
571 
572     Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
573     if (ACPI_FAILURE (Status))
574     {
575         return_ACPI_STATUS (Status);
576     }
577 
578     if (TableIndex >= AcpiGbl_RootTableList.Count)
579     {
580         /* The table index does not exist */
581 
582         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
583         return_ACPI_STATUS (AE_NOT_EXIST);
584     }
585 
586     /* Get the owner ID for this table, used to delete namespace nodes */
587 
588     OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
589     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
590 
591     /*
592      * Need to acquire the namespace writer lock to prevent interference
593      * with any concurrent namespace walks. The interpreter must be
594      * released during the deletion since the acquisition of the deletion
595      * lock may block, and also since the execution of a namespace walk
596      * must be allowed to use the interpreter.
597      */
598     (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
599     Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
600 
601     AcpiNsDeleteNamespaceByOwner (OwnerId);
602     if (ACPI_FAILURE (Status))
603     {
604         return_ACPI_STATUS (Status);
605     }
606 
607     AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
608 
609     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
610     return_ACPI_STATUS (Status);
611 }
612 
613 
614 /*******************************************************************************
615  *
616  * FUNCTION:    AcpiTbAllocateOwnerId
617  *
618  * PARAMETERS:  TableIndex          - Table index
619  *
620  * RETURN:      Status
621  *
622  * DESCRIPTION: Allocates OwnerId in TableDesc
623  *
624  ******************************************************************************/
625 
626 ACPI_STATUS
627 AcpiTbAllocateOwnerId (
628     UINT32                  TableIndex)
629 {
630     ACPI_STATUS             Status = AE_BAD_PARAMETER;
631 
632 
633     ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
634 
635 
636     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
637     if (TableIndex < AcpiGbl_RootTableList.Count)
638     {
639         Status = AcpiUtAllocateOwnerId
640                     (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
641     }
642 
643     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
644     return_ACPI_STATUS (Status);
645 }
646 
647 
648 /*******************************************************************************
649  *
650  * FUNCTION:    AcpiTbReleaseOwnerId
651  *
652  * PARAMETERS:  TableIndex          - Table index
653  *
654  * RETURN:      Status
655  *
656  * DESCRIPTION: Releases OwnerId in TableDesc
657  *
658  ******************************************************************************/
659 
660 ACPI_STATUS
661 AcpiTbReleaseOwnerId (
662     UINT32                  TableIndex)
663 {
664     ACPI_STATUS             Status = AE_BAD_PARAMETER;
665 
666 
667     ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
668 
669 
670     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
671     if (TableIndex < AcpiGbl_RootTableList.Count)
672     {
673         AcpiUtReleaseOwnerId (
674             &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
675         Status = AE_OK;
676     }
677 
678     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
679     return_ACPI_STATUS (Status);
680 }
681 
682 
683 /*******************************************************************************
684  *
685  * FUNCTION:    AcpiTbGetOwnerId
686  *
687  * PARAMETERS:  TableIndex          - Table index
688  *              OwnerId             - Where the table OwnerId is returned
689  *
690  * RETURN:      Status
691  *
692  * DESCRIPTION: returns OwnerId for the ACPI table
693  *
694  ******************************************************************************/
695 
696 ACPI_STATUS
697 AcpiTbGetOwnerId (
698     UINT32                  TableIndex,
699     ACPI_OWNER_ID           *OwnerId)
700 {
701     ACPI_STATUS             Status = AE_BAD_PARAMETER;
702 
703 
704     ACPI_FUNCTION_TRACE (TbGetOwnerId);
705 
706 
707     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
708     if (TableIndex < AcpiGbl_RootTableList.Count)
709     {
710         *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
711         Status = AE_OK;
712     }
713 
714     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
715     return_ACPI_STATUS (Status);
716 }
717 
718 
719 /*******************************************************************************
720  *
721  * FUNCTION:    AcpiTbIsTableLoaded
722  *
723  * PARAMETERS:  TableIndex          - Table index
724  *
725  * RETURN:      Table Loaded Flag
726  *
727  ******************************************************************************/
728 
729 BOOLEAN
730 AcpiTbIsTableLoaded (
731     UINT32                  TableIndex)
732 {
733     BOOLEAN                 IsLoaded = FALSE;
734 
735 
736     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
737     if (TableIndex < AcpiGbl_RootTableList.Count)
738     {
739         IsLoaded = (BOOLEAN)
740             (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
741             ACPI_TABLE_IS_LOADED);
742     }
743 
744     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
745     return (IsLoaded);
746 }
747 
748 
749 /*******************************************************************************
750  *
751  * FUNCTION:    AcpiTbSetTableLoadedFlag
752  *
753  * PARAMETERS:  TableIndex          - Table index
754  *              IsLoaded            - TRUE if table is loaded, FALSE otherwise
755  *
756  * RETURN:      None
757  *
758  * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
759  *
760  ******************************************************************************/
761 
762 void
763 AcpiTbSetTableLoadedFlag (
764     UINT32                  TableIndex,
765     BOOLEAN                 IsLoaded)
766 {
767 
768     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
769     if (TableIndex < AcpiGbl_RootTableList.Count)
770     {
771         if (IsLoaded)
772         {
773             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
774                 ACPI_TABLE_IS_LOADED;
775         }
776         else
777         {
778             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
779                 ~ACPI_TABLE_IS_LOADED;
780         }
781     }
782 
783     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
784 }
785 
786