Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenexsystem.c
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * 00004 * Module Name: exsystem - Interface to OS services 00005 * 00006 *****************************************************************************/ 00007 00008 /****************************************************************************** 00009 * 00010 * 1. Copyright Notice 00011 * 00012 * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. 00013 * All rights reserved. 00014 * 00015 * 2. License 00016 * 00017 * 2.1. This is your license from Intel Corp. under its intellectual property 00018 * rights. You may have additional license terms from the party that provided 00019 * you this software, covering your right to use that party's intellectual 00020 * property rights. 00021 * 00022 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 00023 * copy of the source code appearing in this file ("Covered Code") an 00024 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 00025 * base code distributed originally by Intel ("Original Intel Code") to copy, 00026 * make derivatives, distribute, use and display any portion of the Covered 00027 * Code in any form, with the right to sublicense such rights; and 00028 * 00029 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 00030 * license (with the right to sublicense), under only those claims of Intel 00031 * patents that are infringed by the Original Intel Code, to make, use, sell, 00032 * offer to sell, and import the Covered Code and derivative works thereof 00033 * solely to the minimum extent necessary to exercise the above copyright 00034 * license, and in no event shall the patent license extend to any additions 00035 * to or modifications of the Original Intel Code. No other license or right 00036 * is granted directly or by implication, estoppel or otherwise; 00037 * 00038 * The above copyright and patent license is granted only if the following 00039 * conditions are met: 00040 * 00041 * 3. Conditions 00042 * 00043 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 00044 * Redistribution of source code of any substantial portion of the Covered 00045 * Code or modification with rights to further distribute source must include 00046 * the above Copyright Notice, the above License, this list of Conditions, 00047 * and the following Disclaimer and Export Compliance provision. In addition, 00048 * Licensee must cause all Covered Code to which Licensee contributes to 00049 * contain a file documenting the changes Licensee made to create that Covered 00050 * Code and the date of any change. Licensee must include in that file the 00051 * documentation of any changes made by any predecessor Licensee. Licensee 00052 * must include a prominent statement that the modification is derived, 00053 * directly or indirectly, from Original Intel Code. 00054 * 00055 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 00056 * Redistribution of source code of any substantial portion of the Covered 00057 * Code or modification without rights to further distribute source must 00058 * include the following Disclaimer and Export Compliance provision in the 00059 * documentation and/or other materials provided with distribution. In 00060 * addition, Licensee may not authorize further sublicense of source of any 00061 * portion of the Covered Code, and must include terms to the effect that the 00062 * license from Licensee to its licensee is limited to the intellectual 00063 * property embodied in the software Licensee provides to its licensee, and 00064 * not to intellectual property embodied in modifications its licensee may 00065 * make. 00066 * 00067 * 3.3. Redistribution of Executable. Redistribution in executable form of any 00068 * substantial portion of the Covered Code or modification must reproduce the 00069 * above Copyright Notice, and the following Disclaimer and Export Compliance 00070 * provision in the documentation and/or other materials provided with the 00071 * distribution. 00072 * 00073 * 3.4. Intel retains all right, title, and interest in and to the Original 00074 * Intel Code. 00075 * 00076 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 00077 * Intel shall be used in advertising or otherwise to promote the sale, use or 00078 * other dealings in products derived from or relating to the Covered Code 00079 * without prior written authorization from Intel. 00080 * 00081 * 4. Disclaimer and Export Compliance 00082 * 00083 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 00084 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 00085 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 00086 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 00087 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 00088 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 00089 * PARTICULAR PURPOSE. 00090 * 00091 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 00092 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 00093 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 00094 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 00095 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 00096 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 00097 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 00098 * LIMITED REMEDY. 00099 * 00100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 00101 * software or system incorporating such software without first obtaining any 00102 * required license or other approval from the U. S. Department of Commerce or 00103 * any other agency or department of the United States Government. In the 00104 * event Licensee exports any such software from the United States or 00105 * re-exports any such software from a foreign destination, Licensee shall 00106 * ensure that the distribution and export/re-export of the software is in 00107 * compliance with all laws, regulations, orders, or other restrictions of the 00108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 00109 * any of its subsidiaries will export/re-export any technical data, process, 00110 * software, or service, directly or indirectly, to any country for which the 00111 * United States government or any agency thereof requires an export license, 00112 * other governmental approval, or letter of assurance, without first obtaining 00113 * such license, approval or letter. 00114 * 00115 *****************************************************************************/ 00116 00117 #define __EXSYSTEM_C__ 00118 00119 #include "acpi.h" 00120 #include "accommon.h" 00121 #include "acinterp.h" 00122 00123 #define _COMPONENT ACPI_EXECUTER 00124 ACPI_MODULE_NAME ("exsystem") 00125 00126 00127 /******************************************************************************* 00128 * 00129 * FUNCTION: AcpiExSystemWaitSemaphore 00130 * 00131 * PARAMETERS: Semaphore - Semaphore to wait on 00132 * Timeout - Max time to wait 00133 * 00134 * RETURN: Status 00135 * 00136 * DESCRIPTION: Implements a semaphore wait with a check to see if the 00137 * semaphore is available immediately. If it is not, the 00138 * interpreter is released before waiting. 00139 * 00140 ******************************************************************************/ 00141 00142 ACPI_STATUS 00143 AcpiExSystemWaitSemaphore ( 00144 ACPI_SEMAPHORE Semaphore, 00145 UINT16 Timeout) 00146 { 00147 ACPI_STATUS Status; 00148 00149 00150 ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore); 00151 00152 00153 Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT); 00154 if (ACPI_SUCCESS (Status)) 00155 { 00156 return_ACPI_STATUS (Status); 00157 } 00158 00159 if (Status == AE_TIME) 00160 { 00161 /* We must wait, so unlock the interpreter */ 00162 00163 AcpiExRelinquishInterpreter (); 00164 00165 Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout); 00166 00167 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00168 "*** Thread awake after blocking, %s\n", 00169 AcpiFormatException (Status))); 00170 00171 /* Reacquire the interpreter */ 00172 00173 AcpiExReacquireInterpreter (); 00174 } 00175 00176 return_ACPI_STATUS (Status); 00177 } 00178 00179 00180 /******************************************************************************* 00181 * 00182 * FUNCTION: AcpiExSystemWaitMutex 00183 * 00184 * PARAMETERS: Mutex - Mutex to wait on 00185 * Timeout - Max time to wait 00186 * 00187 * RETURN: Status 00188 * 00189 * DESCRIPTION: Implements a mutex wait with a check to see if the 00190 * mutex is available immediately. If it is not, the 00191 * interpreter is released before waiting. 00192 * 00193 ******************************************************************************/ 00194 00195 ACPI_STATUS 00196 AcpiExSystemWaitMutex ( 00197 ACPI_MUTEX Mutex, 00198 UINT16 Timeout) 00199 { 00200 ACPI_STATUS Status; 00201 00202 00203 ACPI_FUNCTION_TRACE (ExSystemWaitMutex); 00204 00205 00206 Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT); 00207 if (ACPI_SUCCESS (Status)) 00208 { 00209 return_ACPI_STATUS (Status); 00210 } 00211 00212 if (Status == AE_TIME) 00213 { 00214 /* We must wait, so unlock the interpreter */ 00215 00216 AcpiExRelinquishInterpreter (); 00217 00218 Status = AcpiOsAcquireMutex (Mutex, Timeout); 00219 00220 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 00221 "*** Thread awake after blocking, %s\n", 00222 AcpiFormatException (Status))); 00223 00224 /* Reacquire the interpreter */ 00225 00226 AcpiExReacquireInterpreter (); 00227 } 00228 00229 return_ACPI_STATUS (Status); 00230 } 00231 00232 00233 /******************************************************************************* 00234 * 00235 * FUNCTION: AcpiExSystemDoStall 00236 * 00237 * PARAMETERS: HowLong - The amount of time to stall, 00238 * in microseconds 00239 * 00240 * RETURN: Status 00241 * 00242 * DESCRIPTION: Suspend running thread for specified amount of time. 00243 * Note: ACPI specification requires that Stall() does not 00244 * relinquish the processor, and delays longer than 100 usec 00245 * should use Sleep() instead. We allow stalls up to 255 usec 00246 * for compatibility with other interpreters and existing BIOSs. 00247 * 00248 ******************************************************************************/ 00249 00250 ACPI_STATUS 00251 AcpiExSystemDoStall ( 00252 UINT32 HowLong) 00253 { 00254 ACPI_STATUS Status = AE_OK; 00255 00256 00257 ACPI_FUNCTION_ENTRY (); 00258 00259 00260 if (HowLong > 255) /* 255 microseconds */ 00261 { 00262 /* 00263 * Longer than 255 usec, this is an error 00264 * 00265 * (ACPI specifies 100 usec as max, but this gives some slack in 00266 * order to support existing BIOSs) 00267 */ 00268 ACPI_ERROR ((AE_INFO, "Time parameter is too large (%u)", 00269 HowLong)); 00270 Status = AE_AML_OPERAND_VALUE; 00271 } 00272 else 00273 { 00274 AcpiOsStall (HowLong); 00275 } 00276 00277 return (Status); 00278 } 00279 00280 00281 /******************************************************************************* 00282 * 00283 * FUNCTION: AcpiExSystemDoSleep 00284 * 00285 * PARAMETERS: HowLong - The amount of time to sleep, 00286 * in milliseconds 00287 * 00288 * RETURN: None 00289 * 00290 * DESCRIPTION: Sleep the running thread for specified amount of time. 00291 * 00292 ******************************************************************************/ 00293 00294 ACPI_STATUS 00295 AcpiExSystemDoSleep ( 00296 UINT64 HowLong) 00297 { 00298 ACPI_FUNCTION_ENTRY (); 00299 00300 00301 /* Since this thread will sleep, we must release the interpreter */ 00302 00303 AcpiExRelinquishInterpreter (); 00304 00305 /* 00306 * For compatibility with other ACPI implementations and to prevent 00307 * accidental deep sleeps, limit the sleep time to something reasonable. 00308 */ 00309 if (HowLong > ACPI_MAX_SLEEP) 00310 { 00311 HowLong = ACPI_MAX_SLEEP; 00312 } 00313 00314 AcpiOsSleep (HowLong); 00315 00316 /* And now we must get the interpreter again */ 00317 00318 AcpiExReacquireInterpreter (); 00319 return (AE_OK); 00320 } 00321 00322 00323 /******************************************************************************* 00324 * 00325 * FUNCTION: AcpiExSystemSignalEvent 00326 * 00327 * PARAMETERS: ObjDesc - The object descriptor for this op 00328 * 00329 * RETURN: Status 00330 * 00331 * DESCRIPTION: Provides an access point to perform synchronization operations 00332 * within the AML. 00333 * 00334 ******************************************************************************/ 00335 00336 ACPI_STATUS 00337 AcpiExSystemSignalEvent ( 00338 ACPI_OPERAND_OBJECT *ObjDesc) 00339 { 00340 ACPI_STATUS Status = AE_OK; 00341 00342 00343 ACPI_FUNCTION_TRACE (ExSystemSignalEvent); 00344 00345 00346 if (ObjDesc) 00347 { 00348 Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1); 00349 } 00350 00351 return_ACPI_STATUS (Status); 00352 } 00353 00354 00355 /******************************************************************************* 00356 * 00357 * FUNCTION: AcpiExSystemWaitEvent 00358 * 00359 * PARAMETERS: TimeDesc - The 'time to delay' object descriptor 00360 * ObjDesc - The object descriptor for this op 00361 * 00362 * RETURN: Status 00363 * 00364 * DESCRIPTION: Provides an access point to perform synchronization operations 00365 * within the AML. This operation is a request to wait for an 00366 * event. 00367 * 00368 ******************************************************************************/ 00369 00370 ACPI_STATUS 00371 AcpiExSystemWaitEvent ( 00372 ACPI_OPERAND_OBJECT *TimeDesc, 00373 ACPI_OPERAND_OBJECT *ObjDesc) 00374 { 00375 ACPI_STATUS Status = AE_OK; 00376 00377 00378 ACPI_FUNCTION_TRACE (ExSystemWaitEvent); 00379 00380 00381 if (ObjDesc) 00382 { 00383 Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore, 00384 (UINT16) TimeDesc->Integer.Value); 00385 } 00386 00387 return_ACPI_STATUS (Status); 00388 } 00389 00390 00391 /******************************************************************************* 00392 * 00393 * FUNCTION: AcpiExSystemResetEvent 00394 * 00395 * PARAMETERS: ObjDesc - The object descriptor for this op 00396 * 00397 * RETURN: Status 00398 * 00399 * DESCRIPTION: Reset an event to a known state. 00400 * 00401 ******************************************************************************/ 00402 00403 ACPI_STATUS 00404 AcpiExSystemResetEvent ( 00405 ACPI_OPERAND_OBJECT *ObjDesc) 00406 { 00407 ACPI_STATUS Status = AE_OK; 00408 ACPI_SEMAPHORE TempSemaphore; 00409 00410 00411 ACPI_FUNCTION_ENTRY (); 00412 00413 00414 /* 00415 * We are going to simply delete the existing semaphore and 00416 * create a new one! 00417 */ 00418 Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore); 00419 if (ACPI_SUCCESS (Status)) 00420 { 00421 (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore); 00422 ObjDesc->Event.OsSemaphore = TempSemaphore; 00423 } 00424 00425 return (Status); 00426 } 00427 Generated on Sun May 27 2012 04:27:17 for ReactOS by
1.7.6.1
|