Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenutstate.c
Go to the documentation of this file.
00001 /******************************************************************************* 00002 * 00003 * Module Name: utstate - state object support procedures 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 #define __UTSTATE_C__ 00118 00119 #include "acpi.h" 00120 #include "accommon.h" 00121 00122 #define _COMPONENT ACPI_UTILITIES 00123 ACPI_MODULE_NAME ("utstate") 00124 00125 00126 /******************************************************************************* 00127 * 00128 * FUNCTION: AcpiUtCreatePkgStateAndPush 00129 * 00130 * PARAMETERS: Object - Object to be added to the new state 00131 * Action - Increment/Decrement 00132 * StateList - List the state will be added to 00133 * 00134 * RETURN: Status 00135 * 00136 * DESCRIPTION: Create a new state and push it 00137 * 00138 ******************************************************************************/ 00139 00140 ACPI_STATUS 00141 AcpiUtCreatePkgStateAndPush ( 00142 void *InternalObject, 00143 void *ExternalObject, 00144 UINT16 Index, 00145 ACPI_GENERIC_STATE **StateList) 00146 { 00147 ACPI_GENERIC_STATE *State; 00148 00149 00150 ACPI_FUNCTION_ENTRY (); 00151 00152 00153 State = AcpiUtCreatePkgState (InternalObject, ExternalObject, Index); 00154 if (!State) 00155 { 00156 return (AE_NO_MEMORY); 00157 } 00158 00159 AcpiUtPushGenericState (StateList, State); 00160 return (AE_OK); 00161 } 00162 00163 00164 /******************************************************************************* 00165 * 00166 * FUNCTION: AcpiUtPushGenericState 00167 * 00168 * PARAMETERS: ListHead - Head of the state stack 00169 * State - State object to push 00170 * 00171 * RETURN: None 00172 * 00173 * DESCRIPTION: Push a state object onto a state stack 00174 * 00175 ******************************************************************************/ 00176 00177 void 00178 AcpiUtPushGenericState ( 00179 ACPI_GENERIC_STATE **ListHead, 00180 ACPI_GENERIC_STATE *State) 00181 { 00182 ACPI_FUNCTION_TRACE (UtPushGenericState); 00183 00184 00185 /* Push the state object onto the front of the list (stack) */ 00186 00187 State->Common.Next = *ListHead; 00188 *ListHead = State; 00189 00190 return_VOID; 00191 } 00192 00193 00194 /******************************************************************************* 00195 * 00196 * FUNCTION: AcpiUtPopGenericState 00197 * 00198 * PARAMETERS: ListHead - Head of the state stack 00199 * 00200 * RETURN: The popped state object 00201 * 00202 * DESCRIPTION: Pop a state object from a state stack 00203 * 00204 ******************************************************************************/ 00205 00206 ACPI_GENERIC_STATE * 00207 AcpiUtPopGenericState ( 00208 ACPI_GENERIC_STATE **ListHead) 00209 { 00210 ACPI_GENERIC_STATE *State; 00211 00212 00213 ACPI_FUNCTION_TRACE (UtPopGenericState); 00214 00215 00216 /* Remove the state object at the head of the list (stack) */ 00217 00218 State = *ListHead; 00219 if (State) 00220 { 00221 /* Update the list head */ 00222 00223 *ListHead = State->Common.Next; 00224 } 00225 00226 return_PTR (State); 00227 } 00228 00229 00230 /******************************************************************************* 00231 * 00232 * FUNCTION: AcpiUtCreateGenericState 00233 * 00234 * PARAMETERS: None 00235 * 00236 * RETURN: The new state object. NULL on failure. 00237 * 00238 * DESCRIPTION: Create a generic state object. Attempt to obtain one from 00239 * the global state cache; If none available, create a new one. 00240 * 00241 ******************************************************************************/ 00242 00243 ACPI_GENERIC_STATE * 00244 AcpiUtCreateGenericState ( 00245 void) 00246 { 00247 ACPI_GENERIC_STATE *State; 00248 00249 00250 ACPI_FUNCTION_ENTRY (); 00251 00252 00253 State = AcpiOsAcquireObject (AcpiGbl_StateCache); 00254 if (State) 00255 { 00256 /* Initialize */ 00257 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE; 00258 } 00259 00260 return (State); 00261 } 00262 00263 00264 /******************************************************************************* 00265 * 00266 * FUNCTION: AcpiUtCreateThreadState 00267 * 00268 * PARAMETERS: None 00269 * 00270 * RETURN: New Thread State. NULL on failure 00271 * 00272 * DESCRIPTION: Create a "Thread State" - a flavor of the generic state used 00273 * to track per-thread info during method execution 00274 * 00275 ******************************************************************************/ 00276 00277 ACPI_THREAD_STATE * 00278 AcpiUtCreateThreadState ( 00279 void) 00280 { 00281 ACPI_GENERIC_STATE *State; 00282 00283 00284 ACPI_FUNCTION_TRACE (UtCreateThreadState); 00285 00286 00287 /* Create the generic state object */ 00288 00289 State = AcpiUtCreateGenericState (); 00290 if (!State) 00291 { 00292 return_PTR (NULL); 00293 } 00294 00295 /* Init fields specific to the update struct */ 00296 00297 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_THREAD; 00298 State->Thread.ThreadId = AcpiOsGetThreadId (); 00299 00300 /* Check for invalid thread ID - zero is very bad, it will break things */ 00301 00302 if (!State->Thread.ThreadId) 00303 { 00304 ACPI_ERROR ((AE_INFO, "Invalid zero ID from AcpiOsGetThreadId")); 00305 State->Thread.ThreadId = (ACPI_THREAD_ID) 1; 00306 } 00307 00308 return_PTR ((ACPI_THREAD_STATE *) State); 00309 } 00310 00311 00312 /******************************************************************************* 00313 * 00314 * FUNCTION: AcpiUtCreateUpdateState 00315 * 00316 * PARAMETERS: Object - Initial Object to be installed in the state 00317 * Action - Update action to be performed 00318 * 00319 * RETURN: New state object, null on failure 00320 * 00321 * DESCRIPTION: Create an "Update State" - a flavor of the generic state used 00322 * to update reference counts and delete complex objects such 00323 * as packages. 00324 * 00325 ******************************************************************************/ 00326 00327 ACPI_GENERIC_STATE * 00328 AcpiUtCreateUpdateState ( 00329 ACPI_OPERAND_OBJECT *Object, 00330 UINT16 Action) 00331 { 00332 ACPI_GENERIC_STATE *State; 00333 00334 00335 ACPI_FUNCTION_TRACE_PTR (UtCreateUpdateState, Object); 00336 00337 00338 /* Create the generic state object */ 00339 00340 State = AcpiUtCreateGenericState (); 00341 if (!State) 00342 { 00343 return_PTR (NULL); 00344 } 00345 00346 /* Init fields specific to the update struct */ 00347 00348 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_UPDATE; 00349 State->Update.Object = Object; 00350 State->Update.Value = Action; 00351 00352 return_PTR (State); 00353 } 00354 00355 00356 /******************************************************************************* 00357 * 00358 * FUNCTION: AcpiUtCreatePkgState 00359 * 00360 * PARAMETERS: Object - Initial Object to be installed in the state 00361 * Action - Update action to be performed 00362 * 00363 * RETURN: New state object, null on failure 00364 * 00365 * DESCRIPTION: Create a "Package State" 00366 * 00367 ******************************************************************************/ 00368 00369 ACPI_GENERIC_STATE * 00370 AcpiUtCreatePkgState ( 00371 void *InternalObject, 00372 void *ExternalObject, 00373 UINT16 Index) 00374 { 00375 ACPI_GENERIC_STATE *State; 00376 00377 00378 ACPI_FUNCTION_TRACE_PTR (UtCreatePkgState, InternalObject); 00379 00380 00381 /* Create the generic state object */ 00382 00383 State = AcpiUtCreateGenericState (); 00384 if (!State) 00385 { 00386 return_PTR (NULL); 00387 } 00388 00389 /* Init fields specific to the update struct */ 00390 00391 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_PACKAGE; 00392 State->Pkg.SourceObject = (ACPI_OPERAND_OBJECT *) InternalObject; 00393 State->Pkg.DestObject = ExternalObject; 00394 State->Pkg.Index= Index; 00395 State->Pkg.NumPackages = 1; 00396 00397 return_PTR (State); 00398 } 00399 00400 00401 /******************************************************************************* 00402 * 00403 * FUNCTION: AcpiUtCreateControlState 00404 * 00405 * PARAMETERS: None 00406 * 00407 * RETURN: New state object, null on failure 00408 * 00409 * DESCRIPTION: Create a "Control State" - a flavor of the generic state used 00410 * to support nested IF/WHILE constructs in the AML. 00411 * 00412 ******************************************************************************/ 00413 00414 ACPI_GENERIC_STATE * 00415 AcpiUtCreateControlState ( 00416 void) 00417 { 00418 ACPI_GENERIC_STATE *State; 00419 00420 00421 ACPI_FUNCTION_TRACE (UtCreateControlState); 00422 00423 00424 /* Create the generic state object */ 00425 00426 State = AcpiUtCreateGenericState (); 00427 if (!State) 00428 { 00429 return_PTR (NULL); 00430 } 00431 00432 /* Init fields specific to the control struct */ 00433 00434 State->Common.DescriptorType = ACPI_DESC_TYPE_STATE_CONTROL; 00435 State->Common.State = ACPI_CONTROL_CONDITIONAL_EXECUTING; 00436 00437 return_PTR (State); 00438 } 00439 00440 00441 /******************************************************************************* 00442 * 00443 * FUNCTION: AcpiUtDeleteGenericState 00444 * 00445 * PARAMETERS: State - The state object to be deleted 00446 * 00447 * RETURN: None 00448 * 00449 * DESCRIPTION: Release a state object to the state cache. NULL state objects 00450 * are ignored. 00451 * 00452 ******************************************************************************/ 00453 00454 void 00455 AcpiUtDeleteGenericState ( 00456 ACPI_GENERIC_STATE *State) 00457 { 00458 ACPI_FUNCTION_TRACE (UtDeleteGenericState); 00459 00460 00461 /* Ignore null state */ 00462 00463 if (State) 00464 { 00465 (void) AcpiOsReleaseObject (AcpiGbl_StateCache, State); 00466 } 00467 return_VOID; 00468 } 00469 00470 Generated on Sun May 27 2012 04:27:24 for ReactOS by
1.7.6.1
|