2 #include <resources/acpi.h>
6 /*****************************************************************************
9 #include <proto/acpi.h>
11 AROS_LH2I(void, ACPI_WriteReg
,
14 AROS_LHA(struct GENERIC_ACPI_ADDR
*, reg
, A0
),
15 AROS_LHA(IPTR
, value
, D0
),
18 struct ACPIBase
*, ACPIBase
, 4, Acpi
)
21 Write a value from the register specified by GAS
24 reg - a pointer to a generic address structure
25 value - a value to write to the register
31 Only memory and I/O spaces are supported.
32 64-bit registers are supported only in memory space and only on 64-bit platforms.
33 The given GAS must address a complete register, not a data structure.
43 ******************************************************************************/
47 unsigned char size
= GetSize(reg
);
49 if (reg
->register_bit_width
!= FullSize
[reg
->size
])
53 * Read original value from the register and replace the needed bits.
55 unsigned long mask
= ((1 << reg
->register_bit_width
) - 1) << reg
->register_bit_offset
;
56 unsigned long old
= ReadRegInt(reg
, size
);
58 value
= (value
<< reg
->register_bit_offset
) & mask
;
59 value
|= (old
& ~mask
);
62 switch (reg
->address_space_id
)
68 *((UBYTE
*)(IPTR
)reg
->address
) = value
;
72 *((UWORD
*)(IPTR
)reg
->address
) = value
;
76 *((ULONG
*)(IPTR
)reg
->address
) = value
;
81 *((UQUAD
*)(IPTR
)reg
->address
) = value
;
91 outb(value
, reg
->address
);
95 outw(value
, reg
->address
);
99 outl(value
, reg
->address
);
102 /* ACPI_SIZE_QUAD - not supported ? */