Subversion Repositories Kolibri OS

Rev

Rev 1498 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1498 serge 1
/******************************************************************************
2
 *
3
 * Module Name: tbinstal - ACPI table installation and removal
4
 *
5
 *****************************************************************************/
6
 
7
/******************************************************************************
8
 *
9
 * 1. Copyright Notice
10
 *
2216 Serge 11
 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
1498 serge 12
 * All rights reserved.
13
 *
14
 * 2. License
15
 *
16
 * 2.1. This is your license from Intel Corp. under its intellectual property
17
 * rights.  You may have additional license terms from the party that provided
18
 * you this software, covering your right to use that party's intellectual
19
 * property rights.
20
 *
21
 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22
 * copy of the source code appearing in this file ("Covered Code") an
23
 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24
 * base code distributed originally by Intel ("Original Intel Code") to copy,
25
 * make derivatives, distribute, use and display any portion of the Covered
26
 * Code in any form, with the right to sublicense such rights; and
27
 *
28
 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29
 * license (with the right to sublicense), under only those claims of Intel
30
 * patents that are infringed by the Original Intel Code, to make, use, sell,
31
 * offer to sell, and import the Covered Code and derivative works thereof
32
 * solely to the minimum extent necessary to exercise the above copyright
33
 * license, and in no event shall the patent license extend to any additions
34
 * to or modifications of the Original Intel Code.  No other license or right
35
 * is granted directly or by implication, estoppel or otherwise;
36
 *
37
 * The above copyright and patent license is granted only if the following
38
 * conditions are met:
39
 *
40
 * 3. Conditions
41
 *
42
 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43
 * Redistribution of source code of any substantial portion of the Covered
44
 * Code or modification with rights to further distribute source must include
45
 * the above Copyright Notice, the above License, this list of Conditions,
46
 * and the following Disclaimer and Export Compliance provision.  In addition,
47
 * Licensee must cause all Covered Code to which Licensee contributes to
48
 * contain a file documenting the changes Licensee made to create that Covered
49
 * Code and the date of any change.  Licensee must include in that file the
50
 * documentation of any changes made by any predecessor Licensee.  Licensee
51
 * must include a prominent statement that the modification is derived,
52
 * directly or indirectly, from Original Intel Code.
53
 *
54
 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55
 * Redistribution of source code of any substantial portion of the Covered
56
 * Code or modification without rights to further distribute source must
57
 * include the following Disclaimer and Export Compliance provision in the
58
 * documentation and/or other materials provided with distribution.  In
59
 * addition, Licensee may not authorize further sublicense of source of any
60
 * portion of the Covered Code, and must include terms to the effect that the
61
 * license from Licensee to its licensee is limited to the intellectual
62
 * property embodied in the software Licensee provides to its licensee, and
63
 * not to intellectual property embodied in modifications its licensee may
64
 * make.
65
 *
66
 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67
 * substantial portion of the Covered Code or modification must reproduce the
68
 * above Copyright Notice, and the following Disclaimer and Export Compliance
69
 * provision in the documentation and/or other materials provided with the
70
 * distribution.
71
 *
72
 * 3.4. Intel retains all right, title, and interest in and to the Original
73
 * Intel Code.
74
 *
75
 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76
 * Intel shall be used in advertising or otherwise to promote the sale, use or
77
 * other dealings in products derived from or relating to the Covered Code
78
 * without prior written authorization from Intel.
79
 *
80
 * 4. Disclaimer and Export Compliance
81
 *
82
 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83
 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84
 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85
 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86
 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87
 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88
 * PARTICULAR PURPOSE.
89
 *
90
 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91
 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92
 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93
 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94
 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95
 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96
 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97
 * LIMITED REMEDY.
98
 *
99
 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100
 * software or system incorporating such software without first obtaining any
101
 * required license or other approval from the U. S. Department of Commerce or
102
 * any other agency or department of the United States Government.  In the
103
 * event Licensee exports any such software from the United States or
104
 * re-exports any such software from a foreign destination, Licensee shall
105
 * ensure that the distribution and export/re-export of the software is in
106
 * compliance with all laws, regulations, orders, or other restrictions of the
107
 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108
 * any of its subsidiaries will export/re-export any technical data, process,
109
 * software, or service, directly or indirectly, to any country for which the
110
 * United States government or any agency thereof requires an export license,
111
 * other governmental approval, or letter of assurance, without first obtaining
112
 * such license, approval or letter.
113
 *
114
 *****************************************************************************/
115
 
116
 
117
#define __TBINSTAL_C__
118
 
119
#include "acpi.h"
120
#include "accommon.h"
121
#include "acnamesp.h"
122
#include "actables.h"
123
 
124
 
125
#define _COMPONENT          ACPI_TABLES
126
        ACPI_MODULE_NAME    ("tbinstal")
127
 
128
 
129
/******************************************************************************
130
 *
131
 * FUNCTION:    AcpiTbVerifyTable
132
 *
133
 * PARAMETERS:  TableDesc           - table
134
 *
135
 * RETURN:      Status
136
 *
137
 * DESCRIPTION: this function is called to verify and map table
138
 *
139
 *****************************************************************************/
140
 
141
ACPI_STATUS
142
AcpiTbVerifyTable (
143
    ACPI_TABLE_DESC         *TableDesc)
144
{
145
    ACPI_STATUS             Status = AE_OK;
146
 
147
 
148
    ACPI_FUNCTION_TRACE (TbVerifyTable);
149
 
150
 
151
    /* Map the table if necessary */
152
 
153
    if (!TableDesc->Pointer)
154
    {
155
        if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
156
            ACPI_TABLE_ORIGIN_MAPPED)
157
        {
158
            TableDesc->Pointer = AcpiOsMapMemory (
159
                TableDesc->Address, TableDesc->Length);
160
        }
161
 
162
        if (!TableDesc->Pointer)
163
        {
164
            return_ACPI_STATUS (AE_NO_MEMORY);
165
        }
166
    }
167
 
168
    /* FACS is the odd table, has no standard ACPI header and no checksum */
169
 
170
    if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
171
    {
172
        /* Always calculate checksum, ignore bad checksum if requested */
173
 
174
        Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
175
    }
176
 
177
    return_ACPI_STATUS (Status);
178
}
179
 
180
 
181
/*******************************************************************************
182
 *
183
 * FUNCTION:    AcpiTbAddTable
184
 *
185
 * PARAMETERS:  TableDesc           - Table descriptor
186
 *              TableIndex          - Where the table index is returned
187
 *
188
 * RETURN:      Status
189
 *
190
 * DESCRIPTION: This function is called to add an ACPI table. It is used to
191
 *              dynamically load tables via the Load and LoadTable AML
192
 *              operators.
193
 *
194
 ******************************************************************************/
195
 
196
ACPI_STATUS
197
AcpiTbAddTable (
198
    ACPI_TABLE_DESC         *TableDesc,
199
    UINT32                  *TableIndex)
200
{
201
    UINT32                  i;
202
    ACPI_STATUS             Status = AE_OK;
203
    ACPI_TABLE_HEADER       *OverrideTable = NULL;
204
 
205
 
206
    ACPI_FUNCTION_TRACE (TbAddTable);
207
 
208
 
209
    if (!TableDesc->Pointer)
210
    {
211
        Status = AcpiTbVerifyTable (TableDesc);
212
        if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
213
        {
214
            return_ACPI_STATUS (Status);
215
        }
216
    }
217
 
218
    /*
2216 Serge 219
     * Validate the incoming table signature.
220
     *
221
     * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
222
     * 2) We added support for OEMx tables, signature "OEM".
223
     * 3) Valid tables were encountered with a null signature, so we just
224
     *    gave up on validating the signature, (05/2008).
225
     * 4) We encountered non-AML tables such as the MADT, which caused
226
     *    interpreter errors and kernel faults. So now, we once again allow
227
     *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
1498 serge 228
     */
2216 Serge 229
    if ((TableDesc->Pointer->Signature[0] != 0x00) &&
230
       (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
231
       (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
232
    {
233
        ACPI_ERROR ((AE_INFO,
234
            "Table has invalid signature [%4.4s] (0x%8.8X), must be SSDT or OEMx",
235
            AcpiUtValidAcpiName (*(UINT32 *) TableDesc->Pointer->Signature) ?
236
                TableDesc->Pointer->Signature : "????",
237
            *(UINT32 *) TableDesc->Pointer->Signature));
1498 serge 238
 
2216 Serge 239
        return_ACPI_STATUS (AE_BAD_SIGNATURE);
240
    }
241
 
1498 serge 242
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
243
 
244
    /* Check if table is already registered */
245
 
246
    for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
247
    {
248
        if (!AcpiGbl_RootTableList.Tables[i].Pointer)
249
        {
250
            Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
251
            if (ACPI_FAILURE (Status) ||
252
                !AcpiGbl_RootTableList.Tables[i].Pointer)
253
            {
254
                continue;
255
            }
256
        }
257
 
258
        /*
259
         * Check for a table match on the entire table length,
260
         * not just the header.
261
         */
262
        if (TableDesc->Length != AcpiGbl_RootTableList.Tables[i].Length)
263
        {
264
            continue;
265
        }
266
 
267
        if (ACPI_MEMCMP (TableDesc->Pointer,
268
                AcpiGbl_RootTableList.Tables[i].Pointer,
269
                AcpiGbl_RootTableList.Tables[i].Length))
270
        {
271
            continue;
272
        }
273
 
274
        /*
275
         * Note: the current mechanism does not unregister a table if it is
276
         * dynamically unloaded. The related namespace entries are deleted,
277
         * but the table remains in the root table list.
278
         *
279
         * The assumption here is that the number of different tables that
280
         * will be loaded is actually small, and there is minimal overhead
281
         * in just keeping the table in case it is needed again.
282
         *
283
         * If this assumption changes in the future (perhaps on large
284
         * machines with many table load/unload operations), tables will
285
         * need to be unregistered when they are unloaded, and slots in the
286
         * root table list should be reused when empty.
287
         */
288
 
289
        /*
290
         * Table is already registered.
291
         * We can delete the table that was passed as a parameter.
292
         */
293
        AcpiTbDeleteTable (TableDesc);
294
        *TableIndex = i;
295
 
296
        if (AcpiGbl_RootTableList.Tables[i].Flags & ACPI_TABLE_IS_LOADED)
297
        {
298
            /* Table is still loaded, this is an error */
299
 
300
            Status = AE_ALREADY_EXISTS;
301
            goto Release;
302
        }
303
        else
304
        {
305
            /* Table was unloaded, allow it to be reloaded */
306
 
307
            TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
308
            TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
309
            Status = AE_OK;
310
            goto PrintHeader;
311
        }
312
    }
313
 
314
    /*
315
     * ACPI Table Override:
316
     * Allow the host to override dynamically loaded tables.
317
     */
318
    Status = AcpiOsTableOverride (TableDesc->Pointer, &OverrideTable);
319
    if (ACPI_SUCCESS (Status) && OverrideTable)
320
    {
321
        ACPI_INFO ((AE_INFO,
322
            "%4.4s @ 0x%p Table override, replaced with:",
323
            TableDesc->Pointer->Signature,
324
            ACPI_CAST_PTR (void, TableDesc->Address)));
325
 
326
        /* We can delete the table that was passed as a parameter */
327
 
328
        AcpiTbDeleteTable (TableDesc);
329
 
330
        /* Setup descriptor for the new table */
331
 
332
        TableDesc->Address = ACPI_PTR_TO_PHYSADDR (OverrideTable);
333
        TableDesc->Pointer = OverrideTable;
334
        TableDesc->Length = OverrideTable->Length;
335
        TableDesc->Flags = ACPI_TABLE_ORIGIN_OVERRIDE;
336
    }
337
 
338
    /* Add the table to the global root table list */
339
 
340
    Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
341
                TableDesc->Length, TableDesc->Flags, TableIndex);
342
    if (ACPI_FAILURE (Status))
343
    {
344
        goto Release;
345
    }
346
 
347
PrintHeader:
348
    AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
349
 
350
Release:
351
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
352
    return_ACPI_STATUS (Status);
353
}
354
 
355
 
356
/*******************************************************************************
357
 *
358
 * FUNCTION:    AcpiTbResizeRootTableList
359
 *
360
 * PARAMETERS:  None
361
 *
362
 * RETURN:      Status
363
 *
364
 * DESCRIPTION: Expand the size of global table array
365
 *
366
 ******************************************************************************/
367
 
368
ACPI_STATUS
369
AcpiTbResizeRootTableList (
370
    void)
371
{
372
    ACPI_TABLE_DESC         *Tables;
373
 
374
 
375
    ACPI_FUNCTION_TRACE (TbResizeRootTableList);
376
 
377
 
378
    /* AllowResize flag is a parameter to AcpiInitializeTables */
379
 
380
    if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
381
    {
382
        ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
383
        return_ACPI_STATUS (AE_SUPPORT);
384
    }
385
 
386
    /* Increase the Table Array size */
387
 
388
    Tables = ACPI_ALLOCATE_ZEROED (
389
        ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
390
            ACPI_ROOT_TABLE_SIZE_INCREMENT) *
391
        sizeof (ACPI_TABLE_DESC));
392
    if (!Tables)
393
    {
394
        ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
395
        return_ACPI_STATUS (AE_NO_MEMORY);
396
    }
397
 
398
    /* Copy and free the previous table array */
399
 
400
    if (AcpiGbl_RootTableList.Tables)
401
    {
402
        ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
403
            (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
404
 
405
        if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
406
        {
407
            ACPI_FREE (AcpiGbl_RootTableList.Tables);
408
        }
409
    }
410
 
411
    AcpiGbl_RootTableList.Tables = Tables;
412
    AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
413
    AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;
414
 
415
    return_ACPI_STATUS (AE_OK);
416
}
417
 
418
 
419
/*******************************************************************************
420
 *
421
 * FUNCTION:    AcpiTbStoreTable
422
 *
423
 * PARAMETERS:  Address             - Table address
424
 *              Table               - Table header
425
 *              Length              - Table length
426
 *              Flags               - flags
427
 *
428
 * RETURN:      Status and table index.
429
 *
430
 * DESCRIPTION: Add an ACPI table to the global table list
431
 *
432
 ******************************************************************************/
433
 
434
ACPI_STATUS
435
AcpiTbStoreTable (
436
    ACPI_PHYSICAL_ADDRESS   Address,
437
    ACPI_TABLE_HEADER       *Table,
438
    UINT32                  Length,
439
    UINT8                   Flags,
440
    UINT32                  *TableIndex)
441
{
442
    ACPI_STATUS             Status;
443
    ACPI_TABLE_DESC         *NewTable;
444
 
445
 
446
    /* Ensure that there is room for the table in the Root Table List */
447
 
448
    if (AcpiGbl_RootTableList.CurrentTableCount >=
449
        AcpiGbl_RootTableList.MaxTableCount)
450
    {
451
        Status = AcpiTbResizeRootTableList();
452
        if (ACPI_FAILURE (Status))
453
        {
454
            return (Status);
455
        }
456
    }
457
 
458
    NewTable = &AcpiGbl_RootTableList.Tables[AcpiGbl_RootTableList.CurrentTableCount];
459
 
460
    /* Initialize added table */
461
 
462
    NewTable->Address = Address;
463
    NewTable->Pointer = Table;
464
    NewTable->Length = Length;
465
    NewTable->OwnerId = 0;
466
    NewTable->Flags = Flags;
467
 
468
    ACPI_MOVE_32_TO_32 (&NewTable->Signature, Table->Signature);
469
 
470
    *TableIndex = AcpiGbl_RootTableList.CurrentTableCount;
471
    AcpiGbl_RootTableList.CurrentTableCount++;
472
    return (AE_OK);
473
}
474
 
475
 
476
/*******************************************************************************
477
 *
478
 * FUNCTION:    AcpiTbDeleteTable
479
 *
480
 * PARAMETERS:  TableIndex          - Table index
481
 *
482
 * RETURN:      None
483
 *
484
 * DESCRIPTION: Delete one internal ACPI table
485
 *
486
 ******************************************************************************/
487
 
488
void
489
AcpiTbDeleteTable (
490
    ACPI_TABLE_DESC         *TableDesc)
491
{
492
 
493
    /* Table must be mapped or allocated */
494
 
495
    if (!TableDesc->Pointer)
496
    {
497
        return;
498
    }
499
 
500
    switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
501
    {
502
    case ACPI_TABLE_ORIGIN_MAPPED:
503
        AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
504
        break;
505
 
506
    case ACPI_TABLE_ORIGIN_ALLOCATED:
507
        ACPI_FREE (TableDesc->Pointer);
508
        break;
509
 
510
    default:
511
        break;
512
    }
513
 
514
    TableDesc->Pointer = NULL;
515
}
516
 
517
 
518
/*******************************************************************************
519
 *
520
 * FUNCTION:    AcpiTbTerminate
521
 *
522
 * PARAMETERS:  None
523
 *
524
 * RETURN:      None
525
 *
526
 * DESCRIPTION: Delete all internal ACPI tables
527
 *
528
 ******************************************************************************/
529
 
530
void
531
AcpiTbTerminate (
532
    void)
533
{
534
    UINT32                  i;
535
 
536
 
537
    ACPI_FUNCTION_TRACE (TbTerminate);
538
 
539
 
540
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
541
 
542
    /* Delete the individual tables */
543
 
544
    for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
545
    {
546
        AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
547
    }
548
 
549
    /*
550
     * Delete the root table array if allocated locally. Array cannot be
551
     * mapped, so we don't need to check for that flag.
552
     */
553
    if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
554
    {
555
        ACPI_FREE (AcpiGbl_RootTableList.Tables);
556
    }
557
 
558
    AcpiGbl_RootTableList.Tables = NULL;
559
    AcpiGbl_RootTableList.Flags = 0;
560
    AcpiGbl_RootTableList.CurrentTableCount = 0;
561
 
562
    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
563
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
564
}
565
 
566
 
567
/*******************************************************************************
568
 *
569
 * FUNCTION:    AcpiTbDeleteNamespaceByOwner
570
 *
571
 * PARAMETERS:  TableIndex          - Table index
572
 *
573
 * RETURN:      Status
574
 *
575
 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
576
 *
577
 ******************************************************************************/
578
 
579
ACPI_STATUS
580
AcpiTbDeleteNamespaceByOwner (
581
    UINT32                  TableIndex)
582
{
583
    ACPI_OWNER_ID           OwnerId;
584
    ACPI_STATUS             Status;
585
 
586
 
587
    ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner);
588
 
589
 
590
    Status = AcpiUtAcquireMutex (ACPI_MTX_TABLES);
591
    if (ACPI_FAILURE (Status))
592
    {
593
        return_ACPI_STATUS (Status);
594
    }
595
 
596
    if (TableIndex >= AcpiGbl_RootTableList.CurrentTableCount)
597
    {
598
        /* The table index does not exist */
599
 
600
        (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
601
        return_ACPI_STATUS (AE_NOT_EXIST);
602
    }
603
 
604
    /* Get the owner ID for this table, used to delete namespace nodes */
605
 
606
    OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
607
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
608
 
609
    /*
610
     * Need to acquire the namespace writer lock to prevent interference
611
     * with any concurrent namespace walks. The interpreter must be
612
     * released during the deletion since the acquisition of the deletion
613
     * lock may block, and also since the execution of a namespace walk
614
     * must be allowed to use the interpreter.
615
     */
616
    (void) AcpiUtReleaseMutex (ACPI_MTX_INTERPRETER);
617
    Status = AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock);
618
 
619
    AcpiNsDeleteNamespaceByOwner (OwnerId);
620
    if (ACPI_FAILURE (Status))
621
    {
622
        return_ACPI_STATUS (Status);
623
    }
624
 
625
    AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock);
626
 
627
    Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
628
    return_ACPI_STATUS (Status);
629
}
630
 
631
 
632
/*******************************************************************************
633
 *
634
 * FUNCTION:    AcpiTbAllocateOwnerId
635
 *
636
 * PARAMETERS:  TableIndex          - Table index
637
 *
638
 * RETURN:      Status
639
 *
640
 * DESCRIPTION: Allocates OwnerId in TableDesc
641
 *
642
 ******************************************************************************/
643
 
644
ACPI_STATUS
645
AcpiTbAllocateOwnerId (
646
    UINT32                  TableIndex)
647
{
648
    ACPI_STATUS             Status = AE_BAD_PARAMETER;
649
 
650
 
651
    ACPI_FUNCTION_TRACE (TbAllocateOwnerId);
652
 
653
 
654
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
655
    if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
656
    {
657
        Status = AcpiUtAllocateOwnerId
658
                    (&(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
659
    }
660
 
661
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
662
    return_ACPI_STATUS (Status);
663
}
664
 
665
 
666
/*******************************************************************************
667
 *
668
 * FUNCTION:    AcpiTbReleaseOwnerId
669
 *
670
 * PARAMETERS:  TableIndex          - Table index
671
 *
672
 * RETURN:      Status
673
 *
674
 * DESCRIPTION: Releases OwnerId in TableDesc
675
 *
676
 ******************************************************************************/
677
 
678
ACPI_STATUS
679
AcpiTbReleaseOwnerId (
680
    UINT32                  TableIndex)
681
{
682
    ACPI_STATUS             Status = AE_BAD_PARAMETER;
683
 
684
 
685
    ACPI_FUNCTION_TRACE (TbReleaseOwnerId);
686
 
687
 
688
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
689
    if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
690
    {
691
        AcpiUtReleaseOwnerId (
692
            &(AcpiGbl_RootTableList.Tables[TableIndex].OwnerId));
693
        Status = AE_OK;
694
    }
695
 
696
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
697
    return_ACPI_STATUS (Status);
698
}
699
 
700
 
701
/*******************************************************************************
702
 *
703
 * FUNCTION:    AcpiTbGetOwnerId
704
 *
705
 * PARAMETERS:  TableIndex          - Table index
706
 *              OwnerId             - Where the table OwnerId is returned
707
 *
708
 * RETURN:      Status
709
 *
710
 * DESCRIPTION: returns OwnerId for the ACPI table
711
 *
712
 ******************************************************************************/
713
 
714
ACPI_STATUS
715
AcpiTbGetOwnerId (
716
    UINT32                  TableIndex,
717
    ACPI_OWNER_ID           *OwnerId)
718
{
719
    ACPI_STATUS             Status = AE_BAD_PARAMETER;
720
 
721
 
722
    ACPI_FUNCTION_TRACE (TbGetOwnerId);
723
 
724
 
725
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
726
    if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
727
    {
728
        *OwnerId = AcpiGbl_RootTableList.Tables[TableIndex].OwnerId;
729
        Status = AE_OK;
730
    }
731
 
732
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
733
    return_ACPI_STATUS (Status);
734
}
735
 
736
 
737
/*******************************************************************************
738
 *
739
 * FUNCTION:    AcpiTbIsTableLoaded
740
 *
741
 * PARAMETERS:  TableIndex          - Table index
742
 *
743
 * RETURN:      Table Loaded Flag
744
 *
745
 ******************************************************************************/
746
 
747
BOOLEAN
748
AcpiTbIsTableLoaded (
749
    UINT32                  TableIndex)
750
{
751
    BOOLEAN                 IsLoaded = FALSE;
752
 
753
 
754
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
755
    if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
756
    {
757
        IsLoaded = (BOOLEAN)
758
            (AcpiGbl_RootTableList.Tables[TableIndex].Flags &
759
            ACPI_TABLE_IS_LOADED);
760
    }
761
 
762
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
763
    return (IsLoaded);
764
}
765
 
766
 
767
/*******************************************************************************
768
 *
769
 * FUNCTION:    AcpiTbSetTableLoadedFlag
770
 *
771
 * PARAMETERS:  TableIndex          - Table index
772
 *              IsLoaded            - TRUE if table is loaded, FALSE otherwise
773
 *
774
 * RETURN:      None
775
 *
776
 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
777
 *
778
 ******************************************************************************/
779
 
780
void
781
AcpiTbSetTableLoadedFlag (
782
    UINT32                  TableIndex,
783
    BOOLEAN                 IsLoaded)
784
{
785
 
786
    (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
787
    if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
788
    {
789
        if (IsLoaded)
790
        {
791
            AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
792
                ACPI_TABLE_IS_LOADED;
793
        }
794
        else
795
        {
796
            AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
797
                ~ACPI_TABLE_IS_LOADED;
798
        }
799
    }
800
 
801
    (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
802
}
803