xref: /freebsd/sys/contrib/dev/acpica/components/tables/tbinstal.c (revision a159c266a93c3c4f229864954c5f963acd8f60f2)
1*a159c266SJung-uk Kim /******************************************************************************
2*a159c266SJung-uk Kim  *
3*a159c266SJung-uk Kim  * Module Name: tbinstal - ACPI table installation and removal
4*a159c266SJung-uk Kim  *
5*a159c266SJung-uk Kim  *****************************************************************************/
6*a159c266SJung-uk Kim 
7*a159c266SJung-uk Kim /*
8*a159c266SJung-uk Kim  * Copyright (C) 2000 - 2012, Intel Corp.
9*a159c266SJung-uk Kim  * All rights reserved.
10*a159c266SJung-uk Kim  *
11*a159c266SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
12*a159c266SJung-uk Kim  * modification, are permitted provided that the following conditions
13*a159c266SJung-uk Kim  * are met:
14*a159c266SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
15*a159c266SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
16*a159c266SJung-uk Kim  *    without modification.
17*a159c266SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*a159c266SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
19*a159c266SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
20*a159c266SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
21*a159c266SJung-uk Kim  *    binary redistribution.
22*a159c266SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
23*a159c266SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
24*a159c266SJung-uk Kim  *    from this software without specific prior written permission.
25*a159c266SJung-uk Kim  *
26*a159c266SJung-uk Kim  * Alternatively, this software may be distributed under the terms of the
27*a159c266SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
28*a159c266SJung-uk Kim  * Software Foundation.
29*a159c266SJung-uk Kim  *
30*a159c266SJung-uk Kim  * NO WARRANTY
31*a159c266SJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*a159c266SJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*a159c266SJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*a159c266SJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*a159c266SJung-uk Kim  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*a159c266SJung-uk Kim  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*a159c266SJung-uk Kim  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*a159c266SJung-uk Kim  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*a159c266SJung-uk Kim  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*a159c266SJung-uk Kim  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*a159c266SJung-uk Kim  * POSSIBILITY OF SUCH DAMAGES.
42*a159c266SJung-uk Kim  */
43*a159c266SJung-uk Kim 
44*a159c266SJung-uk Kim 
45*a159c266SJung-uk Kim #define __TBINSTAL_C__
46*a159c266SJung-uk Kim 
47*a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
48*a159c266SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
49*a159c266SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
50*a159c266SJung-uk Kim #include <contrib/dev/acpica/include/actables.h>
51*a159c266SJung-uk Kim 
52*a159c266SJung-uk Kim 
53*a159c266SJung-uk Kim #define _COMPONENT          ACPI_TABLES
54*a159c266SJung-uk Kim         ACPI_MODULE_NAME    ("tbinstal")
55*a159c266SJung-uk Kim 
56*a159c266SJung-uk Kim 
57*a159c266SJung-uk Kim /******************************************************************************
58*a159c266SJung-uk Kim  *
59*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbVerifyTable
60*a159c266SJung-uk Kim  *
61*a159c266SJung-uk Kim  * PARAMETERS:  TableDesc           - table
62*a159c266SJung-uk Kim  *
63*a159c266SJung-uk Kim  * RETURN:      Status
64*a159c266SJung-uk Kim  *
65*a159c266SJung-uk Kim  * DESCRIPTION: this function is called to verify and map table
66*a159c266SJung-uk Kim  *
67*a159c266SJung-uk Kim  *****************************************************************************/
68*a159c266SJung-uk Kim 
69*a159c266SJung-uk Kim ACPI_STATUS
70*a159c266SJung-uk Kim AcpiTbVerifyTable (
71*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *TableDesc)
72*a159c266SJung-uk Kim {
73*a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_OK;
74*a159c266SJung-uk Kim 
75*a159c266SJung-uk Kim 
76*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbVerifyTable);
77*a159c266SJung-uk Kim 
78*a159c266SJung-uk Kim 
79*a159c266SJung-uk Kim     /* Map the table if necessary */
80*a159c266SJung-uk Kim 
81*a159c266SJung-uk Kim     if (!TableDesc->Pointer)
82*a159c266SJung-uk Kim     {
83*a159c266SJung-uk Kim         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
84*a159c266SJung-uk Kim             ACPI_TABLE_ORIGIN_MAPPED)
85*a159c266SJung-uk Kim         {
86*a159c266SJung-uk Kim             TableDesc->Pointer = AcpiOsMapMemory (
87*a159c266SJung-uk Kim                 TableDesc->Address, TableDesc->Length);
88*a159c266SJung-uk Kim         }
89*a159c266SJung-uk Kim 
90*a159c266SJung-uk Kim         if (!TableDesc->Pointer)
91*a159c266SJung-uk Kim         {
92*a159c266SJung-uk Kim             return_ACPI_STATUS (AE_NO_MEMORY);
93*a159c266SJung-uk Kim         }
94*a159c266SJung-uk Kim     }
95*a159c266SJung-uk Kim 
96*a159c266SJung-uk Kim     /* FACS is the odd table, has no standard ACPI header and no checksum */
97*a159c266SJung-uk Kim 
98*a159c266SJung-uk Kim     if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
99*a159c266SJung-uk Kim     {
100*a159c266SJung-uk Kim         /* Always calculate checksum, ignore bad checksum if requested */
101*a159c266SJung-uk Kim 
102*a159c266SJung-uk Kim         Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
103*a159c266SJung-uk Kim     }
104*a159c266SJung-uk Kim 
105*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
106*a159c266SJung-uk Kim }
107*a159c266SJung-uk Kim 
108*a159c266SJung-uk Kim 
109*a159c266SJung-uk Kim /*******************************************************************************
110*a159c266SJung-uk Kim  *
111*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbAddTable
112*a159c266SJung-uk Kim  *
113*a159c266SJung-uk Kim  * PARAMETERS:  TableDesc           - Table descriptor
114*a159c266SJung-uk Kim  *              TableIndex          - Where the table index is returned
115*a159c266SJung-uk Kim  *
116*a159c266SJung-uk Kim  * RETURN:      Status
117*a159c266SJung-uk Kim  *
118*a159c266SJung-uk Kim  * DESCRIPTION: This function is called to add an ACPI table. It is used to
119*a159c266SJung-uk Kim  *              dynamically load tables via the Load and LoadTable AML
120*a159c266SJung-uk Kim  *              operators.
121*a159c266SJung-uk Kim  *
122*a159c266SJung-uk Kim  ******************************************************************************/
123*a159c266SJung-uk Kim 
124*a159c266SJung-uk Kim ACPI_STATUS
125*a159c266SJung-uk Kim AcpiTbAddTable (
126*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *TableDesc,
127*a159c266SJung-uk Kim     UINT32                  *TableIndex)
128*a159c266SJung-uk Kim {
129*a159c266SJung-uk Kim     UINT32                  i;
130*a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_OK;
131*a159c266SJung-uk Kim 
132*a159c266SJung-uk Kim 
133*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbAddTable);
134*a159c266SJung-uk Kim 
135*a159c266SJung-uk Kim 
136*a159c266SJung-uk Kim     if (!TableDesc->Pointer)
137*a159c266SJung-uk Kim     {
138*a159c266SJung-uk Kim         Status = AcpiTbVerifyTable (TableDesc);
139*a159c266SJung-uk Kim         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
140*a159c266SJung-uk Kim         {
141*a159c266SJung-uk Kim             return_ACPI_STATUS (Status);
142*a159c266SJung-uk Kim         }
143*a159c266SJung-uk Kim     }
144*a159c266SJung-uk Kim 
145*a159c266SJung-uk Kim     /*
146*a159c266SJung-uk Kim      * Validate the incoming table signature.
147*a159c266SJung-uk Kim      *
148*a159c266SJung-uk Kim      * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
149*a159c266SJung-uk Kim      * 2) We added support for OEMx tables, signature "OEM".
150*a159c266SJung-uk Kim      * 3) Valid tables were encountered with a null signature, so we just
151*a159c266SJung-uk Kim      *    gave up on validating the signature, (05/2008).
152*a159c266SJung-uk Kim      * 4) We encountered non-AML tables such as the MADT, which caused
153*a159c266SJung-uk Kim      *    interpreter errors and kernel faults. So now, we once again allow
154*a159c266SJung-uk Kim      *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
155*a159c266SJung-uk Kim      */
156*a159c266SJung-uk Kim     if ((TableDesc->Pointer->Signature[0] != 0x00) &&
157*a159c266SJung-uk Kim        (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
158*a159c266SJung-uk Kim        (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
159*a159c266SJung-uk Kim     {
160*a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO,
161*a159c266SJung-uk Kim             "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
162*a159c266SJung-uk Kim             AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
163*a159c266SJung-uk Kim                 TableDesc->Pointer->Signature : "????",
164*a159c266SJung-uk Kim             *(UINT32 *) TableDesc->Pointer->Signature));
165*a159c266SJung-uk Kim 
166*a159c266SJung-uk Kim         return_ACPI_STATUS (AE_BAD_SIGNATURE);
167*a159c266SJung-uk Kim     }
168*a159c266SJung-uk Kim 
169*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
170*a159c266SJung-uk Kim 
171*a159c266SJung-uk Kim     /* Check if table is already registered */
172*a159c266SJung-uk Kim 
173*a159c266SJung-uk Kim     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
174*a159c266SJung-uk Kim     {
175*a159c266SJung-uk Kim         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
176*a159c266SJung-uk Kim         {
177*a159c266SJung-uk Kim             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
178*a159c266SJung-uk Kim             if (ACPI_FAILURE (Status) ||
179*a159c266SJung-uk Kim                 !AcpiGbl_RootTableList.Tables[i].Pointer)
180*a159c266SJung-uk Kim             {
181*a159c266SJung-uk Kim                 continue;
182*a159c266SJung-uk Kim             }
183*a159c266SJung-uk Kim         }
184*a159c266SJung-uk Kim 
185*a159c266SJung-uk Kim         /*
186*a159c266SJung-uk Kim          * Check for a table match on the entire table length,
187*a159c266SJung-uk Kim          * not just the header.
188*a159c266SJung-uk Kim          */
189*a159c266SJung-uk Kim         if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
190*a159c266SJung-uk Kim         {
191*a159c266SJung-uk Kim             continue;
192*a159c266SJung-uk Kim         }
193*a159c266SJung-uk Kim 
194*a159c266SJung-uk Kim         if (ACPI_MEMCMP (TableDesc->Pointer,
195*a159c266SJung-uk Kim                 AcpiGbl_RootTableList.Tables[i].Pointer,
196*a159c266SJung-uk Kim                 AcpiGbl_RootTableList.Tables[i].Length))
197*a159c266SJung-uk Kim         {
198*a159c266SJung-uk Kim             continue;
199*a159c266SJung-uk Kim         }
200*a159c266SJung-uk Kim 
201*a159c266SJung-uk Kim         /*
202*a159c266SJung-uk Kim          * Note: the current mechanism does not unregister a table if it is
203*a159c266SJung-uk Kim          * dynamically unloaded. The related namespace entries are deleted,
204*a159c266SJung-uk Kim          * but the table remains in the root table list.
205*a159c266SJung-uk Kim          *
206*a159c266SJung-uk Kim          * The assumption here is that the number of different tables that
207*a159c266SJung-uk Kim          * will be loaded is actually small, and there is minimal overhead
208*a159c266SJung-uk Kim          * in just keeping the table in case it is needed again.
209*a159c266SJung-uk Kim          *
210*a159c266SJung-uk Kim          * If this assumption changes in the future (perhaps on large
211*a159c266SJung-uk Kim          * machines with many table load/unload operations), tables will
212*a159c266SJung-uk Kim          * need to be unregistered when they are unloaded, and slots in the
213*a159c266SJung-uk Kim          * root table list should be reused when empty.
214*a159c266SJung-uk Kim          */
215*a159c266SJung-uk Kim 
216*a159c266SJung-uk Kim         /*
217*a159c266SJung-uk Kim          * Table is already registered.
218*a159c266SJung-uk Kim          * We can delete the table that was passed as a parameter.
219*a159c266SJung-uk Kim          */
220*a159c266SJung-uk Kim         AcpiTbDeleteTable (TableDesc);
221*a159c266SJung-uk Kim         *TableIndex = i;
222*a159c266SJung-uk Kim 
223*a159c266SJung-uk Kim         if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
224*a159c266SJung-uk Kim         {
225*a159c266SJung-uk Kim             /* Table is still loaded, this is an error */
226*a159c266SJung-uk Kim 
227*a159c266SJung-uk Kim             Status = AE_ALREADY_EXISTS;
228*a159c266SJung-uk Kim             goto Release;
229*a159c266SJung-uk Kim         }
230*a159c266SJung-uk Kim         else
231*a159c266SJung-uk Kim         {
232*a159c266SJung-uk Kim             /* Table was unloaded, allow it to be reloaded */
233*a159c266SJung-uk Kim 
234*a159c266SJung-uk Kim             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
235*a159c266SJung-uk Kim             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
236*a159c266SJung-uk Kim             Status = AE_OK;
237*a159c266SJung-uk Kim             goto PrintHeader;
238*a159c266SJung-uk Kim         }
239*a159c266SJung-uk Kim     }
240*a159c266SJung-uk Kim 
241*a159c266SJung-uk Kim     /*
242*a159c266SJung-uk Kim      * ACPI Table Override:
243*a159c266SJung-uk Kim      * Allow the host to override dynamically loaded tables.
244*a159c266SJung-uk Kim      * NOTE: the table is fully mapped at this point, and the mapping will
245*a159c266SJung-uk Kim      * be deleted by TbTableOverride if the table is actually overridden.
246*a159c266SJung-uk Kim      */
247*a159c266SJung-uk Kim     (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc);
248*a159c266SJung-uk Kim 
249*a159c266SJung-uk Kim     /* Add the table to the global root table list */
250*a159c266SJung-uk Kim 
251*a159c266SJung-uk Kim     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
252*a159c266SJung-uk Kim                 TableDesc->Length, TableDesc->Flags, TableIndex);
253*a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
254*a159c266SJung-uk Kim     {
255*a159c266SJung-uk Kim         goto Release;
256*a159c266SJung-uk Kim     }
257*a159c266SJung-uk Kim 
258*a159c266SJung-uk Kim PrintHeader:
259*a159c266SJung-uk Kim     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
260*a159c266SJung-uk Kim 
261*a159c266SJung-uk Kim Release:
262*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
263*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
264*a159c266SJung-uk Kim }
265*a159c266SJung-uk Kim 
266*a159c266SJung-uk Kim 
267*a159c266SJung-uk Kim /*******************************************************************************
268*a159c266SJung-uk Kim  *
269*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbTableOverride
270*a159c266SJung-uk Kim  *
271*a159c266SJung-uk Kim  * PARAMETERS:  TableHeader         - Header for the original table
272*a159c266SJung-uk Kim  *              TableDesc           - Table descriptor initialized for the
273*a159c266SJung-uk Kim  *                                    original table. May or may not be mapped.
274*a159c266SJung-uk Kim  *
275*a159c266SJung-uk Kim  * RETURN:      Pointer to the entire new table. NULL if table not overridden.
276*a159c266SJung-uk Kim  *              If overridden, installs the new table within the input table
277*a159c266SJung-uk Kim  *              descriptor.
278*a159c266SJung-uk Kim  *
279*a159c266SJung-uk Kim  * DESCRIPTION: Attempt table override by calling the OSL override functions.
280*a159c266SJung-uk Kim  *              Note: If the table is overridden, then the entire new table
281*a159c266SJung-uk Kim  *              is mapped and returned by this function.
282*a159c266SJung-uk Kim  *
283*a159c266SJung-uk Kim  ******************************************************************************/
284*a159c266SJung-uk Kim 
285*a159c266SJung-uk Kim ACPI_TABLE_HEADER *
286*a159c266SJung-uk Kim AcpiTbTableOverride (
287*a159c266SJung-uk Kim     ACPI_TABLE_HEADER       *TableHeader,
288*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *TableDesc)
289*a159c266SJung-uk Kim {
290*a159c266SJung-uk Kim     ACPI_STATUS             Status;
291*a159c266SJung-uk Kim     ACPI_TABLE_HEADER       *NewTable = NULL;
292*a159c266SJung-uk Kim     ACPI_PHYSICAL_ADDRESS   NewAddress = 0;
293*a159c266SJung-uk Kim     UINT32                  NewTableLength = 0;
294*a159c266SJung-uk Kim     UINT8                   NewFlags;
295*a159c266SJung-uk Kim     char                    *OverrideType;
296*a159c266SJung-uk Kim 
297*a159c266SJung-uk Kim 
298*a159c266SJung-uk Kim     /* (1) Attempt logical override (returns a logical address) */
299*a159c266SJung-uk Kim 
300*a159c266SJung-uk Kim     Status = AcpiOsTableOverride (TableHeader, &NewTable);
301*a159c266SJung-uk Kim     if (ACPI_SUCCESS (Status) && NewTable)
302*a159c266SJung-uk Kim     {
303*a159c266SJung-uk Kim         NewAddress = ACPI_PTR_TO_PHYSADDR (NewTable);
304*a159c266SJung-uk Kim         NewTableLength = NewTable->Length;
305*a159c266SJung-uk Kim         NewFlags = ACPI_TABLE_ORIGIN_OVERRIDE;
306*a159c266SJung-uk Kim         OverrideType = "Logical";
307*a159c266SJung-uk Kim         goto FinishOverride;
308*a159c266SJung-uk Kim     }
309*a159c266SJung-uk Kim 
310*a159c266SJung-uk Kim     /* (2) Attempt physical override (returns a physical address) */
311*a159c266SJung-uk Kim 
312*a159c266SJung-uk Kim     Status = AcpiOsPhysicalTableOverride (TableHeader,
313*a159c266SJung-uk Kim         &NewAddress, &NewTableLength);
314*a159c266SJung-uk Kim     if (ACPI_SUCCESS (Status) && NewAddress && NewTableLength)
315*a159c266SJung-uk Kim     {
316*a159c266SJung-uk Kim         /* Map the entire new table */
317*a159c266SJung-uk Kim 
318*a159c266SJung-uk Kim         NewTable = AcpiOsMapMemory (NewAddress, NewTableLength);
319*a159c266SJung-uk Kim         if (!NewTable)
320*a159c266SJung-uk Kim         {
321*a159c266SJung-uk Kim             ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
322*a159c266SJung-uk Kim                 "%4.4s %p Attempted physical table override failed",
323*a159c266SJung-uk Kim                 TableHeader->Signature,
324*a159c266SJung-uk Kim                 ACPI_CAST_PTR (void, TableDesc->Address)));
325*a159c266SJung-uk Kim             return (NULL);
326*a159c266SJung-uk Kim         }
327*a159c266SJung-uk Kim 
328*a159c266SJung-uk Kim         OverrideType = "Physical";
329*a159c266SJung-uk Kim         NewFlags = ACPI_TABLE_ORIGIN_MAPPED;
330*a159c266SJung-uk Kim         goto FinishOverride;
331*a159c266SJung-uk Kim     }
332*a159c266SJung-uk Kim 
333*a159c266SJung-uk Kim     return (NULL); /* There was no override */
334*a159c266SJung-uk Kim 
335*a159c266SJung-uk Kim 
336*a159c266SJung-uk Kim FinishOverride:
337*a159c266SJung-uk Kim 
338*a159c266SJung-uk Kim     ACPI_INFO ((AE_INFO,
339*a159c266SJung-uk Kim         "%4.4s %p %s table override, new table: %p",
340*a159c266SJung-uk Kim         TableHeader->Signature,
341*a159c266SJung-uk Kim         ACPI_CAST_PTR (void, TableDesc->Address),
342*a159c266SJung-uk Kim         OverrideType, NewTable));
343*a159c266SJung-uk Kim 
344*a159c266SJung-uk Kim     /* We can now unmap/delete the original table (if fully mapped) */
345*a159c266SJung-uk Kim 
346*a159c266SJung-uk Kim     AcpiTbDeleteTable (TableDesc);
347*a159c266SJung-uk Kim 
348*a159c266SJung-uk Kim     /* Setup descriptor for the new table */
349*a159c266SJung-uk Kim 
350*a159c266SJung-uk Kim     TableDesc->Address = NewAddress;
351*a159c266SJung-uk Kim     TableDesc->Pointer = NewTable;
352*a159c266SJung-uk Kim     TableDesc->Length = NewTableLength;
353*a159c266SJung-uk Kim     TableDesc->Flags = NewFlags;
354*a159c266SJung-uk Kim 
355*a159c266SJung-uk Kim     return (NewTable);
356*a159c266SJung-uk Kim }
357*a159c266SJung-uk Kim 
358*a159c266SJung-uk Kim 
359*a159c266SJung-uk Kim /*******************************************************************************
360*a159c266SJung-uk Kim  *
361*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbResizeRootTableList
362*a159c266SJung-uk Kim  *
363*a159c266SJung-uk Kim  * PARAMETERS:  None
364*a159c266SJung-uk Kim  *
365*a159c266SJung-uk Kim  * RETURN:      Status
366*a159c266SJung-uk Kim  *
367*a159c266SJung-uk Kim  * DESCRIPTION: Expand the size of global table array
368*a159c266SJung-uk Kim  *
369*a159c266SJung-uk Kim  ******************************************************************************/
370*a159c266SJung-uk Kim 
371*a159c266SJung-uk Kim ACPI_STATUS
372*a159c266SJung-uk Kim AcpiTbResizeRootTableList (
373*a159c266SJung-uk Kim     void)
374*a159c266SJung-uk Kim {
375*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *Tables;
376*a159c266SJung-uk Kim 
377*a159c266SJung-uk Kim 
378*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
379*a159c266SJung-uk Kim 
380*a159c266SJung-uk Kim 
381*a159c266SJung-uk Kim     /* AllowResize flag is a parameter to AcpiInitializeTables */
382*a159c266SJung-uk Kim 
383*a159c266SJung-uk Kim     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
384*a159c266SJung-uk Kim     {
385*a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
386*a159c266SJung-uk Kim         return_ACPI_STATUS (AE_SUPPORT);
387*a159c266SJung-uk Kim     }
388*a159c266SJung-uk Kim 
389*a159c266SJung-uk Kim     /* Increase the Table Array size */
390*a159c266SJung-uk Kim 
391*a159c266SJung-uk Kim     Tables = ACPI_ALLOCATE_ZEROED (
392*a159c266SJung-uk Kim         ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
393*a159c266SJung-uk Kim             ACPI_ROOT_TABLE_SIZE_INCREMENT) *
394*a159c266SJung-uk Kim         sizeof (ACPI_TABLE_DESC));
395*a159c266SJung-uk Kim     if (!Tables)
396*a159c266SJung-uk Kim     {
397*a159c266SJung-uk Kim         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
398*a159c266SJung-uk Kim         return_ACPI_STATUS (AE_NO_MEMORY);
399*a159c266SJung-uk Kim     }
400*a159c266SJung-uk Kim 
401*a159c266SJung-uk Kim     /* Copy and free the previous table array */
402*a159c266SJung-uk Kim 
403*a159c266SJung-uk Kim     if (AcpiGbl_RootTableList.Tables)
404*a159c266SJung-uk Kim     {
405*a159c266SJung-uk Kim         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
406*a159c266SJung-uk Kim             (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
407*a159c266SJung-uk Kim 
408*a159c266SJung-uk Kim         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
409*a159c266SJung-uk Kim         {
410*a159c266SJung-uk Kim             ACPI_FREE (AcpiGbl_RootTableList.Tables);
411*a159c266SJung-uk Kim         }
412*a159c266SJung-uk Kim     }
413*a159c266SJung-uk Kim 
414*a159c266SJung-uk Kim     AcpiGbl_RootTableList.Tables = Tables;
415*a159c266SJung-uk Kim     AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
416*a159c266SJung-uk Kim     AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
417*a159c266SJung-uk Kim 
418*a159c266SJung-uk Kim     return_ACPI_STATUS (AE_OK);
419*a159c266SJung-uk Kim }
420*a159c266SJung-uk Kim 
421*a159c266SJung-uk Kim 
422*a159c266SJung-uk Kim /*******************************************************************************
423*a159c266SJung-uk Kim  *
424*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbStoreTable
425*a159c266SJung-uk Kim  *
426*a159c266SJung-uk Kim  * PARAMETERS:  Address             - Table address
427*a159c266SJung-uk Kim  *              Table               - Table header
428*a159c266SJung-uk Kim  *              Length              - Table length
429*a159c266SJung-uk Kim  *              Flags               - flags
430*a159c266SJung-uk Kim  *
431*a159c266SJung-uk Kim  * RETURN:      Status and table index.
432*a159c266SJung-uk Kim  *
433*a159c266SJung-uk Kim  * DESCRIPTION: Add an ACPI table to the global table list
434*a159c266SJung-uk Kim  *
435*a159c266SJung-uk Kim  ******************************************************************************/
436*a159c266SJung-uk Kim 
437*a159c266SJung-uk Kim ACPI_STATUS
438*a159c266SJung-uk Kim AcpiTbStoreTable (
439*a159c266SJung-uk Kim     ACPI_PHYSICAL_ADDRESS   Address,
440*a159c266SJung-uk Kim     ACPI_TABLE_HEADER       *Table,
441*a159c266SJung-uk Kim     UINT32                  Length,
442*a159c266SJung-uk Kim     UINT8                   Flags,
443*a159c266SJung-uk Kim     UINT32                  *TableIndex)
444*a159c266SJung-uk Kim {
445*a159c266SJung-uk Kim     ACPI_STATUS             Status;
446*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *NewTable;
447*a159c266SJung-uk Kim 
448*a159c266SJung-uk Kim 
449*a159c266SJung-uk Kim     /* Ensure that there is room for the table in the Root Table List */
450*a159c266SJung-uk Kim 
451*a159c266SJung-uk Kim     if (AcpiGbl_RootTableList.CurrentTableCount >=
452*a159c266SJung-uk Kim         AcpiGbl_RootTableList.MaxTableCount)
453*a159c266SJung-uk Kim     {
454*a159c266SJung-uk Kim         Status = AcpiTbResizeRootTableList();
455*a159c266SJung-uk Kim         if (ACPI_FAILURE (Status))
456*a159c266SJung-uk Kim         {
457*a159c266SJung-uk Kim             return (Status);
458*a159c266SJung-uk Kim         }
459*a159c266SJung-uk Kim     }
460*a159c266SJung-uk Kim 
461*a159c266SJung-uk Kim     NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount];
462*a159c266SJung-uk Kim 
463*a159c266SJung-uk Kim     /* Initialize added table */
464*a159c266SJung-uk Kim 
465*a159c266SJung-uk Kim     NewTable->Address = Address;
466*a159c266SJung-uk Kim     NewTable->Pointer = Table;
467*a159c266SJung-uk Kim     NewTable->Length = Length;
468*a159c266SJung-uk Kim     NewTable->OwnerId = 0;
469*a159c266SJung-uk Kim     NewTable->Flags = Flags;
470*a159c266SJung-uk Kim 
471*a159c266SJung-uk Kim     ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature);
472*a159c266SJung-uk Kim 
473*a159c266SJung-uk Kim     *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
474*a159c266SJung-uk Kim     AcpiGbl_RootTableList.CurrentTableCount++;
475*a159c266SJung-uk Kim     return (AE_OK);
476*a159c266SJung-uk Kim }
477*a159c266SJung-uk Kim 
478*a159c266SJung-uk Kim 
479*a159c266SJung-uk Kim /*******************************************************************************
480*a159c266SJung-uk Kim  *
481*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbDeleteTable
482*a159c266SJung-uk Kim  *
483*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
484*a159c266SJung-uk Kim  *
485*a159c266SJung-uk Kim  * RETURN:      None
486*a159c266SJung-uk Kim  *
487*a159c266SJung-uk Kim  * DESCRIPTION: Delete one internal ACPI table
488*a159c266SJung-uk Kim  *
489*a159c266SJung-uk Kim  ******************************************************************************/
490*a159c266SJung-uk Kim 
491*a159c266SJung-uk Kim void
492*a159c266SJung-uk Kim AcpiTbDeleteTable (
493*a159c266SJung-uk Kim     ACPI_TABLE_DESC         *TableDesc)
494*a159c266SJung-uk Kim {
495*a159c266SJung-uk Kim 
496*a159c266SJung-uk Kim     /* Table must be mapped or allocated */
497*a159c266SJung-uk Kim 
498*a159c266SJung-uk Kim     if (!TableDesc->Pointer)
499*a159c266SJung-uk Kim     {
500*a159c266SJung-uk Kim         return;
501*a159c266SJung-uk Kim     }
502*a159c266SJung-uk Kim 
503*a159c266SJung-uk Kim     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
504*a159c266SJung-uk Kim     {
505*a159c266SJung-uk Kim     case ACPI_TABLE_ORIGIN_MAPPED:
506*a159c266SJung-uk Kim         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
507*a159c266SJung-uk Kim         break;
508*a159c266SJung-uk Kim 
509*a159c266SJung-uk Kim     case ACPI_TABLE_ORIGIN_ALLOCATED:
510*a159c266SJung-uk Kim         ACPI_FREE (TableDesc->Pointer);
511*a159c266SJung-uk Kim         break;
512*a159c266SJung-uk Kim 
513*a159c266SJung-uk Kim     default:
514*a159c266SJung-uk Kim         break;
515*a159c266SJung-uk Kim     }
516*a159c266SJung-uk Kim 
517*a159c266SJung-uk Kim     TableDesc->Pointer = NULL;
518*a159c266SJung-uk Kim }
519*a159c266SJung-uk Kim 
520*a159c266SJung-uk Kim 
521*a159c266SJung-uk Kim /*******************************************************************************
522*a159c266SJung-uk Kim  *
523*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbTerminate
524*a159c266SJung-uk Kim  *
525*a159c266SJung-uk Kim  * PARAMETERS:  None
526*a159c266SJung-uk Kim  *
527*a159c266SJung-uk Kim  * RETURN:      None
528*a159c266SJung-uk Kim  *
529*a159c266SJung-uk Kim  * DESCRIPTION: Delete all internal ACPI tables
530*a159c266SJung-uk Kim  *
531*a159c266SJung-uk Kim  ******************************************************************************/
532*a159c266SJung-uk Kim 
533*a159c266SJung-uk Kim void
534*a159c266SJung-uk Kim AcpiTbTerminate (
535*a159c266SJung-uk Kim     void)
536*a159c266SJung-uk Kim {
537*a159c266SJung-uk Kim     UINT32                  i;
538*a159c266SJung-uk Kim 
539*a159c266SJung-uk Kim 
540*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbTerminate);
541*a159c266SJung-uk Kim 
542*a159c266SJung-uk Kim 
543*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
544*a159c266SJung-uk Kim 
545*a159c266SJung-uk Kim     /* Delete the individual tables */
546*a159c266SJung-uk Kim 
547*a159c266SJung-uk Kim     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
548*a159c266SJung-uk Kim     {
549*a159c266SJung-uk Kim         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
550*a159c266SJung-uk Kim     }
551*a159c266SJung-uk Kim 
552*a159c266SJung-uk Kim     /*
553*a159c266SJung-uk Kim      * Delete the root table array if allocated locally. Array cannot be
554*a159c266SJung-uk Kim      * mapped, so we don't need to check for that flag.
555*a159c266SJung-uk Kim      */
556*a159c266SJung-uk Kim     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
557*a159c266SJung-uk Kim     {
558*a159c266SJung-uk Kim         ACPI_FREE (AcpiGbl_RootTableList.Tables);
559*a159c266SJung-uk Kim     }
560*a159c266SJung-uk Kim 
561*a159c266SJung-uk Kim     AcpiGbl_RootTableList.Tables = NULL;
562*a159c266SJung-uk Kim     AcpiGbl_RootTableList.Flags = 0;
563*a159c266SJung-uk Kim     AcpiGbl_RootTableList.CurrentTableCount = 0;
564*a159c266SJung-uk Kim 
565*a159c266SJung-uk Kim     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
566*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
567*a159c266SJung-uk Kim }
568*a159c266SJung-uk Kim 
569*a159c266SJung-uk Kim 
570*a159c266SJung-uk Kim /*******************************************************************************
571*a159c266SJung-uk Kim  *
572*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
573*a159c266SJung-uk Kim  *
574*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
575*a159c266SJung-uk Kim  *
576*a159c266SJung-uk Kim  * RETURN:      Status
577*a159c266SJung-uk Kim  *
578*a159c266SJung-uk Kim  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
579*a159c266SJung-uk Kim  *
580*a159c266SJung-uk Kim  ******************************************************************************/
581*a159c266SJung-uk Kim 
582*a159c266SJung-uk Kim ACPI_STATUS
583*a159c266SJung-uk Kim AcpiTbDeleteNamespaceByOwner (
584*a159c266SJung-uk Kim     UINT32                  TableIndex)
585*a159c266SJung-uk Kim {
586*a159c266SJung-uk Kim     ACPI_OWNER_ID           OwnerId;
587*a159c266SJung-uk Kim     ACPI_STATUS             Status;
588*a159c266SJung-uk Kim 
589*a159c266SJung-uk Kim 
590*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
591*a159c266SJung-uk Kim 
592*a159c266SJung-uk Kim 
593*a159c266SJung-uk Kim     Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
594*a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
595*a159c266SJung-uk Kim     {
596*a159c266SJung-uk Kim         return_ACPI_STATUS (Status);
597*a159c266SJung-uk Kim     }
598*a159c266SJung-uk Kim 
599*a159c266SJung-uk Kim     if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
600*a159c266SJung-uk Kim     {
601*a159c266SJung-uk Kim         /* The table index does not exist */
602*a159c266SJung-uk Kim 
603*a159c266SJung-uk Kim         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
604*a159c266SJung-uk Kim         return_ACPI_STATUS (AE_NOT_EXIST);
605*a159c266SJung-uk Kim     }
606*a159c266SJung-uk Kim 
607*a159c266SJung-uk Kim     /* Get the owner ID for this table, used to delete namespace nodes */
608*a159c266SJung-uk Kim 
609*a159c266SJung-uk Kim     OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
610*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
611*a159c266SJung-uk Kim 
612*a159c266SJung-uk Kim     /*
613*a159c266SJung-uk Kim      * Need to acquire the namespace writer lock to prevent interference
614*a159c266SJung-uk Kim      * with any concurrent namespace walks. The interpreter must be
615*a159c266SJung-uk Kim      * released during the deletion since the acquisition of the deletion
616*a159c266SJung-uk Kim      * lock may block, and also since the execution of a namespace walk
617*a159c266SJung-uk Kim      * must be allowed to use the interpreter.
618*a159c266SJung-uk Kim      */
619*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
620*a159c266SJung-uk Kim     Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
621*a159c266SJung-uk Kim 
622*a159c266SJung-uk Kim     AcpiNsDeleteNamespaceByOwner (OwnerId);
623*a159c266SJung-uk Kim     if (ACPI_FAILURE (Status))
624*a159c266SJung-uk Kim     {
625*a159c266SJung-uk Kim         return_ACPI_STATUS (Status);
626*a159c266SJung-uk Kim     }
627*a159c266SJung-uk Kim 
628*a159c266SJung-uk Kim     AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
629*a159c266SJung-uk Kim 
630*a159c266SJung-uk Kim     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
631*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
632*a159c266SJung-uk Kim }
633*a159c266SJung-uk Kim 
634*a159c266SJung-uk Kim 
635*a159c266SJung-uk Kim /*******************************************************************************
636*a159c266SJung-uk Kim  *
637*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbAllocateOwnerId
638*a159c266SJung-uk Kim  *
639*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
640*a159c266SJung-uk Kim  *
641*a159c266SJung-uk Kim  * RETURN:      Status
642*a159c266SJung-uk Kim  *
643*a159c266SJung-uk Kim  * DESCRIPTION: Allocates OwnerId in TableDesc
644*a159c266SJung-uk Kim  *
645*a159c266SJung-uk Kim  ******************************************************************************/
646*a159c266SJung-uk Kim 
647*a159c266SJung-uk Kim ACPI_STATUS
648*a159c266SJung-uk Kim AcpiTbAllocateOwnerId (
649*a159c266SJung-uk Kim     UINT32                  TableIndex)
650*a159c266SJung-uk Kim {
651*a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_BAD_PARAMETER;
652*a159c266SJung-uk Kim 
653*a159c266SJung-uk Kim 
654*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
655*a159c266SJung-uk Kim 
656*a159c266SJung-uk Kim 
657*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
658*a159c266SJung-uk Kim     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
659*a159c266SJung-uk Kim     {
660*a159c266SJung-uk Kim         Status = AcpiUtAllocateOwnerId
661*a159c266SJung-uk Kim                     (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
662*a159c266SJung-uk Kim     }
663*a159c266SJung-uk Kim 
664*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
665*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
666*a159c266SJung-uk Kim }
667*a159c266SJung-uk Kim 
668*a159c266SJung-uk Kim 
669*a159c266SJung-uk Kim /*******************************************************************************
670*a159c266SJung-uk Kim  *
671*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbReleaseOwnerId
672*a159c266SJung-uk Kim  *
673*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
674*a159c266SJung-uk Kim  *
675*a159c266SJung-uk Kim  * RETURN:      Status
676*a159c266SJung-uk Kim  *
677*a159c266SJung-uk Kim  * DESCRIPTION: Releases OwnerId in TableDesc
678*a159c266SJung-uk Kim  *
679*a159c266SJung-uk Kim  ******************************************************************************/
680*a159c266SJung-uk Kim 
681*a159c266SJung-uk Kim ACPI_STATUS
682*a159c266SJung-uk Kim AcpiTbReleaseOwnerId (
683*a159c266SJung-uk Kim     UINT32                  TableIndex)
684*a159c266SJung-uk Kim {
685*a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_BAD_PARAMETER;
686*a159c266SJung-uk Kim 
687*a159c266SJung-uk Kim 
688*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
689*a159c266SJung-uk Kim 
690*a159c266SJung-uk Kim 
691*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
692*a159c266SJung-uk Kim     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
693*a159c266SJung-uk Kim     {
694*a159c266SJung-uk Kim         AcpiUtReleaseOwnerId (
695*a159c266SJung-uk Kim             &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
696*a159c266SJung-uk Kim         Status = AE_OK;
697*a159c266SJung-uk Kim     }
698*a159c266SJung-uk Kim 
699*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
700*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
701*a159c266SJung-uk Kim }
702*a159c266SJung-uk Kim 
703*a159c266SJung-uk Kim 
704*a159c266SJung-uk Kim /*******************************************************************************
705*a159c266SJung-uk Kim  *
706*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbGetOwnerId
707*a159c266SJung-uk Kim  *
708*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
709*a159c266SJung-uk Kim  *              OwnerId             - Where the table OwnerId is returned
710*a159c266SJung-uk Kim  *
711*a159c266SJung-uk Kim  * RETURN:      Status
712*a159c266SJung-uk Kim  *
713*a159c266SJung-uk Kim  * DESCRIPTION: returns OwnerId for the ACPI table
714*a159c266SJung-uk Kim  *
715*a159c266SJung-uk Kim  ******************************************************************************/
716*a159c266SJung-uk Kim 
717*a159c266SJung-uk Kim ACPI_STATUS
718*a159c266SJung-uk Kim AcpiTbGetOwnerId (
719*a159c266SJung-uk Kim     UINT32                  TableIndex,
720*a159c266SJung-uk Kim     ACPI_OWNER_ID           *OwnerId)
721*a159c266SJung-uk Kim {
722*a159c266SJung-uk Kim     ACPI_STATUS             Status = AE_BAD_PARAMETER;
723*a159c266SJung-uk Kim 
724*a159c266SJung-uk Kim 
725*a159c266SJung-uk Kim     ACPI_FUNCTION_TRACE (TbGetOwnerId);
726*a159c266SJung-uk Kim 
727*a159c266SJung-uk Kim 
728*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
729*a159c266SJung-uk Kim     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
730*a159c266SJung-uk Kim     {
731*a159c266SJung-uk Kim         *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
732*a159c266SJung-uk Kim         Status = AE_OK;
733*a159c266SJung-uk Kim     }
734*a159c266SJung-uk Kim 
735*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
736*a159c266SJung-uk Kim     return_ACPI_STATUS (Status);
737*a159c266SJung-uk Kim }
738*a159c266SJung-uk Kim 
739*a159c266SJung-uk Kim 
740*a159c266SJung-uk Kim /*******************************************************************************
741*a159c266SJung-uk Kim  *
742*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbIsTableLoaded
743*a159c266SJung-uk Kim  *
744*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
745*a159c266SJung-uk Kim  *
746*a159c266SJung-uk Kim  * RETURN:      Table Loaded Flag
747*a159c266SJung-uk Kim  *
748*a159c266SJung-uk Kim  ******************************************************************************/
749*a159c266SJung-uk Kim 
750*a159c266SJung-uk Kim BOOLEAN
751*a159c266SJung-uk Kim AcpiTbIsTableLoaded (
752*a159c266SJung-uk Kim     UINT32                  TableIndex)
753*a159c266SJung-uk Kim {
754*a159c266SJung-uk Kim     BOOLEAN                 IsLoaded = FALSE;
755*a159c266SJung-uk Kim 
756*a159c266SJung-uk Kim 
757*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
758*a159c266SJung-uk Kim     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
759*a159c266SJung-uk Kim     {
760*a159c266SJung-uk Kim         IsLoaded = (BOOLEAN)
761*a159c266SJung-uk Kim             (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
762*a159c266SJung-uk Kim             ACPI_TABLE_IS_LOADED);
763*a159c266SJung-uk Kim     }
764*a159c266SJung-uk Kim 
765*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
766*a159c266SJung-uk Kim     return (IsLoaded);
767*a159c266SJung-uk Kim }
768*a159c266SJung-uk Kim 
769*a159c266SJung-uk Kim 
770*a159c266SJung-uk Kim /*******************************************************************************
771*a159c266SJung-uk Kim  *
772*a159c266SJung-uk Kim  * FUNCTION:    AcpiTbSetTableLoadedFlag
773*a159c266SJung-uk Kim  *
774*a159c266SJung-uk Kim  * PARAMETERS:  TableIndex          - Table index
775*a159c266SJung-uk Kim  *              IsLoaded            - TRUE if table is loaded, FALSE otherwise
776*a159c266SJung-uk Kim  *
777*a159c266SJung-uk Kim  * RETURN:      None
778*a159c266SJung-uk Kim  *
779*a159c266SJung-uk Kim  * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
780*a159c266SJung-uk Kim  *
781*a159c266SJung-uk Kim  ******************************************************************************/
782*a159c266SJung-uk Kim 
783*a159c266SJung-uk Kim void
784*a159c266SJung-uk Kim AcpiTbSetTableLoadedFlag (
785*a159c266SJung-uk Kim     UINT32                  TableIndex,
786*a159c266SJung-uk Kim     BOOLEAN                 IsLoaded)
787*a159c266SJung-uk Kim {
788*a159c266SJung-uk Kim 
789*a159c266SJung-uk Kim     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
790*a159c266SJung-uk Kim     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
791*a159c266SJung-uk Kim     {
792*a159c266SJung-uk Kim         if (IsLoaded)
793*a159c266SJung-uk Kim         {
794*a159c266SJung-uk Kim             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
795*a159c266SJung-uk Kim                 ACPI_TABLE_IS_LOADED;
796*a159c266SJung-uk Kim         }
797*a159c266SJung-uk Kim         else
798*a159c266SJung-uk Kim         {
799*a159c266SJung-uk Kim             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
800*a159c266SJung-uk Kim                 ~ACPI_TABLE_IS_LOADED;
801*a159c266SJung-uk Kim         }
802*a159c266SJung-uk Kim     }
803*a159c266SJung-uk Kim 
804*a159c266SJung-uk Kim     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
805*a159c266SJung-uk Kim }
806*a159c266SJung-uk Kim 
807