tbdata.c revision 1.2 1 /******************************************************************************
2 *
3 * Module Name: tbdata - Table manager data structure functions
4 *
5 *****************************************************************************/
6
7 /*
8 * Copyright (C) 2000 - 2014, Intel Corp.
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
44 #define __TBDATA_C__
45
46 #include "acpi.h"
47 #include "accommon.h"
48 #include "acnamesp.h"
49 #include "actables.h"
50
51 #define _COMPONENT ACPI_TABLES
52 ACPI_MODULE_NAME ("tbdata")
53
54
55 /*******************************************************************************
56 *
57 * FUNCTION: AcpiTbInitTableDescriptor
58 *
59 * PARAMETERS: TableDesc - Table descriptor
60 * Address - Physical address of the table
61 * Flags - Allocation flags of the table
62 * Table - Pointer to the table
63 *
64 * RETURN: None
65 *
66 * DESCRIPTION: Initialize a new table descriptor
67 *
68 ******************************************************************************/
69
70 void
71 AcpiTbInitTableDescriptor (
72 ACPI_TABLE_DESC *TableDesc,
73 ACPI_PHYSICAL_ADDRESS Address,
74 UINT8 Flags,
75 ACPI_TABLE_HEADER *Table)
76 {
77
78 /*
79 * Initialize the table descriptor. Set the pointer to NULL, since the
80 * table is not fully mapped at this time.
81 */
82 ACPI_MEMSET (TableDesc, 0, sizeof (ACPI_TABLE_DESC));
83 TableDesc->Address = Address;
84 TableDesc->Length = Table->Length;
85 TableDesc->Flags = Flags;
86 ACPI_MOVE_32_TO_32 (TableDesc->Signature.Ascii, Table->Signature);
87 }
88
89
90 /*******************************************************************************
91 *
92 * FUNCTION: AcpiTbAcquireTable
93 *
94 * PARAMETERS: TableDesc - Table descriptor
95 * TablePtr - Where table is returned
96 * TableLength - Where table length is returned
97 * TableFlags - Where table allocation flags are returned
98 *
99 * RETURN: Status
100 *
101 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
102 * maintained in the AcpiGbl_RootTableList.
103 *
104 ******************************************************************************/
105
106 ACPI_STATUS
107 AcpiTbAcquireTable (
108 ACPI_TABLE_DESC *TableDesc,
109 ACPI_TABLE_HEADER **TablePtr,
110 UINT32 *TableLength,
111 UINT8 *TableFlags)
112 {
113 ACPI_TABLE_HEADER *Table = NULL;
114
115
116 switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
117 {
118 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
119
120 Table = AcpiOsMapMemory (TableDesc->Address, TableDesc->Length);
121 break;
122
123 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
124 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
125
126 Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, TableDesc->Address);
127 break;
128
129 default:
130
131 break;
132 }
133
134 /* Table is not valid yet */
135
136 if (!Table)
137 {
138 return (AE_NO_MEMORY);
139 }
140
141 /* Fill the return values */
142
143 *TablePtr = Table;
144 *TableLength = TableDesc->Length;
145 *TableFlags = TableDesc->Flags;
146 return (AE_OK);
147 }
148
149
150 /*******************************************************************************
151 *
152 * FUNCTION: AcpiTbReleaseTable
153 *
154 * PARAMETERS: Table - Pointer for the table
155 * TableLength - Length for the table
156 * TableFlags - Allocation flags for the table
157 *
158 * RETURN: None
159 *
160 * DESCRIPTION: Release a table. The inverse of AcpiTbAcquireTable().
161 *
162 ******************************************************************************/
163
164 void
165 AcpiTbReleaseTable (
166 ACPI_TABLE_HEADER *Table,
167 UINT32 TableLength,
168 UINT8 TableFlags)
169 {
170
171 switch (TableFlags & ACPI_TABLE_ORIGIN_MASK)
172 {
173 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
174
175 AcpiOsUnmapMemory (Table, TableLength);
176 break;
177
178 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
179 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
180 default:
181
182 break;
183 }
184 }
185
186
187 /*******************************************************************************
188 *
189 * FUNCTION: AcpiTbAcquireTempTable
190 *
191 * PARAMETERS: TableDesc - Table descriptor to be acquired
192 * Address - Address of the table
193 * Flags - Allocation flags of the table
194 *
195 * RETURN: Status
196 *
197 * DESCRIPTION: This function validates the table header to obtain the length
198 * of a table and fills the table descriptor to make its state as
199 * "INSTALLED". Such a table descriptor is only used for verified
200 * installation.
201 *
202 ******************************************************************************/
203
204 ACPI_STATUS
205 AcpiTbAcquireTempTable (
206 ACPI_TABLE_DESC *TableDesc,
207 ACPI_PHYSICAL_ADDRESS Address,
208 UINT8 Flags)
209 {
210 ACPI_TABLE_HEADER *TableHeader;
211
212
213 switch (Flags & ACPI_TABLE_ORIGIN_MASK)
214 {
215 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
216
217 /* Get the length of the full table from the header */
218
219 TableHeader = AcpiOsMapMemory (Address, sizeof (ACPI_TABLE_HEADER));
220 if (!TableHeader)
221 {
222 return (AE_NO_MEMORY);
223 }
224
225 AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader);
226 AcpiOsUnmapMemory (TableHeader, sizeof (ACPI_TABLE_HEADER));
227 return (AE_OK);
228
229 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
230 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
231
232 TableHeader = ACPI_CAST_PTR (ACPI_TABLE_HEADER, Address);
233 if (!TableHeader)
234 {
235 return (AE_NO_MEMORY);
236 }
237
238 AcpiTbInitTableDescriptor (TableDesc, Address, Flags, TableHeader);
239 return (AE_OK);
240
241 default:
242
243 break;
244 }
245
246 /* Table is not valid yet */
247
248 return (AE_NO_MEMORY);
249 }
250
251
252 /*******************************************************************************
253 *
254 * FUNCTION: AcpiTbReleaseTempTable
255 *
256 * PARAMETERS: TableDesc - Table descriptor to be released
257 *
258 * RETURN: Status
259 *
260 * DESCRIPTION: The inverse of AcpiTbAcquireTempTable().
261 *
262 *****************************************************************************/
263
264 void
265 AcpiTbReleaseTempTable (
266 ACPI_TABLE_DESC *TableDesc)
267 {
268
269 /*
270 * Note that the .Address is maintained by the callers of
271 * AcpiTbAcquireTempTable(), thus do not invoke AcpiTbUninstallTable()
272 * where .Address will be freed.
273 */
274 AcpiTbInvalidateTable (TableDesc);
275 }
276
277
278 /******************************************************************************
279 *
280 * FUNCTION: AcpiTbValidateTable
281 *
282 * PARAMETERS: TableDesc - Table descriptor
283 *
284 * RETURN: Status
285 *
286 * DESCRIPTION: This function is called to validate the table, the returned
287 * table descriptor is in "VALIDATED" state.
288 *
289 *****************************************************************************/
290
291 ACPI_STATUS
292 AcpiTbValidateTable (
293 ACPI_TABLE_DESC *TableDesc)
294 {
295 ACPI_STATUS Status = AE_OK;
296
297
298 ACPI_FUNCTION_TRACE (TbValidateTable);
299
300
301 /* Validate the table if necessary */
302
303 if (!TableDesc->Pointer)
304 {
305 Status = AcpiTbAcquireTable (TableDesc, &TableDesc->Pointer,
306 &TableDesc->Length, &TableDesc->Flags);
307 if (!TableDesc->Pointer)
308 {
309 Status = AE_NO_MEMORY;
310 }
311 }
312
313 return_ACPI_STATUS (Status);
314 }
315
316
317 /*******************************************************************************
318 *
319 * FUNCTION: AcpiTbInvalidateTable
320 *
321 * PARAMETERS: TableDesc - Table descriptor
322 *
323 * RETURN: None
324 *
325 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
326 * AcpiTbValidateTable().
327 *
328 ******************************************************************************/
329
330 void
331 AcpiTbInvalidateTable (
332 ACPI_TABLE_DESC *TableDesc)
333 {
334
335 ACPI_FUNCTION_TRACE (TbInvalidateTable);
336
337
338 /* Table must be validated */
339
340 if (!TableDesc->Pointer)
341 {
342 return_VOID;
343 }
344
345 AcpiTbReleaseTable (TableDesc->Pointer, TableDesc->Length,
346 TableDesc->Flags);
347 TableDesc->Pointer = NULL;
348
349 return_VOID;
350 }
351
352
353 /******************************************************************************
354 *
355 * FUNCTION: AcpiTbValidateTempTable
356 *
357 * PARAMETERS: TableDesc - Table descriptor
358 *
359 * RETURN: Status
360 *
361 * DESCRIPTION: This function is called to validate the table, the returned
362 * table descriptor is in "VALIDATED" state.
363 *
364 *****************************************************************************/
365
366 ACPI_STATUS
367 AcpiTbValidateTempTable (
368 ACPI_TABLE_DESC *TableDesc)
369 {
370
371 if (!TableDesc->Pointer && !AcpiGbl_VerifyTableChecksum)
372 {
373 /*
374 * Only validates the header of the table.
375 * Note that Length contains the size of the mapping after invoking
376 * this work around, this value is required by
377 * AcpiTbReleaseTempTable().
378 * We can do this because in AcpiInitTableDescriptor(), the Length
379 * field of the installed descriptor is filled with the actual
380 * table length obtaining from the table header.
381 */
382 TableDesc->Length = sizeof (ACPI_TABLE_HEADER);
383 }
384
385 return (AcpiTbValidateTable (TableDesc));
386 }
387
388
389 /******************************************************************************
390 *
391 * FUNCTION: AcpiTbVerifyTempTable
392 *
393 * PARAMETERS: TableDesc - Table descriptor
394 * Signature - Table signature to verify
395 *
396 * RETURN: Status
397 *
398 * DESCRIPTION: This function is called to validate and verify the table, the
399 * returned table descriptor is in "VALIDATED" state.
400 *
401 *****************************************************************************/
402
403 ACPI_STATUS
404 AcpiTbVerifyTempTable (
405 ACPI_TABLE_DESC *TableDesc,
406 const char *Signature)
407 {
408 ACPI_STATUS Status = AE_OK;
409
410
411 ACPI_FUNCTION_TRACE (TbVerifyTempTable);
412
413
414 /* Validate the table */
415
416 Status = AcpiTbValidateTempTable (TableDesc);
417 if (ACPI_FAILURE (Status))
418 {
419 return_ACPI_STATUS (AE_NO_MEMORY);
420 }
421
422 /* If a particular signature is expected (DSDT/FACS), it must match */
423
424 if (Signature &&
425 !ACPI_COMPARE_NAME (&TableDesc->Signature, Signature))
426 {
427 ACPI_BIOS_ERROR ((AE_INFO,
428 "Invalid signature 0x%X for ACPI table, expected [%s]",
429 TableDesc->Signature.Integer, Signature));
430 Status = AE_BAD_SIGNATURE;
431 goto InvalidateAndExit;
432 }
433
434 /* Verify the checksum */
435
436 if (AcpiGbl_VerifyTableChecksum)
437 {
438 Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
439 if (ACPI_FAILURE (Status))
440 {
441 ACPI_EXCEPTION ((AE_INFO, AE_NO_MEMORY,
442 "%4.4s " ACPI_PRINTF_UINT
443 " Attempted table install failed",
444 AcpiUtValidAcpiName (TableDesc->Signature.Ascii) ?
445 TableDesc->Signature.Ascii : "????",
446 ACPI_FORMAT_TO_UINT (TableDesc->Address)));
447 goto InvalidateAndExit;
448 }
449 }
450
451 return_ACPI_STATUS (AE_OK);
452
453 InvalidateAndExit:
454 AcpiTbInvalidateTable (TableDesc);
455 return_ACPI_STATUS (Status);
456 }
457
458
459 /*******************************************************************************
460 *
461 * FUNCTION: AcpiTbResizeRootTableList
462 *
463 * PARAMETERS: None
464 *
465 * RETURN: Status
466 *
467 * DESCRIPTION: Expand the size of global table array
468 *
469 ******************************************************************************/
470
471 ACPI_STATUS
472 AcpiTbResizeRootTableList (
473 void)
474 {
475 ACPI_TABLE_DESC *Tables;
476 UINT32 TableCount;
477
478
479 ACPI_FUNCTION_TRACE (TbResizeRootTableList);
480
481
482 /* AllowResize flag is a parameter to AcpiInitializeTables */
483
484 if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
485 {
486 ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
487 return_ACPI_STATUS (AE_SUPPORT);
488 }
489
490 /* Increase the Table Array size */
491
492 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
493 {
494 TableCount = AcpiGbl_RootTableList.MaxTableCount;
495 }
496 else
497 {
498 TableCount = AcpiGbl_RootTableList.CurrentTableCount;
499 }
500
501 Tables = ACPI_ALLOCATE_ZEROED (
502 ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *
503 sizeof (ACPI_TABLE_DESC));
504 if (!Tables)
505 {
506 ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
507 return_ACPI_STATUS (AE_NO_MEMORY);
508 }
509
510 /* Copy and free the previous table array */
511
512 if (AcpiGbl_RootTableList.Tables)
513 {
514 ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
515 (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
516
517 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
518 {
519 ACPI_FREE (AcpiGbl_RootTableList.Tables);
520 }
521 }
522
523 AcpiGbl_RootTableList.Tables = Tables;
524 AcpiGbl_RootTableList.MaxTableCount =
525 TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
526 AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
527
528 return_ACPI_STATUS (AE_OK);
529 }
530
531
532 /*******************************************************************************
533 *
534 * FUNCTION: AcpiTbGetNextRootIndex
535 *
536 * PARAMETERS: TableIndex - Where table index is returned
537 *
538 * RETURN: Status and table index.
539 *
540 * DESCRIPTION: Allocate a new ACPI table entry to the global table list
541 *
542 ******************************************************************************/
543
544 ACPI_STATUS
545 AcpiTbGetNextRootIndex (
546 UINT32 *TableIndex)
547 {
548 ACPI_STATUS Status;
549
550
551 /* Ensure that there is room for the table in the Root Table List */
552
553 if (AcpiGbl_RootTableList.CurrentTableCount >=
554 AcpiGbl_RootTableList.MaxTableCount)
555 {
556 Status = AcpiTbResizeRootTableList();
557 if (ACPI_FAILURE (Status))
558 {
559 return (Status);
560 }
561 }
562
563 *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
564 AcpiGbl_RootTableList.CurrentTableCount++;
565 return (AE_OK);
566 }
567
568
569 /*******************************************************************************
570 *
571 * FUNCTION: AcpiTbTerminate
572 *
573 * PARAMETERS: None
574 *
575 * RETURN: None
576 *
577 * DESCRIPTION: Delete all internal ACPI tables
578 *
579 ******************************************************************************/
580
581 void
582 AcpiTbTerminate (
583 void)
584 {
585 UINT32 i;
586
587
588 ACPI_FUNCTION_TRACE (TbTerminate);
589
590
591 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
592
593 /* Delete the individual tables */
594
595 for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
596 {
597 AcpiTbUninstallTable (&AcpiGbl_RootTableList.Tables[i]);
598 }
599
600 /*
601 * Delete the root table array if allocated locally. Array cannot be
602 * mapped, so we don't need to check for that flag.
603 */
604 if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
605 {
606 ACPI_FREE (AcpiGbl_RootTableList.Tables);
607 }
608
609 AcpiGbl_RootTableList.Tables = NULL;
610 AcpiGbl_RootTableList.Flags = 0;
611 AcpiGbl_RootTableList.CurrentTableCount = 0;
612
613 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
614
615 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
616 return_VOID;
617 }
618
619
620 /*******************************************************************************
621 *
622 * FUNCTION: AcpiTbDeleteNamespaceByOwner
623 *
624 * PARAMETERS: TableIndex - Table index
625 *
626 * RETURN: Status
627 *
628 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
629 *
630 ******************************************************************************/
631
632 ACPI_STATUS
633 AcpiTbDeleteNamespaceByOwner (
634 UINT32 TableIndex)
635 {
636 ACPI_OWNER_ID OwnerId;
637 ACPI_STATUS Status;
638
639
640 ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
641
642
643 Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
644 if (ACPI_FAILURE (Status))
645 {
646 return_ACPI_STATUS (Status);
647 }
648
649 if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
650 {
651 /* The table index does not exist */
652
653 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
654 return_ACPI_STATUS (AE_NOT_EXIST);
655 }
656
657 /* Get the owner ID for this table, used to delete namespace nodes */
658
659 OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
660 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
661
662 /*
663 * Need to acquire the namespace writer lock to prevent interference
664 * with any concurrent namespace walks. The interpreter must be
665 * released during the deletion since the acquisition of the deletion
666 * lock may block, and also since the execution of a namespace walk
667 * must be allowed to use the interpreter.
668 */
669 (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
670 Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
671
672 AcpiNsDeleteNamespaceByOwner (OwnerId);
673 if (ACPI_FAILURE (Status))
674 {
675 return_ACPI_STATUS (Status);
676 }
677
678 AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
679
680 Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
681 return_ACPI_STATUS (Status);
682 }
683
684
685 /*******************************************************************************
686 *
687 * FUNCTION: AcpiTbAllocateOwnerId
688 *
689 * PARAMETERS: TableIndex - Table index
690 *
691 * RETURN: Status
692 *
693 * DESCRIPTION: Allocates OwnerId in TableDesc
694 *
695 ******************************************************************************/
696
697 ACPI_STATUS
698 AcpiTbAllocateOwnerId (
699 UINT32 TableIndex)
700 {
701 ACPI_STATUS Status = AE_BAD_PARAMETER;
702
703
704 ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
705
706
707 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
708 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
709 {
710 Status = AcpiUtAllocateOwnerId (
711 &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
712 }
713
714 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
715 return_ACPI_STATUS (Status);
716 }
717
718
719 /*******************************************************************************
720 *
721 * FUNCTION: AcpiTbReleaseOwnerId
722 *
723 * PARAMETERS: TableIndex - Table index
724 *
725 * RETURN: Status
726 *
727 * DESCRIPTION: Releases OwnerId in TableDesc
728 *
729 ******************************************************************************/
730
731 ACPI_STATUS
732 AcpiTbReleaseOwnerId (
733 UINT32 TableIndex)
734 {
735 ACPI_STATUS Status = AE_BAD_PARAMETER;
736
737
738 ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
739
740
741 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
742 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
743 {
744 AcpiUtReleaseOwnerId (
745 &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
746 Status = AE_OK;
747 }
748
749 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
750 return_ACPI_STATUS (Status);
751 }
752
753
754 /*******************************************************************************
755 *
756 * FUNCTION: AcpiTbGetOwnerId
757 *
758 * PARAMETERS: TableIndex - Table index
759 * OwnerId - Where the table OwnerId is returned
760 *
761 * RETURN: Status
762 *
763 * DESCRIPTION: returns OwnerId for the ACPI table
764 *
765 ******************************************************************************/
766
767 ACPI_STATUS
768 AcpiTbGetOwnerId (
769 UINT32 TableIndex,
770 ACPI_OWNER_ID *OwnerId)
771 {
772 ACPI_STATUS Status = AE_BAD_PARAMETER;
773
774
775 ACPI_FUNCTION_TRACE (TbGetOwnerId);
776
777
778 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
779 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
780 {
781 *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
782 Status = AE_OK;
783 }
784
785 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
786 return_ACPI_STATUS (Status);
787 }
788
789
790 /*******************************************************************************
791 *
792 * FUNCTION: AcpiTbIsTableLoaded
793 *
794 * PARAMETERS: TableIndex - Index into the root table
795 *
796 * RETURN: Table Loaded Flag
797 *
798 ******************************************************************************/
799
800 BOOLEAN
801 AcpiTbIsTableLoaded (
802 UINT32 TableIndex)
803 {
804 BOOLEAN IsLoaded = FALSE;
805
806
807 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
808 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
809 {
810 IsLoaded = (BOOLEAN)
811 (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
812 ACPI_TABLE_IS_LOADED);
813 }
814
815 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
816 return (IsLoaded);
817 }
818
819
820 /*******************************************************************************
821 *
822 * FUNCTION: AcpiTbSetTableLoadedFlag
823 *
824 * PARAMETERS: TableIndex - Table index
825 * IsLoaded - TRUE if table is loaded, FALSE otherwise
826 *
827 * RETURN: None
828 *
829 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
830 *
831 ******************************************************************************/
832
833 void
834 AcpiTbSetTableLoadedFlag (
835 UINT32 TableIndex,
836 BOOLEAN IsLoaded)
837 {
838
839 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
840 if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
841 {
842 if (IsLoaded)
843 {
844 AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
845 ACPI_TABLE_IS_LOADED;
846 }
847 else
848 {
849 AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
850 ~ACPI_TABLE_IS_LOADED;
851 }
852 }
853
854 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
855 }
856