The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/dev/acpica/components/executer/excreate.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /******************************************************************************
    2  *
    3  * Module Name: excreate - Named object creation
    4  *
    5  *****************************************************************************/
    6 
    7 /******************************************************************************
    8  *
    9  * 1. Copyright Notice
   10  *
   11  * Some or all of this work - Copyright (c) 1999 - 2022, Intel Corp.
   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 
   87  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
   88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
   89  * PARTICULAR PURPOSE.
   90  *
   91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
   92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
   93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
   94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
   95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
   96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
   97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
   98  * LIMITED REMEDY.
   99  *
  100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
  101  * software or system incorporating such software without first obtaining any
  102  * required license or other approval from the U. S. Department of Commerce or
  103  * any other agency or department of the United States Government. In the
  104  * event Licensee exports any such software from the United States or
  105  * re-exports any such software from a foreign destination, Licensee shall
  106  * ensure that the distribution and export/re-export of the software is in
  107  * compliance with all laws, regulations, orders, or other restrictions of the
  108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
  109  * any of its subsidiaries will export/re-export any technical data, process,
  110  * software, or service, directly or indirectly, to any country for which the
  111  * United States government or any agency thereof requires an export license,
  112  * other governmental approval, or letter of assurance, without first obtaining
  113  * such license, approval or letter.
  114  *
  115  *****************************************************************************
  116  *
  117  * Alternatively, you may choose to be licensed under the terms of the
  118  * following license:
  119  *
  120  * Redistribution and use in source and binary forms, with or without
  121  * modification, are permitted provided that the following conditions
  122  * are met:
  123  * 1. Redistributions of source code must retain the above copyright
  124  *    notice, this list of conditions, and the following disclaimer,
  125  *    without modification.
  126  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  127  *    substantially similar to the "NO WARRANTY" disclaimer below
  128  *    ("Disclaimer") and any redistribution must be conditioned upon
  129  *    including a substantially similar Disclaimer requirement for further
  130  *    binary redistribution.
  131  * 3. Neither the names of the above-listed copyright holders nor the names
  132  *    of any contributors may be used to endorse or promote products derived
  133  *    from this software without specific prior written permission.
  134  *
  135  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  136  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  137  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  138  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  139  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  140  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  141  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  142  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  143  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  144  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  145  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  146  *
  147  * Alternatively, you may choose to be licensed under the terms of the
  148  * GNU General Public License ("GPL") version 2 as published by the Free
  149  * Software Foundation.
  150  *
  151  *****************************************************************************/
  152 
  153 #include <contrib/dev/acpica/include/acpi.h>
  154 #include <contrib/dev/acpica/include/accommon.h>
  155 #include <contrib/dev/acpica/include/acinterp.h>
  156 #include <contrib/dev/acpica/include/amlcode.h>
  157 #include <contrib/dev/acpica/include/acnamesp.h>
  158 
  159 
  160 #define _COMPONENT          ACPI_EXECUTER
  161         ACPI_MODULE_NAME    ("excreate")
  162 
  163 
  164 /*******************************************************************************
  165  *
  166  * FUNCTION:    AcpiExCreateAlias
  167  *
  168  * PARAMETERS:  WalkState            - Current state, contains operands
  169  *
  170  * RETURN:      Status
  171  *
  172  * DESCRIPTION: Create a new named alias
  173  *
  174  ******************************************************************************/
  175 
  176 ACPI_STATUS
  177 AcpiExCreateAlias (
  178     ACPI_WALK_STATE         *WalkState)
  179 {
  180     ACPI_NAMESPACE_NODE     *TargetNode;
  181     ACPI_NAMESPACE_NODE     *AliasNode;
  182     ACPI_STATUS             Status = AE_OK;
  183 
  184 
  185     ACPI_FUNCTION_TRACE (ExCreateAlias);
  186 
  187 
  188     /* Get the source/alias operands (both namespace nodes) */
  189 
  190     AliasNode =  (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
  191     TargetNode = (ACPI_NAMESPACE_NODE *) WalkState->Operands[1];
  192 
  193     if ((TargetNode->Type == ACPI_TYPE_LOCAL_ALIAS)  ||
  194         (TargetNode->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
  195     {
  196         /*
  197          * Dereference an existing alias so that we don't create a chain
  198          * of aliases. With this code, we guarantee that an alias is
  199          * always exactly one level of indirection away from the
  200          * actual aliased name.
  201          */
  202         TargetNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, TargetNode->Object);
  203     }
  204 
  205     /* Ensure that the target node is valid */
  206 
  207     if (!TargetNode)
  208     {
  209         return_ACPI_STATUS (AE_NULL_OBJECT);
  210     }
  211 
  212     /* Construct the alias object (a namespace node) */
  213 
  214     switch (TargetNode->Type)
  215     {
  216     case ACPI_TYPE_METHOD:
  217         /*
  218          * Control method aliases need to be differentiated with
  219          * a special type
  220          */
  221         AliasNode->Type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
  222         break;
  223 
  224     default:
  225         /*
  226          * All other object types.
  227          *
  228          * The new alias has the type ALIAS and points to the original
  229          * NS node, not the object itself.
  230          */
  231         AliasNode->Type = ACPI_TYPE_LOCAL_ALIAS;
  232         AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
  233         break;
  234     }
  235 
  236     /* Since both operands are Nodes, we don't need to delete them */
  237 
  238     AliasNode->Object = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, TargetNode);
  239     return_ACPI_STATUS (Status);
  240 }
  241 
  242 
  243 /*******************************************************************************
  244  *
  245  * FUNCTION:    AcpiExCreateEvent
  246  *
  247  * PARAMETERS:  WalkState           - Current state
  248  *
  249  * RETURN:      Status
  250  *
  251  * DESCRIPTION: Create a new event object
  252  *
  253  ******************************************************************************/
  254 
  255 ACPI_STATUS
  256 AcpiExCreateEvent (
  257     ACPI_WALK_STATE         *WalkState)
  258 {
  259     ACPI_STATUS             Status;
  260     ACPI_OPERAND_OBJECT     *ObjDesc;
  261 
  262 
  263     ACPI_FUNCTION_TRACE (ExCreateEvent);
  264 
  265 
  266     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_EVENT);
  267     if (!ObjDesc)
  268     {
  269         Status = AE_NO_MEMORY;
  270         goto Cleanup;
  271     }
  272 
  273     /*
  274      * Create the actual OS semaphore, with zero initial units -- meaning
  275      * that the event is created in an unsignalled state
  276      */
  277     Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0,
  278         &ObjDesc->Event.OsSemaphore);
  279     if (ACPI_FAILURE (Status))
  280     {
  281         goto Cleanup;
  282     }
  283 
  284     /* Attach object to the Node */
  285 
  286     Status = AcpiNsAttachObject (
  287         (ACPI_NAMESPACE_NODE *) WalkState->Operands[0],
  288         ObjDesc, ACPI_TYPE_EVENT);
  289 
  290 Cleanup:
  291     /*
  292      * Remove local reference to the object (on error, will cause deletion
  293      * of both object and semaphore if present.)
  294      */
  295     AcpiUtRemoveReference (ObjDesc);
  296     return_ACPI_STATUS (Status);
  297 }
  298 
  299 
  300 /*******************************************************************************
  301  *
  302  * FUNCTION:    AcpiExCreateMutex
  303  *
  304  * PARAMETERS:  WalkState           - Current state
  305  *
  306  * RETURN:      Status
  307  *
  308  * DESCRIPTION: Create a new mutex object
  309  *
  310  *              Mutex (Name[0], SyncLevel[1])
  311  *
  312  ******************************************************************************/
  313 
  314 ACPI_STATUS
  315 AcpiExCreateMutex (
  316     ACPI_WALK_STATE         *WalkState)
  317 {
  318     ACPI_STATUS             Status = AE_OK;
  319     ACPI_OPERAND_OBJECT     *ObjDesc;
  320 
  321 
  322     ACPI_FUNCTION_TRACE_PTR (ExCreateMutex, ACPI_WALK_OPERANDS);
  323 
  324 
  325     /* Create the new mutex object */
  326 
  327     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_MUTEX);
  328     if (!ObjDesc)
  329     {
  330         Status = AE_NO_MEMORY;
  331         goto Cleanup;
  332     }
  333 
  334     /* Create the actual OS Mutex */
  335 
  336     Status = AcpiOsCreateMutex (&ObjDesc->Mutex.OsMutex);
  337     if (ACPI_FAILURE (Status))
  338     {
  339         goto Cleanup;
  340     }
  341 
  342     /* Init object and attach to NS node */
  343 
  344     ObjDesc->Mutex.SyncLevel = (UINT8) WalkState->Operands[1]->Integer.Value;
  345     ObjDesc->Mutex.Node = (ACPI_NAMESPACE_NODE *) WalkState->Operands[0];
  346 
  347     Status = AcpiNsAttachObject (
  348         ObjDesc->Mutex.Node, ObjDesc, ACPI_TYPE_MUTEX);
  349 
  350 
  351 Cleanup:
  352     /*
  353      * Remove local reference to the object (on error, will cause deletion
  354      * of both object and semaphore if present.)
  355      */
  356     AcpiUtRemoveReference (ObjDesc);
  357     return_ACPI_STATUS (Status);
  358 }
  359 
  360 
  361 /*******************************************************************************
  362  *
  363  * FUNCTION:    AcpiExCreateRegion
  364  *
  365  * PARAMETERS:  AmlStart            - Pointer to the region declaration AML
  366  *              AmlLength           - Max length of the declaration AML
  367  *              SpaceId             - Address space ID for the region
  368  *              WalkState           - Current state
  369  *
  370  * RETURN:      Status
  371  *
  372  * DESCRIPTION: Create a new operation region object
  373  *
  374  ******************************************************************************/
  375 
  376 ACPI_STATUS
  377 AcpiExCreateRegion (
  378     UINT8                   *AmlStart,
  379     UINT32                  AmlLength,
  380     UINT8                   SpaceId,
  381     ACPI_WALK_STATE         *WalkState)
  382 {
  383     ACPI_STATUS             Status;
  384     ACPI_OPERAND_OBJECT     *ObjDesc;
  385     ACPI_NAMESPACE_NODE     *Node;
  386     ACPI_OPERAND_OBJECT     *RegionObj2;
  387 
  388 
  389     ACPI_FUNCTION_TRACE (ExCreateRegion);
  390 
  391 
  392     /* Get the Namespace Node */
  393 
  394     Node = WalkState->Op->Common.Node;
  395 
  396     /*
  397      * If the region object is already attached to this node,
  398      * just return
  399      */
  400     if (AcpiNsGetAttachedObject (Node))
  401     {
  402         return_ACPI_STATUS (AE_OK);
  403     }
  404 
  405     /*
  406      * Space ID must be one of the predefined IDs, or in the user-defined
  407      * range
  408      */
  409     if (!AcpiIsValidSpaceId (SpaceId))
  410     {
  411         /*
  412          * Print an error message, but continue. We don't want to abort
  413          * a table load for this exception. Instead, if the region is
  414          * actually used at runtime, abort the executing method.
  415          */
  416         ACPI_ERROR ((AE_INFO,
  417             "Invalid/unknown Address Space ID: 0x%2.2X", SpaceId));
  418     }
  419 
  420     ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
  421         AcpiUtGetRegionName (SpaceId), SpaceId));
  422 
  423     /* Create the region descriptor */
  424 
  425     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_REGION);
  426     if (!ObjDesc)
  427     {
  428         Status = AE_NO_MEMORY;
  429         goto Cleanup;
  430     }
  431 
  432     /*
  433      * Remember location in AML stream of address & length
  434      * operands since they need to be evaluated at run time.
  435      */
  436     RegionObj2 = AcpiNsGetSecondaryObject (ObjDesc);
  437     RegionObj2->Extra.AmlStart = AmlStart;
  438     RegionObj2->Extra.AmlLength = AmlLength;
  439     RegionObj2->Extra.Method_REG = NULL;
  440     if (WalkState->ScopeInfo)
  441     {
  442         RegionObj2->Extra.ScopeNode = WalkState->ScopeInfo->Scope.Node;
  443     }
  444     else
  445     {
  446         RegionObj2->Extra.ScopeNode = Node;
  447     }
  448 
  449     /* Init the region from the operands */
  450 
  451     ObjDesc->Region.SpaceId = SpaceId;
  452     ObjDesc->Region.Address = 0;
  453     ObjDesc->Region.Length = 0;
  454     ObjDesc->Region.Pointer = NULL;
  455     ObjDesc->Region.Node = Node;
  456     ObjDesc->Region.Handler = NULL;
  457     ObjDesc->Common.Flags &=
  458         ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
  459           AOPOBJ_OBJECT_INITIALIZED);
  460 
  461     /* Install the new region object in the parent Node */
  462 
  463     Status = AcpiNsAttachObject (Node, ObjDesc, ACPI_TYPE_REGION);
  464 
  465 
  466 Cleanup:
  467 
  468     /* Remove local reference to the object */
  469 
  470     AcpiUtRemoveReference (ObjDesc);
  471     return_ACPI_STATUS (Status);
  472 }
  473 
  474 
  475 /*******************************************************************************
  476  *
  477  * FUNCTION:    AcpiExCreateProcessor
  478  *
  479  * PARAMETERS:  WalkState           - Current state
  480  *
  481  * RETURN:      Status
  482  *
  483  * DESCRIPTION: Create a new processor object and populate the fields
  484  *
  485  *              Processor (Name[0], CpuID[1], PblockAddr[2], PblockLength[3])
  486  *
  487  ******************************************************************************/
  488 
  489 ACPI_STATUS
  490 AcpiExCreateProcessor (
  491     ACPI_WALK_STATE         *WalkState)
  492 {
  493     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
  494     ACPI_OPERAND_OBJECT     *ObjDesc;
  495     ACPI_STATUS             Status;
  496 
  497 
  498     ACPI_FUNCTION_TRACE_PTR (ExCreateProcessor, WalkState);
  499 
  500 
  501     /* Create the processor object */
  502 
  503     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_PROCESSOR);
  504     if (!ObjDesc)
  505     {
  506         return_ACPI_STATUS (AE_NO_MEMORY);
  507     }
  508 
  509     /* Initialize the processor object from the operands */
  510 
  511     ObjDesc->Processor.ProcId = (UINT8) Operand[1]->Integer.Value;
  512     ObjDesc->Processor.Length = (UINT8) Operand[3]->Integer.Value;
  513     ObjDesc->Processor.Address = (ACPI_IO_ADDRESS) Operand[2]->Integer.Value;
  514 
  515     /* Install the processor object in the parent Node */
  516 
  517     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
  518         ObjDesc, ACPI_TYPE_PROCESSOR);
  519 
  520     /* Remove local reference to the object */
  521 
  522     AcpiUtRemoveReference (ObjDesc);
  523     return_ACPI_STATUS (Status);
  524 }
  525 
  526 
  527 /*******************************************************************************
  528  *
  529  * FUNCTION:    AcpiExCreatePowerResource
  530  *
  531  * PARAMETERS:  WalkState           - Current state
  532  *
  533  * RETURN:      Status
  534  *
  535  * DESCRIPTION: Create a new PowerResource object and populate the fields
  536  *
  537  *              PowerResource (Name[0], SystemLevel[1], ResourceOrder[2])
  538  *
  539  ******************************************************************************/
  540 
  541 ACPI_STATUS
  542 AcpiExCreatePowerResource (
  543     ACPI_WALK_STATE         *WalkState)
  544 {
  545     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
  546     ACPI_STATUS             Status;
  547     ACPI_OPERAND_OBJECT     *ObjDesc;
  548 
  549 
  550     ACPI_FUNCTION_TRACE_PTR (ExCreatePowerResource, WalkState);
  551 
  552 
  553     /* Create the power resource object */
  554 
  555     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_POWER);
  556     if (!ObjDesc)
  557     {
  558         return_ACPI_STATUS (AE_NO_MEMORY);
  559     }
  560 
  561     /* Initialize the power object from the operands */
  562 
  563     ObjDesc->PowerResource.SystemLevel = (UINT8) Operand[1]->Integer.Value;
  564     ObjDesc->PowerResource.ResourceOrder = (UINT16) Operand[2]->Integer.Value;
  565 
  566     /* Install the  power resource object in the parent Node */
  567 
  568     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
  569         ObjDesc, ACPI_TYPE_POWER);
  570 
  571     /* Remove local reference to the object */
  572 
  573     AcpiUtRemoveReference (ObjDesc);
  574     return_ACPI_STATUS (Status);
  575 }
  576 
  577 
  578 /*******************************************************************************
  579  *
  580  * FUNCTION:    AcpiExCreateMethod
  581  *
  582  * PARAMETERS:  AmlStart        - First byte of the method's AML
  583  *              AmlLength       - AML byte count for this method
  584  *              WalkState       - Current state
  585  *
  586  * RETURN:      Status
  587  *
  588  * DESCRIPTION: Create a new method object
  589  *
  590  ******************************************************************************/
  591 
  592 ACPI_STATUS
  593 AcpiExCreateMethod (
  594     UINT8                   *AmlStart,
  595     UINT32                  AmlLength,
  596     ACPI_WALK_STATE         *WalkState)
  597 {
  598     ACPI_OPERAND_OBJECT     **Operand = &WalkState->Operands[0];
  599     ACPI_OPERAND_OBJECT     *ObjDesc;
  600     ACPI_STATUS             Status;
  601     UINT8                   MethodFlags;
  602 
  603 
  604     ACPI_FUNCTION_TRACE_PTR (ExCreateMethod, WalkState);
  605 
  606 
  607     /* Create a new method object */
  608 
  609     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_METHOD);
  610     if (!ObjDesc)
  611     {
  612        Status = AE_NO_MEMORY;
  613        goto Exit;
  614     }
  615 
  616     /* Save the method's AML pointer and length  */
  617 
  618     ObjDesc->Method.AmlStart = AmlStart;
  619     ObjDesc->Method.AmlLength = AmlLength;
  620     ObjDesc->Method.Node = Operand[0];
  621 
  622     /*
  623      * Disassemble the method flags. Split off the ArgCount, Serialized
  624      * flag, and SyncLevel for efficiency.
  625      */
  626     MethodFlags = (UINT8) Operand[1]->Integer.Value;
  627     ObjDesc->Method.ParamCount = (UINT8)
  628         (MethodFlags & AML_METHOD_ARG_COUNT);
  629 
  630     /*
  631      * Get the SyncLevel. If method is serialized, a mutex will be
  632      * created for this method when it is parsed.
  633      */
  634     if (MethodFlags & AML_METHOD_SERIALIZED)
  635     {
  636         ObjDesc->Method.InfoFlags = ACPI_METHOD_SERIALIZED;
  637 
  638         /*
  639          * ACPI 1.0: SyncLevel = 0
  640          * ACPI 2.0: SyncLevel = SyncLevel in method declaration
  641          */
  642         ObjDesc->Method.SyncLevel = (UINT8)
  643             ((MethodFlags & AML_METHOD_SYNC_LEVEL) >> 4);
  644     }
  645 
  646     /* Attach the new object to the method Node */
  647 
  648     Status = AcpiNsAttachObject ((ACPI_NAMESPACE_NODE *) Operand[0],
  649         ObjDesc, ACPI_TYPE_METHOD);
  650 
  651     /* Remove local reference to the object */
  652 
  653     AcpiUtRemoveReference (ObjDesc);
  654 
  655 Exit:
  656     /* Remove a reference to the operand */
  657 
  658     AcpiUtRemoveReference (Operand[1]);
  659     return_ACPI_STATUS (Status);
  660 }

Cache object: f076e6b2018d77e05835156c214eb023


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.