summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2016-11-09 04:05:05 +0800
committerLv Zheng <lv.zheng@intel.com>2016-11-09 04:05:05 +0800
commitcfca5fb4c9c843c176e94a364c4b75b5d9b0f39e (patch)
tree4d75e2c3eca4eb7d0c6f64058c7d26324920857e
parentadaead47de2dd98ee556de911fd798371ba4c378 (diff)
downloadacpica-cfca5fb4c9c843c176e94a364c4b75b5d9b0f39e.tar.gz
Hardware: Introduce a set of macros to handle bit width mask generation
This patch adds a set of macros to generate masks from bit width values. This patch also cleans up an existing line using the new macros. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com>
-rw-r--r--source/components/executer/exfldio.c15
-rw-r--r--source/include/acmacros.h12
2 files changed, 14 insertions, 13 deletions
diff --git a/source/components/executer/exfldio.c b/source/components/executer/exfldio.c
index b7e86fdb0..578ba48e0 100644
--- a/source/components/executer/exfldio.c
+++ b/source/components/executer/exfldio.c
@@ -1018,20 +1018,9 @@ AcpiExInsertIntoField (
AccessBitWidth = ACPI_MUL_8 (ObjDesc->CommonField.AccessByteWidth);
- /*
- * Create the bitmasks used for bit insertion.
- * Note: This if/else is used to bypass compiler differences with the
- * shift operator
- */
- if (AccessBitWidth == ACPI_INTEGER_BIT_SIZE)
- {
- WidthMask = ACPI_UINT64_MAX;
- }
- else
- {
- WidthMask = ACPI_MASK_BITS_ABOVE (AccessBitWidth);
- }
+ /* Create the bitmasks used for bit insertion */
+ WidthMask = ACPI_MASK_BITS_ABOVE_64 (AccessBitWidth);
Mask = WidthMask &
ACPI_MASK_BITS_BELOW (ObjDesc->CommonField.StartFieldBitOffset);
diff --git a/source/include/acmacros.h b/source/include/acmacros.h
index b451cbbbd..d1304fe5b 100644
--- a/source/include/acmacros.h
+++ b/source/include/acmacros.h
@@ -346,9 +346,21 @@
* Bit positions start at zero.
* MASK_BITS_ABOVE creates a mask starting AT the position and above
* MASK_BITS_BELOW creates a mask starting one bit BELOW the position
+ * MASK_BITS_ABOVE/BELOW accpets a bit offset to create a mask
+ * MASK_BITS_ABOVE/BELOW_32/64 accpets a bit width to create a mask
+ * Note: The ACPI_INTEGER_BIT_SIZE check is used to bypass compiler
+ * differences with the shift operator
*/
#define ACPI_MASK_BITS_ABOVE(position) (~((ACPI_UINT64_MAX) << ((UINT32) (position))))
#define ACPI_MASK_BITS_BELOW(position) ((ACPI_UINT64_MAX) << ((UINT32) (position)))
+#define ACPI_MASK_BITS_ABOVE_32(width) ((UINT32) ACPI_MASK_BITS_ABOVE(width))
+#define ACPI_MASK_BITS_BELOW_32(width) ((UINT32) ACPI_MASK_BITS_BELOW(width))
+#define ACPI_MASK_BITS_ABOVE_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
+ ACPI_UINT64_MAX : \
+ ACPI_MASK_BITS_ABOVE(width))
+#define ACPI_MASK_BITS_BELOW_64(width) ((width) == ACPI_INTEGER_BIT_SIZE ? \
+ (UINT64) 0 : \
+ ACPI_MASK_BITS_BELOW(width))
/* Bitfields within ACPI registers */