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 - 2005, 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"
123 #include "acevents.h"
125 #define _COMPONENT ACPI_HARDWARE
126 ACPI_MODULE_NAME ("hwregs")
129 /*******************************************************************************
131 * FUNCTION: AcpiHwClearAcpiStatus
133 * PARAMETERS: Flags - Lock the hardware or not
137 * DESCRIPTION: Clears all fixed and general purpose status bits
138 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
140 ******************************************************************************/
143 AcpiHwClearAcpiStatus (
149 ACPI_FUNCTION_TRACE ("HwClearAcpiStatus");
152 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %04X to %04X\n",
153 ACPI_BITMASK_ALL_FIXED_STATUS,
154 (UINT16) ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm1aEvtBlk.Address)));
156 if (Flags & ACPI_MTX_LOCK)
158 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
159 if (ACPI_FAILURE (Status))
161 return_ACPI_STATUS (Status);
165 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK, ACPI_REGISTER_PM1_STATUS,
166 ACPI_BITMASK_ALL_FIXED_STATUS);
167 if (ACPI_FAILURE (Status))
172 /* Clear the fixed events */
174 if (ACPI_VALID_ADDRESS (AcpiGbl_FADT->XPm1bEvtBlk.Address))
176 Status = AcpiHwLowLevelWrite (16, ACPI_BITMASK_ALL_FIXED_STATUS,
177 &AcpiGbl_FADT->XPm1bEvtBlk);
178 if (ACPI_FAILURE (Status))
184 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
186 Status = AcpiEvWalkGpeList (AcpiHwClearGpeBlock, ACPI_ISR);
189 if (Flags & ACPI_MTX_LOCK)
191 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
193 return_ACPI_STATUS (Status);
197 /*******************************************************************************
199 * FUNCTION: AcpiGetSleepTypeData
201 * PARAMETERS: SleepState - Numeric sleep state
202 * *SleepTypeA - Where SLP_TYPa is returned
203 * *SleepTypeB - Where SLP_TYPb is returned
205 * RETURN: Status - ACPI status
207 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
210 ******************************************************************************/
213 AcpiGetSleepTypeData (
218 ACPI_STATUS Status = AE_OK;
219 ACPI_PARAMETER_INFO Info;
222 ACPI_FUNCTION_TRACE ("AcpiGetSleepTypeData");
226 * Validate parameters
228 if ((SleepState > ACPI_S_STATES_MAX) ||
229 !SleepTypeA || !SleepTypeB)
231 return_ACPI_STATUS (AE_BAD_PARAMETER);
235 * Evaluate the namespace object containing the values for this state
237 Info.Parameters = NULL;
238 Status = AcpiNsEvaluateByName ((char *) AcpiGbl_SleepStateNames[SleepState],
240 if (ACPI_FAILURE (Status))
242 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s while evaluating SleepState [%s]\n",
243 AcpiFormatException (Status), AcpiGbl_SleepStateNames[SleepState]));
245 return_ACPI_STATUS (Status);
248 /* Must have a return object */
250 if (!Info.ReturnObject)
252 ACPI_REPORT_ERROR (("Missing Sleep State object\n"));
253 Status = AE_NOT_EXIST;
256 /* It must be of type Package */
258 else if (ACPI_GET_OBJECT_TYPE (Info.ReturnObject) != ACPI_TYPE_PACKAGE)
260 ACPI_REPORT_ERROR (("Sleep State object not a Package\n"));
261 Status = AE_AML_OPERAND_TYPE;
264 /* The package must have at least two elements */
266 else if (Info.ReturnObject->Package.Count < 2)
268 ACPI_REPORT_ERROR (("Sleep State package does not have at least two elements\n"));
269 Status = AE_AML_NO_OPERAND;
272 /* The first two elements must both be of type Integer */
274 else if ((ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[0]) != ACPI_TYPE_INTEGER) ||
275 (ACPI_GET_OBJECT_TYPE (Info.ReturnObject->Package.Elements[1]) != ACPI_TYPE_INTEGER))
277 ACPI_REPORT_ERROR (("Sleep State package elements are not both Integers (%s, %s)\n",
278 AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[0]),
279 AcpiUtGetObjectTypeName (Info.ReturnObject->Package.Elements[1])));
280 Status = AE_AML_OPERAND_TYPE;
285 * Valid _Sx_ package size, type, and value
287 *SleepTypeA = (UINT8) (Info.ReturnObject->Package.Elements[0])->Integer.Value;
288 *SleepTypeB = (UINT8) (Info.ReturnObject->Package.Elements[1])->Integer.Value;
291 if (ACPI_FAILURE (Status))
293 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
294 "While evaluating SleepState [%s], bad Sleep object %p type %s\n",
295 AcpiGbl_SleepStateNames[SleepState], Info.ReturnObject,
296 AcpiUtGetObjectTypeName (Info.ReturnObject)));
299 AcpiUtRemoveReference (Info.ReturnObject);
300 return_ACPI_STATUS (Status);
304 /*******************************************************************************
306 * FUNCTION: AcpiHwGetRegisterBitMask
308 * PARAMETERS: RegisterId - Index of ACPI Register to access
310 * RETURN: The bit mask to be used when accessing the register
312 * DESCRIPTION: Map RegisterId into a register bit mask.
314 ******************************************************************************/
316 ACPI_BIT_REGISTER_INFO *
317 AcpiHwGetBitRegisterInfo (
320 ACPI_FUNCTION_NAME ("HwGetBitRegisterInfo");
323 if (RegisterId > ACPI_BITREG_MAX)
325 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid BitRegister ID: %X\n", RegisterId));
329 return (&AcpiGbl_BitRegisterInfo[RegisterId]);
333 /*******************************************************************************
335 * FUNCTION: AcpiGetRegister
337 * PARAMETERS: RegisterId - ID of ACPI BitRegister to access
338 * ReturnValue - Value that was read from the register
339 * Flags - Lock the hardware or not
341 * RETURN: Status and the value read from specified Register. Value
342 * returned is normalized to bit0 (is shifted all the way right)
344 * DESCRIPTION: ACPI BitRegister read function.
346 ******************************************************************************/
354 UINT32 RegisterValue = 0;
355 ACPI_BIT_REGISTER_INFO *BitRegInfo;
359 ACPI_FUNCTION_TRACE ("AcpiGetRegister");
362 /* Get the info structure corresponding to the requested ACPI Register */
364 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
367 return_ACPI_STATUS (AE_BAD_PARAMETER);
370 if (Flags & ACPI_MTX_LOCK)
372 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
373 if (ACPI_FAILURE (Status))
375 return_ACPI_STATUS (Status);
379 /* Read from the register */
381 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
382 BitRegInfo->ParentRegister, &RegisterValue);
384 if (Flags & ACPI_MTX_LOCK)
386 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
389 if (ACPI_SUCCESS (Status))
391 /* Normalize the value that was read */
393 RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask)
394 >> BitRegInfo->BitPosition);
396 *ReturnValue = RegisterValue;
398 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read value %8.8X register %X\n",
399 RegisterValue, BitRegInfo->ParentRegister));
402 return_ACPI_STATUS (Status);
406 /*******************************************************************************
408 * FUNCTION: AcpiSetRegister
410 * PARAMETERS: RegisterId - ID of ACPI BitRegister to access
411 * Value - (only used on write) value to write to the
412 * Register, NOT pre-normalized to the bit pos
413 * Flags - Lock the hardware or not
417 * DESCRIPTION: ACPI Bit Register write function.
419 ******************************************************************************/
427 UINT32 RegisterValue = 0;
428 ACPI_BIT_REGISTER_INFO *BitRegInfo;
432 ACPI_FUNCTION_TRACE_U32 ("AcpiSetRegister", RegisterId);
435 /* Get the info structure corresponding to the requested ACPI Register */
437 BitRegInfo = AcpiHwGetBitRegisterInfo (RegisterId);
440 ACPI_REPORT_ERROR (("Bad ACPI HW RegisterId: %X\n", RegisterId));
441 return_ACPI_STATUS (AE_BAD_PARAMETER);
444 if (Flags & ACPI_MTX_LOCK)
446 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
447 if (ACPI_FAILURE (Status))
449 return_ACPI_STATUS (Status);
453 /* Always do a register read first so we can insert the new bits */
455 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
456 BitRegInfo->ParentRegister, &RegisterValue);
457 if (ACPI_FAILURE (Status))
463 * Decode the Register ID
464 * Register ID = [Register block ID] | [bit ID]
466 * Check bit ID to fine locate Register offset.
467 * Check Mask to determine Register offset, and then read-write.
469 switch (BitRegInfo->ParentRegister)
471 case ACPI_REGISTER_PM1_STATUS:
474 * Status Registers are different from the rest. Clear by
475 * writing 1, and writing 0 has no effect. So, the only relevant
476 * information is the single bit we're interested in, all others should
477 * be written as 0 so they will be left unchanged.
479 Value = ACPI_REGISTER_PREPARE_BITS (Value,
480 BitRegInfo->BitPosition, BitRegInfo->AccessBitMask);
483 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
484 ACPI_REGISTER_PM1_STATUS, (UINT16) Value);
490 case ACPI_REGISTER_PM1_ENABLE:
492 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
493 BitRegInfo->AccessBitMask, Value);
495 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
496 ACPI_REGISTER_PM1_ENABLE, (UINT16) RegisterValue);
500 case ACPI_REGISTER_PM1_CONTROL:
503 * Write the PM1 Control register.
504 * Note that at this level, the fact that there are actually TWO
505 * registers (A and B - and B may not exist) is abstracted.
507 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM1 control: Read %X\n", RegisterValue));
509 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
510 BitRegInfo->AccessBitMask, Value);
512 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
513 ACPI_REGISTER_PM1_CONTROL, (UINT16) RegisterValue);
517 case ACPI_REGISTER_PM2_CONTROL:
519 Status = AcpiHwRegisterRead (ACPI_MTX_DO_NOT_LOCK,
520 ACPI_REGISTER_PM2_CONTROL, &RegisterValue);
521 if (ACPI_FAILURE (Status))
526 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "PM2 control: Read %X from %8.8X%8.8X\n",
528 ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
530 ACPI_REGISTER_INSERT_VALUE (RegisterValue, BitRegInfo->BitPosition,
531 BitRegInfo->AccessBitMask, Value);
533 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "About to write %4.4X to %8.8X%8.8X\n",
535 ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (AcpiGbl_FADT->XPm2CntBlk.Address))));
537 Status = AcpiHwRegisterWrite (ACPI_MTX_DO_NOT_LOCK,
538 ACPI_REGISTER_PM2_CONTROL, (UINT8) (RegisterValue));
549 if (Flags & ACPI_MTX_LOCK)
551 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
554 /* Normalize the value that was read */
556 ACPI_DEBUG_EXEC (RegisterValue = ((RegisterValue & BitRegInfo->AccessBitMask) >> BitRegInfo->BitPosition));
558 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Set bits: %8.8X actual %8.8X register %X\n",
559 Value, RegisterValue, BitRegInfo->ParentRegister));
560 return_ACPI_STATUS (Status);
564 /******************************************************************************
566 * FUNCTION: AcpiHwRegisterRead
568 * PARAMETERS: UseLock - Mutex hw access
569 * RegisterId - RegisterID + Offset
570 * ReturnValue - Value that was read from the register
572 * RETURN: Status and the value read.
574 * DESCRIPTION: Acpi register read function. Registers are read at the
577 ******************************************************************************/
590 ACPI_FUNCTION_TRACE ("HwRegisterRead");
593 if (ACPI_MTX_LOCK == UseLock)
595 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
596 if (ACPI_FAILURE (Status))
598 return_ACPI_STATUS (Status);
604 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
606 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aEvtBlk);
607 if (ACPI_FAILURE (Status))
612 /* PM1B is optional */
614 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bEvtBlk);
619 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access */
621 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_XPm1aEnable);
622 if (ACPI_FAILURE (Status))
627 /* PM1B is optional */
629 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_XPm1bEnable);
634 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
636 Status = AcpiHwLowLevelRead (16, &Value1, &AcpiGbl_FADT->XPm1aCntBlk);
637 if (ACPI_FAILURE (Status))
642 Status = AcpiHwLowLevelRead (16, &Value2, &AcpiGbl_FADT->XPm1bCntBlk);
647 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
649 Status = AcpiHwLowLevelRead (8, &Value1, &AcpiGbl_FADT->XPm2CntBlk);
653 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
655 Status = AcpiHwLowLevelRead (32, &Value1, &AcpiGbl_FADT->XPmTmrBlk);
658 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
660 Status = AcpiOsReadPort (AcpiGbl_FADT->SmiCmd, &Value1, 8);
664 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Unknown Register ID: %X\n", RegisterId));
665 Status = AE_BAD_PARAMETER;
670 if (ACPI_MTX_LOCK == UseLock)
672 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
675 if (ACPI_SUCCESS (Status))
677 *ReturnValue = Value1;
680 return_ACPI_STATUS (Status);
684 /******************************************************************************
686 * FUNCTION: AcpiHwRegisterWrite
688 * PARAMETERS: UseLock - Mutex hw access
689 * RegisterId - RegisterID + Offset
690 * Value - The value to write
694 * DESCRIPTION: Acpi register Write function. Registers are written at the
697 ******************************************************************************/
700 AcpiHwRegisterWrite (
708 ACPI_FUNCTION_TRACE ("HwRegisterWrite");
711 if (ACPI_MTX_LOCK == UseLock)
713 Status = AcpiUtAcquireMutex (ACPI_MTX_HARDWARE);
714 if (ACPI_FAILURE (Status))
716 return_ACPI_STATUS (Status);
722 case ACPI_REGISTER_PM1_STATUS: /* 16-bit access */
724 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aEvtBlk);
725 if (ACPI_FAILURE (Status))
730 /* PM1B is optional */
732 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bEvtBlk);
736 case ACPI_REGISTER_PM1_ENABLE: /* 16-bit access*/
738 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1aEnable);
739 if (ACPI_FAILURE (Status))
744 /* PM1B is optional */
746 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_XPm1bEnable);
750 case ACPI_REGISTER_PM1_CONTROL: /* 16-bit access */
752 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk);
753 if (ACPI_FAILURE (Status))
758 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk);
762 case ACPI_REGISTER_PM1A_CONTROL: /* 16-bit access */
764 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1aCntBlk);
768 case ACPI_REGISTER_PM1B_CONTROL: /* 16-bit access */
770 Status = AcpiHwLowLevelWrite (16, Value, &AcpiGbl_FADT->XPm1bCntBlk);
774 case ACPI_REGISTER_PM2_CONTROL: /* 8-bit access */
776 Status = AcpiHwLowLevelWrite (8, Value, &AcpiGbl_FADT->XPm2CntBlk);
780 case ACPI_REGISTER_PM_TIMER: /* 32-bit access */
782 Status = AcpiHwLowLevelWrite (32, Value, &AcpiGbl_FADT->XPmTmrBlk);
786 case ACPI_REGISTER_SMI_COMMAND_BLOCK: /* 8-bit access */
788 /* SMI_CMD is currently always in IO space */
790 Status = AcpiOsWritePort (AcpiGbl_FADT->SmiCmd, Value, 8);
795 Status = AE_BAD_PARAMETER;
800 if (ACPI_MTX_LOCK == UseLock)
802 (void) AcpiUtReleaseMutex (ACPI_MTX_HARDWARE);
805 return_ACPI_STATUS (Status);
809 /******************************************************************************
811 * FUNCTION: AcpiHwLowLevelRead
813 * PARAMETERS: Width - 8, 16, or 32
814 * Value - Where the value is returned
815 * Reg - GAS register structure
819 * DESCRIPTION: Read from either memory or IO space.
821 ******************************************************************************/
827 ACPI_GENERIC_ADDRESS *Reg)
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.
846 /* Get a local copy of the address. Handles possible alignment issues */
848 ACPI_MOVE_64_TO_64 (&Address, &Reg->Address);
849 if (!ACPI_VALID_ADDRESS (Address))
856 * Two address spaces supported: Memory or IO.
857 * PCI_Config is not supported here because the GAS struct is insufficient
859 switch (Reg->AddressSpaceId)
861 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
863 Status = AcpiOsReadMemory (
864 (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address),
869 case ACPI_ADR_SPACE_SYSTEM_IO:
871 Status = AcpiOsReadPort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address),
877 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
878 "Unsupported address space: %X\n", Reg->AddressSpaceId));
879 return (AE_BAD_PARAMETER);
882 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
884 ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)),
885 AcpiUtGetRegionName (Reg->AddressSpaceId)));
891 /******************************************************************************
893 * FUNCTION: AcpiHwLowLevelWrite
895 * PARAMETERS: Width - 8, 16, or 32
896 * Value - To be written
897 * Reg - GAS register structure
901 * DESCRIPTION: Write to either memory or IO space.
903 ******************************************************************************/
906 AcpiHwLowLevelWrite (
909 ACPI_GENERIC_ADDRESS *Reg)
915 ACPI_FUNCTION_NAME ("HwLowLevelWrite");
919 * Must have a valid pointer to a GAS structure, and
920 * a non-zero address within. However, don't return an error
921 * because the PM1A/B code must not fail if B isn't present.
928 /* Get a local copy of the address. Handles possible alignment issues */
930 ACPI_MOVE_64_TO_64 (&Address, &Reg->Address);
931 if (!ACPI_VALID_ADDRESS (Address))
937 * Two address spaces supported: Memory or IO.
938 * PCI_Config is not supported here because the GAS struct is insufficient
940 switch (Reg->AddressSpaceId)
942 case ACPI_ADR_SPACE_SYSTEM_MEMORY:
944 Status = AcpiOsWriteMemory (
945 (ACPI_PHYSICAL_ADDRESS) ACPI_GET_ADDRESS (Address),
950 case ACPI_ADR_SPACE_SYSTEM_IO:
952 Status = AcpiOsWritePort ((ACPI_IO_ADDRESS) ACPI_GET_ADDRESS (Address),
958 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
959 "Unsupported address space: %X\n", Reg->AddressSpaceId));
960 return (AE_BAD_PARAMETER);
963 ACPI_DEBUG_PRINT ((ACPI_DB_IO, "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
965 ACPI_FORMAT_UINT64 (ACPI_GET_ADDRESS (Address)),
966 AcpiUtGetRegionName (Reg->AddressSpaceId)));