diff options
Diffstat (limited to 'include/acpi/acmacros.h')
-rw-r--r-- | include/acpi/acmacros.h | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 65a1a5c1a689..0fa8f72dbace 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h | |||
@@ -60,7 +60,7 @@ | |||
60 | 60 | ||
61 | /* | 61 | /* |
62 | * For 16-bit addresses, we have to assume that the upper 32 bits | 62 | * For 16-bit addresses, we have to assume that the upper 32 bits |
63 | * are zero. | 63 | * (out of 64) are zero. |
64 | */ | 64 | */ |
65 | #define ACPI_LODWORD(l) ((u32)(l)) | 65 | #define ACPI_LODWORD(l) ((u32)(l)) |
66 | #define ACPI_HIDWORD(l) ((u32)(0)) | 66 | #define ACPI_HIDWORD(l) ((u32)(0)) |
@@ -104,8 +104,9 @@ | |||
104 | #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) | 104 | #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) |
105 | 105 | ||
106 | /* | 106 | /* |
107 | * Extract a byte of data using a pointer. Any more than a byte and we | 107 | * Extract 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 | * Use with care. | ||
109 | */ | 110 | */ |
110 | #define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) | 111 | #define ACPI_GET8(ptr) *ACPI_CAST_PTR (u8, ptr) |
111 | #define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) | 112 | #define ACPI_GET16(ptr) *ACPI_CAST_PTR (u16, ptr) |
@@ -116,16 +117,17 @@ | |||
116 | #define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) | 117 | #define ACPI_SET32(ptr) *ACPI_CAST_PTR (u32, ptr) |
117 | #define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) | 118 | #define ACPI_SET64(ptr) *ACPI_CAST_PTR (u64, ptr) |
118 | 119 | ||
119 | /* Pointer manipulation */ | 120 | /* |
120 | 121 | * Pointer manipulation | |
121 | #define ACPI_CAST_PTR(t, p) ((t *)(void *)(p)) | 122 | */ |
122 | #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **)(void *)(p)) | 123 | #define ACPI_CAST_PTR(t, p) ((t *) (acpi_uintptr_t) (p)) |
123 | #define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_native_uint)(b))) | 124 | #define ACPI_CAST_INDIRECT_PTR(t, p) ((t **) (acpi_uintptr_t) (p)) |
124 | #define ACPI_PTR_DIFF(a,b) (acpi_native_uint) ((char *)(a) - (char *)(b)) | 125 | #define ACPI_ADD_PTR(t,a,b) ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8,(a)) + (acpi_native_uint)(b))) |
126 | #define ACPI_PTR_DIFF(a,b) (acpi_native_uint) (ACPI_CAST_PTR (u8,(a)) - ACPI_CAST_PTR (u8,(b))) | ||
125 | 127 | ||
126 | /* Pointer/Integer type conversions */ | 128 | /* Pointer/Integer type conversions */ |
127 | 129 | ||
128 | #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void, (void *) NULL,(acpi_native_uint)i) | 130 | #define ACPI_TO_POINTER(i) ACPI_ADD_PTR (void,(void *) NULL,(acpi_native_uint) i) |
129 | #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) | 131 | #define ACPI_TO_INTEGER(p) ACPI_PTR_DIFF (p,(void *) NULL) |
130 | #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) | 132 | #define ACPI_OFFSET(d,f) (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL) |
131 | #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) | 133 | #define ACPI_FADT_OFFSET(f) ACPI_OFFSET (FADT_DESCRIPTOR, f) |
@@ -133,7 +135,7 @@ | |||
133 | #if ACPI_MACHINE_WIDTH == 16 | 135 | #if ACPI_MACHINE_WIDTH == 16 |
134 | #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) | 136 | #define ACPI_STORE_POINTER(d,s) ACPI_MOVE_32_TO_32(d,s) |
135 | #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) | 137 | #define ACPI_PHYSADDR_TO_PTR(i) (void *)(i) |
136 | #define ACPI_PTR_TO_PHYSADDR(i) (u32) (char *)(i) | 138 | #define ACPI_PTR_TO_PHYSADDR(i) (u32) ACPI_CAST_PTR (u8,(i)) |
137 | #else | 139 | #else |
138 | #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) | 140 | #define ACPI_PHYSADDR_TO_PTR(i) ACPI_TO_POINTER(i) |
139 | #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) | 141 | #define ACPI_PTR_TO_PHYSADDR(i) ACPI_TO_INTEGER(i) |