From be030a576854238250d70135644cde6a0ba34b0d Mon Sep 17 00:00:00 2001 From: Bob Moore Date: Fri, 17 Aug 2012 13:07:54 +0800 Subject: ACPICA: Add support for complex _PLD buffers. _PLD (Physical Location of Device) returns a bit-packed buffer that is difficult to parse. This change adds a new interface, AcpiDecodePldBuffer that parses the buffer into a more usable local struct. Also adds macros to both get and set individual fields within the packed _PLD buffer. Adds a new include file, acbuffer.h - which will be expanded to add structs for other ACPI names that return buffers. ACPICA BZ 954. Emit (in comments) the decoded contents of a static _PLD buffer in order to improve comprehension of this bit-packed buffer. Add multi-endian support to the _PLD decode routine. Deploy the multi-endian macros to extract data from the _PLD buffer. Signed-off-by: Bob Moore Signed-off-by: Feng Tang Signed-off-by: Len Brown --- drivers/acpi/acpica/acmacros.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'drivers/acpi/acpica/acmacros.h') diff --git a/drivers/acpi/acpica/acmacros.h b/drivers/acpi/acpica/acmacros.h index 832b619..a7f68c4 100644 --- a/drivers/acpi/acpica/acmacros.h +++ b/drivers/acpi/acpica/acmacros.h @@ -277,10 +277,33 @@ /* Bitfields within ACPI registers */ -#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) -#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) +#define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) \ + ((val << pos) & mask) -#define ACPI_INSERT_BITS(target, mask, source) target = ((target & (~(mask))) | (source & mask)) +#define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) \ + reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) + +#define ACPI_INSERT_BITS(target, mask, source) \ + target = ((target & (~(mask))) | (source & mask)) + +/* Generic bitfield macros and masks */ + +#define ACPI_GET_BITS(source_ptr, position, mask) \ + ((*source_ptr >> position) & mask) + +#define ACPI_SET_BITS(target_ptr, position, mask, value) \ + (*target_ptr |= ((value & mask) << position)) + +#define ACPI_1BIT_MASK 0x00000001 +#define ACPI_2BIT_MASK 0x00000003 +#define ACPI_3BIT_MASK 0x00000007 +#define ACPI_4BIT_MASK 0x0000000F +#define ACPI_5BIT_MASK 0x0000001F +#define ACPI_6BIT_MASK 0x0000003F +#define ACPI_7BIT_MASK 0x0000007F +#define ACPI_8BIT_MASK 0x000000FF +#define ACPI_16BIT_MASK 0x0000FFFF +#define ACPI_24BIT_MASK 0x00FFFFFF /* * An object of type struct acpi_namespace_node can appear in some contexts -- cgit v1.1