Print this page
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
   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.


  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 __EXCONFIG_C__
  45 
  46 #include "acpi.h"
  47 #include "accommon.h"
  48 #include "acinterp.h"
  49 #include "acnamesp.h"
  50 #include "actables.h"
  51 #include "acdispat.h"
  52 #include "acevents.h"

  53 
  54 
  55 #define _COMPONENT          ACPI_EXECUTER
  56         ACPI_MODULE_NAME    ("exconfig")
  57 
  58 /* Local prototypes */
  59 
  60 static ACPI_STATUS
  61 AcpiExAddTable (
  62     UINT32                  TableIndex,
  63     ACPI_NAMESPACE_NODE     *ParentNode,
  64     ACPI_OPERAND_OBJECT     **DdbHandle);
  65 
  66 static ACPI_STATUS
  67 AcpiExRegionRead (
  68     ACPI_OPERAND_OBJECT     *ObjDesc,
  69     UINT32                  Length,
  70     UINT8                   *Buffer);
  71 
  72 


 162  ******************************************************************************/
 163 
 164 ACPI_STATUS
 165 AcpiExLoadTableOp (
 166     ACPI_WALK_STATE         *WalkState,
 167     ACPI_OPERAND_OBJECT     **ReturnDesc)
 168 {
 169     ACPI_STATUS             Status;
 170     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 171     ACPI_NAMESPACE_NODE     *ParentNode;
 172     ACPI_NAMESPACE_NODE     *StartNode;
 173     ACPI_NAMESPACE_NODE     *ParameterNode = NULL;
 174     ACPI_OPERAND_OBJECT     *DdbHandle;
 175     ACPI_TABLE_HEADER       *Table;
 176     UINT32                  TableIndex;
 177 
 178 
 179     ACPI_FUNCTION_TRACE (ExLoadTableOp);
 180 
 181 
 182     /* Validate lengths for the SignatureString, OEMIDString, OEMTableID */
 183 
 184     if ((Operand[0]->String.Length > ACPI_NAME_SIZE) ||
 185         (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) ||
 186         (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE))
 187     {
 188         return_ACPI_STATUS (AE_BAD_PARAMETER);
 189     }
 190 
 191     /* Find the ACPI table in the RSDT/XSDT */
 192 
 193     Status = AcpiTbFindTable (Operand[0]->String.Pointer,

 194                               Operand[1]->String.Pointer,
 195                               Operand[2]->String.Pointer, &TableIndex);
 196     if (ACPI_FAILURE (Status))
 197     {
 198         if (Status != AE_NOT_FOUND)
 199         {
 200             return_ACPI_STATUS (Status);
 201         }
 202 
 203         /* Table not found, return an Integer=0 and AE_OK */
 204 
 205         DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0);
 206         if (!DdbHandle)
 207         {
 208             return_ACPI_STATUS (AE_NO_MEMORY);
 209         }
 210 
 211         *ReturnDesc = DdbHandle;
 212         return_ACPI_STATUS (AE_OK);
 213     }


 220     /* RootPath (optional parameter) */
 221 
 222     if (Operand[3]->String.Length > 0)
 223     {
 224         /*
 225          * Find the node referenced by the RootPathString.  This is the
 226          * location within the namespace where the table will be loaded.
 227          */
 228         Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer,
 229                     ACPI_NS_SEARCH_PARENT, &ParentNode);
 230         if (ACPI_FAILURE (Status))
 231         {
 232             return_ACPI_STATUS (Status);
 233         }
 234     }
 235 
 236     /* ParameterPath (optional parameter) */
 237 
 238     if (Operand[4]->String.Length > 0)
 239     {
 240         if ((Operand[4]->String.Pointer[0] != '\\') &&
 241             (Operand[4]->String.Pointer[0] != '^'))
 242         {
 243             /*
 244              * Path is not absolute, so it will be relative to the node
 245              * referenced by the RootPathString (or the NS root if omitted)
 246              */
 247             StartNode = ParentNode;
 248         }
 249 
 250         /* Find the node referenced by the ParameterPathString */
 251 
 252         Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
 253                     ACPI_NS_SEARCH_PARENT, &ParameterNode);
 254         if (ACPI_FAILURE (Status))
 255         {
 256             return_ACPI_STATUS (Status);
 257         }
 258     }
 259 
 260     /* Load the table into the namespace */
 261 


 317  *              beginning of the region.
 318  *
 319  ******************************************************************************/
 320 
 321 static ACPI_STATUS
 322 AcpiExRegionRead (
 323     ACPI_OPERAND_OBJECT     *ObjDesc,
 324     UINT32                  Length,
 325     UINT8                   *Buffer)
 326 {
 327     ACPI_STATUS             Status;
 328     UINT64                  Value;
 329     UINT32                  RegionOffset = 0;
 330     UINT32                  i;
 331 
 332 
 333     /* Bytewise reads */
 334 
 335     for (i = 0; i < Length; i++)
 336     {
 337         Status = AcpiEvAddressSpaceDispatch (ObjDesc, ACPI_READ,
 338                     RegionOffset, 8, &Value);
 339         if (ACPI_FAILURE (Status))
 340         {
 341             return (Status);
 342         }
 343 
 344         *Buffer = (UINT8) Value;
 345         Buffer++;
 346         RegionOffset++;
 347     }
 348 
 349     return (AE_OK);
 350 }
 351 
 352 
 353 /*******************************************************************************
 354  *
 355  * FUNCTION:    AcpiExLoadOp
 356  *
 357  * PARAMETERS:  ObjDesc         - Region or Buffer/Field where the table will be


 464 
 465         TableDesc.Pointer = ACPI_ALLOCATE (Length);
 466         if (!TableDesc.Pointer)
 467         {
 468             return_ACPI_STATUS (AE_NO_MEMORY);
 469         }
 470 
 471         /* Read the entire table */
 472 
 473         Status = AcpiExRegionRead (ObjDesc, Length,
 474                     ACPI_CAST_PTR (UINT8, TableDesc.Pointer));
 475         if (ACPI_FAILURE (Status))
 476         {
 477             ACPI_FREE (TableDesc.Pointer);
 478             return_ACPI_STATUS (Status);
 479         }
 480 
 481         TableDesc.Address = ObjDesc->Region.Address;
 482         break;
 483 
 484 
 485     case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
 486 
 487         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 488             "Load table from Buffer or Field %p\n", ObjDesc));
 489 
 490         /* Must have at least an ACPI table header */
 491 
 492         if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
 493         {
 494             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
 495         }
 496 
 497         /* Get the actual table length from the table header */
 498 
 499         Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
 500         Length = Table->Length;
 501 
 502         /* Table cannot extend beyond the buffer */
 503 
 504         if (Length > ObjDesc->Buffer.Length)


 507         }
 508         if (Length < sizeof (ACPI_TABLE_HEADER))
 509         {
 510             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
 511         }
 512 
 513         /*
 514          * Copy the table from the buffer because the buffer could be modified
 515          * or even deleted in the future
 516          */
 517         TableDesc.Pointer = ACPI_ALLOCATE (Length);
 518         if (!TableDesc.Pointer)
 519         {
 520             return_ACPI_STATUS (AE_NO_MEMORY);
 521         }
 522 
 523         ACPI_MEMCPY (TableDesc.Pointer, Table, Length);
 524         TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer);
 525         break;
 526 
 527 
 528     default:

 529         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 530     }
 531 
 532     /* Validate table checksum (will not get validated in TbAddTable) */
 533 
 534     Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length);
 535     if (ACPI_FAILURE (Status))
 536     {
 537         ACPI_FREE (TableDesc.Pointer);
 538         return_ACPI_STATUS (Status);
 539     }
 540 
 541     /* Complete the table descriptor */
 542 
 543     TableDesc.Length = Length;
 544     TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
 545 
 546     /* Install the new table into the local data structures */
 547 
 548     Status = AcpiTbAddTable (&TableDesc, &TableIndex);


 624 
 625 
 626     ACPI_FUNCTION_TRACE (ExUnloadTable);
 627 
 628 
 629     /*
 630      * Validate the handle
 631      * Although the handle is partially validated in AcpiExReconfiguration()
 632      * when it calls AcpiExResolveOperands(), the handle is more completely
 633      * validated here.
 634      *
 635      * Handle must be a valid operand object of type reference. Also, the
 636      * DdbHandle must still be marked valid (table has not been previously
 637      * unloaded)
 638      */
 639     if ((!DdbHandle) ||
 640         (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) ||
 641         (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
 642         (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
 643     {
 644         return_ACPI_STATUS (AE_BAD_PARAMETER);
 645     }
 646 
 647     /* Get the table index from the DdbHandle */
 648 
 649     TableIndex = TableDesc->Reference.Value;
 650 
 651     /* Ensure the table is still loaded */
 652 
 653     if (!AcpiTbIsTableLoaded (TableIndex))
 654     {
 655         return_ACPI_STATUS (AE_NOT_EXIST);
 656     }
 657 
 658     /* Invoke table handler if present */
 659 
 660     if (AcpiGbl_TableHandler)
 661     {
 662         Status = AcpiGetTableByIndex (TableIndex, &Table);
 663         if (ACPI_SUCCESS (Status))
 664         {


 668     }
 669 
 670     /* Delete the portion of the namespace owned by this table */
 671 
 672     Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
 673     if (ACPI_FAILURE (Status))
 674     {
 675         return_ACPI_STATUS (Status);
 676     }
 677 
 678     (void) AcpiTbReleaseOwnerId (TableIndex);
 679     AcpiTbSetTableLoadedFlag (TableIndex, FALSE);
 680 
 681     /*
 682      * Invalidate the handle. We do this because the handle may be stored
 683      * in a named object and may not be actually deleted until much later.
 684      */
 685     DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
 686     return_ACPI_STATUS (AE_OK);
 687 }
 688 
   1 /******************************************************************************
   2  *
   3  * Module Name: exconfig - Namespace reconfiguration (Load/Unload opcodes)
   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.


  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 __EXCONFIG_C__
  45 
  46 #include "acpi.h"
  47 #include "accommon.h"
  48 #include "acinterp.h"
  49 #include "acnamesp.h"
  50 #include "actables.h"
  51 #include "acdispat.h"
  52 #include "acevents.h"
  53 #include "amlcode.h"
  54 
  55 
  56 #define _COMPONENT          ACPI_EXECUTER
  57         ACPI_MODULE_NAME    ("exconfig")
  58 
  59 /* Local prototypes */
  60 
  61 static ACPI_STATUS
  62 AcpiExAddTable (
  63     UINT32                  TableIndex,
  64     ACPI_NAMESPACE_NODE     *ParentNode,
  65     ACPI_OPERAND_OBJECT     **DdbHandle);
  66 
  67 static ACPI_STATUS
  68 AcpiExRegionRead (
  69     ACPI_OPERAND_OBJECT     *ObjDesc,
  70     UINT32                  Length,
  71     UINT8                   *Buffer);
  72 
  73 


 163  ******************************************************************************/
 164 
 165 ACPI_STATUS
 166 AcpiExLoadTableOp (
 167     ACPI_WALK_STATE         *WalkState,
 168     ACPI_OPERAND_OBJECT     **ReturnDesc)
 169 {
 170     ACPI_STATUS             Status;
 171     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
 172     ACPI_NAMESPACE_NODE     *ParentNode;
 173     ACPI_NAMESPACE_NODE     *StartNode;
 174     ACPI_NAMESPACE_NODE     *ParameterNode = NULL;
 175     ACPI_OPERAND_OBJECT     *DdbHandle;
 176     ACPI_TABLE_HEADER       *Table;
 177     UINT32                  TableIndex;
 178 
 179 
 180     ACPI_FUNCTION_TRACE (ExLoadTableOp);
 181 
 182 
 183     /* Validate lengths for the Signature, OemId, and OemTableId strings */
 184 
 185     if ((Operand[0]->String.Length > ACPI_NAME_SIZE) ||
 186         (Operand[1]->String.Length > ACPI_OEM_ID_SIZE) ||
 187         (Operand[2]->String.Length > ACPI_OEM_TABLE_ID_SIZE))
 188     {
 189         return_ACPI_STATUS (AE_AML_STRING_LIMIT);
 190     }
 191 
 192     /* Find the ACPI table in the RSDT/XSDT */
 193 
 194     Status = AcpiTbFindTable (
 195                 Operand[0]->String.Pointer,
 196                 Operand[1]->String.Pointer,
 197                 Operand[2]->String.Pointer, &TableIndex);
 198     if (ACPI_FAILURE (Status))
 199     {
 200         if (Status != AE_NOT_FOUND)
 201         {
 202             return_ACPI_STATUS (Status);
 203         }
 204 
 205         /* Table not found, return an Integer=0 and AE_OK */
 206 
 207         DdbHandle = AcpiUtCreateIntegerObject ((UINT64) 0);
 208         if (!DdbHandle)
 209         {
 210             return_ACPI_STATUS (AE_NO_MEMORY);
 211         }
 212 
 213         *ReturnDesc = DdbHandle;
 214         return_ACPI_STATUS (AE_OK);
 215     }


 222     /* RootPath (optional parameter) */
 223 
 224     if (Operand[3]->String.Length > 0)
 225     {
 226         /*
 227          * Find the node referenced by the RootPathString. This is the
 228          * location within the namespace where the table will be loaded.
 229          */
 230         Status = AcpiNsGetNode (StartNode, Operand[3]->String.Pointer,
 231                     ACPI_NS_SEARCH_PARENT, &ParentNode);
 232         if (ACPI_FAILURE (Status))
 233         {
 234             return_ACPI_STATUS (Status);
 235         }
 236     }
 237 
 238     /* ParameterPath (optional parameter) */
 239 
 240     if (Operand[4]->String.Length > 0)
 241     {
 242         if ((Operand[4]->String.Pointer[0] != AML_ROOT_PREFIX) &&
 243             (Operand[4]->String.Pointer[0] != AML_PARENT_PREFIX))
 244         {
 245             /*
 246              * Path is not absolute, so it will be relative to the node
 247              * referenced by the RootPathString (or the NS root if omitted)
 248              */
 249             StartNode = ParentNode;
 250         }
 251 
 252         /* Find the node referenced by the ParameterPathString */
 253 
 254         Status = AcpiNsGetNode (StartNode, Operand[4]->String.Pointer,
 255                     ACPI_NS_SEARCH_PARENT, &ParameterNode);
 256         if (ACPI_FAILURE (Status))
 257         {
 258             return_ACPI_STATUS (Status);
 259         }
 260     }
 261 
 262     /* Load the table into the namespace */
 263 


 319  *              beginning of the region.
 320  *
 321  ******************************************************************************/
 322 
 323 static ACPI_STATUS
 324 AcpiExRegionRead (
 325     ACPI_OPERAND_OBJECT     *ObjDesc,
 326     UINT32                  Length,
 327     UINT8                   *Buffer)
 328 {
 329     ACPI_STATUS             Status;
 330     UINT64                  Value;
 331     UINT32                  RegionOffset = 0;
 332     UINT32                  i;
 333 
 334 
 335     /* Bytewise reads */
 336 
 337     for (i = 0; i < Length; i++)
 338     {
 339         Status = AcpiEvAddressSpaceDispatch (ObjDesc, NULL, ACPI_READ,
 340                     RegionOffset, 8, &Value);
 341         if (ACPI_FAILURE (Status))
 342         {
 343             return (Status);
 344         }
 345 
 346         *Buffer = (UINT8) Value;
 347         Buffer++;
 348         RegionOffset++;
 349     }
 350 
 351     return (AE_OK);
 352 }
 353 
 354 
 355 /*******************************************************************************
 356  *
 357  * FUNCTION:    AcpiExLoadOp
 358  *
 359  * PARAMETERS:  ObjDesc         - Region or Buffer/Field where the table will be


 466 
 467         TableDesc.Pointer = ACPI_ALLOCATE (Length);
 468         if (!TableDesc.Pointer)
 469         {
 470             return_ACPI_STATUS (AE_NO_MEMORY);
 471         }
 472 
 473         /* Read the entire table */
 474 
 475         Status = AcpiExRegionRead (ObjDesc, Length,
 476                     ACPI_CAST_PTR (UINT8, TableDesc.Pointer));
 477         if (ACPI_FAILURE (Status))
 478         {
 479             ACPI_FREE (TableDesc.Pointer);
 480             return_ACPI_STATUS (Status);
 481         }
 482 
 483         TableDesc.Address = ObjDesc->Region.Address;
 484         break;
 485 

 486     case ACPI_TYPE_BUFFER: /* Buffer or resolved RegionField */
 487 
 488         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 489             "Load table from Buffer or Field %p\n", ObjDesc));
 490 
 491         /* Must have at least an ACPI table header */
 492 
 493         if (ObjDesc->Buffer.Length < sizeof (ACPI_TABLE_HEADER))
 494         {
 495             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
 496         }
 497 
 498         /* Get the actual table length from the table header */
 499 
 500         Table = ACPI_CAST_PTR (ACPI_TABLE_HEADER, ObjDesc->Buffer.Pointer);
 501         Length = Table->Length;
 502 
 503         /* Table cannot extend beyond the buffer */
 504 
 505         if (Length > ObjDesc->Buffer.Length)


 508         }
 509         if (Length < sizeof (ACPI_TABLE_HEADER))
 510         {
 511             return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH);
 512         }
 513 
 514         /*
 515          * Copy the table from the buffer because the buffer could be modified
 516          * or even deleted in the future
 517          */
 518         TableDesc.Pointer = ACPI_ALLOCATE (Length);
 519         if (!TableDesc.Pointer)
 520         {
 521             return_ACPI_STATUS (AE_NO_MEMORY);
 522         }
 523 
 524         ACPI_MEMCPY (TableDesc.Pointer, Table, Length);
 525         TableDesc.Address = ACPI_TO_INTEGER (TableDesc.Pointer);
 526         break;
 527 

 528     default:
 529 
 530         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 531     }
 532 
 533     /* Validate table checksum (will not get validated in TbAddTable) */
 534 
 535     Status = AcpiTbVerifyChecksum (TableDesc.Pointer, Length);
 536     if (ACPI_FAILURE (Status))
 537     {
 538         ACPI_FREE (TableDesc.Pointer);
 539         return_ACPI_STATUS (Status);
 540     }
 541 
 542     /* Complete the table descriptor */
 543 
 544     TableDesc.Length = Length;
 545     TableDesc.Flags = ACPI_TABLE_ORIGIN_ALLOCATED;
 546 
 547     /* Install the new table into the local data structures */
 548 
 549     Status = AcpiTbAddTable (&TableDesc, &TableIndex);


 625 
 626 
 627     ACPI_FUNCTION_TRACE (ExUnloadTable);
 628 
 629 
 630     /*
 631      * Validate the handle
 632      * Although the handle is partially validated in AcpiExReconfiguration()
 633      * when it calls AcpiExResolveOperands(), the handle is more completely
 634      * validated here.
 635      *
 636      * Handle must be a valid operand object of type reference. Also, the
 637      * DdbHandle must still be marked valid (table has not been previously
 638      * unloaded)
 639      */
 640     if ((!DdbHandle) ||
 641         (ACPI_GET_DESCRIPTOR_TYPE (DdbHandle) != ACPI_DESC_TYPE_OPERAND) ||
 642         (DdbHandle->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) ||
 643         (!(DdbHandle->Common.Flags & AOPOBJ_DATA_VALID)))
 644     {
 645         return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 646     }
 647 
 648     /* Get the table index from the DdbHandle */
 649 
 650     TableIndex = TableDesc->Reference.Value;
 651 
 652     /* Ensure the table is still loaded */
 653 
 654     if (!AcpiTbIsTableLoaded (TableIndex))
 655     {
 656         return_ACPI_STATUS (AE_NOT_EXIST);
 657     }
 658 
 659     /* Invoke table handler if present */
 660 
 661     if (AcpiGbl_TableHandler)
 662     {
 663         Status = AcpiGetTableByIndex (TableIndex, &Table);
 664         if (ACPI_SUCCESS (Status))
 665         {


 669     }
 670 
 671     /* Delete the portion of the namespace owned by this table */
 672 
 673     Status = AcpiTbDeleteNamespaceByOwner (TableIndex);
 674     if (ACPI_FAILURE (Status))
 675     {
 676         return_ACPI_STATUS (Status);
 677     }
 678 
 679     (void) AcpiTbReleaseOwnerId (TableIndex);
 680     AcpiTbSetTableLoadedFlag (TableIndex, FALSE);
 681 
 682     /*
 683      * Invalidate the handle. We do this because the handle may be stored
 684      * in a named object and may not be actually deleted until much later.
 685      */
 686     DdbHandle->Common.Flags &= ~AOPOBJ_DATA_VALID;
 687     return_ACPI_STATUS (AE_OK);
 688 }