xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/tables/tbxfload.c (revision 6dde014f768e0ee49bae871ed857cf433837b9ff)
16822cda0SFredrik Holmqvist /******************************************************************************
26822cda0SFredrik Holmqvist  *
36822cda0SFredrik Holmqvist  * Module Name: tbxfload - Table load/unload external interfaces
46822cda0SFredrik Holmqvist  *
56822cda0SFredrik Holmqvist  *****************************************************************************/
66822cda0SFredrik Holmqvist 
76822cda0SFredrik Holmqvist /******************************************************************************
86822cda0SFredrik Holmqvist  *
96822cda0SFredrik Holmqvist  * 1. Copyright Notice
106822cda0SFredrik Holmqvist  *
11*6dde014fSPulkoMandy  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
126822cda0SFredrik Holmqvist  * All rights reserved.
136822cda0SFredrik Holmqvist  *
146822cda0SFredrik Holmqvist  * 2. License
156822cda0SFredrik Holmqvist  *
166822cda0SFredrik Holmqvist  * 2.1. This is your license from Intel Corp. under its intellectual property
176822cda0SFredrik Holmqvist  * rights. You may have additional license terms from the party that provided
186822cda0SFredrik Holmqvist  * you this software, covering your right to use that party's intellectual
196822cda0SFredrik Holmqvist  * property rights.
206822cda0SFredrik Holmqvist  *
216822cda0SFredrik Holmqvist  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
226822cda0SFredrik Holmqvist  * copy of the source code appearing in this file ("Covered Code") an
236822cda0SFredrik Holmqvist  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
246822cda0SFredrik Holmqvist  * base code distributed originally by Intel ("Original Intel Code") to copy,
256822cda0SFredrik Holmqvist  * make derivatives, distribute, use and display any portion of the Covered
266822cda0SFredrik Holmqvist  * Code in any form, with the right to sublicense such rights; and
276822cda0SFredrik Holmqvist  *
286822cda0SFredrik Holmqvist  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
296822cda0SFredrik Holmqvist  * license (with the right to sublicense), under only those claims of Intel
306822cda0SFredrik Holmqvist  * patents that are infringed by the Original Intel Code, to make, use, sell,
316822cda0SFredrik Holmqvist  * offer to sell, and import the Covered Code and derivative works thereof
326822cda0SFredrik Holmqvist  * solely to the minimum extent necessary to exercise the above copyright
336822cda0SFredrik Holmqvist  * license, and in no event shall the patent license extend to any additions
346822cda0SFredrik Holmqvist  * to or modifications of the Original Intel Code. No other license or right
356822cda0SFredrik Holmqvist  * is granted directly or by implication, estoppel or otherwise;
366822cda0SFredrik Holmqvist  *
376822cda0SFredrik Holmqvist  * The above copyright and patent license is granted only if the following
386822cda0SFredrik Holmqvist  * conditions are met:
396822cda0SFredrik Holmqvist  *
406822cda0SFredrik Holmqvist  * 3. Conditions
416822cda0SFredrik Holmqvist  *
426822cda0SFredrik Holmqvist  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
436822cda0SFredrik Holmqvist  * Redistribution of source code of any substantial portion of the Covered
446822cda0SFredrik Holmqvist  * Code or modification with rights to further distribute source must include
456822cda0SFredrik Holmqvist  * the above Copyright Notice, the above License, this list of Conditions,
466822cda0SFredrik Holmqvist  * and the following Disclaimer and Export Compliance provision. In addition,
476822cda0SFredrik Holmqvist  * Licensee must cause all Covered Code to which Licensee contributes to
486822cda0SFredrik Holmqvist  * contain a file documenting the changes Licensee made to create that Covered
496822cda0SFredrik Holmqvist  * Code and the date of any change. Licensee must include in that file the
506822cda0SFredrik Holmqvist  * documentation of any changes made by any predecessor Licensee. Licensee
516822cda0SFredrik Holmqvist  * must include a prominent statement that the modification is derived,
526822cda0SFredrik Holmqvist  * directly or indirectly, from Original Intel Code.
536822cda0SFredrik Holmqvist  *
546822cda0SFredrik Holmqvist  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
556822cda0SFredrik Holmqvist  * Redistribution of source code of any substantial portion of the Covered
566822cda0SFredrik Holmqvist  * Code or modification without rights to further distribute source must
576822cda0SFredrik Holmqvist  * include the following Disclaimer and Export Compliance provision in the
586822cda0SFredrik Holmqvist  * documentation and/or other materials provided with distribution. In
596822cda0SFredrik Holmqvist  * addition, Licensee may not authorize further sublicense of source of any
606822cda0SFredrik Holmqvist  * portion of the Covered Code, and must include terms to the effect that the
616822cda0SFredrik Holmqvist  * license from Licensee to its licensee is limited to the intellectual
626822cda0SFredrik Holmqvist  * property embodied in the software Licensee provides to its licensee, and
636822cda0SFredrik Holmqvist  * not to intellectual property embodied in modifications its licensee may
646822cda0SFredrik Holmqvist  * make.
656822cda0SFredrik Holmqvist  *
666822cda0SFredrik Holmqvist  * 3.3. Redistribution of Executable. Redistribution in executable form of any
676822cda0SFredrik Holmqvist  * substantial portion of the Covered Code or modification must reproduce the
686822cda0SFredrik Holmqvist  * above Copyright Notice, and the following Disclaimer and Export Compliance
696822cda0SFredrik Holmqvist  * provision in the documentation and/or other materials provided with the
706822cda0SFredrik Holmqvist  * distribution.
716822cda0SFredrik Holmqvist  *
726822cda0SFredrik Holmqvist  * 3.4. Intel retains all right, title, and interest in and to the Original
736822cda0SFredrik Holmqvist  * Intel Code.
746822cda0SFredrik Holmqvist  *
756822cda0SFredrik Holmqvist  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
766822cda0SFredrik Holmqvist  * Intel shall be used in advertising or otherwise to promote the sale, use or
776822cda0SFredrik Holmqvist  * other dealings in products derived from or relating to the Covered Code
786822cda0SFredrik Holmqvist  * without prior written authorization from Intel.
796822cda0SFredrik Holmqvist  *
806822cda0SFredrik Holmqvist  * 4. Disclaimer and Export Compliance
816822cda0SFredrik Holmqvist  *
826822cda0SFredrik Holmqvist  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
836822cda0SFredrik Holmqvist  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
846822cda0SFredrik Holmqvist  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
856822cda0SFredrik Holmqvist  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
866822cda0SFredrik Holmqvist  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
876822cda0SFredrik Holmqvist  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
886822cda0SFredrik Holmqvist  * PARTICULAR PURPOSE.
896822cda0SFredrik Holmqvist  *
906822cda0SFredrik Holmqvist  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
916822cda0SFredrik Holmqvist  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
926822cda0SFredrik Holmqvist  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
936822cda0SFredrik Holmqvist  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
946822cda0SFredrik Holmqvist  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
956822cda0SFredrik Holmqvist  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
966822cda0SFredrik Holmqvist  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
976822cda0SFredrik Holmqvist  * LIMITED REMEDY.
986822cda0SFredrik Holmqvist  *
996822cda0SFredrik Holmqvist  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1006822cda0SFredrik Holmqvist  * software or system incorporating such software without first obtaining any
1016822cda0SFredrik Holmqvist  * required license or other approval from the U. S. Department of Commerce or
1026822cda0SFredrik Holmqvist  * any other agency or department of the United States Government. In the
1036822cda0SFredrik Holmqvist  * event Licensee exports any such software from the United States or
1046822cda0SFredrik Holmqvist  * re-exports any such software from a foreign destination, Licensee shall
1056822cda0SFredrik Holmqvist  * ensure that the distribution and export/re-export of the software is in
1066822cda0SFredrik Holmqvist  * compliance with all laws, regulations, orders, or other restrictions of the
1076822cda0SFredrik Holmqvist  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1086822cda0SFredrik Holmqvist  * any of its subsidiaries will export/re-export any technical data, process,
1096822cda0SFredrik Holmqvist  * software, or service, directly or indirectly, to any country for which the
1106822cda0SFredrik Holmqvist  * United States government or any agency thereof requires an export license,
1116822cda0SFredrik Holmqvist  * other governmental approval, or letter of assurance, without first obtaining
1126822cda0SFredrik Holmqvist  * such license, approval or letter.
1136822cda0SFredrik Holmqvist  *
114ff2e2f81SFredrik Holmqvist  *****************************************************************************
115ff2e2f81SFredrik Holmqvist  *
116ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
117ff2e2f81SFredrik Holmqvist  * following license:
118ff2e2f81SFredrik Holmqvist  *
119ff2e2f81SFredrik Holmqvist  * Redistribution and use in source and binary forms, with or without
120ff2e2f81SFredrik Holmqvist  * modification, are permitted provided that the following conditions
121ff2e2f81SFredrik Holmqvist  * are met:
122ff2e2f81SFredrik Holmqvist  * 1. Redistributions of source code must retain the above copyright
123ff2e2f81SFredrik Holmqvist  *    notice, this list of conditions, and the following disclaimer,
124ff2e2f81SFredrik Holmqvist  *    without modification.
125ff2e2f81SFredrik Holmqvist  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126ff2e2f81SFredrik Holmqvist  *    substantially similar to the "NO WARRANTY" disclaimer below
127ff2e2f81SFredrik Holmqvist  *    ("Disclaimer") and any redistribution must be conditioned upon
128ff2e2f81SFredrik Holmqvist  *    including a substantially similar Disclaimer requirement for further
129ff2e2f81SFredrik Holmqvist  *    binary redistribution.
130ff2e2f81SFredrik Holmqvist  * 3. Neither the names of the above-listed copyright holders nor the names
131ff2e2f81SFredrik Holmqvist  *    of any contributors may be used to endorse or promote products derived
132ff2e2f81SFredrik Holmqvist  *    from this software without specific prior written permission.
133ff2e2f81SFredrik Holmqvist  *
134ff2e2f81SFredrik Holmqvist  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135ff2e2f81SFredrik Holmqvist  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136ff2e2f81SFredrik Holmqvist  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137ff2e2f81SFredrik Holmqvist  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138ff2e2f81SFredrik Holmqvist  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139ff2e2f81SFredrik Holmqvist  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140ff2e2f81SFredrik Holmqvist  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141ff2e2f81SFredrik Holmqvist  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142ff2e2f81SFredrik Holmqvist  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143ff2e2f81SFredrik Holmqvist  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144ff2e2f81SFredrik Holmqvist  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145ff2e2f81SFredrik Holmqvist  *
146ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
147ff2e2f81SFredrik Holmqvist  * GNU General Public License ("GPL") version 2 as published by the Free
148ff2e2f81SFredrik Holmqvist  * Software Foundation.
149ff2e2f81SFredrik Holmqvist  *
1506822cda0SFredrik Holmqvist  *****************************************************************************/
1516822cda0SFredrik Holmqvist 
152ad5bbfb8SFredrik Holmqvist #define EXPORT_ACPI_INTERFACES
1536822cda0SFredrik Holmqvist 
1546822cda0SFredrik Holmqvist #include "acpi.h"
1556822cda0SFredrik Holmqvist #include "accommon.h"
1566822cda0SFredrik Holmqvist #include "acnamesp.h"
1576822cda0SFredrik Holmqvist #include "actables.h"
15874ffd18dSFredrik Holmqvist #include "acevents.h"
1596822cda0SFredrik Holmqvist 
1606822cda0SFredrik Holmqvist #define _COMPONENT          ACPI_TABLES
1616822cda0SFredrik Holmqvist         ACPI_MODULE_NAME    ("tbxfload")
1626822cda0SFredrik Holmqvist 
1636822cda0SFredrik Holmqvist 
1646822cda0SFredrik Holmqvist /*******************************************************************************
1656822cda0SFredrik Holmqvist  *
1666822cda0SFredrik Holmqvist  * FUNCTION:    AcpiLoadTables
1676822cda0SFredrik Holmqvist  *
1686822cda0SFredrik Holmqvist  * PARAMETERS:  None
1696822cda0SFredrik Holmqvist  *
1706822cda0SFredrik Holmqvist  * RETURN:      Status
1716822cda0SFredrik Holmqvist  *
1726822cda0SFredrik Holmqvist  * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
1736822cda0SFredrik Holmqvist  *
1746822cda0SFredrik Holmqvist  ******************************************************************************/
1756822cda0SFredrik Holmqvist 
17674ffd18dSFredrik Holmqvist ACPI_STATUS ACPI_INIT_FUNCTION
AcpiLoadTables(void)1776822cda0SFredrik Holmqvist AcpiLoadTables (
1786822cda0SFredrik Holmqvist     void)
1796822cda0SFredrik Holmqvist {
1806822cda0SFredrik Holmqvist     ACPI_STATUS             Status;
1816822cda0SFredrik Holmqvist 
1826822cda0SFredrik Holmqvist 
1836822cda0SFredrik Holmqvist     ACPI_FUNCTION_TRACE (AcpiLoadTables);
1846822cda0SFredrik Holmqvist 
1856822cda0SFredrik Holmqvist 
18674ffd18dSFredrik Holmqvist     /*
18774ffd18dSFredrik Holmqvist      * Install the default operation region handlers. These are the
18874ffd18dSFredrik Holmqvist      * handlers that are defined by the ACPI specification to be
18974ffd18dSFredrik Holmqvist      * "always accessible" -- namely, SystemMemory, SystemIO, and
19074ffd18dSFredrik Holmqvist      * PCI_Config. This also means that no _REG methods need to be
19174ffd18dSFredrik Holmqvist      * run for these address spaces. We need to have these handlers
19274ffd18dSFredrik Holmqvist      * installed before any AML code can be executed, especially any
19374ffd18dSFredrik Holmqvist      * module-level code (11/2015).
19474ffd18dSFredrik Holmqvist      * Note that we allow OSPMs to install their own region handlers
19574ffd18dSFredrik Holmqvist      * between AcpiInitializeSubsystem() and AcpiLoadTables() to use
19674ffd18dSFredrik Holmqvist      * their customized default region handlers.
19774ffd18dSFredrik Holmqvist      */
19874ffd18dSFredrik Holmqvist     Status = AcpiEvInstallRegionHandlers ();
19974ffd18dSFredrik Holmqvist     if (ACPI_FAILURE (Status))
20074ffd18dSFredrik Holmqvist     {
20174ffd18dSFredrik Holmqvist         ACPI_EXCEPTION ((AE_INFO, Status, "During Region initialization"));
20274ffd18dSFredrik Holmqvist         return_ACPI_STATUS (Status);
20374ffd18dSFredrik Holmqvist     }
20474ffd18dSFredrik Holmqvist 
2056822cda0SFredrik Holmqvist     /* Load the namespace from the tables */
2066822cda0SFredrik Holmqvist 
2076822cda0SFredrik Holmqvist     Status = AcpiTbLoadNamespace ();
208e226d1d0SFredrik Holmqvist 
209e226d1d0SFredrik Holmqvist     /* Don't let single failures abort the load */
210e226d1d0SFredrik Holmqvist 
211e226d1d0SFredrik Holmqvist     if (Status == AE_CTRL_TERMINATE)
212e226d1d0SFredrik Holmqvist     {
213e226d1d0SFredrik Holmqvist         Status = AE_OK;
214e226d1d0SFredrik Holmqvist     }
215e226d1d0SFredrik Holmqvist 
2166822cda0SFredrik Holmqvist     if (ACPI_FAILURE (Status))
2176822cda0SFredrik Holmqvist     {
2186822cda0SFredrik Holmqvist         ACPI_EXCEPTION ((AE_INFO, Status,
2196822cda0SFredrik Holmqvist             "While loading namespace from ACPI tables"));
2206822cda0SFredrik Holmqvist     }
2216822cda0SFredrik Holmqvist 
22274ffd18dSFredrik Holmqvist     /*
2230ffed378SFredrik Holmqvist      * Initialize the objects in the namespace that remain uninitialized.
2240ffed378SFredrik Holmqvist      * This runs the executable AML that may be part of the declaration of
2250ffed378SFredrik Holmqvist      * these name objects:
22674ffd18dSFredrik Holmqvist      *     OperationRegions, BufferFields, Buffers, and Packages.
22708c9948cSFredrik Holmqvist      *
22874ffd18dSFredrik Holmqvist      */
22974ffd18dSFredrik Holmqvist     Status = AcpiNsInitializeObjects ();
2300ffed378SFredrik Holmqvist     if (ACPI_SUCCESS (Status))
23174ffd18dSFredrik Holmqvist     {
2320ffed378SFredrik Holmqvist         AcpiGbl_NamespaceInitialized = TRUE;
23374ffd18dSFredrik Holmqvist     }
23474ffd18dSFredrik Holmqvist 
2356822cda0SFredrik Holmqvist     return_ACPI_STATUS (Status);
2366822cda0SFredrik Holmqvist }
2376822cda0SFredrik Holmqvist 
ACPI_EXPORT_SYMBOL_INIT(AcpiLoadTables)238ad5bbfb8SFredrik Holmqvist ACPI_EXPORT_SYMBOL_INIT (AcpiLoadTables)
2396822cda0SFredrik Holmqvist 
2406822cda0SFredrik Holmqvist 
2416822cda0SFredrik Holmqvist /*******************************************************************************
2426822cda0SFredrik Holmqvist  *
2436822cda0SFredrik Holmqvist  * FUNCTION:    AcpiTbLoadNamespace
2446822cda0SFredrik Holmqvist  *
2456822cda0SFredrik Holmqvist  * PARAMETERS:  None
2466822cda0SFredrik Holmqvist  *
2476822cda0SFredrik Holmqvist  * RETURN:      Status
2486822cda0SFredrik Holmqvist  *
2496822cda0SFredrik Holmqvist  * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
2506822cda0SFredrik Holmqvist  *              the RSDT/XSDT.
2516822cda0SFredrik Holmqvist  *
2526822cda0SFredrik Holmqvist  ******************************************************************************/
2536822cda0SFredrik Holmqvist 
254e226d1d0SFredrik Holmqvist ACPI_STATUS
2556822cda0SFredrik Holmqvist AcpiTbLoadNamespace (
2566822cda0SFredrik Holmqvist     void)
2576822cda0SFredrik Holmqvist {
2586822cda0SFredrik Holmqvist     ACPI_STATUS             Status;
2596822cda0SFredrik Holmqvist     UINT32                  i;
2606822cda0SFredrik Holmqvist     ACPI_TABLE_HEADER       *NewDsdt;
261e226d1d0SFredrik Holmqvist     ACPI_TABLE_DESC         *Table;
262e226d1d0SFredrik Holmqvist     UINT32                  TablesLoaded = 0;
263e226d1d0SFredrik Holmqvist     UINT32                  TablesFailed = 0;
2646822cda0SFredrik Holmqvist 
2656822cda0SFredrik Holmqvist 
2666822cda0SFredrik Holmqvist     ACPI_FUNCTION_TRACE (TbLoadNamespace);
2676822cda0SFredrik Holmqvist 
2686822cda0SFredrik Holmqvist 
2696822cda0SFredrik Holmqvist     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
2706822cda0SFredrik Holmqvist 
2716822cda0SFredrik Holmqvist     /*
2726822cda0SFredrik Holmqvist      * Load the namespace. The DSDT is required, but any SSDT and
2736822cda0SFredrik Holmqvist      * PSDT tables are optional. Verify the DSDT.
2746822cda0SFredrik Holmqvist      */
275e226d1d0SFredrik Holmqvist     Table = &AcpiGbl_RootTableList.Tables[AcpiGbl_DsdtIndex];
276e226d1d0SFredrik Holmqvist 
2776822cda0SFredrik Holmqvist     if (!AcpiGbl_RootTableList.CurrentTableCount ||
2780ffed378SFredrik Holmqvist         !ACPI_COMPARE_NAMESEG (Table->Signature.Ascii, ACPI_SIG_DSDT) ||
279e226d1d0SFredrik Holmqvist          ACPI_FAILURE (AcpiTbValidateTable (Table)))
2806822cda0SFredrik Holmqvist     {
2816822cda0SFredrik Holmqvist         Status = AE_NO_ACPI_TABLES;
2826822cda0SFredrik Holmqvist         goto UnlockAndExit;
2836822cda0SFredrik Holmqvist     }
2846822cda0SFredrik Holmqvist 
2856822cda0SFredrik Holmqvist     /*
2866822cda0SFredrik Holmqvist      * Save the DSDT pointer for simple access. This is the mapped memory
2876822cda0SFredrik Holmqvist      * address. We must take care here because the address of the .Tables
2886822cda0SFredrik Holmqvist      * array can change dynamically as tables are loaded at run-time. Note:
289ad5bbfb8SFredrik Holmqvist      * .Pointer field is not validated until after call to AcpiTbValidateTable.
2906822cda0SFredrik Holmqvist      */
291e226d1d0SFredrik Holmqvist     AcpiGbl_DSDT = Table->Pointer;
2926822cda0SFredrik Holmqvist 
2936822cda0SFredrik Holmqvist     /*
2946822cda0SFredrik Holmqvist      * Optionally copy the entire DSDT to local memory (instead of simply
2956822cda0SFredrik Holmqvist      * mapping it.) There are some BIOSs that corrupt or replace the original
2966822cda0SFredrik Holmqvist      * DSDT, creating the need for this option. Default is FALSE, do not copy
2976822cda0SFredrik Holmqvist      * the DSDT.
2986822cda0SFredrik Holmqvist      */
2996822cda0SFredrik Holmqvist     if (AcpiGbl_CopyDsdtLocally)
3006822cda0SFredrik Holmqvist     {
301e226d1d0SFredrik Holmqvist         NewDsdt = AcpiTbCopyDsdt (AcpiGbl_DsdtIndex);
3026822cda0SFredrik Holmqvist         if (NewDsdt)
3036822cda0SFredrik Holmqvist         {
3046822cda0SFredrik Holmqvist             AcpiGbl_DSDT = NewDsdt;
3056822cda0SFredrik Holmqvist         }
3066822cda0SFredrik Holmqvist     }
3076822cda0SFredrik Holmqvist 
3086822cda0SFredrik Holmqvist     /*
3096822cda0SFredrik Holmqvist      * Save the original DSDT header for detection of table corruption
3106822cda0SFredrik Holmqvist      * and/or replacement of the DSDT from outside the OS.
3116822cda0SFredrik Holmqvist      */
312e226d1d0SFredrik Holmqvist     memcpy (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
3136822cda0SFredrik Holmqvist         sizeof (ACPI_TABLE_HEADER));
3146822cda0SFredrik Holmqvist 
3156822cda0SFredrik Holmqvist     /* Load and parse tables */
3166822cda0SFredrik Holmqvist 
317ff2e2f81SFredrik Holmqvist     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
318e226d1d0SFredrik Holmqvist     Status = AcpiNsLoadTable (AcpiGbl_DsdtIndex, AcpiGbl_RootNode);
319ff2e2f81SFredrik Holmqvist     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
3206822cda0SFredrik Holmqvist     if (ACPI_FAILURE (Status))
3216822cda0SFredrik Holmqvist     {
322e226d1d0SFredrik Holmqvist         ACPI_EXCEPTION ((AE_INFO, Status, "[DSDT] table load failed"));
323e226d1d0SFredrik Holmqvist         TablesFailed++;
324e226d1d0SFredrik Holmqvist     }
325e226d1d0SFredrik Holmqvist     else
326e226d1d0SFredrik Holmqvist     {
327e226d1d0SFredrik Holmqvist         TablesLoaded++;
3286822cda0SFredrik Holmqvist     }
3296822cda0SFredrik Holmqvist 
3306822cda0SFredrik Holmqvist     /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
3316822cda0SFredrik Holmqvist 
3326822cda0SFredrik Holmqvist     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
3336822cda0SFredrik Holmqvist     {
334e226d1d0SFredrik Holmqvist         Table = &AcpiGbl_RootTableList.Tables[i];
335e226d1d0SFredrik Holmqvist 
336ff2e2f81SFredrik Holmqvist         if (!Table->Address ||
3370ffed378SFredrik Holmqvist             (!ACPI_COMPARE_NAMESEG (Table->Signature.Ascii, ACPI_SIG_SSDT) &&
3380ffed378SFredrik Holmqvist              !ACPI_COMPARE_NAMESEG (Table->Signature.Ascii, ACPI_SIG_PSDT) &&
3390ffed378SFredrik Holmqvist              !ACPI_COMPARE_NAMESEG (Table->Signature.Ascii, ACPI_SIG_OSDT)) ||
340e226d1d0SFredrik Holmqvist             ACPI_FAILURE (AcpiTbValidateTable (Table)))
3416822cda0SFredrik Holmqvist         {
3426822cda0SFredrik Holmqvist             continue;
3436822cda0SFredrik Holmqvist         }
3446822cda0SFredrik Holmqvist 
3456822cda0SFredrik Holmqvist         /* Ignore errors while loading tables, get as many as possible */
3466822cda0SFredrik Holmqvist 
3476822cda0SFredrik Holmqvist         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
348e226d1d0SFredrik Holmqvist         Status =  AcpiNsLoadTable (i, AcpiGbl_RootNode);
349ff2e2f81SFredrik Holmqvist         (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
350e226d1d0SFredrik Holmqvist         if (ACPI_FAILURE (Status))
351e226d1d0SFredrik Holmqvist         {
352e226d1d0SFredrik Holmqvist             ACPI_EXCEPTION ((AE_INFO, Status, "(%4.4s:%8.8s) while loading table",
353e226d1d0SFredrik Holmqvist                 Table->Signature.Ascii, Table->Pointer->OemTableId));
354b64e8511SFredrik Holmqvist 
355e226d1d0SFredrik Holmqvist             TablesFailed++;
356e226d1d0SFredrik Holmqvist 
357e226d1d0SFredrik Holmqvist             ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
358e226d1d0SFredrik Holmqvist                 "Table [%4.4s:%8.8s] (id FF) - Table namespace load failed\n\n",
359e226d1d0SFredrik Holmqvist                 Table->Signature.Ascii, Table->Pointer->OemTableId));
360e226d1d0SFredrik Holmqvist         }
361e226d1d0SFredrik Holmqvist         else
362e226d1d0SFredrik Holmqvist         {
363e226d1d0SFredrik Holmqvist             TablesLoaded++;
364e226d1d0SFredrik Holmqvist         }
3656822cda0SFredrik Holmqvist     }
3666822cda0SFredrik Holmqvist 
367e226d1d0SFredrik Holmqvist     if (!TablesFailed)
368e226d1d0SFredrik Holmqvist     {
36974ffd18dSFredrik Holmqvist         ACPI_INFO ((
370ff2e2f81SFredrik Holmqvist             "%u ACPI AML tables successfully acquired and loaded",
371e226d1d0SFredrik Holmqvist             TablesLoaded));
372e226d1d0SFredrik Holmqvist     }
373e226d1d0SFredrik Holmqvist     else
374e226d1d0SFredrik Holmqvist     {
375e226d1d0SFredrik Holmqvist         ACPI_ERROR ((AE_INFO,
376e226d1d0SFredrik Holmqvist             "%u table load failures, %u successful",
377e226d1d0SFredrik Holmqvist             TablesFailed, TablesLoaded));
378e226d1d0SFredrik Holmqvist 
379e226d1d0SFredrik Holmqvist         /* Indicate at least one failure */
380e226d1d0SFredrik Holmqvist 
381e226d1d0SFredrik Holmqvist         Status = AE_CTRL_TERMINATE;
382e226d1d0SFredrik Holmqvist     }
3836822cda0SFredrik Holmqvist 
384ff2e2f81SFredrik Holmqvist #ifdef ACPI_APPLICATION
385ff2e2f81SFredrik Holmqvist     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "\n"));
386ff2e2f81SFredrik Holmqvist #endif
387ff2e2f81SFredrik Holmqvist 
388ff2e2f81SFredrik Holmqvist 
3896822cda0SFredrik Holmqvist UnlockAndExit:
3906822cda0SFredrik Holmqvist     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
3916822cda0SFredrik Holmqvist     return_ACPI_STATUS (Status);
3926822cda0SFredrik Holmqvist }
3936822cda0SFredrik Holmqvist 
3946822cda0SFredrik Holmqvist 
3956822cda0SFredrik Holmqvist /*******************************************************************************
3966822cda0SFredrik Holmqvist  *
397ad5bbfb8SFredrik Holmqvist  * FUNCTION:    AcpiInstallTable
398ad5bbfb8SFredrik Holmqvist  *
39915338de9SPulkoMandy  * PARAMETERS:  Table               - Pointer to the ACPI table to be installed.
400ad5bbfb8SFredrik Holmqvist  *
401ad5bbfb8SFredrik Holmqvist  * RETURN:      Status
402ad5bbfb8SFredrik Holmqvist  *
403ad5bbfb8SFredrik Holmqvist  * DESCRIPTION: Dynamically install an ACPI table.
404ad5bbfb8SFredrik Holmqvist  *              Note: This function should only be invoked after
405ad5bbfb8SFredrik Holmqvist  *                    AcpiInitializeTables() and before AcpiLoadTables().
406ad5bbfb8SFredrik Holmqvist  *
407ad5bbfb8SFredrik Holmqvist  ******************************************************************************/
408ad5bbfb8SFredrik Holmqvist 
40974ffd18dSFredrik Holmqvist ACPI_STATUS ACPI_INIT_FUNCTION
AcpiInstallTable(ACPI_TABLE_HEADER * Table)410ad5bbfb8SFredrik Holmqvist AcpiInstallTable (
41115338de9SPulkoMandy     ACPI_TABLE_HEADER       *Table)
412ad5bbfb8SFredrik Holmqvist {
413ad5bbfb8SFredrik Holmqvist     ACPI_STATUS             Status;
414ad5bbfb8SFredrik Holmqvist     UINT32                  TableIndex;
415ad5bbfb8SFredrik Holmqvist 
416ad5bbfb8SFredrik Holmqvist 
417ad5bbfb8SFredrik Holmqvist     ACPI_FUNCTION_TRACE (AcpiInstallTable);
418ad5bbfb8SFredrik Holmqvist 
419ad5bbfb8SFredrik Holmqvist 
42015338de9SPulkoMandy     Status = AcpiTbInstallStandardTable (ACPI_PTR_TO_PHYSADDR (Table),
42115338de9SPulkoMandy         ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, Table, FALSE, FALSE, &TableIndex);
422ad5bbfb8SFredrik Holmqvist 
423ad5bbfb8SFredrik Holmqvist     return_ACPI_STATUS (Status);
424ad5bbfb8SFredrik Holmqvist }
425ad5bbfb8SFredrik Holmqvist 
ACPI_EXPORT_SYMBOL_INIT(AcpiInstallTable)426ad5bbfb8SFredrik Holmqvist ACPI_EXPORT_SYMBOL_INIT (AcpiInstallTable)
427ad5bbfb8SFredrik Holmqvist 
428ad5bbfb8SFredrik Holmqvist 
429ad5bbfb8SFredrik Holmqvist /*******************************************************************************
430ad5bbfb8SFredrik Holmqvist  *
43115338de9SPulkoMandy  * FUNCTION:    AcpiInstallPhysicalTable
43215338de9SPulkoMandy  *
43315338de9SPulkoMandy  * PARAMETERS:  Address             - Address of the ACPI table to be installed.
43415338de9SPulkoMandy  *
43515338de9SPulkoMandy  * RETURN:      Status
43615338de9SPulkoMandy  *
43715338de9SPulkoMandy  * DESCRIPTION: Dynamically install an ACPI table.
43815338de9SPulkoMandy  *              Note: This function should only be invoked after
43915338de9SPulkoMandy  *                    AcpiInitializeTables() and before AcpiLoadTables().
44015338de9SPulkoMandy  *
44115338de9SPulkoMandy  ******************************************************************************/
44215338de9SPulkoMandy 
44315338de9SPulkoMandy ACPI_STATUS ACPI_INIT_FUNCTION
44415338de9SPulkoMandy AcpiInstallPhysicalTable (
44515338de9SPulkoMandy     ACPI_PHYSICAL_ADDRESS   Address)
44615338de9SPulkoMandy {
44715338de9SPulkoMandy     ACPI_STATUS             Status;
44815338de9SPulkoMandy     UINT32                  TableIndex;
44915338de9SPulkoMandy 
45015338de9SPulkoMandy 
45115338de9SPulkoMandy     ACPI_FUNCTION_TRACE (AcpiInstallPhysicalTable);
45215338de9SPulkoMandy 
45315338de9SPulkoMandy 
45415338de9SPulkoMandy     Status = AcpiTbInstallStandardTable (Address,
45515338de9SPulkoMandy         ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL, NULL, FALSE, FALSE, &TableIndex);
45615338de9SPulkoMandy 
45715338de9SPulkoMandy     return_ACPI_STATUS (Status);
45815338de9SPulkoMandy }
45915338de9SPulkoMandy 
ACPI_EXPORT_SYMBOL_INIT(AcpiInstallPhysicalTable)46015338de9SPulkoMandy ACPI_EXPORT_SYMBOL_INIT (AcpiInstallPhysicalTable)
46115338de9SPulkoMandy 
46215338de9SPulkoMandy 
46315338de9SPulkoMandy /*******************************************************************************
46415338de9SPulkoMandy  *
4656822cda0SFredrik Holmqvist  * FUNCTION:    AcpiLoadTable
4666822cda0SFredrik Holmqvist  *
4676822cda0SFredrik Holmqvist  * PARAMETERS:  Table               - Pointer to a buffer containing the ACPI
4686822cda0SFredrik Holmqvist  *                                    table to be loaded.
4690ffed378SFredrik Holmqvist  *              TableIdx            - Pointer to a UINT32 for storing the table
4700ffed378SFredrik Holmqvist  *                                    index, might be NULL
4716822cda0SFredrik Holmqvist  *
4726822cda0SFredrik Holmqvist  * RETURN:      Status
4736822cda0SFredrik Holmqvist  *
4746822cda0SFredrik Holmqvist  * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must
4756822cda0SFredrik Holmqvist  *              be a valid ACPI table with a valid ACPI table header.
4766822cda0SFredrik Holmqvist  *              Note1: Mainly intended to support hotplug addition of SSDTs.
4779b0d045cSFredrik Holmqvist  *              Note2: Does not copy the incoming table. User is responsible
4786822cda0SFredrik Holmqvist  *              to ensure that the table is not deleted or unmapped.
4796822cda0SFredrik Holmqvist  *
4806822cda0SFredrik Holmqvist  ******************************************************************************/
4816822cda0SFredrik Holmqvist 
4826822cda0SFredrik Holmqvist ACPI_STATUS
4836822cda0SFredrik Holmqvist AcpiLoadTable (
4840ffed378SFredrik Holmqvist     ACPI_TABLE_HEADER       *Table,
4850ffed378SFredrik Holmqvist     UINT32                  *TableIdx)
4866822cda0SFredrik Holmqvist {
4876822cda0SFredrik Holmqvist     ACPI_STATUS             Status;
4886822cda0SFredrik Holmqvist     UINT32                  TableIndex;
4896822cda0SFredrik Holmqvist 
4906822cda0SFredrik Holmqvist 
4916822cda0SFredrik Holmqvist     ACPI_FUNCTION_TRACE (AcpiLoadTable);
4926822cda0SFredrik Holmqvist 
4936822cda0SFredrik Holmqvist 
4946822cda0SFredrik Holmqvist     /* Parameter validation */
4956822cda0SFredrik Holmqvist 
4966822cda0SFredrik Holmqvist     if (!Table)
4976822cda0SFredrik Holmqvist     {
4986822cda0SFredrik Holmqvist         return_ACPI_STATUS (AE_BAD_PARAMETER);
4996822cda0SFredrik Holmqvist     }
5006822cda0SFredrik Holmqvist 
5016822cda0SFredrik Holmqvist     /* Install the table and load it into the namespace */
5026822cda0SFredrik Holmqvist 
50374ffd18dSFredrik Holmqvist     ACPI_INFO (("Host-directed Dynamic ACPI Table Load:"));
504ff2e2f81SFredrik Holmqvist     Status = AcpiTbInstallAndLoadTable (ACPI_PTR_TO_PHYSADDR (Table),
50515338de9SPulkoMandy         ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL, Table, FALSE, &TableIndex);
5060ffed378SFredrik Holmqvist     if (TableIdx)
5070ffed378SFredrik Holmqvist     {
5080ffed378SFredrik Holmqvist         *TableIdx = TableIndex;
5090ffed378SFredrik Holmqvist     }
5100ffed378SFredrik Holmqvist 
5110ffed378SFredrik Holmqvist     if (ACPI_SUCCESS (Status))
5120ffed378SFredrik Holmqvist     {
5130ffed378SFredrik Holmqvist         /* Complete the initialization/resolution of new objects */
5140ffed378SFredrik Holmqvist 
5150ffed378SFredrik Holmqvist         AcpiNsInitializeObjects ();
5160ffed378SFredrik Holmqvist     }
5170ffed378SFredrik Holmqvist 
5186822cda0SFredrik Holmqvist     return_ACPI_STATUS (Status);
5196822cda0SFredrik Holmqvist }
5206822cda0SFredrik Holmqvist 
ACPI_EXPORT_SYMBOL(AcpiLoadTable)5216822cda0SFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiLoadTable)
5226822cda0SFredrik Holmqvist 
5236822cda0SFredrik Holmqvist 
5246822cda0SFredrik Holmqvist /*******************************************************************************
5256822cda0SFredrik Holmqvist  *
5266822cda0SFredrik Holmqvist  * FUNCTION:    AcpiUnloadParentTable
5276822cda0SFredrik Holmqvist  *
5286822cda0SFredrik Holmqvist  * PARAMETERS:  Object              - Handle to any namespace object owned by
5296822cda0SFredrik Holmqvist  *                                    the table to be unloaded
5306822cda0SFredrik Holmqvist  *
5316822cda0SFredrik Holmqvist  * RETURN:      Status
5326822cda0SFredrik Holmqvist  *
5336822cda0SFredrik Holmqvist  * DESCRIPTION: Via any namespace object within an SSDT or OEMx table, unloads
5346822cda0SFredrik Holmqvist  *              the table and deletes all namespace objects associated with
5356822cda0SFredrik Holmqvist  *              that table. Unloading of the DSDT is not allowed.
5366822cda0SFredrik Holmqvist  *              Note: Mainly intended to support hotplug removal of SSDTs.
5376822cda0SFredrik Holmqvist  *
5386822cda0SFredrik Holmqvist  ******************************************************************************/
5396822cda0SFredrik Holmqvist 
5406822cda0SFredrik Holmqvist ACPI_STATUS
5416822cda0SFredrik Holmqvist AcpiUnloadParentTable (
5426822cda0SFredrik Holmqvist     ACPI_HANDLE             Object)
5436822cda0SFredrik Holmqvist {
5446822cda0SFredrik Holmqvist     ACPI_NAMESPACE_NODE     *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Object);
5456822cda0SFredrik Holmqvist     ACPI_STATUS             Status = AE_NOT_EXIST;
5466822cda0SFredrik Holmqvist     ACPI_OWNER_ID           OwnerId;
5476822cda0SFredrik Holmqvist     UINT32                  i;
5486822cda0SFredrik Holmqvist 
5496822cda0SFredrik Holmqvist 
5506822cda0SFredrik Holmqvist     ACPI_FUNCTION_TRACE (AcpiUnloadParentTable);
5516822cda0SFredrik Holmqvist 
5526822cda0SFredrik Holmqvist 
5536822cda0SFredrik Holmqvist     /* Parameter validation */
5546822cda0SFredrik Holmqvist 
5556822cda0SFredrik Holmqvist     if (!Object)
5566822cda0SFredrik Holmqvist     {
5576822cda0SFredrik Holmqvist         return_ACPI_STATUS (AE_BAD_PARAMETER);
5586822cda0SFredrik Holmqvist     }
5596822cda0SFredrik Holmqvist 
5606822cda0SFredrik Holmqvist     /*
5616822cda0SFredrik Holmqvist      * The node OwnerId is currently the same as the parent table ID.
5626822cda0SFredrik Holmqvist      * However, this could change in the future.
5636822cda0SFredrik Holmqvist      */
5646822cda0SFredrik Holmqvist     OwnerId = Node->OwnerId;
5656822cda0SFredrik Holmqvist     if (!OwnerId)
5666822cda0SFredrik Holmqvist     {
5676822cda0SFredrik Holmqvist         /* OwnerId==0 means DSDT is the owner. DSDT cannot be unloaded */
5686822cda0SFredrik Holmqvist 
5696822cda0SFredrik Holmqvist         return_ACPI_STATUS (AE_TYPE);
5706822cda0SFredrik Holmqvist     }
5716822cda0SFredrik Holmqvist 
572ff2e2f81SFredrik Holmqvist     /* Must acquire the table lock during this operation */
5736822cda0SFredrik Holmqvist 
574ff2e2f81SFredrik Holmqvist     Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
5756822cda0SFredrik Holmqvist     if (ACPI_FAILURE (Status))
5766822cda0SFredrik Holmqvist     {
5776822cda0SFredrik Holmqvist         return_ACPI_STATUS (Status);
5786822cda0SFredrik Holmqvist     }
5796822cda0SFredrik Holmqvist 
5806822cda0SFredrik Holmqvist     /* Find the table in the global table list */
5816822cda0SFredrik Holmqvist 
5826822cda0SFredrik Holmqvist     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
5836822cda0SFredrik Holmqvist     {
5846822cda0SFredrik Holmqvist         if (OwnerId != AcpiGbl_RootTableList.Tables[i].OwnerId)
5856822cda0SFredrik Holmqvist         {
5866822cda0SFredrik Holmqvist             continue;
5876822cda0SFredrik Holmqvist         }
5886822cda0SFredrik Holmqvist 
5896822cda0SFredrik Holmqvist         /*
5906822cda0SFredrik Holmqvist          * Allow unload of SSDT and OEMx tables only. Do not allow unload
5916822cda0SFredrik Holmqvist          * of the DSDT. No other types of tables should get here, since
5926822cda0SFredrik Holmqvist          * only these types can contain AML and thus are the only types
5936822cda0SFredrik Holmqvist          * that can create namespace objects.
5946822cda0SFredrik Holmqvist          */
5950ffed378SFredrik Holmqvist         if (ACPI_COMPARE_NAMESEG (
5966822cda0SFredrik Holmqvist                 AcpiGbl_RootTableList.Tables[i].Signature.Ascii,
5976822cda0SFredrik Holmqvist                 ACPI_SIG_DSDT))
5986822cda0SFredrik Holmqvist         {
5996822cda0SFredrik Holmqvist             Status = AE_TYPE;
6006822cda0SFredrik Holmqvist             break;
6016822cda0SFredrik Holmqvist         }
6026822cda0SFredrik Holmqvist 
603ff2e2f81SFredrik Holmqvist         (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
604ff2e2f81SFredrik Holmqvist         Status = AcpiTbUnloadTable (i);
605ff2e2f81SFredrik Holmqvist         (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
6066822cda0SFredrik Holmqvist         break;
6076822cda0SFredrik Holmqvist     }
6086822cda0SFredrik Holmqvist 
609ff2e2f81SFredrik Holmqvist     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
6106822cda0SFredrik Holmqvist     return_ACPI_STATUS (Status);
6116822cda0SFredrik Holmqvist }
6126822cda0SFredrik Holmqvist 
ACPI_EXPORT_SYMBOL(AcpiUnloadParentTable)6136822cda0SFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiUnloadParentTable)
6140ffed378SFredrik Holmqvist 
6150ffed378SFredrik Holmqvist 
6160ffed378SFredrik Holmqvist /*******************************************************************************
6170ffed378SFredrik Holmqvist  *
6180ffed378SFredrik Holmqvist  * FUNCTION:    AcpiUnloadTable
6190ffed378SFredrik Holmqvist  *
6200ffed378SFredrik Holmqvist  * PARAMETERS:  TableIndex          - Index as returned by AcpiLoadTable
6210ffed378SFredrik Holmqvist  *
6220ffed378SFredrik Holmqvist  * RETURN:      Status
6230ffed378SFredrik Holmqvist  *
6240ffed378SFredrik Holmqvist  * DESCRIPTION: Via the TableIndex representing an SSDT or OEMx table, unloads
6250ffed378SFredrik Holmqvist  *              the table and deletes all namespace objects associated with
6260ffed378SFredrik Holmqvist  *              that table. Unloading of the DSDT is not allowed.
6270ffed378SFredrik Holmqvist  *              Note: Mainly intended to support hotplug removal of SSDTs.
6280ffed378SFredrik Holmqvist  *
6290ffed378SFredrik Holmqvist  ******************************************************************************/
6300ffed378SFredrik Holmqvist 
6310ffed378SFredrik Holmqvist ACPI_STATUS
6320ffed378SFredrik Holmqvist AcpiUnloadTable (
6330ffed378SFredrik Holmqvist     UINT32                  TableIndex)
6340ffed378SFredrik Holmqvist {
6350ffed378SFredrik Holmqvist     ACPI_STATUS             Status;
6360ffed378SFredrik Holmqvist 
6370ffed378SFredrik Holmqvist 
6380ffed378SFredrik Holmqvist     ACPI_FUNCTION_TRACE (AcpiUnloadTable);
6390ffed378SFredrik Holmqvist 
6400ffed378SFredrik Holmqvist 
6410ffed378SFredrik Holmqvist     if (TableIndex == 1)
6420ffed378SFredrik Holmqvist     {
6430ffed378SFredrik Holmqvist         /* TableIndex==1 means DSDT is the owner. DSDT cannot be unloaded */
6440ffed378SFredrik Holmqvist 
6450ffed378SFredrik Holmqvist         return_ACPI_STATUS (AE_TYPE);
6460ffed378SFredrik Holmqvist     }
6470ffed378SFredrik Holmqvist 
6480ffed378SFredrik Holmqvist     Status = AcpiTbUnloadTable (TableIndex);
6490ffed378SFredrik Holmqvist     return_ACPI_STATUS (Status);
6500ffed378SFredrik Holmqvist }
6510ffed378SFredrik Holmqvist 
6520ffed378SFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiUnloadTable)
653