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