tbxfload.c revision 1.1.1.1.4.2 1 1.1.1.1.4.2 rmind /******************************************************************************
2 1.1.1.1.4.2 rmind *
3 1.1.1.1.4.2 rmind * Module Name: tbxfload - Table load/unload external interfaces
4 1.1.1.1.4.2 rmind *
5 1.1.1.1.4.2 rmind *****************************************************************************/
6 1.1.1.1.4.2 rmind
7 1.1.1.1.4.2 rmind /*
8 1.1.1.1.4.2 rmind * Copyright (C) 2000 - 2013, Intel Corp.
9 1.1.1.1.4.2 rmind * All rights reserved.
10 1.1.1.1.4.2 rmind *
11 1.1.1.1.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.4.2 rmind * modification, are permitted provided that the following conditions
13 1.1.1.1.4.2 rmind * are met:
14 1.1.1.1.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.4.2 rmind * without modification.
17 1.1.1.1.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.4.2 rmind * binary redistribution.
22 1.1.1.1.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.4.2 rmind * from this software without specific prior written permission.
25 1.1.1.1.4.2 rmind *
26 1.1.1.1.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.4.2 rmind * Software Foundation.
29 1.1.1.1.4.2 rmind *
30 1.1.1.1.4.2 rmind * NO WARRANTY
31 1.1.1.1.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.4.2 rmind */
43 1.1.1.1.4.2 rmind
44 1.1.1.1.4.2 rmind #define __TBXFLOAD_C__
45 1.1.1.1.4.2 rmind #define EXPORT_ACPI_INTERFACES
46 1.1.1.1.4.2 rmind
47 1.1.1.1.4.2 rmind #include "acpi.h"
48 1.1.1.1.4.2 rmind #include "accommon.h"
49 1.1.1.1.4.2 rmind #include "acnamesp.h"
50 1.1.1.1.4.2 rmind #include "actables.h"
51 1.1.1.1.4.2 rmind
52 1.1.1.1.4.2 rmind #define _COMPONENT ACPI_TABLES
53 1.1.1.1.4.2 rmind ACPI_MODULE_NAME ("tbxfload")
54 1.1.1.1.4.2 rmind
55 1.1.1.1.4.2 rmind /* Local prototypes */
56 1.1.1.1.4.2 rmind
57 1.1.1.1.4.2 rmind static ACPI_STATUS
58 1.1.1.1.4.2 rmind AcpiTbLoadNamespace (
59 1.1.1.1.4.2 rmind void);
60 1.1.1.1.4.2 rmind
61 1.1.1.1.4.2 rmind
62 1.1.1.1.4.2 rmind /*******************************************************************************
63 1.1.1.1.4.2 rmind *
64 1.1.1.1.4.2 rmind * FUNCTION: AcpiLoadTables
65 1.1.1.1.4.2 rmind *
66 1.1.1.1.4.2 rmind * PARAMETERS: None
67 1.1.1.1.4.2 rmind *
68 1.1.1.1.4.2 rmind * RETURN: Status
69 1.1.1.1.4.2 rmind *
70 1.1.1.1.4.2 rmind * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
71 1.1.1.1.4.2 rmind *
72 1.1.1.1.4.2 rmind ******************************************************************************/
73 1.1.1.1.4.2 rmind
74 1.1.1.1.4.2 rmind ACPI_STATUS
75 1.1.1.1.4.2 rmind AcpiLoadTables (
76 1.1.1.1.4.2 rmind void)
77 1.1.1.1.4.2 rmind {
78 1.1.1.1.4.2 rmind ACPI_STATUS Status;
79 1.1.1.1.4.2 rmind
80 1.1.1.1.4.2 rmind
81 1.1.1.1.4.2 rmind ACPI_FUNCTION_TRACE (AcpiLoadTables);
82 1.1.1.1.4.2 rmind
83 1.1.1.1.4.2 rmind
84 1.1.1.1.4.2 rmind /* Load the namespace from the tables */
85 1.1.1.1.4.2 rmind
86 1.1.1.1.4.2 rmind Status = AcpiTbLoadNamespace ();
87 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
88 1.1.1.1.4.2 rmind {
89 1.1.1.1.4.2 rmind ACPI_EXCEPTION ((AE_INFO, Status,
90 1.1.1.1.4.2 rmind "While loading namespace from ACPI tables"));
91 1.1.1.1.4.2 rmind }
92 1.1.1.1.4.2 rmind
93 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
94 1.1.1.1.4.2 rmind }
95 1.1.1.1.4.2 rmind
96 1.1.1.1.4.2 rmind ACPI_EXPORT_SYMBOL_INIT (AcpiLoadTables)
97 1.1.1.1.4.2 rmind
98 1.1.1.1.4.2 rmind
99 1.1.1.1.4.2 rmind /*******************************************************************************
100 1.1.1.1.4.2 rmind *
101 1.1.1.1.4.2 rmind * FUNCTION: AcpiTbLoadNamespace
102 1.1.1.1.4.2 rmind *
103 1.1.1.1.4.2 rmind * PARAMETERS: None
104 1.1.1.1.4.2 rmind *
105 1.1.1.1.4.2 rmind * RETURN: Status
106 1.1.1.1.4.2 rmind *
107 1.1.1.1.4.2 rmind * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
108 1.1.1.1.4.2 rmind * the RSDT/XSDT.
109 1.1.1.1.4.2 rmind *
110 1.1.1.1.4.2 rmind ******************************************************************************/
111 1.1.1.1.4.2 rmind
112 1.1.1.1.4.2 rmind static ACPI_STATUS
113 1.1.1.1.4.2 rmind AcpiTbLoadNamespace (
114 1.1.1.1.4.2 rmind void)
115 1.1.1.1.4.2 rmind {
116 1.1.1.1.4.2 rmind ACPI_STATUS Status;
117 1.1.1.1.4.2 rmind UINT32 i;
118 1.1.1.1.4.2 rmind ACPI_TABLE_HEADER *NewDsdt;
119 1.1.1.1.4.2 rmind
120 1.1.1.1.4.2 rmind
121 1.1.1.1.4.2 rmind ACPI_FUNCTION_TRACE (TbLoadNamespace);
122 1.1.1.1.4.2 rmind
123 1.1.1.1.4.2 rmind
124 1.1.1.1.4.2 rmind (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
125 1.1.1.1.4.2 rmind
126 1.1.1.1.4.2 rmind /*
127 1.1.1.1.4.2 rmind * Load the namespace. The DSDT is required, but any SSDT and
128 1.1.1.1.4.2 rmind * PSDT tables are optional. Verify the DSDT.
129 1.1.1.1.4.2 rmind */
130 1.1.1.1.4.2 rmind if (!AcpiGbl_RootTableList.CurrentTableCount ||
131 1.1.1.1.4.2 rmind !ACPI_COMPARE_NAME (
132 1.1.1.1.4.2 rmind &(AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Signature),
133 1.1.1.1.4.2 rmind ACPI_SIG_DSDT) ||
134 1.1.1.1.4.2 rmind ACPI_FAILURE (AcpiTbVerifyTable (
135 1.1.1.1.4.2 rmind &AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT])))
136 1.1.1.1.4.2 rmind {
137 1.1.1.1.4.2 rmind Status = AE_NO_ACPI_TABLES;
138 1.1.1.1.4.2 rmind goto UnlockAndExit;
139 1.1.1.1.4.2 rmind }
140 1.1.1.1.4.2 rmind
141 1.1.1.1.4.2 rmind /*
142 1.1.1.1.4.2 rmind * Save the DSDT pointer for simple access. This is the mapped memory
143 1.1.1.1.4.2 rmind * address. We must take care here because the address of the .Tables
144 1.1.1.1.4.2 rmind * array can change dynamically as tables are loaded at run-time. Note:
145 1.1.1.1.4.2 rmind * .Pointer field is not validated until after call to AcpiTbVerifyTable.
146 1.1.1.1.4.2 rmind */
147 1.1.1.1.4.2 rmind AcpiGbl_DSDT = AcpiGbl_RootTableList.Tables[ACPI_TABLE_INDEX_DSDT].Pointer;
148 1.1.1.1.4.2 rmind
149 1.1.1.1.4.2 rmind /*
150 1.1.1.1.4.2 rmind * Optionally copy the entire DSDT to local memory (instead of simply
151 1.1.1.1.4.2 rmind * mapping it.) There are some BIOSs that corrupt or replace the original
152 1.1.1.1.4.2 rmind * DSDT, creating the need for this option. Default is FALSE, do not copy
153 1.1.1.1.4.2 rmind * the DSDT.
154 1.1.1.1.4.2 rmind */
155 1.1.1.1.4.2 rmind if (AcpiGbl_CopyDsdtLocally)
156 1.1.1.1.4.2 rmind {
157 1.1.1.1.4.2 rmind NewDsdt = AcpiTbCopyDsdt (ACPI_TABLE_INDEX_DSDT);
158 1.1.1.1.4.2 rmind if (NewDsdt)
159 1.1.1.1.4.2 rmind {
160 1.1.1.1.4.2 rmind AcpiGbl_DSDT = NewDsdt;
161 1.1.1.1.4.2 rmind }
162 1.1.1.1.4.2 rmind }
163 1.1.1.1.4.2 rmind
164 1.1.1.1.4.2 rmind /*
165 1.1.1.1.4.2 rmind * Save the original DSDT header for detection of table corruption
166 1.1.1.1.4.2 rmind * and/or replacement of the DSDT from outside the OS.
167 1.1.1.1.4.2 rmind */
168 1.1.1.1.4.2 rmind ACPI_MEMCPY (&AcpiGbl_OriginalDsdtHeader, AcpiGbl_DSDT,
169 1.1.1.1.4.2 rmind sizeof (ACPI_TABLE_HEADER));
170 1.1.1.1.4.2 rmind
171 1.1.1.1.4.2 rmind (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
172 1.1.1.1.4.2 rmind
173 1.1.1.1.4.2 rmind /* Load and parse tables */
174 1.1.1.1.4.2 rmind
175 1.1.1.1.4.2 rmind Status = AcpiNsLoadTable (ACPI_TABLE_INDEX_DSDT, AcpiGbl_RootNode);
176 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
177 1.1.1.1.4.2 rmind {
178 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
179 1.1.1.1.4.2 rmind }
180 1.1.1.1.4.2 rmind
181 1.1.1.1.4.2 rmind /* Load any SSDT or PSDT tables. Note: Loop leaves tables locked */
182 1.1.1.1.4.2 rmind
183 1.1.1.1.4.2 rmind (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
184 1.1.1.1.4.2 rmind for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
185 1.1.1.1.4.2 rmind {
186 1.1.1.1.4.2 rmind if ((!ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
187 1.1.1.1.4.2 rmind ACPI_SIG_SSDT) &&
188 1.1.1.1.4.2 rmind !ACPI_COMPARE_NAME (&(AcpiGbl_RootTableList.Tables[i].Signature),
189 1.1.1.1.4.2 rmind ACPI_SIG_PSDT)) ||
190 1.1.1.1.4.2 rmind ACPI_FAILURE (AcpiTbVerifyTable (
191 1.1.1.1.4.2 rmind &AcpiGbl_RootTableList.Tables[i])))
192 1.1.1.1.4.2 rmind {
193 1.1.1.1.4.2 rmind continue;
194 1.1.1.1.4.2 rmind }
195 1.1.1.1.4.2 rmind
196 1.1.1.1.4.2 rmind /*
197 1.1.1.1.4.2 rmind * Optionally do not load any SSDTs from the RSDT/XSDT. This can
198 1.1.1.1.4.2 rmind * be useful for debugging ACPI problems on some machines.
199 1.1.1.1.4.2 rmind */
200 1.1.1.1.4.2 rmind if (AcpiGbl_DisableSsdtTableLoad)
201 1.1.1.1.4.2 rmind {
202 1.1.1.1.4.2 rmind ACPI_INFO ((AE_INFO, "Ignoring %4.4s at %p",
203 1.1.1.1.4.2 rmind AcpiGbl_RootTableList.Tables[i].Signature.Ascii,
204 1.1.1.1.4.2 rmind ACPI_CAST_PTR (void, AcpiGbl_RootTableList.Tables[i].Address)));
205 1.1.1.1.4.2 rmind continue;
206 1.1.1.1.4.2 rmind }
207 1.1.1.1.4.2 rmind
208 1.1.1.1.4.2 rmind /* Ignore errors while loading tables, get as many as possible */
209 1.1.1.1.4.2 rmind
210 1.1.1.1.4.2 rmind (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
211 1.1.1.1.4.2 rmind (void) AcpiNsLoadTable (i, AcpiGbl_RootNode);
212 1.1.1.1.4.2 rmind (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
213 1.1.1.1.4.2 rmind }
214 1.1.1.1.4.2 rmind
215 1.1.1.1.4.2 rmind ACPI_INFO ((AE_INFO, "All ACPI Tables successfully acquired"));
216 1.1.1.1.4.2 rmind
217 1.1.1.1.4.2 rmind UnlockAndExit:
218 1.1.1.1.4.2 rmind (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
219 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
220 1.1.1.1.4.2 rmind }
221 1.1.1.1.4.2 rmind
222 1.1.1.1.4.2 rmind
223 1.1.1.1.4.2 rmind /*******************************************************************************
224 1.1.1.1.4.2 rmind *
225 1.1.1.1.4.2 rmind * FUNCTION: AcpiLoadTable
226 1.1.1.1.4.2 rmind *
227 1.1.1.1.4.2 rmind * PARAMETERS: Table - Pointer to a buffer containing the ACPI
228 1.1.1.1.4.2 rmind * table to be loaded.
229 1.1.1.1.4.2 rmind *
230 1.1.1.1.4.2 rmind * RETURN: Status
231 1.1.1.1.4.2 rmind *
232 1.1.1.1.4.2 rmind * DESCRIPTION: Dynamically load an ACPI table from the caller's buffer. Must
233 1.1.1.1.4.2 rmind * be a valid ACPI table with a valid ACPI table header.
234 1.1.1.1.4.2 rmind * Note1: Mainly intended to support hotplug addition of SSDTs.
235 1.1.1.1.4.2 rmind * Note2: Does not copy the incoming table. User is responsible
236 1.1.1.1.4.2 rmind * to ensure that the table is not deleted or unmapped.
237 1.1.1.1.4.2 rmind *
238 1.1.1.1.4.2 rmind ******************************************************************************/
239 1.1.1.1.4.2 rmind
240 1.1.1.1.4.2 rmind ACPI_STATUS
241 1.1.1.1.4.2 rmind AcpiLoadTable (
242 1.1.1.1.4.2 rmind ACPI_TABLE_HEADER *Table)
243 1.1.1.1.4.2 rmind {
244 1.1.1.1.4.2 rmind ACPI_STATUS Status;
245 1.1.1.1.4.2 rmind ACPI_TABLE_DESC TableDesc;
246 1.1.1.1.4.2 rmind UINT32 TableIndex;
247 1.1.1.1.4.2 rmind
248 1.1.1.1.4.2 rmind
249 1.1.1.1.4.2 rmind ACPI_FUNCTION_TRACE (AcpiLoadTable);
250 1.1.1.1.4.2 rmind
251 1.1.1.1.4.2 rmind
252 1.1.1.1.4.2 rmind /* Parameter validation */
253 1.1.1.1.4.2 rmind
254 1.1.1.1.4.2 rmind if (!Table)
255 1.1.1.1.4.2 rmind {
256 1.1.1.1.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
257 1.1.1.1.4.2 rmind }
258 1.1.1.1.4.2 rmind
259 1.1.1.1.4.2 rmind /* Init local table descriptor */
260 1.1.1.1.4.2 rmind
261 1.1.1.1.4.2 rmind ACPI_MEMSET (&TableDesc, 0, sizeof (ACPI_TABLE_DESC));
262 1.1.1.1.4.2 rmind TableDesc.Address = ACPI_PTR_TO_PHYSADDR (Table);
263 1.1.1.1.4.2 rmind TableDesc.Pointer = Table;
264 1.1.1.1.4.2 rmind TableDesc.Length = Table->Length;
265 1.1.1.1.4.2 rmind TableDesc.Flags = ACPI_TABLE_ORIGIN_UNKNOWN;
266 1.1.1.1.4.2 rmind
267 1.1.1.1.4.2 rmind /* Must acquire the interpreter lock during this operation */
268 1.1.1.1.4.2 rmind
269 1.1.1.1.4.2 rmind Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
270 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
271 1.1.1.1.4.2 rmind {
272 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
273 1.1.1.1.4.2 rmind }
274 1.1.1.1.4.2 rmind
275 1.1.1.1.4.2 rmind /* Install the table and load it into the namespace */
276 1.1.1.1.4.2 rmind
277 1.1.1.1.4.2 rmind ACPI_INFO ((AE_INFO, "Host-directed Dynamic ACPI Table Load:"));
278 1.1.1.1.4.2 rmind Status = AcpiTbAddTable (&TableDesc, &TableIndex);
279 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
280 1.1.1.1.4.2 rmind {
281 1.1.1.1.4.2 rmind goto UnlockAndExit;
282 1.1.1.1.4.2 rmind }
283 1.1.1.1.4.2 rmind
284 1.1.1.1.4.2 rmind Status = AcpiNsLoadTable (TableIndex, AcpiGbl_RootNode);
285 1.1.1.1.4.2 rmind
286 1.1.1.1.4.2 rmind /* Invoke table handler if present */
287 1.1.1.1.4.2 rmind
288 1.1.1.1.4.2 rmind if (AcpiGbl_TableHandler)
289 1.1.1.1.4.2 rmind {
290 1.1.1.1.4.2 rmind (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_LOAD, Table,
291 1.1.1.1.4.2 rmind AcpiGbl_TableHandlerContext);
292 1.1.1.1.4.2 rmind }
293 1.1.1.1.4.2 rmind
294 1.1.1.1.4.2 rmind UnlockAndExit:
295 1.1.1.1.4.2 rmind (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
296 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
297 1.1.1.1.4.2 rmind }
298 1.1.1.1.4.2 rmind
299 1.1.1.1.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiLoadTable)
300 1.1.1.1.4.2 rmind
301 1.1.1.1.4.2 rmind
302 1.1.1.1.4.2 rmind /*******************************************************************************
303 1.1.1.1.4.2 rmind *
304 1.1.1.1.4.2 rmind * FUNCTION: AcpiUnloadParentTable
305 1.1.1.1.4.2 rmind *
306 1.1.1.1.4.2 rmind * PARAMETERS: Object - Handle to any namespace object owned by
307 1.1.1.1.4.2 rmind * the table to be unloaded
308 1.1.1.1.4.2 rmind *
309 1.1.1.1.4.2 rmind * RETURN: Status
310 1.1.1.1.4.2 rmind *
311 1.1.1.1.4.2 rmind * DESCRIPTION: Via any namespace object within an SSDT or OEMx table, unloads
312 1.1.1.1.4.2 rmind * the table and deletes all namespace objects associated with
313 1.1.1.1.4.2 rmind * that table. Unloading of the DSDT is not allowed.
314 1.1.1.1.4.2 rmind * Note: Mainly intended to support hotplug removal of SSDTs.
315 1.1.1.1.4.2 rmind *
316 1.1.1.1.4.2 rmind ******************************************************************************/
317 1.1.1.1.4.2 rmind
318 1.1.1.1.4.2 rmind ACPI_STATUS
319 1.1.1.1.4.2 rmind AcpiUnloadParentTable (
320 1.1.1.1.4.2 rmind ACPI_HANDLE Object)
321 1.1.1.1.4.2 rmind {
322 1.1.1.1.4.2 rmind ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Object);
323 1.1.1.1.4.2 rmind ACPI_STATUS Status = AE_NOT_EXIST;
324 1.1.1.1.4.2 rmind ACPI_OWNER_ID OwnerId;
325 1.1.1.1.4.2 rmind UINT32 i;
326 1.1.1.1.4.2 rmind
327 1.1.1.1.4.2 rmind
328 1.1.1.1.4.2 rmind ACPI_FUNCTION_TRACE (AcpiUnloadParentTable);
329 1.1.1.1.4.2 rmind
330 1.1.1.1.4.2 rmind
331 1.1.1.1.4.2 rmind /* Parameter validation */
332 1.1.1.1.4.2 rmind
333 1.1.1.1.4.2 rmind if (!Object)
334 1.1.1.1.4.2 rmind {
335 1.1.1.1.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
336 1.1.1.1.4.2 rmind }
337 1.1.1.1.4.2 rmind
338 1.1.1.1.4.2 rmind /*
339 1.1.1.1.4.2 rmind * The node OwnerId is currently the same as the parent table ID.
340 1.1.1.1.4.2 rmind * However, this could change in the future.
341 1.1.1.1.4.2 rmind */
342 1.1.1.1.4.2 rmind OwnerId = Node->OwnerId;
343 1.1.1.1.4.2 rmind if (!OwnerId)
344 1.1.1.1.4.2 rmind {
345 1.1.1.1.4.2 rmind /* OwnerId==0 means DSDT is the owner. DSDT cannot be unloaded */
346 1.1.1.1.4.2 rmind
347 1.1.1.1.4.2 rmind return_ACPI_STATUS (AE_TYPE);
348 1.1.1.1.4.2 rmind }
349 1.1.1.1.4.2 rmind
350 1.1.1.1.4.2 rmind /* Must acquire the interpreter lock during this operation */
351 1.1.1.1.4.2 rmind
352 1.1.1.1.4.2 rmind Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
353 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
354 1.1.1.1.4.2 rmind {
355 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
356 1.1.1.1.4.2 rmind }
357 1.1.1.1.4.2 rmind
358 1.1.1.1.4.2 rmind /* Find the table in the global table list */
359 1.1.1.1.4.2 rmind
360 1.1.1.1.4.2 rmind for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
361 1.1.1.1.4.2 rmind {
362 1.1.1.1.4.2 rmind if (OwnerId != AcpiGbl_RootTableList.Tables[i].OwnerId)
363 1.1.1.1.4.2 rmind {
364 1.1.1.1.4.2 rmind continue;
365 1.1.1.1.4.2 rmind }
366 1.1.1.1.4.2 rmind
367 1.1.1.1.4.2 rmind /*
368 1.1.1.1.4.2 rmind * Allow unload of SSDT and OEMx tables only. Do not allow unload
369 1.1.1.1.4.2 rmind * of the DSDT. No other types of tables should get here, since
370 1.1.1.1.4.2 rmind * only these types can contain AML and thus are the only types
371 1.1.1.1.4.2 rmind * that can create namespace objects.
372 1.1.1.1.4.2 rmind */
373 1.1.1.1.4.2 rmind if (ACPI_COMPARE_NAME (
374 1.1.1.1.4.2 rmind AcpiGbl_RootTableList.Tables[i].Signature.Ascii,
375 1.1.1.1.4.2 rmind ACPI_SIG_DSDT))
376 1.1.1.1.4.2 rmind {
377 1.1.1.1.4.2 rmind Status = AE_TYPE;
378 1.1.1.1.4.2 rmind break;
379 1.1.1.1.4.2 rmind }
380 1.1.1.1.4.2 rmind
381 1.1.1.1.4.2 rmind /* Ensure the table is actually loaded */
382 1.1.1.1.4.2 rmind
383 1.1.1.1.4.2 rmind if (!AcpiTbIsTableLoaded (i))
384 1.1.1.1.4.2 rmind {
385 1.1.1.1.4.2 rmind Status = AE_NOT_EXIST;
386 1.1.1.1.4.2 rmind break;
387 1.1.1.1.4.2 rmind }
388 1.1.1.1.4.2 rmind
389 1.1.1.1.4.2 rmind /* Invoke table handler if present */
390 1.1.1.1.4.2 rmind
391 1.1.1.1.4.2 rmind if (AcpiGbl_TableHandler)
392 1.1.1.1.4.2 rmind {
393 1.1.1.1.4.2 rmind (void) AcpiGbl_TableHandler (ACPI_TABLE_EVENT_UNLOAD,
394 1.1.1.1.4.2 rmind AcpiGbl_RootTableList.Tables[i].Pointer,
395 1.1.1.1.4.2 rmind AcpiGbl_TableHandlerContext);
396 1.1.1.1.4.2 rmind }
397 1.1.1.1.4.2 rmind
398 1.1.1.1.4.2 rmind /*
399 1.1.1.1.4.2 rmind * Delete all namespace objects owned by this table. Note that
400 1.1.1.1.4.2 rmind * these objects can appear anywhere in the namespace by virtue
401 1.1.1.1.4.2 rmind * of the AML "Scope" operator. Thus, we need to track ownership
402 1.1.1.1.4.2 rmind * by an ID, not simply a position within the hierarchy.
403 1.1.1.1.4.2 rmind */
404 1.1.1.1.4.2 rmind Status = AcpiTbDeleteNamespaceByOwner (i);
405 1.1.1.1.4.2 rmind if (ACPI_FAILURE (Status))
406 1.1.1.1.4.2 rmind {
407 1.1.1.1.4.2 rmind break;
408 1.1.1.1.4.2 rmind }
409 1.1.1.1.4.2 rmind
410 1.1.1.1.4.2 rmind Status = AcpiTbReleaseOwnerId (i);
411 1.1.1.1.4.2 rmind AcpiTbSetTableLoadedFlag (i, FALSE);
412 1.1.1.1.4.2 rmind break;
413 1.1.1.1.4.2 rmind }
414 1.1.1.1.4.2 rmind
415 1.1.1.1.4.2 rmind (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
416 1.1.1.1.4.2 rmind return_ACPI_STATUS (Status);
417 1.1.1.1.4.2 rmind }
418 1.1.1.1.4.2 rmind
419 1.1.1.1.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiUnloadParentTable)
420