hwregs.c revision 123315
167754Smsmith 267754Smsmith/******************************************************************************* 367754Smsmith * 467754Smsmith * Module Name: hwregs - Read/write access functions for the various ACPI 567754Smsmith * control and status registers. 6123315Snjl * $Revision: 152 $ 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 392123315Snjl 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 458123315Snjl * Register ID = [Register block ID] | [bit ID] 45991116Smsmith * 460123315Snjl * 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 469123315Snjl * writing 1, and writing 0 has no effect. So, the only relevant 47091116Smsmith * information is the single bit we're interested in, all others should 471123315Snjl * 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 /* 497123315Snjl * Write the PM1 Control register. 49869450Smsmith * Note that at this level, the fact that there are actually TWO 499123315Snjl * registers (A and B - and 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, 507123315Snjl 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, 522123315Snjl ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); 52369450Smsmith 524102550Siwasaki ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition, 52599679Siwasaki BitRegInfo->AccessBitMask, Value); 52667754Smsmith 52799679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n", 52885756Smsmith RegisterValue, 529123315Snjl ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)))); 53067754Smsmith 53199679Siwasaki Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, 53291116Smsmith ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue)); 53367754Smsmith break; 53467754Smsmith 53567754Smsmith 53667754Smsmith default: 53767754Smsmith break; 53867754Smsmith } 53967754Smsmith 54099679Siwasaki 54199679SiwasakiUnlockAndExit: 54299679Siwasaki 54391116Smsmith if (Flags & ACPI_MTX_LOCK) 54491116Smsmith { 54591116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 54669450Smsmith } 54767754Smsmith 54891116Smsmith /* Normalize the value that was read */ 54969450Smsmith 55099679Siwasaki ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition)); 55167754Smsmith 552117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n", 553117521Snjl Value, RegisterValue, BitRegInfo->ParentRegister)); 55499679Siwasaki return_ACPI_STATUS (Status); 55567754Smsmith} 55669450Smsmith 55769450Smsmith 55869450Smsmith/****************************************************************************** 55969450Smsmith * 56069450Smsmith * FUNCTION: AcpiHwRegisterRead 56169450Smsmith * 56269450Smsmith * PARAMETERS: UseLock - Mutex hw access. 56369450Smsmith * RegisterId - RegisterID + Offset. 56469450Smsmith * 56569450Smsmith * RETURN: Value read or written. 56669450Smsmith * 56769450Smsmith * DESCRIPTION: Acpi register read function. Registers are read at the 56869450Smsmith * given offset. 56969450Smsmith * 57069450Smsmith ******************************************************************************/ 57169450Smsmith 57299679SiwasakiACPI_STATUS 57369450SmsmithAcpiHwRegisterRead ( 57469450Smsmith BOOLEAN UseLock, 57599679Siwasaki UINT32 RegisterId, 57699679Siwasaki UINT32 *ReturnValue) 57769450Smsmith{ 57899679Siwasaki UINT32 Value1 = 0; 57999679Siwasaki UINT32 Value2 = 0; 58099679Siwasaki ACPI_STATUS Status; 58169450Smsmith 58277424Smsmith 58391116Smsmith ACPI_FUNCTION_TRACE ("HwRegisterRead"); 58469450Smsmith 58577424Smsmith 58669450Smsmith if (ACPI_MTX_LOCK == UseLock) 58769450Smsmith { 58899679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 58999679Siwasaki if (ACPI_FAILURE (Status)) 59091116Smsmith { 59199679Siwasaki return_ACPI_STATUS (Status); 59291116Smsmith } 59369450Smsmith } 59469450Smsmith 59591116Smsmith switch (RegisterId) 59669450Smsmith { 59791116Smsmith case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 59869450Smsmith 599117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk); 60099679Siwasaki if (ACPI_FAILURE (Status)) 60199679Siwasaki { 60299679Siwasaki goto UnlockAndExit; 60399679Siwasaki } 60499679Siwasaki 605117521Snjl /* PM1B is optional */ 606117521Snjl 607117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk); 60899679Siwasaki Value1 |= Value2; 60969450Smsmith break; 61069450Smsmith 61169450Smsmith 612117521Snjl case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */ 61369450Smsmith 614117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_XPm1aEnable); 61599679Siwasaki if (ACPI_FAILURE (Status)) 61699679Siwasaki { 61799679Siwasaki goto UnlockAndExit; 61899679Siwasaki } 61999679Siwasaki 620117521Snjl /* PM1B is optional */ 621117521Snjl 622117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_XPm1bEnable); 62399679Siwasaki Value1 |= Value2; 62469450Smsmith break; 62569450Smsmith 62669450Smsmith 62791116Smsmith case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 62869450Smsmith 629117521Snjl Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk); 63099679Siwasaki if (ACPI_FAILURE (Status)) 63199679Siwasaki { 63299679Siwasaki goto UnlockAndExit; 63399679Siwasaki } 63499679Siwasaki 635117521Snjl Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk); 63699679Siwasaki Value1 |= Value2; 63769450Smsmith break; 63869450Smsmith 63969450Smsmith 64091116Smsmith case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 64169450Smsmith 642117521Snjl Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk); 64369450Smsmith break; 64469450Smsmith 64569450Smsmith 64691116Smsmith case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 64769450Smsmith 648117521Snjl Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk); 64969450Smsmith break; 65069450Smsmith 65191116Smsmith case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 65269450Smsmith 65399679Siwasaki Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8); 65469450Smsmith break; 65569450Smsmith 65669450Smsmith default: 65799679Siwasaki ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId)); 65899679Siwasaki Status = AE_BAD_PARAMETER; 65969450Smsmith break; 66069450Smsmith } 66169450Smsmith 66299679SiwasakiUnlockAndExit: 66369450Smsmith if (ACPI_MTX_LOCK == UseLock) 66469450Smsmith { 66591116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 66669450Smsmith } 66769450Smsmith 66899679Siwasaki if (ACPI_SUCCESS (Status)) 66999679Siwasaki { 67099679Siwasaki *ReturnValue = Value1; 67199679Siwasaki } 67299679Siwasaki 67399679Siwasaki return_ACPI_STATUS (Status); 67469450Smsmith} 67569450Smsmith 67669450Smsmith 67769450Smsmith/****************************************************************************** 67869450Smsmith * 67969450Smsmith * FUNCTION: AcpiHwRegisterWrite 68069450Smsmith * 68169450Smsmith * PARAMETERS: UseLock - Mutex hw access. 68269450Smsmith * RegisterId - RegisterID + Offset. 68369450Smsmith * 68469450Smsmith * RETURN: Value read or written. 68569450Smsmith * 68669450Smsmith * DESCRIPTION: Acpi register Write function. Registers are written at the 68769450Smsmith * given offset. 68869450Smsmith * 68969450Smsmith ******************************************************************************/ 69069450Smsmith 69199679SiwasakiACPI_STATUS 69269450SmsmithAcpiHwRegisterWrite ( 69369450Smsmith BOOLEAN UseLock, 69469450Smsmith UINT32 RegisterId, 69569450Smsmith UINT32 Value) 69669450Smsmith{ 69799679Siwasaki ACPI_STATUS Status; 69869450Smsmith 69969450Smsmith 70091116Smsmith ACPI_FUNCTION_TRACE ("HwRegisterWrite"); 70169450Smsmith 70283174Smsmith 70369450Smsmith if (ACPI_MTX_LOCK == UseLock) 70469450Smsmith { 70599679Siwasaki Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE); 70699679Siwasaki if (ACPI_FAILURE (Status)) 70791116Smsmith { 70899679Siwasaki return_ACPI_STATUS (Status); 70991116Smsmith } 71069450Smsmith } 71169450Smsmith 71291116Smsmith switch (RegisterId) 71369450Smsmith { 71491116Smsmith case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */ 71569450Smsmith 716117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk); 71799679Siwasaki if (ACPI_FAILURE (Status)) 71899679Siwasaki { 71999679Siwasaki goto UnlockAndExit; 72099679Siwasaki } 72199679Siwasaki 722117521Snjl /* PM1B is optional */ 723117521Snjl 724117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk); 72569450Smsmith break; 72669450Smsmith 72769450Smsmith 72891116Smsmith case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/ 72969450Smsmith 730117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1aEnable); 73199679Siwasaki if (ACPI_FAILURE (Status)) 73299679Siwasaki { 73399679Siwasaki goto UnlockAndExit; 73499679Siwasaki } 73599679Siwasaki 736117521Snjl /* PM1B is optional */ 737117521Snjl 738117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1bEnable); 73969450Smsmith break; 74069450Smsmith 74169450Smsmith 74291116Smsmith case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */ 74369450Smsmith 744117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); 74599679Siwasaki if (ACPI_FAILURE (Status)) 74699679Siwasaki { 74799679Siwasaki goto UnlockAndExit; 74899679Siwasaki } 74999679Siwasaki 750117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); 75171867Smsmith break; 75269450Smsmith 75369450Smsmith 75491116Smsmith case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */ 75569450Smsmith 756117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk); 75769450Smsmith break; 75869450Smsmith 75969450Smsmith 76091116Smsmith case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */ 76171867Smsmith 762117521Snjl Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk); 76371867Smsmith break; 76471867Smsmith 76571867Smsmith 76691116Smsmith case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */ 76769450Smsmith 768117521Snjl Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk); 76969450Smsmith break; 77069450Smsmith 77169450Smsmith 77291116Smsmith case ACPI_REGISTER_PM_TIMER: /* 32-bit access */ 77369450Smsmith 774117521Snjl Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk); 77569450Smsmith break; 77669450Smsmith 77769450Smsmith 77891116Smsmith case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */ 77969450Smsmith 78091116Smsmith /* SMI_CMD is currently always in IO space */ 78169450Smsmith 782117521Snjl Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, Value, 8); 78369450Smsmith break; 78469450Smsmith 78569450Smsmith 78669450Smsmith default: 78799679Siwasaki Status = AE_BAD_PARAMETER; 78869450Smsmith break; 78969450Smsmith } 79069450Smsmith 79199679SiwasakiUnlockAndExit: 79269450Smsmith if (ACPI_MTX_LOCK == UseLock) 79369450Smsmith { 79491116Smsmith (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE); 79569450Smsmith } 79669450Smsmith 79799679Siwasaki return_ACPI_STATUS (Status); 79869450Smsmith} 79969450Smsmith 80069450Smsmith 80169450Smsmith/****************************************************************************** 80269450Smsmith * 80369450Smsmith * FUNCTION: AcpiHwLowLevelRead 80469450Smsmith * 805117521Snjl * PARAMETERS: Width - 8, 16, or 32 806117521Snjl * Value - Where the value is returned 807117521Snjl * Register - GAS register structure 80869450Smsmith * 809117521Snjl * RETURN: Status 81069450Smsmith * 81169450Smsmith * DESCRIPTION: Read from either memory, IO, or PCI config space. 81269450Smsmith * 81369450Smsmith ******************************************************************************/ 81469450Smsmith 81599679SiwasakiACPI_STATUS 81669450SmsmithAcpiHwLowLevelRead ( 81769450Smsmith UINT32 Width, 81899679Siwasaki UINT32 *Value, 819117521Snjl ACPI_GENERIC_ADDRESS *Reg) 82069450Smsmith{ 82180062Smsmith ACPI_PCI_ID PciId; 82280062Smsmith UINT16 PciRegister; 82399679Siwasaki ACPI_STATUS Status; 82469450Smsmith 82569450Smsmith 82699679Siwasaki ACPI_FUNCTION_NAME ("HwLowLevelRead"); 82783174Smsmith 82883174Smsmith 82969450Smsmith /* 83069450Smsmith * Must have a valid pointer to a GAS structure, and 83199679Siwasaki * a non-zero address within. However, don't return an error 83299679Siwasaki * because the PM1A/B code must not fail if B isn't present. 83369450Smsmith */ 83469450Smsmith if ((!Reg) || 83570243Smsmith (!ACPI_VALID_ADDRESS (Reg->Address))) 83669450Smsmith { 83799679Siwasaki return (AE_OK); 83869450Smsmith } 83999679Siwasaki *Value = 0; 84069450Smsmith 84169450Smsmith /* 84269450Smsmith * Three address spaces supported: 843123315Snjl * Memory, IO, or PCI_Config. 84469450Smsmith */ 84569450Smsmith switch (Reg->AddressSpaceId) 84669450Smsmith { 84777424Smsmith case ACPI_ADR_SPACE_SYSTEM_MEMORY: 84869450Smsmith 849117521Snjl Status = AcpiOsReadMemory ( 850117521Snjl (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 851117521Snjl Value, Width); 85269450Smsmith break; 85369450Smsmith 85469450Smsmith 85577424Smsmith case ACPI_ADR_SPACE_SYSTEM_IO: 85669450Smsmith 857117521Snjl Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 858117521Snjl Value, Width); 85969450Smsmith break; 86069450Smsmith 86169450Smsmith 86277424Smsmith case ACPI_ADR_SPACE_PCI_CONFIG: 86369450Smsmith 86480062Smsmith PciId.Segment = 0; 86580062Smsmith PciId.Bus = 0; 86680062Smsmith PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); 86780062Smsmith PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); 868117521Snjl PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); 86969450Smsmith 870117521Snjl Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, 871117521Snjl Value, Width); 87269450Smsmith break; 87399679Siwasaki 87499679Siwasaki 87599679Siwasaki default: 876117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 877117521Snjl "Unsupported address space: %X\n", Reg->AddressSpaceId)); 878117521Snjl return (AE_BAD_PARAMETER); 87969450Smsmith } 88069450Smsmith 881117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n", 882123315Snjl *Value, Width, 883123315Snjl ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), 884117521Snjl AcpiUtGetRegionName (Reg->AddressSpaceId))); 885117521Snjl 88699679Siwasaki return (Status); 88769450Smsmith} 88869450Smsmith 88969450Smsmith 89069450Smsmith/****************************************************************************** 89169450Smsmith * 89269450Smsmith * FUNCTION: AcpiHwLowLevelWrite 89369450Smsmith * 89469450Smsmith * PARAMETERS: Width - 8, 16, or 32 89569450Smsmith * Value - To be written 89669450Smsmith * Register - GAS register structure 89769450Smsmith * 898117521Snjl * RETURN: Status 89969450Smsmith * 900117521Snjl * DESCRIPTION: Write to either memory, IO, or PCI config space. 90169450Smsmith * 90269450Smsmith ******************************************************************************/ 90369450Smsmith 90499679SiwasakiACPI_STATUS 90569450SmsmithAcpiHwLowLevelWrite ( 90669450Smsmith UINT32 Width, 90769450Smsmith UINT32 Value, 908117521Snjl ACPI_GENERIC_ADDRESS *Reg) 90969450Smsmith{ 91080062Smsmith ACPI_PCI_ID PciId; 91180062Smsmith UINT16 PciRegister; 91299679Siwasaki ACPI_STATUS Status; 91369450Smsmith 91469450Smsmith 91599679Siwasaki ACPI_FUNCTION_NAME ("HwLowLevelWrite"); 91683174Smsmith 91783174Smsmith 91869450Smsmith /* 91969450Smsmith * Must have a valid pointer to a GAS structure, and 92099679Siwasaki * a non-zero address within. However, don't return an error 92199679Siwasaki * because the PM1A/B code must not fail if B isn't present. 92269450Smsmith */ 92369450Smsmith if ((!Reg) || 92470243Smsmith (!ACPI_VALID_ADDRESS (Reg->Address))) 92569450Smsmith { 92699679Siwasaki return (AE_OK); 92769450Smsmith } 928123315Snjl 92969450Smsmith /* 93069450Smsmith * Three address spaces supported: 931123315Snjl * Memory, IO, or PCI_Config. 93269450Smsmith */ 93369450Smsmith switch (Reg->AddressSpaceId) 93469450Smsmith { 93577424Smsmith case ACPI_ADR_SPACE_SYSTEM_MEMORY: 93669450Smsmith 937117521Snjl Status = AcpiOsWriteMemory ( 938117521Snjl (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 939117521Snjl Value, Width); 94069450Smsmith break; 94169450Smsmith 94269450Smsmith 94377424Smsmith case ACPI_ADR_SPACE_SYSTEM_IO: 94469450Smsmith 945117521Snjl Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Reg->Address), 946117521Snjl Value, Width); 94769450Smsmith break; 94869450Smsmith 94969450Smsmith 95077424Smsmith case ACPI_ADR_SPACE_PCI_CONFIG: 95169450Smsmith 95280062Smsmith PciId.Segment = 0; 95380062Smsmith PciId.Bus = 0; 95480062Smsmith PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address)); 95580062Smsmith PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address)); 956117521Snjl PciRegister = (UINT16) ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address)); 95769450Smsmith 958117521Snjl Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, 959117521Snjl (ACPI_INTEGER) Value, Width); 96069450Smsmith break; 96199679Siwasaki 96299679Siwasaki 96399679Siwasaki default: 964117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 965117521Snjl "Unsupported address space: %X\n", Reg->AddressSpaceId)); 966117521Snjl return (AE_BAD_PARAMETER); 96769450Smsmith } 96899679Siwasaki 969117521Snjl ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n", 970123315Snjl Value, Width, 971123315Snjl ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Reg->Address)), 972117521Snjl AcpiUtGetRegionName (Reg->AddressSpaceId))); 973117521Snjl 97499679Siwasaki return (Status); 97569450Smsmith} 976