Print this page
update to acpica-unix2-20140114
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 - 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.


  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 " ACPI_PRINTF_UINT
 319                 " Attempted physical table override failed",
 320                 TableHeader->Signature,
 321                 ACPI_FORMAT_TO_UINT (TableDesc->Address)));
 322             return (NULL);
 323         }
 324 
 325         OverrideType = "Physical";
 326         NewFlags = ACPI_TABLE_ORIGIN_MAPPED;
 327         goto FinishOverride;
 328     }
 329 
 330     return (NULL); /* There was no override */
 331 
 332 
 333 FinishOverride:
 334 
 335     ACPI_INFO ((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
 336         " %s table override, new table: " ACPI_PRINTF_UINT,
 337         TableHeader->Signature,
 338         ACPI_FORMAT_TO_UINT (TableDesc->Address),
 339         OverrideType, ACPI_FORMAT_TO_UINT (NewTable)));
 340 
 341     /* We can now unmap/delete the original table (if fully mapped) */
 342 
 343     AcpiTbDeleteTable (TableDesc);
 344 
 345     /* Setup descriptor for the new table */
 346 
 347     TableDesc->Address = NewAddress;
 348     TableDesc->Pointer = NewTable;
 349     TableDesc->Length = NewTableLength;
 350     TableDesc->Flags = NewFlags;
 351 
 352     return (NewTable);
 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     UINT32                  TableCount;
 374 
 375 
 376     ACPI_FUNCTION_TRACE (TbResizeRootTableList);
 377 
 378 
 379     /* AllowResize flag is a parameter to AcpiInitializeTables */
 380 
 381     if (!(AcpiGbl_RootTableList.Flags & ACPI_ROOT_ALLOW_RESIZE))
 382     {
 383         ACPI_ERROR ((AE_INFO, "Resize of Root Table Array is not allowed"));
 384         return_ACPI_STATUS (AE_SUPPORT);
 385     }
 386 
 387     /* Increase the Table Array size */
 388 
 389     if (AcpiGbl_RootTableList.Flags & ACPI_ROOT_ORIGIN_ALLOCATED)
 390     {
 391         TableCount = AcpiGbl_RootTableList.MaxTableCount;
 392     }
 393     else
 394     {
 395         TableCount = AcpiGbl_RootTableList.CurrentTableCount;
 396     }
 397 
 398     Tables = ACPI_ALLOCATE_ZEROED (
 399         ((ACPI_SIZE) TableCount + ACPI_ROOT_TABLE_SIZE_INCREMENT) *

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


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


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


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