Print this page
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: tbinstal - ACPI table installation and removal
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, 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.


  76     ACPI_FUNCTION_TRACE (TbVerifyTable);
  77 
  78 
  79     /* Map the table if necessary */
  80 
  81     if (!TableDesc->Pointer)
  82     {
  83         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
  84             ACPI_TABLE_ORIGIN_MAPPED)
  85         {
  86             TableDesc->Pointer = AcpiOsMapMemory (
  87                 TableDesc->Address, TableDesc->Length);
  88         }
  89 
  90         if (!TableDesc->Pointer)
  91         {
  92             return_ACPI_STATUS (AE_NO_MEMORY);
  93         }
  94     }
  95 
  96     /* FACS is the odd table, has no standard ACPI header and no checksum */
  97 
  98     if (!ACPI_COMPARE_NAME (&TableDesc->Signature, ACPI_SIG_FACS))
  99     {
 100         /* Always calculate checksum, ignore bad checksum if requested */
 101 
 102         Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);
 103     }
 104 
 105     return_ACPI_STATUS (Status);
 106 }
 107 
 108 
 109 /*******************************************************************************
 110  *
 111  * FUNCTION:    AcpiTbAddTable
 112  *
 113  * PARAMETERS:  TableDesc           - Table descriptor
 114  *              TableIndex          - Where the table index is returned
 115  *
 116  * RETURN:      Status
 117  *
 118  * DESCRIPTION: This function is called to add an ACPI table. It is used to
 119  *              dynamically load tables via the Load and LoadTable AML
 120  *              operators.
 121  *
 122  ******************************************************************************/
 123 
 124 ACPI_STATUS
 125 AcpiTbAddTable (
 126     ACPI_TABLE_DESC         *TableDesc,
 127     UINT32                  *TableIndex)
 128 {
 129     UINT32                  i;
 130     ACPI_STATUS             Status = AE_OK;
 131     ACPI_TABLE_HEADER       *OverrideTable = NULL;
 132 
 133 
 134     ACPI_FUNCTION_TRACE (TbAddTable);
 135 
 136 
 137     if (!TableDesc->Pointer)
 138     {
 139         Status = AcpiTbVerifyTable (TableDesc);
 140         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
 141         {
 142             return_ACPI_STATUS (Status);
 143         }
 144     }
 145 
 146     /*
 147      * Validate the incoming table signature.
 148      *
 149      * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
 150      * 2) We added support for OEMx tables, signature "OEM".
 151      * 3) Valid tables were encountered with a null signature, so we just
 152      *    gave up on validating the signature, (05/2008).
 153      * 4) We encountered non-AML tables such as the MADT, which caused
 154      *    interpreter errors and kernel faults. So now, we once again allow
 155      *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
 156      */
 157     if ((TableDesc->Pointer->Signature[0] != 0x00) &&
 158        (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
 159        (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
 160     {
 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) ?

 164                 TableDesc->Pointer->Signature : "????",
 165             *(UINT32 *) TableDesc->Pointer->Signature));
 166 
 167         return_ACPI_STATUS (AE_BAD_SIGNATURE);
 168     }
 169 
 170     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
 171 
 172     /* Check if table is already registered */
 173 
 174     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
 175     {
 176         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
 177         {
 178             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
 179             if (ACPI_FAILURE (Status) ||
 180                 !AcpiGbl_RootTableList.Tables[i].Pointer)
 181             {
 182                 continue;
 183             }


 225         {
 226             /* Table is still loaded, this is an error */
 227 
 228             Status = AE_ALREADY_EXISTS;
 229             goto Release;
 230         }
 231         else
 232         {
 233             /* Table was unloaded, allow it to be reloaded */
 234 
 235             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
 236             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
 237             Status = AE_OK;
 238             goto PrintHeader;
 239         }
 240     }
 241 
 242     /*
 243      * ACPI Table Override:
 244      * Allow the host to override dynamically loaded tables.


 245      */
 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)));
 253 
 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     /* Add the table to the global root table list */
 267 
 268     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
 269                 TableDesc->Length, TableDesc->Flags, TableIndex);
 270     if (ACPI_FAILURE (Status))
 271     {
 272         goto Release;
 273     }
 274 
 275 PrintHeader:
 276     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
 277 
 278 Release:
 279     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 280     return_ACPI_STATUS (Status);
 281 }
 282 
 283 
 284 /*******************************************************************************
 285  *




























































































 286  * FUNCTION:    AcpiTbResizeRootTableList
 287  *
 288  * PARAMETERS:  None
 289  *
 290  * RETURN:      Status
 291  *
 292  * DESCRIPTION: Expand the size of global table array
 293  *
 294  ******************************************************************************/
 295 
 296 ACPI_STATUS
 297 AcpiTbResizeRootTableList (
 298     void)
 299 {
 300     ACPI_TABLE_DESC         *Tables;

 301 
 302 
 303     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
 304 
 305 
 306     /* AllowResize flag is a parameter to AcpiInitializeTables */
 307 
 308     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
 309     {
 310         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
 311         return_ACPI_STATUS (AE_SUPPORT);
 312     }
 313 
 314     /* Increase the Table Array size */
 315 









 316     Tables = ACPI_ALLOCATE_ZEROED (
 317         ((ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount +
 318             ACPI_ROOT_TABLE_SIZE_INCREMENT) *
 319         sizeof (ACPI_TABLE_DESC));
 320     if (!Tables)
 321     {
 322         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
 323         return_ACPI_STATUS (AE_NO_MEMORY);
 324     }
 325 
 326     /* Copy and free the previous table array */
 327 
 328     if (AcpiGbl_RootTableList.Tables)
 329     {
 330         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
 331             (ACPI_SIZE) AcpiGbl_RootTableList.MaxTableCount * sizeof (ACPI_TABLE_DESC));
 332 
 333         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 334         {
 335             ACPI_FREE (AcpiGbl_RootTableList.Tables);
 336         }
 337     }
 338 
 339     AcpiGbl_RootTableList.Tables = Tables;
 340     AcpiGbl_RootTableList.MaxTableCount += ACPI_ROOT_TABLE_SIZE_INCREMENT;
 341     AcpiGbl_RootTableList.Flags |= (UINT8) ACPI_ROOT_ORIGIN_ALLOCATED;

 342 
 343     return_ACPI_STATUS (AE_OK);
 344 }
 345 
 346 
 347 /*******************************************************************************
 348  *
 349  * FUNCTION:    AcpiTbStoreTable
 350  *
 351  * PARAMETERS:  Address             - Table address
 352  *              Table               - Table header
 353  *              Length              - Table length
 354  *              Flags               - flags
 355  *
 356  * RETURN:      Status and table index.
 357  *
 358  * DESCRIPTION: Add an ACPI table to the global table list
 359  *
 360  ******************************************************************************/
 361 


 411  *
 412  * DESCRIPTION: Delete one internal ACPI table
 413  *
 414  ******************************************************************************/
 415 
 416 void
 417 AcpiTbDeleteTable (
 418     ACPI_TABLE_DESC         *TableDesc)
 419 {
 420 
 421     /* Table must be mapped or allocated */
 422 
 423     if (!TableDesc->Pointer)
 424     {
 425         return;
 426     }
 427 
 428     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
 429     {
 430     case ACPI_TABLE_ORIGIN_MAPPED:

 431         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
 432         break;
 433 
 434     case ACPI_TABLE_ORIGIN_ALLOCATED:

 435         ACPI_FREE (TableDesc->Pointer);
 436         break;
 437 


 438     default:
 439         break;

 440     }
 441 
 442     TableDesc->Pointer = NULL;
 443 }
 444 
 445 
 446 /*******************************************************************************
 447  *
 448  * FUNCTION:    AcpiTbTerminate
 449  *
 450  * PARAMETERS:  None
 451  *
 452  * RETURN:      None
 453  *
 454  * DESCRIPTION: Delete all internal ACPI tables
 455  *
 456  ******************************************************************************/
 457 
 458 void
 459 AcpiTbTerminate (


 472     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
 473     {
 474         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
 475     }
 476 
 477     /*
 478      * Delete the root table array if allocated locally. Array cannot be
 479      * mapped, so we don't need to check for that flag.
 480      */
 481     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 482     {
 483         ACPI_FREE (AcpiGbl_RootTableList.Tables);
 484     }
 485 
 486     AcpiGbl_RootTableList.Tables = NULL;
 487     AcpiGbl_RootTableList.Flags = 0;
 488     AcpiGbl_RootTableList.CurrentTableCount = 0;
 489 
 490     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
 491     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);


 492 }
 493 
 494 
 495 /*******************************************************************************
 496  *
 497  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
 498  *
 499  * PARAMETERS:  TableIndex          - Table index
 500  *
 501  * RETURN:      Status
 502  *
 503  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
 504  *
 505  ******************************************************************************/
 506 
 507 ACPI_STATUS
 508 AcpiTbDeleteNamespaceByOwner (
 509     UINT32                  TableIndex)
 510 {
 511     ACPI_OWNER_ID           OwnerId;


 711     BOOLEAN                 IsLoaded)
 712 {
 713 
 714     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
 715     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
 716     {
 717         if (IsLoaded)
 718         {
 719             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
 720                 ACPI_TABLE_IS_LOADED;
 721         }
 722         else
 723         {
 724             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
 725                 ~ACPI_TABLE_IS_LOADED;
 726         }
 727     }
 728 
 729     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 730 }
 731 
   1 /******************************************************************************
   2  *
   3  * Module Name: tbinstal - ACPI table installation and removal
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2013, 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.


  76     ACPI_FUNCTION_TRACE (TbVerifyTable);
  77 
  78 
  79     /* Map the table if necessary */
  80 
  81     if (!TableDesc->Pointer)
  82     {
  83         if ((TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK) ==
  84             ACPI_TABLE_ORIGIN_MAPPED)
  85         {
  86             TableDesc->Pointer = AcpiOsMapMemory (
  87                 TableDesc->Address, TableDesc->Length);
  88         }
  89 
  90         if (!TableDesc->Pointer)
  91         {
  92             return_ACPI_STATUS (AE_NO_MEMORY);
  93         }
  94     }
  95 




  96     /* Always calculate checksum, ignore bad checksum if requested */
  97 
  98     Status = AcpiTbVerifyChecksum (TableDesc->Pointer, TableDesc->Length);

  99 
 100     return_ACPI_STATUS (Status);
 101 }
 102 
 103 
 104 /*******************************************************************************
 105  *
 106  * FUNCTION:    AcpiTbAddTable
 107  *
 108  * PARAMETERS:  TableDesc           - Table descriptor
 109  *              TableIndex          - Where the table index is returned
 110  *
 111  * RETURN:      Status
 112  *
 113  * DESCRIPTION: This function is called to add an ACPI table. It is used to
 114  *              dynamically load tables via the Load and LoadTable AML
 115  *              operators.
 116  *
 117  ******************************************************************************/
 118 
 119 ACPI_STATUS
 120 AcpiTbAddTable (
 121     ACPI_TABLE_DESC         *TableDesc,
 122     UINT32                  *TableIndex)
 123 {
 124     UINT32                  i;
 125     ACPI_STATUS             Status = AE_OK;

 126 
 127 
 128     ACPI_FUNCTION_TRACE (TbAddTable);
 129 
 130 
 131     if (!TableDesc->Pointer)
 132     {
 133         Status = AcpiTbVerifyTable (TableDesc);
 134         if (ACPI_FAILURE (Status) || !TableDesc->Pointer)
 135         {
 136             return_ACPI_STATUS (Status);
 137         }
 138     }
 139 
 140     /*
 141      * Validate the incoming table signature.
 142      *
 143      * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
 144      * 2) We added support for OEMx tables, signature "OEM".
 145      * 3) Valid tables were encountered with a null signature, so we just
 146      *    gave up on validating the signature, (05/2008).
 147      * 4) We encountered non-AML tables such as the MADT, which caused
 148      *    interpreter errors and kernel faults. So now, we once again allow
 149      *    only "SSDT", "OEMx", and now, also a null signature. (05/2011).
 150      */
 151     if ((TableDesc->Pointer->Signature[0] != 0x00) &&
 152        (!ACPI_COMPARE_NAME (TableDesc->Pointer->Signature, ACPI_SIG_SSDT)) &&
 153        (ACPI_STRNCMP (TableDesc->Pointer->Signature, "OEM", 3)))
 154     {
 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) ?
 159                 TableDesc->Pointer->Signature : "????",
 160             *(UINT32 *) TableDesc->Pointer->Signature));
 161 
 162         return_ACPI_STATUS (AE_BAD_SIGNATURE);
 163     }
 164 
 165     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
 166 
 167     /* Check if table is already registered */
 168 
 169     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; ++i)
 170     {
 171         if (!AcpiGbl_RootTableList.Tables[i].Pointer)
 172         {
 173             Status = AcpiTbVerifyTable (&AcpiGbl_RootTableList.Tables[i]);
 174             if (ACPI_FAILURE (Status) ||
 175                 !AcpiGbl_RootTableList.Tables[i].Pointer)
 176             {
 177                 continue;
 178             }


 220         {
 221             /* Table is still loaded, this is an error */
 222 
 223             Status = AE_ALREADY_EXISTS;
 224             goto Release;
 225         }
 226         else
 227         {
 228             /* Table was unloaded, allow it to be reloaded */
 229 
 230             TableDesc->Pointer = AcpiGbl_RootTableList.Tables[i].Pointer;
 231             TableDesc->Address = AcpiGbl_RootTableList.Tables[i].Address;
 232             Status = AE_OK;
 233             goto PrintHeader;
 234         }
 235     }
 236 
 237     /*
 238      * ACPI Table Override:
 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.
 242      */
 243     (void) AcpiTbTableOverride (TableDesc->Pointer, TableDesc);






 244 












 245     /* Add the table to the global root table list */
 246 
 247     Status = AcpiTbStoreTable (TableDesc->Address, TableDesc->Pointer,
 248                 TableDesc->Length, TableDesc->Flags, TableIndex);
 249     if (ACPI_FAILURE (Status))
 250     {
 251         goto Release;
 252     }
 253 
 254 PrintHeader:
 255     AcpiTbPrintTableHeader (TableDesc->Address, TableDesc->Pointer);
 256 
 257 Release:
 258     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 259     return_ACPI_STATUS (Status);
 260 }
 261 
 262 
 263 /*******************************************************************************
 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  *
 357  * FUNCTION:    AcpiTbResizeRootTableList
 358  *
 359  * PARAMETERS:  None
 360  *
 361  * RETURN:      Status
 362  *
 363  * DESCRIPTION: Expand the size of global table array
 364  *
 365  ******************************************************************************/
 366 
 367 ACPI_STATUS
 368 AcpiTbResizeRootTableList (
 369     void)
 370 {
 371     ACPI_TABLE_DESC         *Tables;
 372     UINT32                  TableCount;
 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     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 
 397     Tables = ACPI_ALLOCATE_ZEROED (
 398         ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *

 399         sizeof (ACPI_TABLE_DESC));
 400     if (!Tables)
 401     {
 402         ACPI_ERROR ((AE_INFO, "Could not allocate new root table array"));
 403         return_ACPI_STATUS (AE_NO_MEMORY);
 404     }
 405 
 406     /* Copy and free the previous table array */
 407 
 408     if (AcpiGbl_RootTableList.Tables)
 409     {
 410         ACPI_MEMCPY (Tables, AcpiGbl_RootTableList.Tables,
 411             (ACPI_SIZE) TableCount * sizeof (ACPI_TABLE_DESC));
 412 
 413         if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 414         {
 415             ACPI_FREE (AcpiGbl_RootTableList.Tables);
 416         }
 417     }
 418 
 419     AcpiGbl_RootTableList.Tables = Tables;
 420     AcpiGbl_RootTableList.MaxTableCount =
 421         TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT;
 422     AcpiGbl_RootTableList.Flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
 423 
 424     return_ACPI_STATUS (AE_OK);
 425 }
 426 
 427 
 428 /*******************************************************************************
 429  *
 430  * FUNCTION:    AcpiTbStoreTable
 431  *
 432  * PARAMETERS:  Address             - Table address
 433  *              Table               - Table header
 434  *              Length              - Table length
 435  *              Flags               - flags
 436  *
 437  * RETURN:      Status and table index.
 438  *
 439  * DESCRIPTION: Add an ACPI table to the global table list
 440  *
 441  ******************************************************************************/
 442 


 492  *
 493  * DESCRIPTION: Delete one internal ACPI table
 494  *
 495  ******************************************************************************/
 496 
 497 void
 498 AcpiTbDeleteTable (
 499     ACPI_TABLE_DESC         *TableDesc)
 500 {
 501 
 502     /* Table must be mapped or allocated */
 503 
 504     if (!TableDesc->Pointer)
 505     {
 506         return;
 507     }
 508 
 509     switch (TableDesc->Flags & ACPI_TABLE_ORIGIN_MASK)
 510     {
 511     case ACPI_TABLE_ORIGIN_MAPPED:
 512 
 513         AcpiOsUnmapMemory (TableDesc->Pointer, TableDesc->Length);
 514         break;
 515 
 516     case ACPI_TABLE_ORIGIN_ALLOCATED:
 517 
 518         ACPI_FREE (TableDesc->Pointer);
 519         break;
 520 
 521     /* Not mapped or allocated, there is nothing we can do */
 522 
 523     default:
 524 
 525         return;
 526     }
 527 
 528     TableDesc->Pointer = NULL;
 529 }
 530 
 531 
 532 /*******************************************************************************
 533  *
 534  * FUNCTION:    AcpiTbTerminate
 535  *
 536  * PARAMETERS:  None
 537  *
 538  * RETURN:      None
 539  *
 540  * DESCRIPTION: Delete all internal ACPI tables
 541  *
 542  ******************************************************************************/
 543 
 544 void
 545 AcpiTbTerminate (


 558     for (i = 0; i < AcpiGbl_RootTableList.CurrentTableCount; i++)
 559     {
 560         AcpiTbDeleteTable (&AcpiGbl_RootTableList.Tables[i]);
 561     }
 562 
 563     /*
 564      * Delete the root table array if allocated locally. Array cannot be
 565      * mapped, so we don't need to check for that flag.
 566      */
 567     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 568     {
 569         ACPI_FREE (AcpiGbl_RootTableList.Tables);
 570     }
 571 
 572     AcpiGbl_RootTableList.Tables = NULL;
 573     AcpiGbl_RootTableList.Flags = 0;
 574     AcpiGbl_RootTableList.CurrentTableCount = 0;
 575 
 576     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ACPI Tables freed\n"));
 577     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 578 
 579     return_VOID;
 580 }
 581 
 582 
 583 /*******************************************************************************
 584  *
 585  * FUNCTION:    AcpiTbDeleteNamespaceByOwner
 586  *
 587  * PARAMETERS:  TableIndex          - Table index
 588  *
 589  * RETURN:      Status
 590  *
 591  * DESCRIPTION: Delete all namespace objects created when this table was loaded.
 592  *
 593  ******************************************************************************/
 594 
 595 ACPI_STATUS
 596 AcpiTbDeleteNamespaceByOwner (
 597     UINT32                  TableIndex)
 598 {
 599     ACPI_OWNER_ID           OwnerId;


 799     BOOLEAN                 IsLoaded)
 800 {
 801 
 802     (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES);
 803     if (TableIndex < AcpiGbl_RootTableList.CurrentTableCount)
 804     {
 805         if (IsLoaded)
 806         {
 807             AcpiGbl_RootTableList.Tables[TableIndex].Flags |=
 808                 ACPI_TABLE_IS_LOADED;
 809         }
 810         else
 811         {
 812             AcpiGbl_RootTableList.Tables[TableIndex].Flags &=
 813                 ~ACPI_TABLE_IS_LOADED;
 814         }
 815     }
 816 
 817     (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES);
 818 }