diff options
Diffstat (limited to 'include/acpi/acmacros.h')
-rw-r--r-- | include/acpi/acmacros.h | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index e42222c3d34c..5b78ff4091b9 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h | |||
@@ -107,23 +107,29 @@ | |||
107 | * Extract a byte of data using a pointer. Any more than a byte and we | 107 | * Extract a byte of data using a pointer. Any more than a byte and we |
108 | * get into potential aligment issues -- see the STORE macros below | 108 | * get into potential aligment issues -- see the STORE macros below |
109 | */ | 109 | */ |
110 | #define ACPI_GET8(addr) (*(u8*)(addr)) | 110 | #define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) |
111 | #define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) | ||
112 | #define ACPI_GET32(ptr) *ACPI_CAST_PTR (u32, ptr) | ||
113 | #define ACPI_GET64(ptr) *ACPI_CAST_PTR (u64, ptr) | ||
114 | #define ACPI_SET8(ptr) *ACPI_CAST_PTR (u8, ptr) | ||
115 | #define ACPI_SET16(ptr) *ACPI_CAST_PTR (u16, ptr) | ||
116 | #define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) | ||
117 | #define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) | ||
111 | 118 | ||
112 | /* Pointer arithmetic */ | 119 | /* Pointer manipulation */ |
113 | 120 | ||
114 | #define ACPI_PTR_ADD(t,a,b) (t *) (void *)((char *)(a) + (acpi_native_uint)(b)) | 121 | #define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) |
122 | #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) | ||
123 | #define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_native_uint)(b))) | ||
115 | #define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) | 124 | #define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) |
116 | 125 | ||
117 | /* Pointer/Integer type conversions */ | 126 | /* Pointer/Integer type conversions */ |
118 | 127 | ||
119 | #define ACPI_TO_POINTER(i) ACPI_PTR_ADD (void, (void *) NULL,(acpi_native_uint)i) | 128 | #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_native_uint)i) |
120 | #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) | 129 | #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) |
121 | #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) | 130 | #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) |
122 | #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) | 131 | #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) |
123 | 132 | ||
124 | #define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) | ||
125 | #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) | ||
126 | |||
127 | #if ACPI_MACHINE_WIDTH == 16 | 133 | #if ACPI_MACHINE_WIDTH == 16 |
128 | #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) | 134 | #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) |
129 | #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) | 135 | #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) |
@@ -365,6 +371,13 @@ | |||
365 | #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) | 371 | #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask) ((val << pos) & mask) |
366 | #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) | 372 | #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val) reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask) |
367 | 373 | ||
374 | /* Generate a UUID */ | ||
375 | |||
376 | #define ACPI_INIT_UUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) (a) & 0xFF, ((a) >> 8) & 0xFF, ((a) >> 16) & 0xFF, ((a) >> 24) & 0xFF, \ | ||
377 | (b) & 0xFF, ((b) >> 8) & 0xFF, \ | ||
378 | (c) & 0xFF, ((c) >> 8) & 0xFF, \ | ||
379 | (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) | ||
380 | |||
368 | /* | 381 | /* |
369 | * An struct acpi_namespace_node * can appear in some contexts, | 382 | * An struct acpi_namespace_node * can appear in some contexts, |
370 | * where a pointer to an union acpi_operand_object can also | 383 | * where a pointer to an union acpi_operand_object can also |