1 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/hwregs.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
2 /*******************************************************************************
4 * Module Name: hwregs - Read/write access functions for the various ACPI
5 * control and status registers.
8 ******************************************************************************/
10 /******************************************************************************
14 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
15 * All rights reserved.
19 * 2.1. This is your license from Intel Corp. under its intellectual property
20 * rights. You may have additional license terms from the party that provided
21 * you this software, covering your right to use that party's intellectual
24 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
25 * copy of the source code appearing in this file ("Covered Code") an
26 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
27 * base code distributed originally by Intel ("Original Intel Code") to copy,
28 * make derivatives, distribute, use and display any portion of the Covered
29 * Code in any form, with the right to sublicense such rights; and
31 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
32 * license (with the right to sublicense), under only those claims of Intel
33 * patents that are infringed by the Original Intel Code, to make, use, sell,
34 * offer to sell, and import the Covered Code and derivative works thereof
35 * solely to the minimum extent necessary to exercise the above copyright
36 * license, and in no event shall the patent license extend to any additions
37 * to or modifications of the Original Intel Code. No other license or right
38 * is granted directly or by implication, estoppel or otherwise;
40 * The above copyright and patent license is granted only if the following
45 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
46 * Redistribution of source code of any substantial portion of the Covered
47 * Code or modification with rights to further distribute source must include
48 * the above Copyright Notice, the above License, this list of Conditions,
49 * and the following Disclaimer and Export Compliance provision. In addition,
50 * Licensee must cause all Covered Code to which Licensee contributes to
51 * contain a file documenting the changes Licensee made to create that Covered
52 * Code and the date of any change. Licensee must include in that file the
53 * documentation of any changes made by any predecessor Licensee. Licensee
54 * must include a prominent statement that the modification is derived,
55 * directly or indirectly, from Original Intel Code.
57 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
58 * Redistribution of source code of any substantial portion of the Covered
59 * Code or modification without rights to further distribute source must
60 * include the following Disclaimer and Export Compliance provision in the
61 * documentation and/or other materials provided with distribution. In
62 * addition, Licensee may not authorize further sublicense of source of any
63 * portion of the Covered Code, and must include terms to the effect that the
64 * license from Licensee to its licensee is limited to the intellectual
65 * property embodied in the software Licensee provides to its licensee, and
66 * not to intellectual property embodied in modifications its licensee may
69 * 3.3. Redistribution of Executable. Redistribution in executable form of any
70 * substantial portion of the Covered Code or modification must reproduce the
71 * above Copyright Notice, and the following Disclaimer and Export Compliance
72 * provision in the documentation and/or other materials provided with the
75 * 3.4. Intel retains all right, title, and interest in and to the Original
78 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
79 * Intel shall be used in advertising or otherwise to promote the sale, use or
80 * other dealings in products derived from or relating to the Covered Code
81 * without prior written authorization from Intel.
83 * 4. Disclaimer and Export Compliance
85 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
86 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
87 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
88 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
89 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
90 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
93 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
94 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
95 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
96 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
97 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
98 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
99 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
102 * 4.3. Licensee shall not export, either directly or indirectly, any of this
103 * software or system incorporating such software without first obtaining any
104 * required license or other approval from the U. S. Department of Commerce or
105 * any other agency or department of the United States Government. In the
106 * event Licensee exports any such software from the United States or
107 * re-exports any such software from a foreign destination, Licensee shall
108 * ensure that the distribution and export/re-export of the software is in
109 * compliance with all laws, regulations, orders, or other restrictions of the
110 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
111 * any of its subsidiaries will export/re-export any technical data, process,
112 * software, or service, directly or indirectly, to any country for which the
113 * United States government or any agency thereof requires an export license,
114 * other governmental approval, or letter of assurance, without first obtaining
115 * such license, approval or letter.
117 *****************************************************************************/
122 #include "acnamesp.h"
124 #define _COMPONENT ACPI_HARDWARE
125 ACPI_MODULE_NAME ("hwregs")
128 /*******************************************************************************
130 * FUNCTION: AcpiHwClearAcpiStatus
136 * DESCRIPTION: Clears all fixed and general purpose status bits
138 ******************************************************************************/
141 AcpiHwClearAcpiStatus (void)
145 ACPI_GPE_BLOCK_INFO *GpeBlock;
148 ACPI_FUNCTION_TRACE ("HwClearAcpiStatus");
151 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
152 ACPI_BITMASK_ALL_FIXED_STATUS,
153 (UINT16) ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address)));
156 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
157 if (ACPI_FAILURE (Status))
159 return_ACPI_STATUS (Status);
162 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
163 ACPI_BITMASK_ALL_FIXED_STATUS);
164 if (ACPI_FAILURE (Status))
169 /* Clear the fixed events */
171 if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1bEvtBlk.Address))
173 Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS,
174 &AcpiGbl_FADT->XPm1bEvtBlk, 0);
175 if (ACPI_FAILURE (Status))
181 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
183 GpeBlock = AcpiGbl_GpeBlockListHead;
186 for (i = 0; i < GpeBlock->RegisterCount; i++)
188 Status = AcpiHwLowLevelWrite (8, 0xFF,
189 &GpeBlock->RegisterInfo[i].StatusAddress, (UINT32) 0);
190 if (ACPI_FAILURE (Status))
196 GpeBlock = GpeBlock->Next;
200 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
201 return_ACPI_STATUS (Status);
205 /*******************************************************************************
207 * FUNCTION: AcpiGetSleepTypeData
209 * PARAMETERS: SleepState - Numeric sleep state
210 * *SleepTypeA - Where SLP_TYPa is returned
211 * *SleepTypeB - Where SLP_TYPb is returned
213 * RETURN: Status - ACPI status
215 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
218 ******************************************************************************/
221 AcpiGetSleepTypeData (
226 ACPI_STATUS Status = AE_OK;
227 ACPI_OPERAND_OBJECT *ObjDesc;
230 ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData");
234 * Validate parameters
236 if ((SleepState > ACPI_S_STATES_MAX) ||
237 !SleepTypeA || !SleepTypeB)
239 return_ACPI_STATUS (AE_BAD_PARAMETER);
243 * Evaluate the namespace object containing the values for this state
245 Status = AcpiNsEvaluateByName ((char *) AcpiGbl_DbSleepStates[SleepState],
247 if (ACPI_FAILURE (Status))
249 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n",
250 AcpiFormatException (Status), AcpiGbl_DbSleepStates[SleepState]));
252 return_ACPI_STATUS (Status);
255 /* Must have a return object */
259 ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
260 Status = AE_NOT_EXIST;
263 /* It must be of type Package */
265 else if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_PACKAGE)
267 ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
268 Status = AE_AML_OPERAND_TYPE;
271 /* The package must have at least two elements */
273 else if (ObjDesc->Package.Count < 2)
275 ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
276 Status = AE_AML_NO_OPERAND;
279 /* The first two elements must both be of type Integer */
281 else if ((ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[0]) != ACPI_TYPE_INTEGER) ||
282 (ACPI_GET_OBJECT_TYPE (ObjDesc->Package.Elements[1]) != ACPI_TYPE_INTEGER))
284 ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
285 AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[0]),
286 AcpiUtGetObjectTypeName (ObjDesc->Package.Elements[1])));
287 Status = AE_AML_OPERAND_TYPE;
292 * Valid _Sx_ package size, type, and value
294 *SleepTypeA = (UINT8) (ObjDesc->Package.Elements[0])->Integer.Value;
295 *SleepTypeB = (UINT8) (ObjDesc->Package.Elements[1])->Integer.Value;
298 if (ACPI_FAILURE (Status))
300 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "While evaluating SleepState [%s], bad Sleep object %p type %s\n",
301 AcpiGbl_DbSleepStates[SleepState], ObjDesc, AcpiUtGetObjectTypeName (ObjDesc)));
304 AcpiUtRemoveReference (ObjDesc);
305 return_ACPI_STATUS (Status);
309 /*******************************************************************************
311 * FUNCTION: AcpiHwGetRegisterBitMask
313 * PARAMETERS: RegisterId - Index of ACPI Register to access
315 * RETURN: The bit mask to be used when accessing the register
317 * DESCRIPTION: Map RegisterId into a register bit mask.
319 ******************************************************************************/
321 ACPI_BIT_REGISTER_INFO *
322 AcpiHwGetBitRegisterInfo (
325 ACPI_FUNCTION_NAME ("HwGetBitRegisterInfo");
328 if (RegisterId > ACPI_BITREG_MAX)
330 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid BitRegister ID: %X\n", RegisterId));
334 return (&AcpiGbl_BitRegisterInfo[RegisterId]);
338 /*******************************************************************************
340 * FUNCTION: AcpiGetRegister
342 * PARAMETERS: RegisterId - Index of ACPI Register to access
343 * UseLock - Lock the hardware
345 * RETURN: Value is read from specified Register. Value returned is
346 * normalized to bit0 (is shifted all the way right)
348 * DESCRIPTION: ACPI BitRegister read function.
350 ******************************************************************************/
358 UINT32 RegisterValue = 0;
359 ACPI_BIT_REGISTER_INFO *BitRegInfo;
363 ACPI_FUNCTION_TRACE ("AcpiGetRegister");
366 /* Get the info structure corresponding to the requested ACPI Register */
368 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
371 return_ACPI_STATUS (AE_BAD_PARAMETER);
374 if (Flags & ACPI_MTX_LOCK)
376 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
377 if (ACPI_FAILURE (Status))
379 return_ACPI_STATUS (Status);
383 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
384 BitRegInfo->ParentRegister, &RegisterValue);
386 if (Flags & ACPI_MTX_LOCK)
388 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
391 if (ACPI_SUCCESS (Status))
393 /* Normalize the value that was read */
395 RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask)
396 >> BitRegInfo->BitPosition);
398 *ReturnValue = RegisterValue;
400 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %X\n", RegisterValue));
403 return_ACPI_STATUS (Status);
407 /*******************************************************************************
409 * FUNCTION: AcpiSetRegister
411 * PARAMETERS: RegisterId - ID of ACPI BitRegister to access
412 * Value - (only used on write) value to write to the
413 * Register, NOT pre-normalized to the bit pos.
414 * Flags - Lock the hardware or not
418 * DESCRIPTION: ACPI Bit Register write function.
420 ******************************************************************************/
428 UINT32 RegisterValue = 0;
429 ACPI_BIT_REGISTER_INFO *BitRegInfo;
433 ACPI_FUNCTION_TRACE_U32 ("AcpiSetRegister", RegisterId);
436 /* Get the info structure corresponding to the requested ACPI Register */
438 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
441 ACPI_REPORT_ERROR (("Bad ACPI HW RegisterId: %X\n", RegisterId));
442 return_ACPI_STATUS (AE_BAD_PARAMETER);
445 if (Flags & ACPI_MTX_LOCK)
447 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
448 if (ACPI_FAILURE (Status))
450 return_ACPI_STATUS (Status);
454 /* Always do a register read first so we can insert the new bits */
456 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
457 BitRegInfo->ParentRegister, &RegisterValue);
458 if (ACPI_FAILURE (Status))
464 * Decode the Register ID
465 * Register id = Register block id | bit id
467 * Check bit id to fine locate Register offset.
468 * Check Mask to determine Register offset, and then read-write.
470 switch (BitRegInfo->ParentRegister)
472 case ACPI_REGISTER_PM1_STATUS:
475 * Status Registers are different from the rest. Clear by
476 * writing 1, writing 0 has no effect. So, the only relevant
477 * information is the single bit we're interested in, all others should
478 * be written as 0 so they will be left unchanged
480 Value = ACPI_REGISTER_PREPARE_BITS (Value,
481 BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
484 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
485 ACPI_REGISTER_PM1_STATUS, (UINT16) Value);
491 case ACPI_REGISTER_PM1_ENABLE:
493 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
494 BitRegInfo->AccessBitMask, Value);
496 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
497 ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue);
501 case ACPI_REGISTER_PM1_CONTROL:
504 * Read the PM1 Control register.
505 * Note that at this level, the fact that there are actually TWO
506 * registers (A and B - and that B may not exist) is abstracted.
508 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", RegisterValue));
510 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
511 BitRegInfo->AccessBitMask, Value);
513 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
514 ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue);
518 case ACPI_REGISTER_PM2_CONTROL:
520 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
521 ACPI_REGISTER_PM2_CONTROL, &RegisterValue);
522 if (ACPI_FAILURE (Status))
527 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
529 ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)),
530 ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
532 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
533 BitRegInfo->AccessBitMask, Value);
535 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
537 ACPI_HIDWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address)),
538 ACPI_LODWORD (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
540 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
541 ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue));
552 if (Flags & ACPI_MTX_LOCK)
554 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
557 /* Normalize the value that was read */
559 ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition));
561 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "ACPI Register Write actual %X\n", RegisterValue));
562 return_ACPI_STATUS (Status);
566 /******************************************************************************
568 * FUNCTION: AcpiHwRegisterRead
570 * PARAMETERS: UseLock - Mutex hw access.
571 * RegisterId - RegisterID + Offset.
573 * RETURN: Value read or written.
575 * DESCRIPTION: Acpi register read function. Registers are read at the
578 ******************************************************************************/
592 ACPI_FUNCTION_TRACE ("HwRegisterRead");
595 if (ACPI_MTX_LOCK == UseLock)
597 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
598 if (ACPI_FAILURE (Status))
600 return_ACPI_STATUS (Status);
606 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
608 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk, 0);
609 if (ACPI_FAILURE (Status))
614 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk, 0);
619 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/
621 BankOffset = ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen);
622 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk, BankOffset);
623 if (ACPI_FAILURE (Status))
628 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk, BankOffset);
633 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
635 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk, 0);
636 if (ACPI_FAILURE (Status))
641 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk, 0);
646 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
648 Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk, 0);
652 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
654 Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk, 0);
657 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
659 Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8);
663 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId));
664 Status = AE_BAD_PARAMETER;
669 if (ACPI_MTX_LOCK == UseLock)
671 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
674 if (ACPI_SUCCESS (Status))
676 *ReturnValue = Value1;
679 return_ACPI_STATUS (Status);
683 /******************************************************************************
685 * FUNCTION: AcpiHwRegisterWrite
687 * PARAMETERS: UseLock - Mutex hw access.
688 * RegisterId - RegisterID + Offset.
690 * RETURN: Value read or written.
692 * DESCRIPTION: Acpi register Write function. Registers are written at the
695 ******************************************************************************/
698 AcpiHwRegisterWrite (
707 ACPI_FUNCTION_TRACE ("HwRegisterWrite");
710 if (ACPI_MTX_LOCK == UseLock)
712 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
713 if (ACPI_FAILURE (Status))
715 return_ACPI_STATUS (Status);
721 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
723 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk, 0);
724 if (ACPI_FAILURE (Status))
729 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk, 0);
733 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/
735 BankOffset = ACPI_DIV_2 (AcpiGbl_FADT->Pm1EvtLen);
736 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk, BankOffset);
737 if (ACPI_FAILURE (Status))
742 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk, BankOffset);
746 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
748 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk, 0);
749 if (ACPI_FAILURE (Status))
754 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk, 0);
758 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
760 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk, 0);
764 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
766 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk, 0);
770 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
772 Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk, 0);
776 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
778 Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk, 0);
782 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
784 /* SMI_CMD is currently always in IO space */
786 Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, (ACPI_INTEGER) Value, 8);
791 Status = AE_BAD_PARAMETER;
796 if (ACPI_MTX_LOCK == UseLock)
798 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
801 return_ACPI_STATUS (Status);
805 /******************************************************************************
807 * FUNCTION: AcpiHwLowLevelRead
809 * PARAMETERS: Register - GAS register structure
810 * Offset - Offset from the base address in the GAS
811 * Width - 8, 16, or 32
815 * DESCRIPTION: Read from either memory, IO, or PCI config space.
817 ******************************************************************************/
823 ACPI_GENERIC_ADDRESS *Reg,
826 ACPI_PHYSICAL_ADDRESS MemAddress;
827 ACPI_IO_ADDRESS IoAddress;
833 ACPI_FUNCTION_NAME ("HwLowLevelRead");
837 * Must have a valid pointer to a GAS structure, and
838 * a non-zero address within. However, don't return an error
839 * because the PM1A/B code must not fail if B isn't present.
842 (!ACPI_VALID_ADDRESS (Reg->Address)))
849 * Three address spaces supported:
850 * Memory, Io, or PCI config.
852 switch (Reg->AddressSpaceId)
854 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
856 MemAddress = (ACPI_GET_ADDRESS (Reg->Address)
857 + (ACPI_PHYSICAL_ADDRESS) Offset);
859 Status = AcpiOsReadMemory (MemAddress, Value, Width);
863 case ACPI_ADR_SPACE_SYSTEM_IO:
865 IoAddress = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (Reg->Address)
866 + (ACPI_PHYSICAL_ADDRESS) Offset);
868 Status = AcpiOsReadPort (IoAddress, Value, Width);
872 case ACPI_ADR_SPACE_PCI_CONFIG:
876 PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address));
877 PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address));
878 PciRegister = (UINT16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address))
881 Status = AcpiOsReadPciConfiguration (&PciId, PciRegister, Value, Width);
886 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId));
887 Status = AE_BAD_PARAMETER;
895 /******************************************************************************
897 * FUNCTION: AcpiHwLowLevelWrite
899 * PARAMETERS: Width - 8, 16, or 32
900 * Value - To be written
901 * Register - GAS register structure
902 * Offset - Offset from the base address in the GAS
907 * DESCRIPTION: Read from either memory, IO, or PCI config space.
909 ******************************************************************************/
912 AcpiHwLowLevelWrite (
915 ACPI_GENERIC_ADDRESS *Reg,
918 ACPI_PHYSICAL_ADDRESS MemAddress;
919 ACPI_IO_ADDRESS IoAddress;
925 ACPI_FUNCTION_NAME ("HwLowLevelWrite");
929 * Must have a valid pointer to a GAS structure, and
930 * a non-zero address within. However, don't return an error
931 * because the PM1A/B code must not fail if B isn't present.
934 (!ACPI_VALID_ADDRESS (Reg->Address)))
939 * Three address spaces supported:
940 * Memory, Io, or PCI config.
942 switch (Reg->AddressSpaceId)
944 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
946 MemAddress = (ACPI_GET_ADDRESS (Reg->Address)
947 + (ACPI_PHYSICAL_ADDRESS) Offset);
949 Status = AcpiOsWriteMemory (MemAddress, (ACPI_INTEGER) Value, Width);
953 case ACPI_ADR_SPACE_SYSTEM_IO:
955 IoAddress = (ACPI_IO_ADDRESS) (ACPI_GET_ADDRESS (Reg->Address)
956 + (ACPI_PHYSICAL_ADDRESS) Offset);
958 Status = AcpiOsWritePort (IoAddress, (ACPI_INTEGER) Value, Width);
962 case ACPI_ADR_SPACE_PCI_CONFIG:
966 PciId.Device = ACPI_PCI_DEVICE (ACPI_GET_ADDRESS (Reg->Address));
967 PciId.Function = ACPI_PCI_FUNCTION (ACPI_GET_ADDRESS (Reg->Address));
968 PciRegister = (UINT16) (ACPI_PCI_REGISTER (ACPI_GET_ADDRESS (Reg->Address))
971 Status = AcpiOsWritePciConfiguration (&PciId, PciRegister, (ACPI_INTEGER) Value, Width);
976 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unsupported address space: %X\n", Reg->AddressSpaceId));
977 Status = AE_BAD_PARAMETER;