Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenevevent.c
Go to the documentation of this file.
00001 /****************************************************************************** 00002 * 00003 * Module Name: evevent - Fixed Event handling and dispatch 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 00120 #define _COMPONENT ACPI_EVENTS 00121 ACPI_MODULE_NAME ("evevent") 00122 00123 /* Local prototypes */ 00124 00125 static ACPI_STATUS 00126 AcpiEvFixedEventInitialize ( 00127 void); 00128 00129 static UINT32 00130 AcpiEvFixedEventDispatch ( 00131 UINT32 Event); 00132 00133 00134 /******************************************************************************* 00135 * 00136 * FUNCTION: AcpiEvInitializeEvents 00137 * 00138 * PARAMETERS: None 00139 * 00140 * RETURN: Status 00141 * 00142 * DESCRIPTION: Initialize global data structures for ACPI events (Fixed, GPE) 00143 * 00144 ******************************************************************************/ 00145 00146 ACPI_STATUS 00147 AcpiEvInitializeEvents ( 00148 void) 00149 { 00150 ACPI_STATUS Status; 00151 00152 00153 ACPI_FUNCTION_TRACE (EvInitializeEvents); 00154 00155 00156 /* 00157 * Initialize the Fixed and General Purpose Events. This is done prior to 00158 * enabling SCIs to prevent interrupts from occurring before the handlers 00159 * are installed. 00160 */ 00161 Status = AcpiEvFixedEventInitialize (); 00162 if (ACPI_FAILURE (Status)) 00163 { 00164 ACPI_EXCEPTION ((AE_INFO, Status, 00165 "Unable to initialize fixed events")); 00166 return_ACPI_STATUS (Status); 00167 } 00168 00169 Status = AcpiEvGpeInitialize (); 00170 if (ACPI_FAILURE (Status)) 00171 { 00172 ACPI_EXCEPTION ((AE_INFO, Status, 00173 "Unable to initialize general purpose events")); 00174 return_ACPI_STATUS (Status); 00175 } 00176 00177 return_ACPI_STATUS (Status); 00178 } 00179 00180 00181 /******************************************************************************* 00182 * 00183 * FUNCTION: AcpiEvInstallXruptHandlers 00184 * 00185 * PARAMETERS: None 00186 * 00187 * RETURN: Status 00188 * 00189 * DESCRIPTION: Install interrupt handlers for the SCI and Global Lock 00190 * 00191 ******************************************************************************/ 00192 00193 ACPI_STATUS 00194 AcpiEvInstallXruptHandlers ( 00195 void) 00196 { 00197 ACPI_STATUS Status; 00198 00199 00200 ACPI_FUNCTION_TRACE (EvInstallXruptHandlers); 00201 00202 00203 /* Install the SCI handler */ 00204 00205 Status = AcpiEvInstallSciHandler (); 00206 if (ACPI_FAILURE (Status)) 00207 { 00208 ACPI_EXCEPTION ((AE_INFO, Status, 00209 "Unable to install System Control Interrupt handler")); 00210 return_ACPI_STATUS (Status); 00211 } 00212 00213 /* Install the handler for the Global Lock */ 00214 00215 Status = AcpiEvInitGlobalLockHandler (); 00216 if (ACPI_FAILURE (Status)) 00217 { 00218 ACPI_EXCEPTION ((AE_INFO, Status, 00219 "Unable to initialize Global Lock handler")); 00220 return_ACPI_STATUS (Status); 00221 } 00222 00223 AcpiGbl_EventsInitialized = TRUE; 00224 return_ACPI_STATUS (Status); 00225 } 00226 00227 00228 /******************************************************************************* 00229 * 00230 * FUNCTION: AcpiEvFixedEventInitialize 00231 * 00232 * PARAMETERS: None 00233 * 00234 * RETURN: Status 00235 * 00236 * DESCRIPTION: Install the fixed event handlers and disable all fixed events. 00237 * 00238 ******************************************************************************/ 00239 00240 static ACPI_STATUS 00241 AcpiEvFixedEventInitialize ( 00242 void) 00243 { 00244 UINT32 i; 00245 ACPI_STATUS Status; 00246 00247 00248 /* 00249 * Initialize the structure that keeps track of fixed event handlers and 00250 * enable the fixed events. 00251 */ 00252 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 00253 { 00254 AcpiGbl_FixedEventHandlers[i].Handler = NULL; 00255 AcpiGbl_FixedEventHandlers[i].Context = NULL; 00256 00257 /* Disable the fixed event */ 00258 00259 if (AcpiGbl_FixedEventInfo[i].EnableRegisterId != 0xFF) 00260 { 00261 Status = AcpiWriteBitRegister ( 00262 AcpiGbl_FixedEventInfo[i].EnableRegisterId, 00263 ACPI_DISABLE_EVENT); 00264 if (ACPI_FAILURE (Status)) 00265 { 00266 return (Status); 00267 } 00268 } 00269 } 00270 00271 return (AE_OK); 00272 } 00273 00274 00275 /******************************************************************************* 00276 * 00277 * FUNCTION: AcpiEvFixedEventDetect 00278 * 00279 * PARAMETERS: None 00280 * 00281 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 00282 * 00283 * DESCRIPTION: Checks the PM status register for active fixed events 00284 * 00285 ******************************************************************************/ 00286 00287 UINT32 00288 AcpiEvFixedEventDetect ( 00289 void) 00290 { 00291 UINT32 IntStatus = ACPI_INTERRUPT_NOT_HANDLED; 00292 UINT32 FixedStatus; 00293 UINT32 FixedEnable; 00294 UINT32 i; 00295 00296 00297 ACPI_FUNCTION_NAME (EvFixedEventDetect); 00298 00299 00300 /* 00301 * Read the fixed feature status and enable registers, as all the cases 00302 * depend on their values. Ignore errors here. 00303 */ 00304 (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_STATUS, &FixedStatus); 00305 (void) AcpiHwRegisterRead (ACPI_REGISTER_PM1_ENABLE, &FixedEnable); 00306 00307 ACPI_DEBUG_PRINT ((ACPI_DB_INTERRUPTS, 00308 "Fixed Event Block: Enable %08X Status %08X\n", 00309 FixedEnable, FixedStatus)); 00310 00311 /* 00312 * Check for all possible Fixed Events and dispatch those that are active 00313 */ 00314 for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) 00315 { 00316 /* Both the status and enable bits must be on for this event */ 00317 00318 if ((FixedStatus & AcpiGbl_FixedEventInfo[i].StatusBitMask) && 00319 (FixedEnable & AcpiGbl_FixedEventInfo[i].EnableBitMask)) 00320 { 00321 /* 00322 * Found an active (signalled) event. Invoke global event 00323 * handler if present. 00324 */ 00325 AcpiFixedEventCount[i]++; 00326 if (AcpiGbl_GlobalEventHandler) 00327 { 00328 AcpiGbl_GlobalEventHandler (ACPI_EVENT_TYPE_FIXED, NULL, 00329 i, AcpiGbl_GlobalEventHandlerContext); 00330 } 00331 00332 IntStatus |= AcpiEvFixedEventDispatch (i); 00333 } 00334 } 00335 00336 return (IntStatus); 00337 } 00338 00339 00340 /******************************************************************************* 00341 * 00342 * FUNCTION: AcpiEvFixedEventDispatch 00343 * 00344 * PARAMETERS: Event - Event type 00345 * 00346 * RETURN: INTERRUPT_HANDLED or INTERRUPT_NOT_HANDLED 00347 * 00348 * DESCRIPTION: Clears the status bit for the requested event, calls the 00349 * handler that previously registered for the event. 00350 * 00351 ******************************************************************************/ 00352 00353 static UINT32 00354 AcpiEvFixedEventDispatch ( 00355 UINT32 Event) 00356 { 00357 00358 ACPI_FUNCTION_ENTRY (); 00359 00360 00361 /* Clear the status bit */ 00362 00363 (void) AcpiWriteBitRegister ( 00364 AcpiGbl_FixedEventInfo[Event].StatusRegisterId, 00365 ACPI_CLEAR_STATUS); 00366 00367 /* 00368 * Make sure we've got a handler. If not, report an error. The event is 00369 * disabled to prevent further interrupts. 00370 */ 00371 if (NULL == AcpiGbl_FixedEventHandlers[Event].Handler) 00372 { 00373 (void) AcpiWriteBitRegister ( 00374 AcpiGbl_FixedEventInfo[Event].EnableRegisterId, 00375 ACPI_DISABLE_EVENT); 00376 00377 ACPI_ERROR ((AE_INFO, 00378 "No installed handler for fixed event [0x%08X]", 00379 Event)); 00380 00381 return (ACPI_INTERRUPT_NOT_HANDLED); 00382 } 00383 00384 /* Invoke the Fixed Event handler */ 00385 00386 return ((AcpiGbl_FixedEventHandlers[Event].Handler)( 00387 AcpiGbl_FixedEventHandlers[Event].Context)); 00388 } 00389 00390 Generated on Sat May 26 2012 04:25:45 for ReactOS by
1.7.6.1
|