Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenhwgpe.c
Go to the documentation of this file.
00001 00002 /****************************************************************************** 00003 * 00004 * Module Name: hwgpe - Low level GPE enable/disable/clear functions 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 #include "acpi.h" 00118 #include "accommon.h" 00119 #include "acevents.h" 00120 00121 #define _COMPONENT ACPI_HARDWARE 00122 ACPI_MODULE_NAME ("hwgpe") 00123 00124 /* Local prototypes */ 00125 00126 static ACPI_STATUS 00127 AcpiHwEnableWakeupGpeBlock ( 00128 ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 00129 ACPI_GPE_BLOCK_INFO *GpeBlock, 00130 void *Context); 00131 00132 00133 /****************************************************************************** 00134 * 00135 * FUNCTION: AcpiHwGetGpeRegisterBit 00136 * 00137 * PARAMETERS: GpeEventInfo - Info block for the GPE 00138 * GpeRegisterInfo - Info block for the GPE register 00139 * 00140 * RETURN: Register mask with a one in the GPE bit position 00141 * 00142 * DESCRIPTION: Compute the register mask for this GPE. One bit is set in the 00143 * correct position for the input GPE. 00144 * 00145 ******************************************************************************/ 00146 00147 UINT32 00148 AcpiHwGetGpeRegisterBit ( 00149 ACPI_GPE_EVENT_INFO *GpeEventInfo, 00150 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo) 00151 { 00152 00153 return ((UINT32) 1 << 00154 (GpeEventInfo->GpeNumber - GpeRegisterInfo->BaseGpeNumber)); 00155 } 00156 00157 00158 /****************************************************************************** 00159 * 00160 * FUNCTION: AcpiHwLowSetGpe 00161 * 00162 * PARAMETERS: GpeEventInfo - Info block for the GPE to be disabled 00163 * Action - Enable or disable 00164 * 00165 * RETURN: Status 00166 * 00167 * DESCRIPTION: Enable or disable a single GPE in the parent enable register. 00168 * 00169 ******************************************************************************/ 00170 00171 ACPI_STATUS 00172 AcpiHwLowSetGpe ( 00173 ACPI_GPE_EVENT_INFO *GpeEventInfo, 00174 UINT32 Action) 00175 { 00176 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 00177 ACPI_STATUS Status; 00178 UINT32 EnableMask; 00179 UINT32 RegisterBit; 00180 00181 00182 ACPI_FUNCTION_ENTRY (); 00183 00184 00185 /* Get the info block for the entire GPE register */ 00186 00187 GpeRegisterInfo = GpeEventInfo->RegisterInfo; 00188 if (!GpeRegisterInfo) 00189 { 00190 return (AE_NOT_EXIST); 00191 } 00192 00193 /* Get current value of the enable register that contains this GPE */ 00194 00195 Status = AcpiHwRead (&EnableMask, &GpeRegisterInfo->EnableAddress); 00196 if (ACPI_FAILURE (Status)) 00197 { 00198 return (Status); 00199 } 00200 00201 /* Set or clear just the bit that corresponds to this GPE */ 00202 00203 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); 00204 switch (Action) 00205 { 00206 case ACPI_GPE_CONDITIONAL_ENABLE: 00207 00208 /* Only enable if the EnableForRun bit is set */ 00209 00210 if (!(RegisterBit & GpeRegisterInfo->EnableForRun)) 00211 { 00212 return (AE_BAD_PARAMETER); 00213 } 00214 00215 /*lint -fallthrough */ 00216 00217 case ACPI_GPE_ENABLE: 00218 ACPI_SET_BIT (EnableMask, RegisterBit); 00219 break; 00220 00221 case ACPI_GPE_DISABLE: 00222 ACPI_CLEAR_BIT (EnableMask, RegisterBit); 00223 break; 00224 00225 default: 00226 ACPI_ERROR ((AE_INFO, "Invalid GPE Action, %u\n", Action)); 00227 return (AE_BAD_PARAMETER); 00228 } 00229 00230 /* Write the updated enable mask */ 00231 00232 Status = AcpiHwWrite (EnableMask, &GpeRegisterInfo->EnableAddress); 00233 return (Status); 00234 } 00235 00236 00237 /****************************************************************************** 00238 * 00239 * FUNCTION: AcpiHwClearGpe 00240 * 00241 * PARAMETERS: GpeEventInfo - Info block for the GPE to be cleared 00242 * 00243 * RETURN: Status 00244 * 00245 * DESCRIPTION: Clear the status bit for a single GPE. 00246 * 00247 ******************************************************************************/ 00248 00249 ACPI_STATUS 00250 AcpiHwClearGpe ( 00251 ACPI_GPE_EVENT_INFO *GpeEventInfo) 00252 { 00253 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 00254 ACPI_STATUS Status; 00255 UINT32 RegisterBit; 00256 00257 00258 ACPI_FUNCTION_ENTRY (); 00259 00260 /* Get the info block for the entire GPE register */ 00261 00262 GpeRegisterInfo = GpeEventInfo->RegisterInfo; 00263 if (!GpeRegisterInfo) 00264 { 00265 return (AE_NOT_EXIST); 00266 } 00267 00268 /* 00269 * Write a one to the appropriate bit in the status register to 00270 * clear this GPE. 00271 */ 00272 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); 00273 00274 Status = AcpiHwWrite (RegisterBit, 00275 &GpeRegisterInfo->StatusAddress); 00276 00277 return (Status); 00278 } 00279 00280 00281 /****************************************************************************** 00282 * 00283 * FUNCTION: AcpiHwGetGpeStatus 00284 * 00285 * PARAMETERS: GpeEventInfo - Info block for the GPE to queried 00286 * EventStatus - Where the GPE status is returned 00287 * 00288 * RETURN: Status 00289 * 00290 * DESCRIPTION: Return the status of a single GPE. 00291 * 00292 ******************************************************************************/ 00293 00294 ACPI_STATUS 00295 AcpiHwGetGpeStatus ( 00296 ACPI_GPE_EVENT_INFO *GpeEventInfo, 00297 ACPI_EVENT_STATUS *EventStatus) 00298 { 00299 UINT32 InByte; 00300 UINT32 RegisterBit; 00301 ACPI_GPE_REGISTER_INFO *GpeRegisterInfo; 00302 ACPI_EVENT_STATUS LocalEventStatus = 0; 00303 ACPI_STATUS Status; 00304 00305 00306 ACPI_FUNCTION_ENTRY (); 00307 00308 00309 if (!EventStatus) 00310 { 00311 return (AE_BAD_PARAMETER); 00312 } 00313 00314 /* Get the info block for the entire GPE register */ 00315 00316 GpeRegisterInfo = GpeEventInfo->RegisterInfo; 00317 00318 /* Get the register bitmask for this GPE */ 00319 00320 RegisterBit = AcpiHwGetGpeRegisterBit (GpeEventInfo, GpeRegisterInfo); 00321 00322 /* GPE currently enabled? (enabled for runtime?) */ 00323 00324 if (RegisterBit & GpeRegisterInfo->EnableForRun) 00325 { 00326 LocalEventStatus |= ACPI_EVENT_FLAG_ENABLED; 00327 } 00328 00329 /* GPE enabled for wake? */ 00330 00331 if (RegisterBit & GpeRegisterInfo->EnableForWake) 00332 { 00333 LocalEventStatus |= ACPI_EVENT_FLAG_WAKE_ENABLED; 00334 } 00335 00336 /* GPE currently active (status bit == 1)? */ 00337 00338 Status = AcpiHwRead (&InByte, &GpeRegisterInfo->StatusAddress); 00339 if (ACPI_FAILURE (Status)) 00340 { 00341 return (Status); 00342 } 00343 00344 if (RegisterBit & InByte) 00345 { 00346 LocalEventStatus |= ACPI_EVENT_FLAG_SET; 00347 } 00348 00349 /* Set return value */ 00350 00351 (*EventStatus) = LocalEventStatus; 00352 return (AE_OK); 00353 } 00354 00355 00356 /****************************************************************************** 00357 * 00358 * FUNCTION: AcpiHwDisableGpeBlock 00359 * 00360 * PARAMETERS: GpeXruptInfo - GPE Interrupt info 00361 * GpeBlock - Gpe Block info 00362 * 00363 * RETURN: Status 00364 * 00365 * DESCRIPTION: Disable all GPEs within a single GPE block 00366 * 00367 ******************************************************************************/ 00368 00369 ACPI_STATUS 00370 AcpiHwDisableGpeBlock ( 00371 ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 00372 ACPI_GPE_BLOCK_INFO *GpeBlock, 00373 void *Context) 00374 { 00375 UINT32 i; 00376 ACPI_STATUS Status; 00377 00378 00379 /* Examine each GPE Register within the block */ 00380 00381 for (i = 0; i < GpeBlock->RegisterCount; i++) 00382 { 00383 /* Disable all GPEs in this register */ 00384 00385 Status = AcpiHwWrite (0x00, &GpeBlock->RegisterInfo[i].EnableAddress); 00386 if (ACPI_FAILURE (Status)) 00387 { 00388 return (Status); 00389 } 00390 } 00391 00392 return (AE_OK); 00393 } 00394 00395 00396 /****************************************************************************** 00397 * 00398 * FUNCTION: AcpiHwClearGpeBlock 00399 * 00400 * PARAMETERS: GpeXruptInfo - GPE Interrupt info 00401 * GpeBlock - Gpe Block info 00402 * 00403 * RETURN: Status 00404 * 00405 * DESCRIPTION: Clear status bits for all GPEs within a single GPE block 00406 * 00407 ******************************************************************************/ 00408 00409 ACPI_STATUS 00410 AcpiHwClearGpeBlock ( 00411 ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 00412 ACPI_GPE_BLOCK_INFO *GpeBlock, 00413 void *Context) 00414 { 00415 UINT32 i; 00416 ACPI_STATUS Status; 00417 00418 00419 /* Examine each GPE Register within the block */ 00420 00421 for (i = 0; i < GpeBlock->RegisterCount; i++) 00422 { 00423 /* Clear status on all GPEs in this register */ 00424 00425 Status = AcpiHwWrite (0xFF, &GpeBlock->RegisterInfo[i].StatusAddress); 00426 if (ACPI_FAILURE (Status)) 00427 { 00428 return (Status); 00429 } 00430 } 00431 00432 return (AE_OK); 00433 } 00434 00435 00436 /****************************************************************************** 00437 * 00438 * FUNCTION: AcpiHwEnableRuntimeGpeBlock 00439 * 00440 * PARAMETERS: GpeXruptInfo - GPE Interrupt info 00441 * GpeBlock - Gpe Block info 00442 * 00443 * RETURN: Status 00444 * 00445 * DESCRIPTION: Enable all "runtime" GPEs within a single GPE block. Includes 00446 * combination wake/run GPEs. 00447 * 00448 ******************************************************************************/ 00449 00450 ACPI_STATUS 00451 AcpiHwEnableRuntimeGpeBlock ( 00452 ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 00453 ACPI_GPE_BLOCK_INFO *GpeBlock, 00454 void *Context) 00455 { 00456 UINT32 i; 00457 ACPI_STATUS Status; 00458 00459 00460 /* NOTE: assumes that all GPEs are currently disabled */ 00461 00462 /* Examine each GPE Register within the block */ 00463 00464 for (i = 0; i < GpeBlock->RegisterCount; i++) 00465 { 00466 if (!GpeBlock->RegisterInfo[i].EnableForRun) 00467 { 00468 continue; 00469 } 00470 00471 /* Enable all "runtime" GPEs in this register */ 00472 00473 Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForRun, 00474 &GpeBlock->RegisterInfo[i].EnableAddress); 00475 if (ACPI_FAILURE (Status)) 00476 { 00477 return (Status); 00478 } 00479 } 00480 00481 return (AE_OK); 00482 } 00483 00484 00485 /****************************************************************************** 00486 * 00487 * FUNCTION: AcpiHwEnableWakeupGpeBlock 00488 * 00489 * PARAMETERS: GpeXruptInfo - GPE Interrupt info 00490 * GpeBlock - Gpe Block info 00491 * 00492 * RETURN: Status 00493 * 00494 * DESCRIPTION: Enable all "wake" GPEs within a single GPE block. Includes 00495 * combination wake/run GPEs. 00496 * 00497 ******************************************************************************/ 00498 00499 static ACPI_STATUS 00500 AcpiHwEnableWakeupGpeBlock ( 00501 ACPI_GPE_XRUPT_INFO *GpeXruptInfo, 00502 ACPI_GPE_BLOCK_INFO *GpeBlock, 00503 void *Context) 00504 { 00505 UINT32 i; 00506 ACPI_STATUS Status; 00507 00508 00509 /* Examine each GPE Register within the block */ 00510 00511 for (i = 0; i < GpeBlock->RegisterCount; i++) 00512 { 00513 if (!GpeBlock->RegisterInfo[i].EnableForWake) 00514 { 00515 continue; 00516 } 00517 00518 /* Enable all "wake" GPEs in this register */ 00519 00520 Status = AcpiHwWrite (GpeBlock->RegisterInfo[i].EnableForWake, 00521 &GpeBlock->RegisterInfo[i].EnableAddress); 00522 if (ACPI_FAILURE (Status)) 00523 { 00524 return (Status); 00525 } 00526 } 00527 00528 return (AE_OK); 00529 } 00530 00531 00532 /****************************************************************************** 00533 * 00534 * FUNCTION: AcpiHwDisableAllGpes 00535 * 00536 * PARAMETERS: None 00537 * 00538 * RETURN: Status 00539 * 00540 * DESCRIPTION: Disable and clear all GPEs in all GPE blocks 00541 * 00542 ******************************************************************************/ 00543 00544 ACPI_STATUS 00545 AcpiHwDisableAllGpes ( 00546 void) 00547 { 00548 ACPI_STATUS Status; 00549 00550 00551 ACPI_FUNCTION_TRACE (HwDisableAllGpes); 00552 00553 00554 Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); 00555 Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, NULL); 00556 return_ACPI_STATUS (Status); 00557 } 00558 00559 00560 /****************************************************************************** 00561 * 00562 * FUNCTION: AcpiHwEnableAllRuntimeGpes 00563 * 00564 * PARAMETERS: None 00565 * 00566 * RETURN: Status 00567 * 00568 * DESCRIPTION: Enable all "runtime" GPEs, in all GPE blocks 00569 * 00570 ******************************************************************************/ 00571 00572 ACPI_STATUS 00573 AcpiHwEnableAllRuntimeGpes ( 00574 void) 00575 { 00576 ACPI_STATUS Status; 00577 00578 00579 ACPI_FUNCTION_TRACE (HwEnableAllRuntimeGpes); 00580 00581 00582 Status = AcpiEvWalkGpeList (AcpiHwEnableRuntimeGpeBlock, NULL); 00583 return_ACPI_STATUS (Status); 00584 } 00585 00586 00587 /****************************************************************************** 00588 * 00589 * FUNCTION: AcpiHwEnableAllWakeupGpes 00590 * 00591 * PARAMETERS: None 00592 * 00593 * RETURN: Status 00594 * 00595 * DESCRIPTION: Enable all "wakeup" GPEs, in all GPE blocks 00596 * 00597 ******************************************************************************/ 00598 00599 ACPI_STATUS 00600 AcpiHwEnableAllWakeupGpes ( 00601 void) 00602 { 00603 ACPI_STATUS Status; 00604 00605 00606 ACPI_FUNCTION_TRACE (HwEnableAllWakeupGpes); 00607 00608 00609 Status = AcpiEvWalkGpeList (AcpiHwEnableWakeupGpeBlock, NULL); 00610 return_ACPI_STATUS (Status); 00611 } 00612 Generated on Sun May 27 2012 04:27:17 for ReactOS by
1.7.6.1
|