Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpsscope.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: psscope - Parser scope stack management routines 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 00117 #include "acpi.h" 00118 #include "accommon.h" 00119 #include "acparser.h" 00120 00121 #define _COMPONENT ACPI_PARSER 00122 ACPI_MODULE_NAME ("psscope") 00123 00124 00125 /******************************************************************************* 00126 * 00127 * FUNCTION: AcpiPsGetParentScope 00128 * 00129 * PARAMETERS: ParserState - Current parser state object 00130 * 00131 * RETURN: Pointer to an Op object 00132 * 00133 * DESCRIPTION: Get parent of current op being parsed 00134 * 00135 ******************************************************************************/ 00136 00137 ACPI_PARSE_OBJECT * 00138 AcpiPsGetParentScope ( 00139 ACPI_PARSE_STATE *ParserState) 00140 { 00141 00142 return (ParserState->Scope->ParseScope.Op); 00143 } 00144 00145 00146 /******************************************************************************* 00147 * 00148 * FUNCTION: AcpiPsHasCompletedScope 00149 * 00150 * PARAMETERS: ParserState - Current parser state object 00151 * 00152 * RETURN: Boolean, TRUE = scope completed. 00153 * 00154 * DESCRIPTION: Is parsing of current argument complete? Determined by 00155 * 1) AML pointer is at or beyond the end of the scope 00156 * 2) The scope argument count has reached zero. 00157 * 00158 ******************************************************************************/ 00159 00160 BOOLEAN 00161 AcpiPsHasCompletedScope ( 00162 ACPI_PARSE_STATE *ParserState) 00163 { 00164 00165 return ((BOOLEAN) 00166 ((ParserState->Aml >= ParserState->Scope->ParseScope.ArgEnd || 00167 !ParserState->Scope->ParseScope.ArgCount))); 00168 } 00169 00170 00171 /******************************************************************************* 00172 * 00173 * FUNCTION: AcpiPsInitScope 00174 * 00175 * PARAMETERS: ParserState - Current parser state object 00176 * Root - the Root Node of this new scope 00177 * 00178 * RETURN: Status 00179 * 00180 * DESCRIPTION: Allocate and init a new scope object 00181 * 00182 ******************************************************************************/ 00183 00184 ACPI_STATUS 00185 AcpiPsInitScope ( 00186 ACPI_PARSE_STATE *ParserState, 00187 ACPI_PARSE_OBJECT *RootOp) 00188 { 00189 ACPI_GENERIC_STATE *Scope; 00190 00191 00192 ACPI_FUNCTION_TRACE_PTR (PsInitScope, RootOp); 00193 00194 00195 Scope = AcpiUtCreateGenericState (); 00196 if (!Scope) 00197 { 00198 return_ACPI_STATUS (AE_NO_MEMORY); 00199 } 00200 00201 Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_RPSCOPE; 00202 Scope->ParseScope.Op = RootOp; 00203 Scope->ParseScope.ArgCount = ACPI_VAR_ARGS; 00204 Scope->ParseScope.ArgEnd = ParserState->AmlEnd; 00205 Scope->ParseScope.PkgEnd = ParserState->AmlEnd; 00206 00207 ParserState->Scope = Scope; 00208 ParserState->StartOp = RootOp; 00209 00210 return_ACPI_STATUS (AE_OK); 00211 } 00212 00213 00214 /******************************************************************************* 00215 * 00216 * FUNCTION: AcpiPsPushScope 00217 * 00218 * PARAMETERS: ParserState - Current parser state object 00219 * Op - Current op to be pushed 00220 * RemainingArgs - List of args remaining 00221 * ArgCount - Fixed or variable number of args 00222 * 00223 * RETURN: Status 00224 * 00225 * DESCRIPTION: Push current op to begin parsing its argument 00226 * 00227 ******************************************************************************/ 00228 00229 ACPI_STATUS 00230 AcpiPsPushScope ( 00231 ACPI_PARSE_STATE *ParserState, 00232 ACPI_PARSE_OBJECT *Op, 00233 UINT32 RemainingArgs, 00234 UINT32 ArgCount) 00235 { 00236 ACPI_GENERIC_STATE *Scope; 00237 00238 00239 ACPI_FUNCTION_TRACE_PTR (PsPushScope, Op); 00240 00241 00242 Scope = AcpiUtCreateGenericState (); 00243 if (!Scope) 00244 { 00245 return_ACPI_STATUS (AE_NO_MEMORY); 00246 } 00247 00248 Scope->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PSCOPE; 00249 Scope->ParseScope.Op = Op; 00250 Scope->ParseScope.ArgList = RemainingArgs; 00251 Scope->ParseScope.ArgCount = ArgCount; 00252 Scope->ParseScope.PkgEnd = ParserState->PkgEnd; 00253 00254 /* Push onto scope stack */ 00255 00256 AcpiUtPushGenericState (&ParserState->Scope, Scope); 00257 00258 if (ArgCount == ACPI_VAR_ARGS) 00259 { 00260 /* Multiple arguments */ 00261 00262 Scope->ParseScope.ArgEnd = ParserState->PkgEnd; 00263 } 00264 else 00265 { 00266 /* Single argument */ 00267 00268 Scope->ParseScope.ArgEnd = ACPI_TO_POINTER (ACPI_MAX_PTR); 00269 } 00270 00271 return_ACPI_STATUS (AE_OK); 00272 } 00273 00274 00275 /******************************************************************************* 00276 * 00277 * FUNCTION: AcpiPsPopScope 00278 * 00279 * PARAMETERS: ParserState - Current parser state object 00280 * Op - Where the popped op is returned 00281 * ArgList - Where the popped "next argument" is 00282 * returned 00283 * ArgCount - Count of objects in ArgList 00284 * 00285 * RETURN: Status 00286 * 00287 * DESCRIPTION: Return to parsing a previous op 00288 * 00289 ******************************************************************************/ 00290 00291 void 00292 AcpiPsPopScope ( 00293 ACPI_PARSE_STATE *ParserState, 00294 ACPI_PARSE_OBJECT **Op, 00295 UINT32 *ArgList, 00296 UINT32 *ArgCount) 00297 { 00298 ACPI_GENERIC_STATE *Scope = ParserState->Scope; 00299 00300 00301 ACPI_FUNCTION_TRACE (PsPopScope); 00302 00303 00304 /* Only pop the scope if there is in fact a next scope */ 00305 00306 if (Scope->Common.Next) 00307 { 00308 Scope = AcpiUtPopGenericState (&ParserState->Scope); 00309 00310 /* Return to parsing previous op */ 00311 00312 *Op = Scope->ParseScope.Op; 00313 *ArgList = Scope->ParseScope.ArgList; 00314 *ArgCount = Scope->ParseScope.ArgCount; 00315 ParserState->PkgEnd = Scope->ParseScope.PkgEnd; 00316 00317 /* All done with this scope state structure */ 00318 00319 AcpiUtDeleteGenericState (Scope); 00320 } 00321 else 00322 { 00323 /* Empty parse stack, prepare to fetch next opcode */ 00324 00325 *Op = NULL; 00326 *ArgList = 0; 00327 *ArgCount = 0; 00328 } 00329 00330 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 00331 "Popped Op %p Args %X\n", *Op, *ArgCount)); 00332 return_VOID; 00333 } 00334 00335 00336 /******************************************************************************* 00337 * 00338 * FUNCTION: AcpiPsCleanupScope 00339 * 00340 * PARAMETERS: ParserState - Current parser state object 00341 * 00342 * RETURN: None 00343 * 00344 * DESCRIPTION: Destroy available list, remaining stack levels, and return 00345 * root scope 00346 * 00347 ******************************************************************************/ 00348 00349 void 00350 AcpiPsCleanupScope ( 00351 ACPI_PARSE_STATE *ParserState) 00352 { 00353 ACPI_GENERIC_STATE *Scope; 00354 00355 00356 ACPI_FUNCTION_TRACE_PTR (PsCleanupScope, ParserState); 00357 00358 00359 if (!ParserState) 00360 { 00361 return_VOID; 00362 } 00363 00364 /* Delete anything on the scope stack */ 00365 00366 while (ParserState->Scope) 00367 { 00368 Scope = AcpiUtPopGenericState (&ParserState->Scope); 00369 AcpiUtDeleteGenericState (Scope); 00370 } 00371 00372 return_VOID; 00373 } 00374 Generated on Sat May 26 2012 04:25:55 for ReactOS by
1.7.6.1
|