2 /*******************************************************************************
4 * Module Name: hwregs - Read/write access functions for the various ACPI
5 * control and status registers.
7 ******************************************************************************/
10 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * All rights reserved.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions, and the following disclaimer,
18 * without modification.
19 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
20 * substantially similar to the "NO WARRANTY" disclaimer below
21 * ("Disclaimer") and any redistribution must be conditioned upon
22 * including a substantially similar Disclaimer requirement for further
23 * binary redistribution.
24 * 3. Neither the names of the above-listed copyright holders nor the names
25 * of any contributors may be used to endorse or promote products derived
26 * from this software without specific prior written permission.
28 * Alternatively, this software may be distributed under the terms of the
29 * GNU General Public License ("GPL") version 2 as published by the Free
30 * Software Foundation.
33 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
34 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
36 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
37 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
38 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
39 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
40 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
41 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
42 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
43 * POSSIBILITY OF SUCH DAMAGES.
46 #include <linux/module.h>
48 #include <acpi/acpi.h>
49 #include <acpi/acnamesp.h>
50 #include <acpi/acevents.h>
52 #define _COMPONENT ACPI_HARDWARE
53 ACPI_MODULE_NAME ("hwregs")
56 /*******************************************************************************
58 * FUNCTION: acpi_hw_clear_acpi_status
60 * PARAMETERS: Flags - Lock the hardware or not
64 * DESCRIPTION: Clears all fixed and general purpose status bits
65 * THIS FUNCTION MUST BE CALLED WITH INTERRUPTS DISABLED
67 ******************************************************************************/
70 acpi_hw_clear_acpi_status (
76 ACPI_FUNCTION_TRACE ("hw_clear_acpi_status");
79 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "About to write %04X to %04X\n",
80 ACPI_BITMASK_ALL_FIXED_STATUS
,
81 (u16
) acpi_gbl_FADT
->xpm1a_evt_blk
.address
));
83 if (flags
& ACPI_MTX_LOCK
) {
84 status
= acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE
);
85 if (ACPI_FAILURE (status
)) {
86 return_ACPI_STATUS (status
);
90 status
= acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK
,
91 ACPI_REGISTER_PM1_STATUS
,
92 ACPI_BITMASK_ALL_FIXED_STATUS
);
93 if (ACPI_FAILURE (status
)) {
97 /* Clear the fixed events */
99 if (acpi_gbl_FADT
->xpm1b_evt_blk
.address
) {
100 status
= acpi_hw_low_level_write (16, ACPI_BITMASK_ALL_FIXED_STATUS
,
101 &acpi_gbl_FADT
->xpm1b_evt_blk
);
102 if (ACPI_FAILURE (status
)) {
103 goto unlock_and_exit
;
107 /* Clear the GPE Bits in all GPE registers in all GPE blocks */
109 status
= acpi_ev_walk_gpe_list (acpi_hw_clear_gpe_block
, ACPI_ISR
);
112 if (flags
& ACPI_MTX_LOCK
) {
113 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE
);
115 return_ACPI_STATUS (status
);
119 /*******************************************************************************
121 * FUNCTION: acpi_get_sleep_type_data
123 * PARAMETERS: sleep_state - Numeric sleep state
124 * *sleep_type_a - Where SLP_TYPa is returned
125 * *sleep_type_b - Where SLP_TYPb is returned
127 * RETURN: Status - ACPI status
129 * DESCRIPTION: Obtain the SLP_TYPa and SLP_TYPb values for the requested sleep
132 ******************************************************************************/
135 acpi_get_sleep_type_data (
140 acpi_status status
= AE_OK
;
141 struct acpi_parameter_info info
;
142 char *sleep_state_name
;
145 ACPI_FUNCTION_TRACE ("acpi_get_sleep_type_data");
148 /* Validate parameters */
150 if ((sleep_state
> ACPI_S_STATES_MAX
) ||
151 !sleep_type_a
|| !sleep_type_b
) {
152 return_ACPI_STATUS (AE_BAD_PARAMETER
);
155 /* Evaluate the namespace object containing the values for this state */
157 info
.parameters
= NULL
;
158 info
.return_object
= NULL
;
159 sleep_state_name
= (char *) acpi_gbl_sleep_state_names
[sleep_state
];
161 status
= acpi_ns_evaluate_by_name (sleep_state_name
, &info
);
162 if (ACPI_FAILURE (status
)) {
163 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC
,
164 "%s while evaluating sleep_state [%s]\n",
165 acpi_format_exception (status
), sleep_state_name
));
167 return_ACPI_STATUS (status
);
170 /* Must have a return object */
172 if (!info
.return_object
) {
173 ACPI_REPORT_ERROR (("No Sleep State object returned from [%s]\n",
175 status
= AE_NOT_EXIST
;
178 /* It must be of type Package */
180 else if (ACPI_GET_OBJECT_TYPE (info
.return_object
) != ACPI_TYPE_PACKAGE
) {
181 ACPI_REPORT_ERROR (("Sleep State return object is not a Package\n"));
182 status
= AE_AML_OPERAND_TYPE
;
186 * The package must have at least two elements. NOTE (March 2005): This
187 * goes against the current ACPI spec which defines this object as a
188 * package with one encoded DWORD element. However, existing practice
189 * by BIOS vendors seems to be to have 2 or more elements, at least
190 * one per sleep type (A/B).
192 else if (info
.return_object
->package
.count
< 2) {
194 "Sleep State return package does not have at least two elements\n"));
195 status
= AE_AML_NO_OPERAND
;
198 /* The first two elements must both be of type Integer */
200 else if ((ACPI_GET_OBJECT_TYPE (info
.return_object
->package
.elements
[0])
201 != ACPI_TYPE_INTEGER
) ||
202 (ACPI_GET_OBJECT_TYPE (info
.return_object
->package
.elements
[1])
203 != ACPI_TYPE_INTEGER
)) {
205 "Sleep State return package elements are not both Integers (%s, %s)\n",
206 acpi_ut_get_object_type_name (info
.return_object
->package
.elements
[0]),
207 acpi_ut_get_object_type_name (info
.return_object
->package
.elements
[1])));
208 status
= AE_AML_OPERAND_TYPE
;
211 /* Valid _Sx_ package size, type, and value */
214 (info
.return_object
->package
.elements
[0])->integer
.value
;
216 (info
.return_object
->package
.elements
[1])->integer
.value
;
219 if (ACPI_FAILURE (status
)) {
220 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
221 "%s While evaluating sleep_state [%s], bad Sleep object %p type %s\n",
222 acpi_format_exception (status
),
223 sleep_state_name
, info
.return_object
,
224 acpi_ut_get_object_type_name (info
.return_object
)));
227 acpi_ut_remove_reference (info
.return_object
);
228 return_ACPI_STATUS (status
);
230 EXPORT_SYMBOL(acpi_get_sleep_type_data
);
233 /*******************************************************************************
235 * FUNCTION: acpi_hw_get_register_bit_mask
237 * PARAMETERS: register_id - Index of ACPI Register to access
239 * RETURN: The bitmask to be used when accessing the register
241 * DESCRIPTION: Map register_id into a register bitmask.
243 ******************************************************************************/
245 struct acpi_bit_register_info
*
246 acpi_hw_get_bit_register_info (
249 ACPI_FUNCTION_NAME ("hw_get_bit_register_info");
252 if (register_id
> ACPI_BITREG_MAX
) {
253 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "Invalid bit_register ID: %X\n", register_id
));
257 return (&acpi_gbl_bit_register_info
[register_id
]);
261 /*******************************************************************************
263 * FUNCTION: acpi_get_register
265 * PARAMETERS: register_id - ID of ACPI bit_register to access
266 * return_value - Value that was read from the register
267 * Flags - Lock the hardware or not
269 * RETURN: Status and the value read from specified Register. Value
270 * returned is normalized to bit0 (is shifted all the way right)
272 * DESCRIPTION: ACPI bit_register read function.
274 ******************************************************************************/
282 u32 register_value
= 0;
283 struct acpi_bit_register_info
*bit_reg_info
;
287 ACPI_FUNCTION_TRACE ("acpi_get_register");
290 /* Get the info structure corresponding to the requested ACPI Register */
292 bit_reg_info
= acpi_hw_get_bit_register_info (register_id
);
294 return_ACPI_STATUS (AE_BAD_PARAMETER
);
297 if (flags
& ACPI_MTX_LOCK
) {
298 status
= acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE
);
299 if (ACPI_FAILURE (status
)) {
300 return_ACPI_STATUS (status
);
304 /* Read from the register */
306 status
= acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK
,
307 bit_reg_info
->parent_register
, ®ister_value
);
309 if (flags
& ACPI_MTX_LOCK
) {
310 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE
);
313 if (ACPI_SUCCESS (status
)) {
314 /* Normalize the value that was read */
316 register_value
= ((register_value
& bit_reg_info
->access_bit_mask
)
317 >> bit_reg_info
->bit_position
);
319 *return_value
= register_value
;
321 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "Read value %8.8X register %X\n",
322 register_value
, bit_reg_info
->parent_register
));
325 return_ACPI_STATUS (status
);
327 EXPORT_SYMBOL(acpi_get_register
);
330 /*******************************************************************************
332 * FUNCTION: acpi_set_register
334 * PARAMETERS: register_id - ID of ACPI bit_register to access
335 * Value - (only used on write) value to write to the
336 * Register, NOT pre-normalized to the bit pos
337 * Flags - Lock the hardware or not
341 * DESCRIPTION: ACPI Bit Register write function.
343 ******************************************************************************/
351 u32 register_value
= 0;
352 struct acpi_bit_register_info
*bit_reg_info
;
356 ACPI_FUNCTION_TRACE_U32 ("acpi_set_register", register_id
);
359 /* Get the info structure corresponding to the requested ACPI Register */
361 bit_reg_info
= acpi_hw_get_bit_register_info (register_id
);
363 ACPI_REPORT_ERROR (("Bad ACPI HW register_id: %X\n", register_id
));
364 return_ACPI_STATUS (AE_BAD_PARAMETER
);
367 if (flags
& ACPI_MTX_LOCK
) {
368 status
= acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE
);
369 if (ACPI_FAILURE (status
)) {
370 return_ACPI_STATUS (status
);
374 /* Always do a register read first so we can insert the new bits */
376 status
= acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK
,
377 bit_reg_info
->parent_register
, ®ister_value
);
378 if (ACPI_FAILURE (status
)) {
379 goto unlock_and_exit
;
383 * Decode the Register ID
384 * Register ID = [Register block ID] | [bit ID]
386 * Check bit ID to fine locate Register offset.
387 * Check Mask to determine Register offset, and then read-write.
389 switch (bit_reg_info
->parent_register
) {
390 case ACPI_REGISTER_PM1_STATUS
:
393 * Status Registers are different from the rest. Clear by
394 * writing 1, and writing 0 has no effect. So, the only relevant
395 * information is the single bit we're interested in, all others should
396 * be written as 0 so they will be left unchanged.
398 value
= ACPI_REGISTER_PREPARE_BITS (value
,
399 bit_reg_info
->bit_position
, bit_reg_info
->access_bit_mask
);
401 status
= acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK
,
402 ACPI_REGISTER_PM1_STATUS
, (u16
) value
);
408 case ACPI_REGISTER_PM1_ENABLE
:
410 ACPI_REGISTER_INSERT_VALUE (register_value
, bit_reg_info
->bit_position
,
411 bit_reg_info
->access_bit_mask
, value
);
413 status
= acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK
,
414 ACPI_REGISTER_PM1_ENABLE
, (u16
) register_value
);
418 case ACPI_REGISTER_PM1_CONTROL
:
421 * Write the PM1 Control register.
422 * Note that at this level, the fact that there are actually TWO
423 * registers (A and B - and B may not exist) is abstracted.
425 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "PM1 control: Read %X\n", register_value
));
427 ACPI_REGISTER_INSERT_VALUE (register_value
, bit_reg_info
->bit_position
,
428 bit_reg_info
->access_bit_mask
, value
);
430 status
= acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK
,
431 ACPI_REGISTER_PM1_CONTROL
, (u16
) register_value
);
435 case ACPI_REGISTER_PM2_CONTROL
:
437 status
= acpi_hw_register_read (ACPI_MTX_DO_NOT_LOCK
,
438 ACPI_REGISTER_PM2_CONTROL
, ®ister_value
);
439 if (ACPI_FAILURE (status
)) {
440 goto unlock_and_exit
;
443 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "PM2 control: Read %X from %8.8X%8.8X\n",
446 acpi_gbl_FADT
->xpm2_cnt_blk
.address
)));
448 ACPI_REGISTER_INSERT_VALUE (register_value
, bit_reg_info
->bit_position
,
449 bit_reg_info
->access_bit_mask
, value
);
451 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "About to write %4.4X to %8.8X%8.8X\n",
454 acpi_gbl_FADT
->xpm2_cnt_blk
.address
)));
456 status
= acpi_hw_register_write (ACPI_MTX_DO_NOT_LOCK
,
457 ACPI_REGISTER_PM2_CONTROL
, (u8
) (register_value
));
468 if (flags
& ACPI_MTX_LOCK
) {
469 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE
);
472 /* Normalize the value that was read */
474 ACPI_DEBUG_EXEC (register_value
=
475 ((register_value
& bit_reg_info
->access_bit_mask
) >>
476 bit_reg_info
->bit_position
));
478 ACPI_DEBUG_PRINT ((ACPI_DB_IO
, "Set bits: %8.8X actual %8.8X register %X\n",
479 value
, register_value
, bit_reg_info
->parent_register
));
480 return_ACPI_STATUS (status
);
482 EXPORT_SYMBOL(acpi_set_register
);
485 /******************************************************************************
487 * FUNCTION: acpi_hw_register_read
489 * PARAMETERS: use_lock - Mutex hw access
490 * register_id - register_iD + Offset
491 * return_value - Where the register value is returned
493 * RETURN: Status and the value read.
495 * DESCRIPTION: Acpi register read function. Registers are read at the
498 ******************************************************************************/
501 acpi_hw_register_read (
511 ACPI_FUNCTION_TRACE ("hw_register_read");
514 if (ACPI_MTX_LOCK
== use_lock
) {
515 status
= acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE
);
516 if (ACPI_FAILURE (status
)) {
517 return_ACPI_STATUS (status
);
521 switch (register_id
) {
522 case ACPI_REGISTER_PM1_STATUS
: /* 16-bit access */
524 status
= acpi_hw_low_level_read (16, &value1
, &acpi_gbl_FADT
->xpm1a_evt_blk
);
525 if (ACPI_FAILURE (status
)) {
526 goto unlock_and_exit
;
529 /* PM1B is optional */
531 status
= acpi_hw_low_level_read (16, &value2
, &acpi_gbl_FADT
->xpm1b_evt_blk
);
536 case ACPI_REGISTER_PM1_ENABLE
: /* 16-bit access */
538 status
= acpi_hw_low_level_read (16, &value1
, &acpi_gbl_xpm1a_enable
);
539 if (ACPI_FAILURE (status
)) {
540 goto unlock_and_exit
;
543 /* PM1B is optional */
545 status
= acpi_hw_low_level_read (16, &value2
, &acpi_gbl_xpm1b_enable
);
550 case ACPI_REGISTER_PM1_CONTROL
: /* 16-bit access */
552 status
= acpi_hw_low_level_read (16, &value1
, &acpi_gbl_FADT
->xpm1a_cnt_blk
);
553 if (ACPI_FAILURE (status
)) {
554 goto unlock_and_exit
;
557 status
= acpi_hw_low_level_read (16, &value2
, &acpi_gbl_FADT
->xpm1b_cnt_blk
);
562 case ACPI_REGISTER_PM2_CONTROL
: /* 8-bit access */
564 status
= acpi_hw_low_level_read (8, &value1
, &acpi_gbl_FADT
->xpm2_cnt_blk
);
568 case ACPI_REGISTER_PM_TIMER
: /* 32-bit access */
570 status
= acpi_hw_low_level_read (32, &value1
, &acpi_gbl_FADT
->xpm_tmr_blk
);
573 case ACPI_REGISTER_SMI_COMMAND_BLOCK
: /* 8-bit access */
575 status
= acpi_os_read_port (acpi_gbl_FADT
->smi_cmd
, &value1
, 8);
579 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
, "Unknown Register ID: %X\n",
581 status
= AE_BAD_PARAMETER
;
586 if (ACPI_MTX_LOCK
== use_lock
) {
587 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE
);
590 if (ACPI_SUCCESS (status
)) {
591 *return_value
= value1
;
594 return_ACPI_STATUS (status
);
598 /******************************************************************************
600 * FUNCTION: acpi_hw_register_write
602 * PARAMETERS: use_lock - Mutex hw access
603 * register_id - register_iD + Offset
604 * Value - The value to write
608 * DESCRIPTION: Acpi register Write function. Registers are written at the
611 ******************************************************************************/
614 acpi_hw_register_write (
622 ACPI_FUNCTION_TRACE ("hw_register_write");
625 if (ACPI_MTX_LOCK
== use_lock
) {
626 status
= acpi_ut_acquire_mutex (ACPI_MTX_HARDWARE
);
627 if (ACPI_FAILURE (status
)) {
628 return_ACPI_STATUS (status
);
632 switch (register_id
) {
633 case ACPI_REGISTER_PM1_STATUS
: /* 16-bit access */
635 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1a_evt_blk
);
636 if (ACPI_FAILURE (status
)) {
637 goto unlock_and_exit
;
640 /* PM1B is optional */
642 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1b_evt_blk
);
646 case ACPI_REGISTER_PM1_ENABLE
: /* 16-bit access*/
648 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_xpm1a_enable
);
649 if (ACPI_FAILURE (status
)) {
650 goto unlock_and_exit
;
653 /* PM1B is optional */
655 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_xpm1b_enable
);
659 case ACPI_REGISTER_PM1_CONTROL
: /* 16-bit access */
661 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1a_cnt_blk
);
662 if (ACPI_FAILURE (status
)) {
663 goto unlock_and_exit
;
666 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1b_cnt_blk
);
670 case ACPI_REGISTER_PM1A_CONTROL
: /* 16-bit access */
672 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1a_cnt_blk
);
676 case ACPI_REGISTER_PM1B_CONTROL
: /* 16-bit access */
678 status
= acpi_hw_low_level_write (16, value
, &acpi_gbl_FADT
->xpm1b_cnt_blk
);
682 case ACPI_REGISTER_PM2_CONTROL
: /* 8-bit access */
684 status
= acpi_hw_low_level_write (8, value
, &acpi_gbl_FADT
->xpm2_cnt_blk
);
688 case ACPI_REGISTER_PM_TIMER
: /* 32-bit access */
690 status
= acpi_hw_low_level_write (32, value
, &acpi_gbl_FADT
->xpm_tmr_blk
);
694 case ACPI_REGISTER_SMI_COMMAND_BLOCK
: /* 8-bit access */
696 /* SMI_CMD is currently always in IO space */
698 status
= acpi_os_write_port (acpi_gbl_FADT
->smi_cmd
, value
, 8);
703 status
= AE_BAD_PARAMETER
;
708 if (ACPI_MTX_LOCK
== use_lock
) {
709 (void) acpi_ut_release_mutex (ACPI_MTX_HARDWARE
);
712 return_ACPI_STATUS (status
);
716 /******************************************************************************
718 * FUNCTION: acpi_hw_low_level_read
720 * PARAMETERS: Width - 8, 16, or 32
721 * Value - Where the value is returned
722 * Reg - GAS register structure
726 * DESCRIPTION: Read from either memory or IO space.
728 ******************************************************************************/
731 acpi_hw_low_level_read (
734 struct acpi_generic_address
*reg
)
740 ACPI_FUNCTION_NAME ("hw_low_level_read");
744 * Must have a valid pointer to a GAS structure, and
745 * a non-zero address within. However, don't return an error
746 * because the PM1A/B code must not fail if B isn't present.
752 /* Get a local copy of the address. Handles possible alignment issues */
754 ACPI_MOVE_64_TO_64 (&address
, ®
->address
);
761 * Two address spaces supported: Memory or IO.
762 * PCI_Config is not supported here because the GAS struct is insufficient
764 switch (reg
->address_space_id
) {
765 case ACPI_ADR_SPACE_SYSTEM_MEMORY
:
767 status
= acpi_os_read_memory (
768 (acpi_physical_address
) address
,
773 case ACPI_ADR_SPACE_SYSTEM_IO
:
775 status
= acpi_os_read_port ((acpi_io_address
) address
,
781 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
782 "Unsupported address space: %X\n", reg
->address_space_id
));
783 return (AE_BAD_PARAMETER
);
786 ACPI_DEBUG_PRINT ((ACPI_DB_IO
,
787 "Read: %8.8X width %2d from %8.8X%8.8X (%s)\n",
789 ACPI_FORMAT_UINT64 (address
),
790 acpi_ut_get_region_name (reg
->address_space_id
)));
796 /******************************************************************************
798 * FUNCTION: acpi_hw_low_level_write
800 * PARAMETERS: Width - 8, 16, or 32
801 * Value - To be written
802 * Reg - GAS register structure
806 * DESCRIPTION: Write to either memory or IO space.
808 ******************************************************************************/
811 acpi_hw_low_level_write (
814 struct acpi_generic_address
*reg
)
820 ACPI_FUNCTION_NAME ("hw_low_level_write");
824 * Must have a valid pointer to a GAS structure, and
825 * a non-zero address within. However, don't return an error
826 * because the PM1A/B code must not fail if B isn't present.
832 /* Get a local copy of the address. Handles possible alignment issues */
834 ACPI_MOVE_64_TO_64 (&address
, ®
->address
);
840 * Two address spaces supported: Memory or IO.
841 * PCI_Config is not supported here because the GAS struct is insufficient
843 switch (reg
->address_space_id
) {
844 case ACPI_ADR_SPACE_SYSTEM_MEMORY
:
846 status
= acpi_os_write_memory (
847 (acpi_physical_address
) address
,
852 case ACPI_ADR_SPACE_SYSTEM_IO
:
854 status
= acpi_os_write_port ((acpi_io_address
) address
,
860 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
861 "Unsupported address space: %X\n", reg
->address_space_id
));
862 return (AE_BAD_PARAMETER
);
865 ACPI_DEBUG_PRINT ((ACPI_DB_IO
,
866 "Wrote: %8.8X width %2d to %8.8X%8.8X (%s)\n",
868 ACPI_FORMAT_UINT64 (address
),
869 acpi_ut_get_region_name (reg
->address_space_id
)));