hwregs.c revision 117525
167754Smsmith 267754Smsmith/******************************************************************************* 367754Smsmith * 467754Smsmith * Module Name: hwregs - Read/write access functions for the various ACPI 567754Smsmith * control and status registers. 6117521Snjl * $Revision: 149 $ 767754Smsmith * 867754Smsmith ******************************************************************************/ 967754Smsmith 1067754Smsmith/****************************************************************************** 1167754Smsmith * 1267754Smsmith * 1. Copyright Notice 1367754Smsmith * 14114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp. 1570243Smsmith * All rights reserved. 1667754Smsmith * 1767754Smsmith * 2. License 1867754Smsmith * 1967754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 2067754Smsmith * rights. You may have additional license terms from the party that provided 2167754Smsmith * you this software, covering your right to use that party's intellectual 2267754Smsmith * property rights. 2367754Smsmith * 2467754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2567754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2667754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2767754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2867754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2967754Smsmith * Code in any form, with the right to sublicense such rights; and 3067754Smsmith * 3167754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3267754Smsmith * license (with the right to sublicense), under only those claims of Intel 3367754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3467754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3567754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3667754Smsmith * license, and in no event shall the patent license extend to any additions 3767754Smsmith * to or modifications of the Original Intel Code. No other license or right 3867754Smsmith * is granted directly or by implication, estoppel or otherwise; 3967754Smsmith * 4067754Smsmith * The above copyright and patent license is granted only if the following 4167754Smsmith * conditions are met: 4267754Smsmith * 4367754Smsmith * 3. Conditions 4467754Smsmith * 4567754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4667754Smsmith * Redistribution of source code of any substantial portion of the Covered 4767754Smsmith * Code or modification with rights to further distribute source must include 4867754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4967754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 5067754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5167754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5267754Smsmith * Code and the date of any change. Licensee must include in that file the 5367754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5467754Smsmith * must include a prominent statement that the modification is derived, 5567754Smsmith * directly or indirectly, from Original Intel Code. 5667754Smsmith * 5767754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5867754Smsmith * Redistribution of source code of any substantial portion of the Covered 5967754Smsmith * Code or modification without rights to further distribute source must 6067754Smsmith * include the following Disclaimer and Export Compliance provision in the 6167754Smsmith * documentation and/or other materials provided with distribution. In 6267754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6367754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6467754Smsmith * license from Licensee to its licensee is limited to the intellectual 6567754Smsmith * property embodied in the software Licensee provides to its licensee, and 6667754Smsmith * not to intellectual property embodied in modifications its licensee may 6767754Smsmith * make. 6867754Smsmith * 6967754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 7067754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7167754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7267754Smsmith * provision in the documentation and/or other materials provided with the 7367754Smsmith * distribution. 7467754Smsmith * 7567754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7667754Smsmith * Intel Code. 7767754Smsmith * 7867754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7967754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 8067754Smsmith * other dealings in products derived from or relating to the Covered Code 8167754Smsmith * without prior written authorization from Intel. 8267754Smsmith * 8367754Smsmith * 4. Disclaimer and Export Compliance 8467754Smsmith * 8567754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8667754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8767754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8867754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8967754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 9067754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9167754Smsmith * PARTICULAR PURPOSE. 9267754Smsmith * 9367754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9467754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9567754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9667754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9767754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9867754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9967754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 10067754Smsmith * LIMITED REMEDY. 10167754Smsmith * 10267754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10367754Smsmith * software or system incorporating such software without first obtaining any 10467754Smsmith * required license or other approval from the U. S. Department of Commerce or 10567754Smsmith * any other agency or department of the United States Government. In the 10667754Smsmith * event Licensee exports any such software from the United States or 10767754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10867754Smsmith * ensure that the distribution and export/re-export of the software is in 10967754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 11067754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11167754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11267754Smsmith * software, or service, directly or indirectly, to any country for which the 11367754Smsmith * United States government or any agency thereof requires an export license, 11467754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11567754Smsmith * such license, approval or letter. 11667754Smsmith * 11767754Smsmith *****************************************************************************/ 11867754Smsmith 11967754Smsmith#define __HWREGS_C__ 12067754Smsmith 12167754Smsmith#include "acpi.h" 12267754Smsmith#include "acnamesp.h" 123117521Snjl#include "acevents.h" 12467754Smsmith 12577424Smsmith#define _COMPONENT ACPI_HARDWARE 12691116Smsmith ACPI_MODULE_NAME ("hwregs") 12767754Smsmith 12867754Smsmith 12967754Smsmith/******************************************************************************* 13067754Smsmith * 13167754Smsmith * FUNCTION: AcpiHwClearAcpiStatus 13267754Smsmith * 133117521Snjl * PARAMETERS: Flags - Lock the hardware or not 13467754Smsmith * 13567754Smsmith * RETURN: none 13667754Smsmith * 13767754Smsmith * DESCRIPTION: Clears all fixed and general purpose status bits 13867754Smsmith * 13967754Smsmith ******************************************************************************/ 14067754Smsmith 14199679SiwasakiACPI_STATUS 142117521SnjlAcpiHwClearAcpiStatus ( 143117521Snjl UINT32 Flags) 14467754Smsmith{ 14591116Smsmith ACPI_STATUS Status; 14667754Smsmith 14767754Smsmith 14891116Smsmith ACPI_FUNCTION_TRACE ("HwClearAcpiStatus"); 14967754Smsmith 15067754Smsmith 15182367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n", 15291116Smsmith ACPI_BITMASK_ALL_FIXED_STATUS, 15377424Smsmith (UINT16) ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address))); 15467754Smsmith 155117521Snjl if (Flags & ACPI_MTX_LOCK) 15691116Smsmith { 157117521Snjl Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 158117521Snjl if (ACPI_FAILURE (Status)) 159117521Snjl { 160117521Snjl return_ACPI_STATUS (Status); 161117521Snjl } 16291116Smsmith } 16367754Smsmith 16499679Siwasaki Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS, 16599679Siwasaki ACPI_BITMASK_ALL_FIXED_STATUS); 16699679Siwasaki if (ACPI_FAILURE (Status)) 16799679Siwasaki { 16899679Siwasaki goto UnlockAndExit; 16999679Siwasaki } 17067754Smsmith 17191116Smsmith /* Clear the fixed events */ 17269450Smsmith 17370243Smsmith if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1bEvtBlk.Address)) 17467754Smsmith { 17599679Siwasaki Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS, 176117521Snjl &AcpiGbl_FADT->XPm1bEvtBlk); 17799679Siwasaki if (ACPI_FAILURE (Status)) 17899679Siwasaki { 17999679Siwasaki goto UnlockAndExit; 18099679Siwasaki } 18167754Smsmith } 18267754Smsmith 183114237Snjl /* Clear the GPE Bits in all GPE registers in all GPE blocks */ 18467754Smsmith 185117521Snjl Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock); 186117521Snjl 187117521SnjlUnlockAndExit: 188117521Snjl if (Flags & ACPI_MTX_LOCK) 18967754Smsmith { 190117521Snjl (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 19167754Smsmith } 19299679Siwasaki return_ACPI_STATUS (Status); 19367754Smsmith} 19467754Smsmith 19567754Smsmith 19667754Smsmith/******************************************************************************* 19767754Smsmith * 19899679Siwasaki * FUNCTION: AcpiGetSleepTypeData 19967754Smsmith * 20091116Smsmith * PARAMETERS: SleepState - Numeric sleep state 20191116Smsmith * *SleepTypeA - Where SLP_TYPa is returned 20291116Smsmith * *SleepTypeB - Where SLP_TYPb is returned 20367754Smsmith * 20467754Smsmith * RETURN: Status - ACPI status 20567754Smsmith * 20691116Smsmith * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep 20791116Smsmith * state. 20867754Smsmith * 20967754Smsmith ******************************************************************************/ 21067754Smsmith 21167754SmsmithACPI_STATUS 21299679SiwasakiAcpiGetSleepTypeData ( 21367754Smsmith UINT8 SleepState, 21491116Smsmith UINT8 *SleepTypeA, 21591116Smsmith UINT8 *SleepTypeB) 21667754Smsmith{ 21767754Smsmith ACPI_STATUS Status = AE_OK; 21867754Smsmith ACPI_OPERAND_OBJECT *ObjDesc; 21967754Smsmith 22067754Smsmith 22199679Siwasaki ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData"); 22267754Smsmith 22367754Smsmith 22467754Smsmith /* 22599679Siwasaki * Validate parameters 22667754Smsmith */ 22767754Smsmith if ((SleepState > ACPI_S_STATES_MAX) || 22891116Smsmith !SleepTypeA || !SleepTypeB) 22967754Smsmith { 23067754Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 23167754Smsmith } 23267754Smsmith 23367754Smsmith /* 23499679Siwasaki * Evaluate the namespace object containing the values for this state 23567754Smsmith */ 236114237Snjl Status = AcpiNsEvaluateByName ((char *) AcpiGbl_DbSleepStates[SleepState], 23783174Smsmith NULL, &ObjDesc); 23867754Smsmith if (ACPI_FAILURE (Status)) 23967754Smsmith { 240114237Snjl ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n", 241114237Snjl AcpiFormatException (Status), AcpiGbl_DbSleepStates[SleepState])); 242114237Snjl 24367754Smsmith return_ACPI_STATUS (Status); 24467754Smsmith } 24567754Smsmith 24699679Siwasaki /* Must have a return object */ 24799679Siwasaki 24867754Smsmith if (!ObjDesc) 24967754Smsmith { 25091116Smsmith ACPI_REPORT_ERROR (("Missing Sleep State object\n")); 25199679Siwasaki Status = AE_NOT_EXIST; 25267754Smsmith } 25367754Smsmith 25499679Siwasaki /* It must be of type Package */ 25567754Smsmith 25699679Siwasaki else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE) 25799679Siwasaki { 25899679Siwasaki ACPI_REPORT_ERROR (("Sleep State object not a Package\n")); 25999679Siwasaki Status = AE_AML_OPERAND_TYPE; 26099679Siwasaki } 26167754Smsmith 26299679Siwasaki /* The package must have at least two elements */ 26399679Siwasaki 26499679Siwasaki else if (ObjDesc->Package.Count < 2) 26567754Smsmith { 26691116Smsmith ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n")); 26791116Smsmith Status = AE_AML_NO_OPERAND; 26867754Smsmith } 26999679Siwasaki 27099679Siwasaki /* The first two elements must both be of type Integer */ 27199679Siwasaki 27299679Siwasaki else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) || 27399679Siwasaki (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER)) 27467754Smsmith { 27599679Siwasaki ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n", 27699679Siwasaki AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]), 27799679Siwasaki AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1]))); 27891116Smsmith Status = AE_AML_OPERAND_TYPE; 27967754Smsmith } 28067754Smsmith else 28167754Smsmith { 28267754Smsmith /* 28399679Siwasaki * Valid _Sx_ package size, type, and value 28467754Smsmith */ 28591116Smsmith *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value; 28691116Smsmith *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value; 28767754Smsmith } 28867754Smsmith 28967754Smsmith if (ACPI_FAILURE (Status)) 29067754Smsmith { 291114237Snjl ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n", 292114237Snjl AcpiGbl_DbSleepStates[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc))); 29367754Smsmith } 29467754Smsmith 29577424Smsmith AcpiUtRemoveReference (ObjDesc); 29667754Smsmith return_ACPI_STATUS (Status); 29767754Smsmith} 29867754Smsmith 29967754Smsmith 30067754Smsmith/******************************************************************************* 30167754Smsmith * 30291116Smsmith * FUNCTION: AcpiHwGetRegisterBitMask 30367754Smsmith * 30499679Siwasaki * PARAMETERS: RegisterId - Index of ACPI Register to access 305102550Siwasaki * 30691116Smsmith * RETURN: The bit mask to be used when accessing the register 30791116Smsmith * 30891116Smsmith * DESCRIPTION: Map RegisterId into a register bit mask. 30991116Smsmith * 31091116Smsmith ******************************************************************************/ 31191116Smsmith 31291116SmsmithACPI_BIT_REGISTER_INFO * 31391116SmsmithAcpiHwGetBitRegisterInfo ( 31491116Smsmith UINT32 RegisterId) 31591116Smsmith{ 31691116Smsmith ACPI_FUNCTION_NAME ("HwGetBitRegisterInfo"); 31791116Smsmith 31891116Smsmith 31991116Smsmith if (RegisterId > ACPI_BITREG_MAX) 32091116Smsmith { 32191116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid BitRegister ID: %X\n", RegisterId)); 32291116Smsmith return (NULL); 32391116Smsmith } 32491116Smsmith 32591116Smsmith return (&AcpiGbl_BitRegisterInfo[RegisterId]); 32691116Smsmith} 32791116Smsmith 32891116Smsmith 32991116Smsmith/******************************************************************************* 33091116Smsmith * 33199679Siwasaki * FUNCTION: AcpiGetRegister 33291116Smsmith * 333117521Snjl * PARAMETERS: RegisterId - ID of ACPI BitRegister to access 334117521Snjl * ReturnValue - Value that was read from the register 335117521Snjl * Flags - Lock the hardware or not 33667754Smsmith * 33791116Smsmith * RETURN: Value is read from specified Register. Value returned is 33891116Smsmith * normalized to bit0 (is shifted all the way right) 33967754Smsmith * 34091116Smsmith * DESCRIPTION: ACPI BitRegister read function. 34167754Smsmith * 34267754Smsmith ******************************************************************************/ 34367754Smsmith 34499679SiwasakiACPI_STATUS 34599679SiwasakiAcpiGetRegister ( 34667754Smsmith UINT32 RegisterId, 34799679Siwasaki UINT32 *ReturnValue, 34891116Smsmith UINT32 Flags) 34967754Smsmith{ 35067754Smsmith UINT32 RegisterValue = 0; 35191116Smsmith ACPI_BIT_REGISTER_INFO *BitRegInfo; 35299679Siwasaki ACPI_STATUS Status; 35367754Smsmith 35477424Smsmith 35599679Siwasaki ACPI_FUNCTION_TRACE ("AcpiGetRegister"); 35667754Smsmith 35767754Smsmith 35891116Smsmith /* Get the info structure corresponding to the requested ACPI Register */ 35991116Smsmith 36091116Smsmith BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); 36191116Smsmith if (!BitRegInfo) 36277424Smsmith { 36391116Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 36469450Smsmith } 36567754Smsmith 36699679Siwasaki if (Flags & ACPI_MTX_LOCK) 36799679Siwasaki { 36899679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 36999679Siwasaki if (ACPI_FAILURE (Status)) 37099679Siwasaki { 37199679Siwasaki return_ACPI_STATUS (Status); 37299679Siwasaki } 37399679Siwasaki } 37491116Smsmith 375102550Siwasaki Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, 37699679Siwasaki BitRegInfo->ParentRegister, &RegisterValue); 37799679Siwasaki 37891116Smsmith if (Flags & ACPI_MTX_LOCK) 37967754Smsmith { 38091116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 38191116Smsmith } 38267754Smsmith 38399679Siwasaki if (ACPI_SUCCESS (Status)) 38499679Siwasaki { 38599679Siwasaki /* Normalize the value that was read */ 38667754Smsmith 387102550Siwasaki RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) 38899679Siwasaki >> BitRegInfo->BitPosition); 38967754Smsmith 39099679Siwasaki *ReturnValue = RegisterValue; 39199679Siwasaki 392117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n", 393117521Snjl RegisterValue, BitRegInfo->ParentRegister)); 39499679Siwasaki } 39599679Siwasaki 39699679Siwasaki return_ACPI_STATUS (Status); 39791116Smsmith} 39867754Smsmith 39967754Smsmith 40091116Smsmith/******************************************************************************* 40191116Smsmith * 40299679Siwasaki * FUNCTION: AcpiSetRegister 40391116Smsmith * 40491116Smsmith * PARAMETERS: RegisterId - ID of ACPI BitRegister to access 40591116Smsmith * Value - (only used on write) value to write to the 40691116Smsmith * Register, NOT pre-normalized to the bit pos. 40791116Smsmith * Flags - Lock the hardware or not 40891116Smsmith * 40999679Siwasaki * RETURN: None 41091116Smsmith * 41191116Smsmith * DESCRIPTION: ACPI Bit Register write function. 41291116Smsmith * 41391116Smsmith ******************************************************************************/ 41467754Smsmith 41599679SiwasakiACPI_STATUS 41699679SiwasakiAcpiSetRegister ( 41791116Smsmith UINT32 RegisterId, 41891116Smsmith UINT32 Value, 41991116Smsmith UINT32 Flags) 42091116Smsmith{ 42191116Smsmith UINT32 RegisterValue = 0; 42291116Smsmith ACPI_BIT_REGISTER_INFO *BitRegInfo; 42399679Siwasaki ACPI_STATUS Status; 42467754Smsmith 42567754Smsmith 42699679Siwasaki ACPI_FUNCTION_TRACE_U32 ("AcpiSetRegister", RegisterId); 42767754Smsmith 42867754Smsmith 42991116Smsmith /* Get the info structure corresponding to the requested ACPI Register */ 43067754Smsmith 43191116Smsmith BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId); 43291116Smsmith if (!BitRegInfo) 43391116Smsmith { 43499679Siwasaki ACPI_REPORT_ERROR (("Bad ACPI HW RegisterId: %X\n", RegisterId)); 43591116Smsmith return_ACPI_STATUS (AE_BAD_PARAMETER); 43691116Smsmith } 43767754Smsmith 43899679Siwasaki if (Flags & ACPI_MTX_LOCK) 43999679Siwasaki { 44099679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 44199679Siwasaki if (ACPI_FAILURE (Status)) 44299679Siwasaki { 44399679Siwasaki return_ACPI_STATUS (Status); 44499679Siwasaki } 44599679Siwasaki } 44699679Siwasaki 44791116Smsmith /* Always do a register read first so we can insert the new bits */ 44867754Smsmith 449102550Siwasaki Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, 45099679Siwasaki BitRegInfo->ParentRegister, &RegisterValue); 45199679Siwasaki if (ACPI_FAILURE (Status)) 45299679Siwasaki { 45399679Siwasaki goto UnlockAndExit; 45499679Siwasaki } 45567754Smsmith 45691116Smsmith /* 45791116Smsmith * Decode the Register ID 45891116Smsmith * Register id = Register block id | bit id 45991116Smsmith * 46091116Smsmith * Check bit id to fine locate Register offset. 46191116Smsmith * Check Mask to determine Register offset, and then read-write. 46291116Smsmith */ 46391116Smsmith switch (BitRegInfo->ParentRegister) 46491116Smsmith { 46591116Smsmith case ACPI_REGISTER_PM1_STATUS: 46667754Smsmith 46791116Smsmith /* 46891116Smsmith * Status Registers are different from the rest. Clear by 469114237Snjl * writing 1, writing 0 has no effect. So, the only relevant 47091116Smsmith * information is the single bit we're interested in, all others should 47191116Smsmith * be written as 0 so they will be left unchanged 47291116Smsmith */ 473102550Siwasaki Value = ACPI_REGISTER_PREPARE_BITS (Value, 47499679Siwasaki BitRegInfo->BitPosition, BitRegInfo->AccessBitMask); 47591116Smsmith if (Value) 47669450Smsmith { 477102550Siwasaki Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, 47899679Siwasaki ACPI_REGISTER_PM1_STATUS, (UINT16) Value); 47991116Smsmith RegisterValue = 0; 48069450Smsmith } 48167754Smsmith break; 48267754Smsmith 48367754Smsmith 48491116Smsmith case ACPI_REGISTER_PM1_ENABLE: 48567754Smsmith 486102550Siwasaki ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, 48799679Siwasaki BitRegInfo->AccessBitMask, Value); 48867754Smsmith 489102550Siwasaki Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, 49099679Siwasaki ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue); 49191116Smsmith break; 49267754Smsmith 49367754Smsmith 49491116Smsmith case ACPI_REGISTER_PM1_CONTROL: 49567754Smsmith 49669450Smsmith /* 49769450Smsmith * Read the PM1 Control register. 49869450Smsmith * Note that at this level, the fact that there are actually TWO 49991116Smsmith * registers (A and B - and that B may not exist) is abstracted. 50069450Smsmith */ 50182367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", RegisterValue)); 50269450Smsmith 503102550Siwasaki ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, 50499679Siwasaki BitRegInfo->AccessBitMask, Value); 50567754Smsmith 506117525Snjl Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, 507117525Snjl ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue); 50867754Smsmith break; 50967754Smsmith 51067754Smsmith 51191116Smsmith case ACPI_REGISTER_PM2_CONTROL: 51267754Smsmith 513102550Siwasaki Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK, 51499679Siwasaki ACPI_REGISTER_PM2_CONTROL, &RegisterValue); 51599679Siwasaki if (ACPI_FAILURE (Status)) 51699679Siwasaki { 51799679Siwasaki goto UnlockAndExit; 51899679Siwasaki } 51967754Smsmith 52085756Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n", 521102550Siwasaki RegisterValue, 52299679Siwasaki ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)), 52399679Siwasaki ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); 52469450Smsmith 525102550Siwasaki ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, 52699679Siwasaki BitRegInfo->AccessBitMask, Value); 52767754Smsmith 52899679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", 52985756Smsmith RegisterValue, 53099679Siwasaki ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)), 53199679Siwasaki ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); 53267754Smsmith 53399679Siwasaki Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, 53491116Smsmith ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); 53567754Smsmith break; 53667754Smsmith 53767754Smsmith 53867754Smsmith default: 53967754Smsmith break; 54067754Smsmith } 54167754Smsmith 54299679Siwasaki 54399679SiwasakiUnlockAndExit: 54499679Siwasaki 54591116Smsmith if (Flags & ACPI_MTX_LOCK) 54691116Smsmith { 54791116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 54869450Smsmith } 54967754Smsmith 55091116Smsmith /* Normalize the value that was read */ 55169450Smsmith 55299679Siwasaki ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition)); 55367754Smsmith 554117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", 555117521Snjl Value, RegisterValue, BitRegInfo->ParentRegister)); 55699679Siwasaki return_ACPI_STATUS (Status); 55767754Smsmith} 55869450Smsmith 55969450Smsmith 56069450Smsmith/****************************************************************************** 56169450Smsmith * 56269450Smsmith * FUNCTION: AcpiHwRegisterRead 56369450Smsmith * 56469450Smsmith * PARAMETERS: UseLock - Mutex hw access. 56569450Smsmith * RegisterId - RegisterID + Offset. 56669450Smsmith * 56769450Smsmith * RETURN: Value read or written. 56869450Smsmith * 56969450Smsmith * DESCRIPTION: Acpi register read function. Registers are read at the 57069450Smsmith * given offset. 57169450Smsmith * 57269450Smsmith ******************************************************************************/ 57369450Smsmith 57499679SiwasakiACPI_STATUS 57569450SmsmithAcpiHwRegisterRead ( 57669450Smsmith BOOLEAN UseLock, 57799679Siwasaki UINT32 RegisterId, 57899679Siwasaki UINT32 *ReturnValue) 57969450Smsmith{ 58099679Siwasaki UINT32 Value1 = 0; 58199679Siwasaki UINT32 Value2 = 0; 58299679Siwasaki ACPI_STATUS Status; 58369450Smsmith 58477424Smsmith 58591116Smsmith ACPI_FUNCTION_TRACE ("HwRegisterRead"); 58669450Smsmith 58777424Smsmith 58869450Smsmith if (ACPI_MTX_LOCK == UseLock) 58969450Smsmith { 59099679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 59199679Siwasaki if (ACPI_FAILURE (Status)) 59291116Smsmith { 59399679Siwasaki return_ACPI_STATUS (Status); 59491116Smsmith } 59569450Smsmith } 59669450Smsmith 59791116Smsmith switch (RegisterId) 59869450Smsmith { 59991116Smsmith case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 60069450Smsmith 601117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk); 60299679Siwasaki if (ACPI_FAILURE (Status)) 60399679Siwasaki { 60499679Siwasaki goto UnlockAndExit; 60599679Siwasaki } 60699679Siwasaki 607117521Snjl /* PM1B is optional */ 608117521Snjl 609117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk); 61099679Siwasaki Value1 |= Value2; 61169450Smsmith break; 61269450Smsmith 61369450Smsmith 614117521Snjl case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 61569450Smsmith 616117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_XPm1aEnable); 61799679Siwasaki if (ACPI_FAILURE (Status)) 61899679Siwasaki { 61999679Siwasaki goto UnlockAndExit; 62099679Siwasaki } 62199679Siwasaki 622117521Snjl /* PM1B is optional */ 623117521Snjl 624117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_XPm1bEnable); 62599679Siwasaki Value1 |= Value2; 62669450Smsmith break; 62769450Smsmith 62869450Smsmith 62991116Smsmith case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 63069450Smsmith 631117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk); 63299679Siwasaki if (ACPI_FAILURE (Status)) 63399679Siwasaki { 63499679Siwasaki goto UnlockAndExit; 63599679Siwasaki } 63699679Siwasaki 637117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk); 63899679Siwasaki Value1 |= Value2; 63969450Smsmith break; 64069450Smsmith 64169450Smsmith 64291116Smsmith case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 64369450Smsmith 644117521Snjl Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk); 64569450Smsmith break; 64669450Smsmith 64769450Smsmith 64891116Smsmith case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 64969450Smsmith 650117521Snjl Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk); 65169450Smsmith break; 65269450Smsmith 65391116Smsmith case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 65469450Smsmith 65599679Siwasaki Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8); 65669450Smsmith break; 65769450Smsmith 65869450Smsmith default: 65999679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId)); 66099679Siwasaki Status = AE_BAD_PARAMETER; 66169450Smsmith break; 66269450Smsmith } 66369450Smsmith 66499679SiwasakiUnlockAndExit: 66569450Smsmith if (ACPI_MTX_LOCK == UseLock) 66669450Smsmith { 66791116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 66869450Smsmith } 66969450Smsmith 67099679Siwasaki if (ACPI_SUCCESS (Status)) 67199679Siwasaki { 67299679Siwasaki *ReturnValue = Value1; 67399679Siwasaki } 67499679Siwasaki 67599679Siwasaki return_ACPI_STATUS (Status); 67669450Smsmith} 67769450Smsmith 67869450Smsmith 67969450Smsmith/****************************************************************************** 68069450Smsmith * 68169450Smsmith * FUNCTION: AcpiHwRegisterWrite 68269450Smsmith * 68369450Smsmith * PARAMETERS: UseLock - Mutex hw access. 68469450Smsmith * RegisterId - RegisterID + Offset. 68569450Smsmith * 68669450Smsmith * RETURN: Value read or written. 68769450Smsmith * 68869450Smsmith * DESCRIPTION: Acpi register Write function. Registers are written at the 68969450Smsmith * given offset. 69069450Smsmith * 69169450Smsmith ******************************************************************************/ 69269450Smsmith 69399679SiwasakiACPI_STATUS 69469450SmsmithAcpiHwRegisterWrite ( 69569450Smsmith BOOLEAN UseLock, 69669450Smsmith UINT32 RegisterId, 69769450Smsmith UINT32 Value) 69869450Smsmith{ 69999679Siwasaki ACPI_STATUS Status; 70069450Smsmith 70169450Smsmith 70291116Smsmith ACPI_FUNCTION_TRACE ("HwRegisterWrite"); 70369450Smsmith 70483174Smsmith 70569450Smsmith if (ACPI_MTX_LOCK == UseLock) 70669450Smsmith { 70799679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 70899679Siwasaki if (ACPI_FAILURE (Status)) 70991116Smsmith { 71099679Siwasaki return_ACPI_STATUS (Status); 71191116Smsmith } 71269450Smsmith } 71369450Smsmith 71491116Smsmith switch (RegisterId) 71569450Smsmith { 71691116Smsmith case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 71769450Smsmith 718117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk); 71999679Siwasaki if (ACPI_FAILURE (Status)) 72099679Siwasaki { 72199679Siwasaki goto UnlockAndExit; 72299679Siwasaki } 72399679Siwasaki 724117521Snjl /* PM1B is optional */ 725117521Snjl 726117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk); 72769450Smsmith break; 72869450Smsmith 72969450Smsmith 73091116Smsmith case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ 73169450Smsmith 732117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1aEnable); 73399679Siwasaki if (ACPI_FAILURE (Status)) 73499679Siwasaki { 73599679Siwasaki goto UnlockAndExit; 73699679Siwasaki } 73799679Siwasaki 738117521Snjl /* PM1B is optional */ 739117521Snjl 740117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1bEnable); 74169450Smsmith break; 74269450Smsmith 74369450Smsmith 74491116Smsmith case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 74569450Smsmith 746117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); 74799679Siwasaki if (ACPI_FAILURE (Status)) 74899679Siwasaki { 74999679Siwasaki goto UnlockAndExit; 75099679Siwasaki } 75199679Siwasaki 752117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); 75371867Smsmith break; 75469450Smsmith 75569450Smsmith 75691116Smsmith case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 75769450Smsmith 758117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); 75969450Smsmith break; 76069450Smsmith 76169450Smsmith 76291116Smsmith case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 76371867Smsmith 764117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); 76571867Smsmith break; 76671867Smsmith 76771867Smsmith 76891116Smsmith case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 76969450Smsmith 770117521Snjl Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk); 77169450Smsmith break; 77269450Smsmith 77369450Smsmith 77491116Smsmith case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 77569450Smsmith 776117521Snjl Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk); 77769450Smsmith break; 77869450Smsmith 77969450Smsmith 78091116Smsmith case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 78169450Smsmith 78291116Smsmith /* SMI_CMD is currently always in IO space */ 78369450Smsmith 784117521Snjl Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, Value, 8); 78569450Smsmith break; 78669450Smsmith 78769450Smsmith 78869450Smsmith default: 78999679Siwasaki Status = AE_BAD_PARAMETER; 79069450Smsmith break; 79169450Smsmith } 79269450Smsmith 79399679SiwasakiUnlockAndExit: 79469450Smsmith if (ACPI_MTX_LOCK == UseLock) 79569450Smsmith { 79691116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 79769450Smsmith } 79869450Smsmith 79999679Siwasaki return_ACPI_STATUS (Status); 80069450Smsmith} 80169450Smsmith 80269450Smsmith 80369450Smsmith/****************************************************************************** 80469450Smsmith * 80569450Smsmith * FUNCTION: AcpiHwLowLevelRead 80669450Smsmith * 807117521Snjl * PARAMETERS: Width - 8, 16, or 32 808117521Snjl * Value - Where the value is returned 809117521Snjl * Register - GAS register structure 81069450Smsmith * 811117521Snjl * RETURN: Status 81269450Smsmith * 81369450Smsmith * DESCRIPTION: Read from either memory, IO, or PCI config space. 81469450Smsmith * 81569450Smsmith ******************************************************************************/ 81669450Smsmith 81799679SiwasakiACPI_STATUS 81869450SmsmithAcpiHwLowLevelRead ( 81969450Smsmith UINT32 Width, 82099679Siwasaki UINT32 *Value, 821117521Snjl ACPI_GENERIC_ADDRESS *Reg) 82269450Smsmith{ 82380062Smsmith ACPI_PCI_ID PciId; 82480062Smsmith UINT16 PciRegister; 82599679Siwasaki ACPI_STATUS Status; 82669450Smsmith 82769450Smsmith 82899679Siwasaki ACPI_FUNCTION_NAME ("HwLowLevelRead"); 82983174Smsmith 83083174Smsmith 83169450Smsmith /* 83269450Smsmith * Must have a valid pointer to a GAS structure, and 83399679Siwasaki * a non-zero address within. However, don't return an error 83499679Siwasaki * because the PM1A/B code must not fail if B isn't present. 83569450Smsmith */ 83669450Smsmith if ((!Reg) || 83770243Smsmith (!ACPI_VALID_ADDRESS (Reg->Address))) 83869450Smsmith { 83999679Siwasaki return (AE_OK); 84069450Smsmith } 84199679Siwasaki *Value = 0; 84269450Smsmith 84369450Smsmith /* 84469450Smsmith * Three address spaces supported: 84569450Smsmith * Memory, Io, or PCI config. 84669450Smsmith */ 84769450Smsmith switch (Reg->AddressSpaceId) 84869450Smsmith { 84977424Smsmith case ACPI_ADR_SPACE_SYSTEM_MEMORY: 85069450Smsmith 851117521Snjl Status = AcpiOsReadMemory ( 852117521Snjl (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 853117521Snjl Value, Width); 85469450Smsmith break; 85569450Smsmith 85669450Smsmith 85777424Smsmith case ACPI_ADR_SPACE_SYSTEM_IO: 85869450Smsmith 859117521Snjl Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 860117521Snjl Value, Width); 86169450Smsmith break; 86269450Smsmith 86369450Smsmith 86477424Smsmith case ACPI_ADR_SPACE_PCI_CONFIG: 86569450Smsmith 86680062Smsmith PciId.Segment = 0; 86780062Smsmith PciId.Bus = 0; 86880062Smsmith PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); 86980062Smsmith PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); 870117521Snjl PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); 87169450Smsmith 872117521Snjl Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, 873117521Snjl Value, Width); 87469450Smsmith break; 87599679Siwasaki 87699679Siwasaki 87799679Siwasaki default: 878117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 879117521Snjl "Unsupported address space: %X\n", Reg->AddressSpaceId)); 880117521Snjl return (AE_BAD_PARAMETER); 88169450Smsmith } 88269450Smsmith 883117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 884117521Snjl *Value, Width, 885117521Snjl ACPI_HIDWORD (ACPI_GET_ADDRESS (Reg->Address)), 886117521Snjl ACPI_LODWORD (ACPI_GET_ADDRESS (Reg->Address)), 887117521Snjl AcpiUtGetRegionName (Reg->AddressSpaceId))); 888117521Snjl 88999679Siwasaki return (Status); 89069450Smsmith} 89169450Smsmith 89269450Smsmith 89369450Smsmith/****************************************************************************** 89469450Smsmith * 89569450Smsmith * FUNCTION: AcpiHwLowLevelWrite 89669450Smsmith * 89769450Smsmith * PARAMETERS: Width - 8, 16, or 32 89869450Smsmith * Value - To be written 89969450Smsmith * Register - GAS register structure 90069450Smsmith * 901117521Snjl * RETURN: Status 90269450Smsmith * 903117521Snjl * DESCRIPTION: Write to either memory, IO, or PCI config space. 90469450Smsmith * 90569450Smsmith ******************************************************************************/ 90669450Smsmith 90799679SiwasakiACPI_STATUS 90869450SmsmithAcpiHwLowLevelWrite ( 90969450Smsmith UINT32 Width, 91069450Smsmith UINT32 Value, 911117521Snjl ACPI_GENERIC_ADDRESS *Reg) 91269450Smsmith{ 91380062Smsmith ACPI_PCI_ID PciId; 91480062Smsmith UINT16 PciRegister; 91599679Siwasaki ACPI_STATUS Status; 91669450Smsmith 91769450Smsmith 91899679Siwasaki ACPI_FUNCTION_NAME ("HwLowLevelWrite"); 91983174Smsmith 92083174Smsmith 92169450Smsmith /* 92269450Smsmith * Must have a valid pointer to a GAS structure, and 92399679Siwasaki * a non-zero address within. However, don't return an error 92499679Siwasaki * because the PM1A/B code must not fail if B isn't present. 92569450Smsmith */ 92669450Smsmith if ((!Reg) || 92770243Smsmith (!ACPI_VALID_ADDRESS (Reg->Address))) 92869450Smsmith { 92999679Siwasaki return (AE_OK); 93069450Smsmith } 93169450Smsmith /* 93269450Smsmith * Three address spaces supported: 93369450Smsmith * Memory, Io, or PCI config. 93469450Smsmith */ 93569450Smsmith switch (Reg->AddressSpaceId) 93669450Smsmith { 93777424Smsmith case ACPI_ADR_SPACE_SYSTEM_MEMORY: 93869450Smsmith 939117521Snjl Status = AcpiOsWriteMemory ( 940117521Snjl (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 941117521Snjl Value, Width); 94269450Smsmith break; 94369450Smsmith 94469450Smsmith 94577424Smsmith case ACPI_ADR_SPACE_SYSTEM_IO: 94669450Smsmith 947117521Snjl Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 948117521Snjl Value, Width); 94969450Smsmith break; 95069450Smsmith 95169450Smsmith 95277424Smsmith case ACPI_ADR_SPACE_PCI_CONFIG: 95369450Smsmith 95480062Smsmith PciId.Segment = 0; 95580062Smsmith PciId.Bus = 0; 95680062Smsmith PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); 95780062Smsmith PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); 958117521Snjl PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); 95969450Smsmith 960117521Snjl Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, 961117521Snjl (ACPI_INTEGER) Value, Width); 96269450Smsmith break; 96399679Siwasaki 96499679Siwasaki 96599679Siwasaki default: 966117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 967117521Snjl "Unsupported address space: %X\n", Reg->AddressSpaceId)); 968117521Snjl return (AE_BAD_PARAMETER); 96969450Smsmith } 97099679Siwasaki 971117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 972117521Snjl Value, Width, 973117521Snjl ACPI_HIDWORD (ACPI_GET_ADDRESS (Reg->Address)), 974117521Snjl ACPI_LODWORD (ACPI_GET_ADDRESS (Reg->Address)), 975117521Snjl AcpiUtGetRegionName (Reg->AddressSpaceId))); 976117521Snjl 97799679Siwasaki return (Status); 97869450Smsmith} 979