hwacpi.c revision 91116
155682Smarkm 2233294Sstas/****************************************************************************** 3233294Sstas * 4233294Sstas * Module Name: hwacpi - ACPI Hardware Initialization/Mode Interface 555682Smarkm * $Revision: 53 $ 6233294Sstas * 7233294Sstas *****************************************************************************/ 8233294Sstas 955682Smarkm/****************************************************************************** 10233294Sstas * 11233294Sstas * 1. Copyright Notice 1255682Smarkm * 13233294Sstas * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp. 14233294Sstas * All rights reserved. 15233294Sstas * 1655682Smarkm * 2. License 17233294Sstas * 18233294Sstas * 2.1. This is your license from Intel Corp. under its intellectual property 19233294Sstas * rights. You may have additional license terms from the party that provided 2055682Smarkm * you this software, covering your right to use that party's intellectual 21233294Sstas * property rights. 22233294Sstas * 23233294Sstas * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 24233294Sstas * copy of the source code appearing in this file ("Covered Code") an 25233294Sstas * irrevocable, perpetual, worldwide license under Intel's copyrights in the 26233294Sstas * base code distributed originally by Intel ("Original Intel Code") to copy, 27233294Sstas * make derivatives, distribute, use and display any portion of the Covered 28233294Sstas * Code in any form, with the right to sublicense such rights; and 29233294Sstas * 30233294Sstas * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 31233294Sstas * license (with the right to sublicense), under only those claims of Intel 3255682Smarkm * patents that are infringed by the Original Intel Code, to make, use, sell, 3355682Smarkm * offer to sell, and import the Covered Code and derivative works thereof 3455682Smarkm * solely to the minimum extent necessary to exercise the above copyright 3555682Smarkm * license, and in no event shall the patent license extend to any additions 3655682Smarkm * to or modifications of the Original Intel Code. No other license or right 3755682Smarkm * is granted directly or by implication, estoppel or otherwise; 38233294Sstas * 3955682Smarkm * The above copyright and patent license is granted only if the following 4055682Smarkm * conditions are met: 4155682Smarkm * 4255682Smarkm * 3. Conditions 4355682Smarkm * 4455682Smarkm * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4555682Smarkm * Redistribution of source code of any substantial portion of the Covered 4655682Smarkm * Code or modification with rights to further distribute source must include 4755682Smarkm * the above Copyright Notice, the above License, this list of Conditions, 4855682Smarkm * and the following Disclaimer and Export Compliance provision. In addition, 4955682Smarkm * Licensee must cause all Covered Code to which Licensee contributes to 5055682Smarkm * contain a file documenting the changes Licensee made to create that Covered 5155682Smarkm * Code and the date of any change. Licensee must include in that file the 5255682Smarkm * documentation of any changes made by any predecessor Licensee. Licensee 5355682Smarkm * must include a prominent statement that the modification is derived, 5455682Smarkm * directly or indirectly, from Original Intel Code. 5555682Smarkm * 5655682Smarkm * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5755682Smarkm * Redistribution of source code of any substantial portion of the Covered 5855682Smarkm * Code or modification without rights to further distribute source must 59233294Sstas * include the following Disclaimer and Export Compliance provision in the 6055682Smarkm * documentation and/or other materials provided with distribution. In 6155682Smarkm * addition, Licensee may not authorize further sublicense of source of any 6255682Smarkm * portion of the Covered Code, and must include terms to the effect that the 6355682Smarkm * license from Licensee to its licensee is limited to the intellectual 6455682Smarkm * property embodied in the software Licensee provides to its licensee, and 6555682Smarkm * not to intellectual property embodied in modifications its licensee may 6655682Smarkm * make. 6755682Smarkm * 6855682Smarkm * 3.3. Redistribution of Executable. Redistribution in executable form of any 6955682Smarkm * substantial portion of the Covered Code or modification must reproduce the 7055682Smarkm * above Copyright Notice, and the following Disclaimer and Export Compliance 7155682Smarkm * provision in the documentation and/or other materials provided with the 7255682Smarkm * distribution. 7355682Smarkm * 7455682Smarkm * 3.4. Intel retains all right, title, and interest in and to the Original 7555682Smarkm * Intel Code. 7655682Smarkm * 7755682Smarkm * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7855682Smarkm * Intel shall be used in advertising or otherwise to promote the sale, use or 7955682Smarkm * other dealings in products derived from or relating to the Covered Code 8055682Smarkm * without prior written authorization from Intel. 8155682Smarkm * 8255682Smarkm * 4. Disclaimer and Export Compliance 8355682Smarkm * 8455682Smarkm * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8555682Smarkm * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8655682Smarkm * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8755682Smarkm * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 90 * PARTICULAR PURPOSE. 91 * 92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 99 * LIMITED REMEDY. 100 * 101 * 4.3. Licensee shall not export, either directly or indirectly, any of this 102 * software or system incorporating such software without first obtaining any 103 * required license or other approval from the U. S. Department of Commerce or 104 * any other agency or department of the United States Government. In the 105 * event Licensee exports any such software from the United States or 106 * re-exports any such software from a foreign destination, Licensee shall 107 * ensure that the distribution and export/re-export of the software is in 108 * compliance with all laws, regulations, orders, or other restrictions of the 109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 110 * any of its subsidiaries will export/re-export any technical data, process, 111 * software, or service, directly or indirectly, to any country for which the 112 * United States government or any agency thereof requires an export license, 113 * other governmental approval, or letter of assurance, without first obtaining 114 * such license, approval or letter. 115 * 116 *****************************************************************************/ 117 118#define __HWACPI_C__ 119 120#include "acpi.h" 121#include "achware.h" 122 123 124#define _COMPONENT ACPI_HARDWARE 125 ACPI_MODULE_NAME ("hwacpi") 126 127 128/****************************************************************************** 129 * 130 * FUNCTION: AcpiHwInitialize 131 * 132 * PARAMETERS: None 133 * 134 * RETURN: Status 135 * 136 * DESCRIPTION: Initialize and validate various ACPI registers 137 * 138 ******************************************************************************/ 139 140ACPI_STATUS 141AcpiHwInitialize ( 142 void) 143{ 144 ACPI_STATUS Status; 145 146 147 ACPI_FUNCTION_TRACE ("HwInitialize"); 148 149 150 /* We must have the ACPI tables by the time we get here */ 151 152 if (!AcpiGbl_FADT) 153 { 154 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "A FADT is not loaded\n")); 155 156 return_ACPI_STATUS (AE_NO_ACPI_TABLES); 157 } 158 159 /* Sanity check the FADT for valid values */ 160 161 Status = AcpiUtValidateFadt (); 162 if (ACPI_FAILURE (Status)) 163 { 164 return_ACPI_STATUS (Status); 165 } 166 167 return_ACPI_STATUS (AE_OK); 168} 169 170 171/****************************************************************************** 172 * 173 * FUNCTION: AcpiHwSetMode 174 * 175 * PARAMETERS: Mode - SYS_MODE_ACPI or SYS_MODE_LEGACY 176 * 177 * RETURN: Status 178 * 179 * DESCRIPTION: Transitions the system into the requested mode. 180 * 181 ******************************************************************************/ 182 183ACPI_STATUS 184AcpiHwSetMode ( 185 UINT32 Mode) 186{ 187 188 ACPI_STATUS Status = AE_NO_HARDWARE_RESPONSE; 189 190 191 ACPI_FUNCTION_TRACE ("HwSetMode"); 192 193 194 if (Mode == ACPI_SYS_MODE_ACPI) 195 { 196 /* BIOS should have disabled ALL fixed and GP events */ 197 198 AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, AcpiGbl_FADT->AcpiEnable, 8); 199 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Attempting to enable ACPI mode\n")); 200 } 201 else if (Mode == ACPI_SYS_MODE_LEGACY) 202 { 203 /* 204 * BIOS should clear all fixed status bits and restore fixed event 205 * enable bits to default 206 */ 207 AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, AcpiGbl_FADT->AcpiDisable, 8); 208 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 209 "Attempting to enable Legacy (non-ACPI) mode\n")); 210 } 211 212 /* Give the platform some time to react */ 213 214 AcpiOsStall (20000); 215 216 if (AcpiHwGetMode () == Mode) 217 { 218 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Mode %X successfully enabled\n", Mode)); 219 Status = AE_OK; 220 } 221 222 return_ACPI_STATUS (Status); 223} 224 225 226/****************************************************************************** 227 * 228 * FUNCTION: AcpiHwGetMode 229 * 230 * PARAMETERS: none 231 * 232 * RETURN: SYS_MODE_ACPI or SYS_MODE_LEGACY 233 * 234 * DESCRIPTION: Return current operating state of system. Determined by 235 * querying the SCI_EN bit. 236 * 237 ******************************************************************************/ 238 239UINT32 240AcpiHwGetMode (void) 241{ 242 243 ACPI_FUNCTION_TRACE ("HwGetMode"); 244 245 246 if (AcpiHwBitRegisterRead (ACPI_BITREG_SCI_ENABLE, ACPI_MTX_LOCK)) 247 { 248 return_VALUE (ACPI_SYS_MODE_ACPI); 249 } 250 else 251 { 252 return_VALUE (ACPI_SYS_MODE_LEGACY); 253 } 254} 255