Back to home page

Quest Cross Reference

 
 

    


Warning, cross-references for /kernel/drivers/acpica/exsystem.c need to be fixed.

0001 
0002 /******************************************************************************
0003  *
0004  * Module Name: exsystem - Interface to OS services
0005  *
0006  *****************************************************************************/
0007 
0008 /******************************************************************************
0009  *
0010  * 1. Copyright Notice
0011  *
0012  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
0013  * All rights reserved.
0014  *
0015  * 2. License
0016  *
0017  * 2.1. This is your license from Intel Corp. under its intellectual property
0018  * rights.  You may have additional license terms from the party that provided
0019  * you this software, covering your right to use that party's intellectual
0020  * property rights.
0021  *
0022  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0023  * copy of the source code appearing in this file ("Covered Code") an
0024  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0025  * base code distributed originally by Intel ("Original Intel Code") to copy,
0026  * make derivatives, distribute, use and display any portion of the Covered
0027  * Code in any form, with the right to sublicense such rights; and
0028  *
0029  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0030  * license (with the right to sublicense), under only those claims of Intel
0031  * patents that are infringed by the Original Intel Code, to make, use, sell,
0032  * offer to sell, and import the Covered Code and derivative works thereof
0033  * solely to the minimum extent necessary to exercise the above copyright
0034  * license, and in no event shall the patent license extend to any additions
0035  * to or modifications of the Original Intel Code.  No other license or right
0036  * is granted directly or by implication, estoppel or otherwise;
0037  *
0038  * The above copyright and patent license is granted only if the following
0039  * conditions are met:
0040  *
0041  * 3. Conditions
0042  *
0043  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0044  * Redistribution of source code of any substantial portion of the Covered
0045  * Code or modification with rights to further distribute source must include
0046  * the above Copyright Notice, the above License, this list of Conditions,
0047  * and the following Disclaimer and Export Compliance provision.  In addition,
0048  * Licensee must cause all Covered Code to which Licensee contributes to
0049  * contain a file documenting the changes Licensee made to create that Covered
0050  * Code and the date of any change.  Licensee must include in that file the
0051  * documentation of any changes made by any predecessor Licensee.  Licensee
0052  * must include a prominent statement that the modification is derived,
0053  * directly or indirectly, from Original Intel Code.
0054  *
0055  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0056  * Redistribution of source code of any substantial portion of the Covered
0057  * Code or modification without rights to further distribute source must
0058  * include the following Disclaimer and Export Compliance provision in the
0059  * documentation and/or other materials provided with distribution.  In
0060  * addition, Licensee may not authorize further sublicense of source of any
0061  * portion of the Covered Code, and must include terms to the effect that the
0062  * license from Licensee to its licensee is limited to the intellectual
0063  * property embodied in the software Licensee provides to its licensee, and
0064  * not to intellectual property embodied in modifications its licensee may
0065  * make.
0066  *
0067  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0068  * substantial portion of the Covered Code or modification must reproduce the
0069  * above Copyright Notice, and the following Disclaimer and Export Compliance
0070  * provision in the documentation and/or other materials provided with the
0071  * distribution.
0072  *
0073  * 3.4. Intel retains all right, title, and interest in and to the Original
0074  * Intel Code.
0075  *
0076  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0077  * Intel shall be used in advertising or otherwise to promote the sale, use or
0078  * other dealings in products derived from or relating to the Covered Code
0079  * without prior written authorization from Intel.
0080  *
0081  * 4. Disclaimer and Export Compliance
0082  *
0083  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0084  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0085  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
0086  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
0087  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
0088  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0089  * PARTICULAR PURPOSE.
0090  *
0091  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0092  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0093  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0094  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0095  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0096  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
0097  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0098  * LIMITED REMEDY.
0099  *
0100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0101  * software or system incorporating such software without first obtaining any
0102  * required license or other approval from the U. S. Department of Commerce or
0103  * any other agency or department of the United States Government.  In the
0104  * event Licensee exports any such software from the United States or
0105  * re-exports any such software from a foreign destination, Licensee shall
0106  * ensure that the distribution and export/re-export of the software is in
0107  * compliance with all laws, regulations, orders, or other restrictions of the
0108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0109  * any of its subsidiaries will export/re-export any technical data, process,
0110  * software, or service, directly or indirectly, to any country for which the
0111  * United States government or any agency thereof requires an export license,
0112  * other governmental approval, or letter of assurance, without first obtaining
0113  * such license, approval or letter.
0114  *
0115  *****************************************************************************/
0116 
0117 #define __EXSYSTEM_C__
0118 
0119 #include "acpi.h"
0120 #include "accommon.h"
0121 #include "acinterp.h"
0122 
0123 #define _COMPONENT          ACPI_EXECUTER
0124         ACPI_MODULE_NAME    ("exsystem")
0125 
0126 
0127 /*******************************************************************************
0128  *
0129  * FUNCTION:    AcpiExSystemWaitSemaphore
0130  *
0131  * PARAMETERS:  Semaphore       - Semaphore to wait on
0132  *              Timeout         - Max time to wait
0133  *
0134  * RETURN:      Status
0135  *
0136  * DESCRIPTION: Implements a semaphore wait with a check to see if the
0137  *              semaphore is available immediately.  If it is not, the
0138  *              interpreter is released before waiting.
0139  *
0140  ******************************************************************************/
0141 
0142 ACPI_STATUS
0143 AcpiExSystemWaitSemaphore (
0144     ACPI_SEMAPHORE          Semaphore,
0145     UINT16                  Timeout)
0146 {
0147     ACPI_STATUS             Status;
0148 
0149 
0150     ACPI_FUNCTION_TRACE (ExSystemWaitSemaphore);
0151 
0152 
0153     Status = AcpiOsWaitSemaphore (Semaphore, 1, ACPI_DO_NOT_WAIT);
0154     if (ACPI_SUCCESS (Status))
0155     {
0156         return_ACPI_STATUS (Status);
0157     }
0158 
0159     if (Status == AE_TIME)
0160     {
0161         /* We must wait, so unlock the interpreter */
0162 
0163         AcpiExRelinquishInterpreter ();
0164 
0165         Status = AcpiOsWaitSemaphore (Semaphore, 1, Timeout);
0166 
0167         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0168             "*** Thread awake after blocking, %s\n",
0169             AcpiFormatException (Status)));
0170 
0171         /* Reacquire the interpreter */
0172 
0173        AcpiExReacquireInterpreter ();
0174     }
0175 
0176     return_ACPI_STATUS (Status);
0177 }
0178 
0179 
0180 /*******************************************************************************
0181  *
0182  * FUNCTION:    AcpiExSystemWaitMutex
0183  *
0184  * PARAMETERS:  Mutex           - Mutex to wait on
0185  *              Timeout         - Max time to wait
0186  *
0187  * RETURN:      Status
0188  *
0189  * DESCRIPTION: Implements a mutex wait with a check to see if the
0190  *              mutex is available immediately.  If it is not, the
0191  *              interpreter is released before waiting.
0192  *
0193  ******************************************************************************/
0194 
0195 ACPI_STATUS
0196 AcpiExSystemWaitMutex (
0197     ACPI_MUTEX              Mutex,
0198     UINT16                  Timeout)
0199 {
0200     ACPI_STATUS             Status;
0201 
0202 
0203     ACPI_FUNCTION_TRACE (ExSystemWaitMutex);
0204 
0205 
0206     Status = AcpiOsAcquireMutex (Mutex, ACPI_DO_NOT_WAIT);
0207     if (ACPI_SUCCESS (Status))
0208     {
0209         return_ACPI_STATUS (Status);
0210     }
0211 
0212     if (Status == AE_TIME)
0213     {
0214         /* We must wait, so unlock the interpreter */
0215 
0216         AcpiExRelinquishInterpreter ();
0217 
0218         Status = AcpiOsAcquireMutex (Mutex, Timeout);
0219 
0220         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
0221             "*** Thread awake after blocking, %s\n",
0222             AcpiFormatException (Status)));
0223 
0224         /* Reacquire the interpreter */
0225 
0226         AcpiExReacquireInterpreter ();
0227     }
0228 
0229     return_ACPI_STATUS (Status);
0230 }
0231 
0232 
0233 /*******************************************************************************
0234  *
0235  * FUNCTION:    AcpiExSystemDoStall
0236  *
0237  * PARAMETERS:  HowLong         - The amount of time to stall,
0238  *                                in microseconds
0239  *
0240  * RETURN:      Status
0241  *
0242  * DESCRIPTION: Suspend running thread for specified amount of time.
0243  *              Note: ACPI specification requires that Stall() does not
0244  *              relinquish the processor, and delays longer than 100 usec
0245  *              should use Sleep() instead.  We allow stalls up to 255 usec
0246  *              for compatibility with other interpreters and existing BIOSs.
0247  *
0248  ******************************************************************************/
0249 
0250 ACPI_STATUS
0251 AcpiExSystemDoStall (
0252     UINT32                  HowLong)
0253 {
0254     ACPI_STATUS             Status = AE_OK;
0255 
0256 
0257     ACPI_FUNCTION_ENTRY ();
0258 
0259 
0260     if (HowLong > 255) /* 255 microseconds */
0261     {
0262         /*
0263          * Longer than 255 usec, this is an error
0264          *
0265          * (ACPI specifies 100 usec as max, but this gives some slack in
0266          * order to support existing BIOSs)
0267          */
0268         ACPI_ERROR ((AE_INFO, "Time parameter is too large (%d)",
0269             HowLong));
0270         Status = AE_AML_OPERAND_VALUE;
0271     }
0272     else
0273     {
0274         AcpiOsStall (HowLong);
0275     }
0276 
0277     return (Status);
0278 }
0279 
0280 
0281 /*******************************************************************************
0282  *
0283  * FUNCTION:    AcpiExSystemDoSuspend
0284  *
0285  * PARAMETERS:  HowLong         - The amount of time to suspend,
0286  *                                in milliseconds
0287  *
0288  * RETURN:      None
0289  *
0290  * DESCRIPTION: Suspend running thread for specified amount of time.
0291  *
0292  ******************************************************************************/
0293 
0294 ACPI_STATUS
0295 AcpiExSystemDoSuspend (
0296     ACPI_INTEGER            HowLong)
0297 {
0298     ACPI_FUNCTION_ENTRY ();
0299 
0300 
0301     /* Since this thread will sleep, we must release the interpreter */
0302 
0303     AcpiExRelinquishInterpreter ();
0304 
0305     AcpiOsSleep (HowLong);
0306 
0307     /* And now we must get the interpreter again */
0308 
0309     AcpiExReacquireInterpreter ();
0310     return (AE_OK);
0311 }
0312 
0313 
0314 /*******************************************************************************
0315  *
0316  * FUNCTION:    AcpiExSystemSignalEvent
0317  *
0318  * PARAMETERS:  ObjDesc         - The object descriptor for this op
0319  *
0320  * RETURN:      Status
0321  *
0322  * DESCRIPTION: Provides an access point to perform synchronization operations
0323  *              within the AML.
0324  *
0325  ******************************************************************************/
0326 
0327 ACPI_STATUS
0328 AcpiExSystemSignalEvent (
0329     ACPI_OPERAND_OBJECT     *ObjDesc)
0330 {
0331     ACPI_STATUS             Status = AE_OK;
0332 
0333 
0334     ACPI_FUNCTION_TRACE (ExSystemSignalEvent);
0335 
0336 
0337     if (ObjDesc)
0338     {
0339         Status = AcpiOsSignalSemaphore (ObjDesc->Event.OsSemaphore, 1);
0340     }
0341 
0342     return_ACPI_STATUS (Status);
0343 }
0344 
0345 
0346 /*******************************************************************************
0347  *
0348  * FUNCTION:    AcpiExSystemWaitEvent
0349  *
0350  * PARAMETERS:  TimeDesc        - The 'time to delay' object descriptor
0351  *              ObjDesc         - The object descriptor for this op
0352  *
0353  * RETURN:      Status
0354  *
0355  * DESCRIPTION: Provides an access point to perform synchronization operations
0356  *              within the AML.  This operation is a request to wait for an
0357  *              event.
0358  *
0359  ******************************************************************************/
0360 
0361 ACPI_STATUS
0362 AcpiExSystemWaitEvent (
0363     ACPI_OPERAND_OBJECT     *TimeDesc,
0364     ACPI_OPERAND_OBJECT     *ObjDesc)
0365 {
0366     ACPI_STATUS             Status = AE_OK;
0367 
0368 
0369     ACPI_FUNCTION_TRACE (ExSystemWaitEvent);
0370 
0371 
0372     if (ObjDesc)
0373     {
0374         Status = AcpiExSystemWaitSemaphore (ObjDesc->Event.OsSemaphore,
0375                     (UINT16) TimeDesc->Integer.Value);
0376     }
0377 
0378     return_ACPI_STATUS (Status);
0379 }
0380 
0381 
0382 /*******************************************************************************
0383  *
0384  * FUNCTION:    AcpiExSystemResetEvent
0385  *
0386  * PARAMETERS:  ObjDesc         - The object descriptor for this op
0387  *
0388  * RETURN:      Status
0389  *
0390  * DESCRIPTION: Reset an event to a known state.
0391  *
0392  ******************************************************************************/
0393 
0394 ACPI_STATUS
0395 AcpiExSystemResetEvent (
0396     ACPI_OPERAND_OBJECT     *ObjDesc)
0397 {
0398     ACPI_STATUS             Status = AE_OK;
0399     ACPI_SEMAPHORE          TempSemaphore;
0400 
0401 
0402     ACPI_FUNCTION_ENTRY ();
0403 
0404 
0405     /*
0406      * We are going to simply delete the existing semaphore and
0407      * create a new one!
0408      */
0409     Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, &TempSemaphore);
0410     if (ACPI_SUCCESS (Status))
0411     {
0412         (void) AcpiOsDeleteSemaphore (ObjDesc->Event.OsSemaphore);
0413         ObjDesc->Event.OsSemaphore = TempSemaphore;
0414     }
0415 
0416     return (Status);
0417 }
0418