ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

psxface.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: psxface - Parser external interfaces
00004  *
00005  *****************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 #define __PSXFACE_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "acparser.h"
00121 #include "acdispat.h"
00122 #include "acinterp.h"
00123 #include "actables.h"
00124 
00125 
00126 #define _COMPONENT          ACPI_PARSER
00127         ACPI_MODULE_NAME    ("psxface")
00128 
00129 /* Local Prototypes */
00130 
00131 static void
00132 AcpiPsStartTrace (
00133     ACPI_EVALUATE_INFO      *Info);
00134 
00135 static void
00136 AcpiPsStopTrace (
00137     ACPI_EVALUATE_INFO      *Info);
00138 
00139 static void
00140 AcpiPsUpdateParameterList (
00141     ACPI_EVALUATE_INFO      *Info,
00142     UINT16                  Action);
00143 
00144 
00145 /*******************************************************************************
00146  *
00147  * FUNCTION:    AcpiDebugTrace
00148  *
00149  * PARAMETERS:  MethodName      - Valid ACPI name string
00150  *              DebugLevel      - Optional level mask. 0 to use default
00151  *              DebugLayer      - Optional layer mask. 0 to use default
00152  *              Flags           - bit 1: one shot(1) or persistent(0)
00153  *
00154  * RETURN:      Status
00155  *
00156  * DESCRIPTION: External interface to enable debug tracing during control
00157  *              method execution
00158  *
00159  ******************************************************************************/
00160 
00161 ACPI_STATUS
00162 AcpiDebugTrace (
00163     char                    *Name,
00164     UINT32                  DebugLevel,
00165     UINT32                  DebugLayer,
00166     UINT32                  Flags)
00167 {
00168     ACPI_STATUS             Status;
00169 
00170 
00171     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00172     if (ACPI_FAILURE (Status))
00173     {
00174         return (Status);
00175     }
00176 
00177     /* TBDs: Validate name, allow full path or just nameseg */
00178 
00179     AcpiGbl_TraceMethodName = *ACPI_CAST_PTR (UINT32, Name);
00180     AcpiGbl_TraceFlags = Flags;
00181 
00182     if (DebugLevel)
00183     {
00184         AcpiGbl_TraceDbgLevel = DebugLevel;
00185     }
00186     if (DebugLayer)
00187     {
00188         AcpiGbl_TraceDbgLayer = DebugLayer;
00189     }
00190 
00191     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00192     return (AE_OK);
00193 }
00194 
00195 
00196 /*******************************************************************************
00197  *
00198  * FUNCTION:    AcpiPsStartTrace
00199  *
00200  * PARAMETERS:  Info        - Method info struct
00201  *
00202  * RETURN:      None
00203  *
00204  * DESCRIPTION: Start control method execution trace
00205  *
00206  ******************************************************************************/
00207 
00208 static void
00209 AcpiPsStartTrace (
00210     ACPI_EVALUATE_INFO      *Info)
00211 {
00212     ACPI_STATUS             Status;
00213 
00214 
00215     ACPI_FUNCTION_ENTRY ();
00216 
00217 
00218     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00219     if (ACPI_FAILURE (Status))
00220     {
00221         return;
00222     }
00223 
00224     if ((!AcpiGbl_TraceMethodName) ||
00225         (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
00226     {
00227         goto Exit;
00228     }
00229 
00230     AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
00231     AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
00232 
00233     AcpiDbgLevel = 0x00FFFFFF;
00234     AcpiDbgLayer = ACPI_UINT32_MAX;
00235 
00236     if (AcpiGbl_TraceDbgLevel)
00237     {
00238         AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
00239     }
00240     if (AcpiGbl_TraceDbgLayer)
00241     {
00242         AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
00243     }
00244 
00245 
00246 Exit:
00247     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00248 }
00249 
00250 
00251 /*******************************************************************************
00252  *
00253  * FUNCTION:    AcpiPsStopTrace
00254  *
00255  * PARAMETERS:  Info        - Method info struct
00256  *
00257  * RETURN:      None
00258  *
00259  * DESCRIPTION: Stop control method execution trace
00260  *
00261  ******************************************************************************/
00262 
00263 static void
00264 AcpiPsStopTrace (
00265     ACPI_EVALUATE_INFO      *Info)
00266 {
00267     ACPI_STATUS             Status;
00268 
00269 
00270     ACPI_FUNCTION_ENTRY ();
00271 
00272 
00273     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
00274     if (ACPI_FAILURE (Status))
00275     {
00276         return;
00277     }
00278 
00279     if ((!AcpiGbl_TraceMethodName) ||
00280         (AcpiGbl_TraceMethodName != Info->ResolvedNode->Name.Integer))
00281     {
00282         goto Exit;
00283     }
00284 
00285     /* Disable further tracing if type is one-shot */
00286 
00287     if (AcpiGbl_TraceFlags & 1)
00288     {
00289         AcpiGbl_TraceMethodName = 0;
00290         AcpiGbl_TraceDbgLevel = 0;
00291         AcpiGbl_TraceDbgLayer = 0;
00292     }
00293 
00294     AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
00295     AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
00296 
00297 Exit:
00298     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
00299 }
00300 
00301 
00302 /*******************************************************************************
00303  *
00304  * FUNCTION:    AcpiPsExecuteMethod
00305  *
00306  * PARAMETERS:  Info            - Method info block, contains:
00307  *                  Node            - Method Node to execute
00308  *                  ObjDesc         - Method object
00309  *                  Parameters      - List of parameters to pass to the method,
00310  *                                    terminated by NULL. Params itself may be
00311  *                                    NULL if no parameters are being passed.
00312  *                  ReturnObject    - Where to put method's return value (if
00313  *                                    any). If NULL, no value is returned.
00314  *                  ParameterType   - Type of Parameter list
00315  *                  ReturnObject    - Where to put method's return value (if
00316  *                                    any). If NULL, no value is returned.
00317  *                  PassNumber      - Parse or execute pass
00318  *
00319  * RETURN:      Status
00320  *
00321  * DESCRIPTION: Execute a control method
00322  *
00323  ******************************************************************************/
00324 
00325 ACPI_STATUS
00326 AcpiPsExecuteMethod (
00327     ACPI_EVALUATE_INFO      *Info)
00328 {
00329     ACPI_STATUS             Status;
00330     ACPI_PARSE_OBJECT       *Op;
00331     ACPI_WALK_STATE         *WalkState;
00332 
00333 
00334     ACPI_FUNCTION_TRACE (PsExecuteMethod);
00335 
00336 
00337     /* Quick validation of DSDT header */
00338 
00339     AcpiTbCheckDsdtHeader ();
00340 
00341     /* Validate the Info and method Node */
00342 
00343     if (!Info || !Info->ResolvedNode)
00344     {
00345         return_ACPI_STATUS (AE_NULL_ENTRY);
00346     }
00347 
00348     /* Init for new method, wait on concurrency semaphore */
00349 
00350     Status = AcpiDsBeginMethodExecution (Info->ResolvedNode, Info->ObjDesc, NULL);
00351     if (ACPI_FAILURE (Status))
00352     {
00353         return_ACPI_STATUS (Status);
00354     }
00355 
00356     /*
00357      * The caller "owns" the parameters, so give each one an extra reference
00358      */
00359     AcpiPsUpdateParameterList (Info, REF_INCREMENT);
00360 
00361     /* Begin tracing if requested */
00362 
00363     AcpiPsStartTrace (Info);
00364 
00365     /*
00366      * Execute the method. Performs parse simultaneously
00367      */
00368     ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
00369         "**** Begin Method Parse/Execute [%4.4s] **** Node=%p Obj=%p\n",
00370         Info->ResolvedNode->Name.Ascii, Info->ResolvedNode, Info->ObjDesc));
00371 
00372     /* Create and init a Root Node */
00373 
00374     Op = AcpiPsCreateScopeOp ();
00375     if (!Op)
00376     {
00377         Status = AE_NO_MEMORY;
00378         goto Cleanup;
00379     }
00380 
00381     /* Create and initialize a new walk state */
00382 
00383     Info->PassNumber = ACPI_IMODE_EXECUTE;
00384     WalkState = AcpiDsCreateWalkState (
00385                     Info->ObjDesc->Method.OwnerId, NULL, NULL, NULL);
00386     if (!WalkState)
00387     {
00388         Status = AE_NO_MEMORY;
00389         goto Cleanup;
00390     }
00391 
00392     Status = AcpiDsInitAmlWalk (WalkState, Op, Info->ResolvedNode,
00393                 Info->ObjDesc->Method.AmlStart,
00394                 Info->ObjDesc->Method.AmlLength, Info, Info->PassNumber);
00395     if (ACPI_FAILURE (Status))
00396     {
00397         AcpiDsDeleteWalkState (WalkState);
00398         goto Cleanup;
00399     }
00400 
00401     if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_MODULE_LEVEL)
00402     {
00403         WalkState->ParseFlags |= ACPI_PARSE_MODULE_LEVEL;
00404     }
00405 
00406     /* Invoke an internal method if necessary */
00407 
00408     if (Info->ObjDesc->Method.InfoFlags & ACPI_METHOD_INTERNAL_ONLY)
00409     {
00410         Status = Info->ObjDesc->Method.Dispatch.Implementation (WalkState);
00411         Info->ReturnObject = WalkState->ReturnDesc;
00412 
00413         /* Cleanup states */
00414 
00415         AcpiDsScopeStackClear (WalkState);
00416         AcpiPsCleanupScope (&WalkState->ParserState);
00417         AcpiDsTerminateControlMethod (WalkState->MethodDesc, WalkState);
00418         AcpiDsDeleteWalkState (WalkState);
00419         goto Cleanup;
00420     }
00421 
00422     /*
00423      * Start method evaluation with an implicit return of zero. This is done
00424      * for Windows compatibility.
00425      */
00426     if (AcpiGbl_EnableInterpreterSlack)
00427     {
00428         WalkState->ImplicitReturnObj =
00429             AcpiUtCreateIntegerObject ((UINT64) 0);
00430         if (!WalkState->ImplicitReturnObj)
00431         {
00432             Status = AE_NO_MEMORY;
00433             AcpiDsDeleteWalkState (WalkState);
00434             goto Cleanup;
00435         }
00436     }
00437 
00438     /* Parse the AML */
00439 
00440     Status = AcpiPsParseAml (WalkState);
00441 
00442     /* WalkState was deleted by ParseAml */
00443 
00444 Cleanup:
00445     AcpiPsDeleteParseTree (Op);
00446 
00447     /* End optional tracing */
00448 
00449     AcpiPsStopTrace (Info);
00450 
00451     /* Take away the extra reference that we gave the parameters above */
00452 
00453     AcpiPsUpdateParameterList (Info, REF_DECREMENT);
00454 
00455     /* Exit now if error above */
00456 
00457     if (ACPI_FAILURE (Status))
00458     {
00459         return_ACPI_STATUS (Status);
00460     }
00461 
00462     /*
00463      * If the method has returned an object, signal this to the caller with
00464      * a control exception code
00465      */
00466     if (Info->ReturnObject)
00467     {
00468         ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned ObjDesc=%p\n",
00469             Info->ReturnObject));
00470         ACPI_DUMP_STACK_ENTRY (Info->ReturnObject);
00471 
00472         Status = AE_CTRL_RETURN_VALUE;
00473     }
00474 
00475     return_ACPI_STATUS (Status);
00476 }
00477 
00478 
00479 /*******************************************************************************
00480  *
00481  * FUNCTION:    AcpiPsUpdateParameterList
00482  *
00483  * PARAMETERS:  Info            - See ACPI_EVALUATE_INFO
00484  *                                (Used: ParameterType and Parameters)
00485  *              Action          - Add or Remove reference
00486  *
00487  * RETURN:      Status
00488  *
00489  * DESCRIPTION: Update reference count on all method parameter objects
00490  *
00491  ******************************************************************************/
00492 
00493 static void
00494 AcpiPsUpdateParameterList (
00495     ACPI_EVALUATE_INFO      *Info,
00496     UINT16                  Action)
00497 {
00498     UINT32                  i;
00499 
00500 
00501     if (Info->Parameters)
00502     {
00503         /* Update reference count for each parameter */
00504 
00505         for (i = 0; Info->Parameters[i]; i++)
00506         {
00507             /* Ignore errors, just do them all */
00508 
00509             (void) AcpiUtUpdateObjectReference (Info->Parameters[i], Action);
00510         }
00511     }
00512 }
00513 
00514 

Generated on Fri May 25 2012 04:25:39 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.