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

evmisc.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: evmisc - Miscellaneous event manager support functions
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 #include "acpi.h"
00117 #include "accommon.h"
00118 #include "acevents.h"
00119 #include "acnamesp.h"
00120 
00121 #define _COMPONENT          ACPI_EVENTS
00122         ACPI_MODULE_NAME    ("evmisc")
00123 
00124 
00125 /* Local prototypes */
00126 
00127 static void ACPI_SYSTEM_XFACE
00128 AcpiEvNotifyDispatch (
00129     void                    *Context);
00130 
00131 
00132 /*******************************************************************************
00133  *
00134  * FUNCTION:    AcpiEvIsNotifyObject
00135  *
00136  * PARAMETERS:  Node            - Node to check
00137  *
00138  * RETURN:      TRUE if notifies allowed on this object
00139  *
00140  * DESCRIPTION: Check type of node for a object that supports notifies.
00141  *
00142  *              TBD: This could be replaced by a flag bit in the node.
00143  *
00144  ******************************************************************************/
00145 
00146 BOOLEAN
00147 AcpiEvIsNotifyObject (
00148     ACPI_NAMESPACE_NODE     *Node)
00149 {
00150     switch (Node->Type)
00151     {
00152     case ACPI_TYPE_DEVICE:
00153     case ACPI_TYPE_PROCESSOR:
00154     case ACPI_TYPE_THERMAL:
00155         /*
00156          * These are the ONLY objects that can receive ACPI notifications
00157          */
00158         return (TRUE);
00159 
00160     default:
00161         return (FALSE);
00162     }
00163 }
00164 
00165 
00166 /*******************************************************************************
00167  *
00168  * FUNCTION:    AcpiEvQueueNotifyRequest
00169  *
00170  * PARAMETERS:  Node            - NS node for the notified object
00171  *              NotifyValue     - Value from the Notify() request
00172  *
00173  * RETURN:      Status
00174  *
00175  * DESCRIPTION: Dispatch a device notification event to a previously
00176  *              installed handler.
00177  *
00178  ******************************************************************************/
00179 
00180 ACPI_STATUS
00181 AcpiEvQueueNotifyRequest (
00182     ACPI_NAMESPACE_NODE     *Node,
00183     UINT32                  NotifyValue)
00184 {
00185     ACPI_OPERAND_OBJECT     *ObjDesc;
00186     ACPI_OPERAND_OBJECT     *HandlerObj = NULL;
00187     ACPI_GENERIC_STATE      *NotifyInfo;
00188     ACPI_STATUS             Status = AE_OK;
00189 
00190 
00191     ACPI_FUNCTION_NAME (EvQueueNotifyRequest);
00192 
00193 
00194     /*
00195      * For value 3 (Ejection Request), some device method may need to be run.
00196      * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need
00197      *   to be run.
00198      * For value 0x80 (Status Change) on the power button or sleep button,
00199      *   initiate soft-off or sleep operation?
00200      */
00201     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
00202         "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n",
00203         AcpiUtGetNodeName (Node), Node, NotifyValue,
00204         AcpiUtGetNotifyName (NotifyValue)));
00205 
00206     /* Get the notify object attached to the NS Node */
00207 
00208     ObjDesc = AcpiNsGetAttachedObject (Node);
00209     if (ObjDesc)
00210     {
00211         /* We have the notify object, Get the right handler */
00212 
00213         switch (Node->Type)
00214         {
00215         /* Notify allowed only on these types */
00216 
00217         case ACPI_TYPE_DEVICE:
00218         case ACPI_TYPE_THERMAL:
00219         case ACPI_TYPE_PROCESSOR:
00220 
00221             if (NotifyValue <= ACPI_MAX_SYS_NOTIFY)
00222             {
00223                 HandlerObj = ObjDesc->CommonNotify.SystemNotify;
00224             }
00225             else
00226             {
00227                 HandlerObj = ObjDesc->CommonNotify.DeviceNotify;
00228             }
00229             break;
00230 
00231         default:
00232 
00233             /* All other types are not supported */
00234 
00235             return (AE_TYPE);
00236         }
00237     }
00238 
00239     /*
00240      * If there is any handler to run, schedule the dispatcher.
00241      * Check for:
00242      * 1) Global system notify handler
00243      * 2) Global device notify handler
00244      * 3) Per-device notify handler
00245      */
00246     if ((AcpiGbl_SystemNotify.Handler &&
00247             (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) ||
00248         (AcpiGbl_DeviceNotify.Handler &&
00249             (NotifyValue > ACPI_MAX_SYS_NOTIFY))  ||
00250         HandlerObj)
00251     {
00252         NotifyInfo = AcpiUtCreateGenericState ();
00253         if (!NotifyInfo)
00254         {
00255             return (AE_NO_MEMORY);
00256         }
00257 
00258         if (!HandlerObj)
00259         {
00260             ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
00261                 "Executing system notify handler for Notify (%4.4s, %X) "
00262                 "node %p\n",
00263                 AcpiUtGetNodeName (Node), NotifyValue, Node));
00264         }
00265 
00266         NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY;
00267         NotifyInfo->Notify.Node = Node;
00268         NotifyInfo->Notify.Value = (UINT16) NotifyValue;
00269         NotifyInfo->Notify.HandlerObj = HandlerObj;
00270 
00271         Status = AcpiOsExecute (
00272                     OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo);
00273         if (ACPI_FAILURE (Status))
00274         {
00275             AcpiUtDeleteGenericState (NotifyInfo);
00276         }
00277     }
00278     else
00279     {
00280         /* There is no notify handler (per-device or system) for this device */
00281 
00282         ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
00283             "No notify handler for Notify (%4.4s, %X) node %p\n",
00284             AcpiUtGetNodeName (Node), NotifyValue, Node));
00285     }
00286 
00287     return (Status);
00288 }
00289 
00290 
00291 /*******************************************************************************
00292  *
00293  * FUNCTION:    AcpiEvNotifyDispatch
00294  *
00295  * PARAMETERS:  Context         - To be passed to the notify handler
00296  *
00297  * RETURN:      None.
00298  *
00299  * DESCRIPTION: Dispatch a device notification event to a previously
00300  *              installed handler.
00301  *
00302  ******************************************************************************/
00303 
00304 static void ACPI_SYSTEM_XFACE
00305 AcpiEvNotifyDispatch (
00306     void                    *Context)
00307 {
00308     ACPI_GENERIC_STATE      *NotifyInfo = (ACPI_GENERIC_STATE *) Context;
00309     ACPI_NOTIFY_HANDLER     GlobalHandler = NULL;
00310     void                    *GlobalContext = NULL;
00311     ACPI_OPERAND_OBJECT     *HandlerObj;
00312 
00313 
00314     ACPI_FUNCTION_ENTRY ();
00315 
00316 
00317     /*
00318      * We will invoke a global notify handler if installed. This is done
00319      * _before_ we invoke the per-device handler attached to the device.
00320      */
00321     if (NotifyInfo->Notify.Value <= ACPI_MAX_SYS_NOTIFY)
00322     {
00323         /* Global system notification handler */
00324 
00325         if (AcpiGbl_SystemNotify.Handler)
00326         {
00327             GlobalHandler = AcpiGbl_SystemNotify.Handler;
00328             GlobalContext = AcpiGbl_SystemNotify.Context;
00329         }
00330     }
00331     else
00332     {
00333         /* Global driver notification handler */
00334 
00335         if (AcpiGbl_DeviceNotify.Handler)
00336         {
00337             GlobalHandler = AcpiGbl_DeviceNotify.Handler;
00338             GlobalContext = AcpiGbl_DeviceNotify.Context;
00339         }
00340     }
00341 
00342     /* Invoke the system handler first, if present */
00343 
00344     if (GlobalHandler)
00345     {
00346         GlobalHandler (NotifyInfo->Notify.Node, NotifyInfo->Notify.Value,
00347             GlobalContext);
00348     }
00349 
00350     /* Now invoke the per-device handler, if present */
00351 
00352     HandlerObj = NotifyInfo->Notify.HandlerObj;
00353     if (HandlerObj)
00354     {
00355         HandlerObj->Notify.Handler (NotifyInfo->Notify.Node,
00356             NotifyInfo->Notify.Value,
00357             HandlerObj->Notify.Context);
00358     }
00359 
00360     /* All done with the info object */
00361 
00362     AcpiUtDeleteGenericState (NotifyInfo);
00363 }
00364 
00365 
00366 /******************************************************************************
00367  *
00368  * FUNCTION:    AcpiEvTerminate
00369  *
00370  * PARAMETERS:  none
00371  *
00372  * RETURN:      none
00373  *
00374  * DESCRIPTION: Disable events and free memory allocated for table storage.
00375  *
00376  ******************************************************************************/
00377 
00378 void
00379 AcpiEvTerminate (
00380     void)
00381 {
00382     UINT32                  i;
00383     ACPI_STATUS             Status;
00384 
00385 
00386     ACPI_FUNCTION_TRACE (EvTerminate);
00387 
00388 
00389     if (AcpiGbl_EventsInitialized)
00390     {
00391         /*
00392          * Disable all event-related functionality. In all cases, on error,
00393          * print a message but obviously we don't abort.
00394          */
00395 
00396         /* Disable all fixed events */
00397 
00398         for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++)
00399         {
00400             Status = AcpiDisableEvent (i, 0);
00401             if (ACPI_FAILURE (Status))
00402             {
00403                 ACPI_ERROR ((AE_INFO,
00404                     "Could not disable fixed event %u", (UINT32) i));
00405             }
00406         }
00407 
00408         /* Disable all GPEs in all GPE blocks */
00409 
00410         Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL);
00411 
00412         /* Remove SCI handler */
00413 
00414         Status = AcpiEvRemoveSciHandler ();
00415         if (ACPI_FAILURE(Status))
00416         {
00417             ACPI_ERROR ((AE_INFO,
00418                 "Could not remove SCI handler"));
00419         }
00420 
00421         Status = AcpiEvRemoveGlobalLockHandler ();
00422         if (ACPI_FAILURE(Status))
00423         {
00424             ACPI_ERROR ((AE_INFO,
00425                 "Could not remove Global Lock handler"));
00426         }
00427     }
00428 
00429     /* Deallocate all handler objects installed within GPE info structs */
00430 
00431     Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL);
00432 
00433     /* Return to original mode if necessary */
00434 
00435     if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY)
00436     {
00437         Status = AcpiDisable ();
00438         if (ACPI_FAILURE (Status))
00439         {
00440             ACPI_WARNING ((AE_INFO, "AcpiDisable failed"));
00441         }
00442     }
00443     return_VOID;
00444 }

Generated on Sun May 27 2012 04:27:15 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.