diff options
Diffstat (limited to 'include/acpi/acmacros.h')
| -rw-r--r-- | include/acpi/acmacros.h | 71 |
1 files changed, 36 insertions, 35 deletions
diff --git a/include/acpi/acmacros.h b/include/acpi/acmacros.h index 99d171c87c84..fb41a3b802fc 100644 --- a/include/acpi/acmacros.h +++ b/include/acpi/acmacros.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
| 6 | 6 | ||
| 7 | /* | 7 | /* |
| 8 | * Copyright (C) 2000 - 2007, R. Byron Moore | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
| 9 | * All rights reserved. | 9 | * All rights reserved. |
| 10 | * | 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without |
| @@ -61,30 +61,6 @@ | |||
| 61 | 61 | ||
| 62 | #define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) | 62 | #define ACPI_ARRAY_LENGTH(x) (sizeof(x) / sizeof((x)[0])) |
| 63 | 63 | ||
| 64 | #ifdef ACPI_NO_INTEGER64_SUPPORT | ||
| 65 | /* | ||
| 66 | * acpi_integer is 32-bits, no 64-bit support on this platform | ||
| 67 | */ | ||
| 68 | #define ACPI_LODWORD(l) ((u32)(l)) | ||
| 69 | #define ACPI_HIDWORD(l) ((u32)(0)) | ||
| 70 | |||
| 71 | #else | ||
| 72 | |||
| 73 | /* | ||
| 74 | * Full 64-bit address/integer on both 32-bit and 64-bit platforms | ||
| 75 | */ | ||
| 76 | #define ACPI_LODWORD(l) ((u32)(u64)(l)) | ||
| 77 | #define ACPI_HIDWORD(l) ((u32)(((*(struct uint64_struct *)(void *)(&l))).hi)) | ||
| 78 | #endif | ||
| 79 | |||
| 80 | /* | ||
| 81 | * printf() format helpers | ||
| 82 | */ | ||
| 83 | |||
| 84 | /* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */ | ||
| 85 | |||
| 86 | #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) | ||
| 87 | |||
| 88 | /* | 64 | /* |
| 89 | * Extract data using a pointer. Any more than a byte and we | 65 | * Extract data using a pointer. Any more than a byte and we |
| 90 | * get into potential aligment issues -- see the STORE macros below. | 66 | * get into potential aligment issues -- see the STORE macros below. |
| @@ -122,6 +98,31 @@ | |||
| 122 | #endif | 98 | #endif |
| 123 | 99 | ||
| 124 | /* | 100 | /* |
| 101 | * Full 64-bit integer must be available on both 32-bit and 64-bit platforms | ||
| 102 | */ | ||
| 103 | struct acpi_integer_overlay { | ||
| 104 | u32 lo_dword; | ||
| 105 | u32 hi_dword; | ||
| 106 | }; | ||
| 107 | |||
| 108 | #define ACPI_LODWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->lo_dword) | ||
| 109 | #define ACPI_HIDWORD(integer) (ACPI_CAST_PTR (struct acpi_integer_overlay, &integer)->hi_dword) | ||
| 110 | |||
| 111 | /* | ||
| 112 | * printf() format helpers | ||
| 113 | */ | ||
| 114 | |||
| 115 | /* Split 64-bit integer into two 32-bit values. Use with %8.8_x%8.8_x */ | ||
| 116 | |||
| 117 | #define ACPI_FORMAT_UINT64(i) ACPI_HIDWORD(i),ACPI_LODWORD(i) | ||
| 118 | |||
| 119 | #if ACPI_MACHINE_WIDTH == 64 | ||
| 120 | #define ACPI_FORMAT_NATIVE_UINT(i) ACPI_FORMAT_UINT64(i) | ||
| 121 | #else | ||
| 122 | #define ACPI_FORMAT_NATIVE_UINT(i) 0, (i) | ||
| 123 | #endif | ||
| 124 | |||
| 125 | /* | ||
| 125 | * Macros for moving data around to/from buffers that are possibly unaligned. | 126 | * Macros for moving data around to/from buffers that are possibly unaligned. |
| 126 | * If the hardware supports the transfer of unaligned data, just do the store. | 127 | * If the hardware supports the transfer of unaligned data, just do the store. |
| 127 | * Otherwise, we have to move one byte at a time. | 128 | * Otherwise, we have to move one byte at a time. |
| @@ -137,29 +138,29 @@ | |||
| 137 | 138 | ||
| 138 | /* These macros reverse the bytes during the move, converting little-endian to big endian */ | 139 | /* These macros reverse the bytes during the move, converting little-endian to big endian */ |
| 139 | 140 | ||
| 140 | /* Big Endian <== Little Endian */ | 141 | /* Big Endian <== Little Endian */ |
| 141 | /* Hi...Lo Lo...Hi */ | 142 | /* Hi...Lo Lo...Hi */ |
| 142 | /* 16-bit source, 16/32/64 destination */ | 143 | /* 16-bit source, 16/32/64 destination */ |
| 143 | 144 | ||
| 144 | #define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ | 145 | #define ACPI_MOVE_16_TO_16(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[1];\ |
| 145 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} | 146 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[0];} |
| 146 | 147 | ||
| 147 | #define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d))=0;\ | 148 | #define ACPI_MOVE_16_TO_32(d,s) {(*(u32 *)(void *)(d))=0;\ |
| 148 | ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ | 149 | ((u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ |
| 149 | ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} | 150 | ((u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} |
| 150 | 151 | ||
| 151 | #define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ | 152 | #define ACPI_MOVE_16_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ |
| 152 | ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ | 153 | ((u8 *)(void *)(d))[6] = ((u8 *)(void *)(s))[1];\ |
| 153 | ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} | 154 | ((u8 *)(void *)(d))[7] = ((u8 *)(void *)(s))[0];} |
| 154 | 155 | ||
| 155 | /* 32-bit source, 16/32/64 destination */ | 156 | /* 32-bit source, 16/32/64 destination */ |
| 156 | 157 | ||
| 157 | #define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ | 158 | #define ACPI_MOVE_32_TO_16(d,s) ACPI_MOVE_16_TO_16(d,s) /* Truncate to 16 */ |
| 158 | 159 | ||
| 159 | #define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ | 160 | #define ACPI_MOVE_32_TO_32(d,s) {(( u8 *)(void *)(d))[0] = ((u8 *)(void *)(s))[3];\ |
| 160 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ | 161 | (( u8 *)(void *)(d))[1] = ((u8 *)(void *)(s))[2];\ |
| 161 | (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ | 162 | (( u8 *)(void *)(d))[2] = ((u8 *)(void *)(s))[1];\ |
| 162 | (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} | 163 | (( u8 *)(void *)(d))[3] = ((u8 *)(void *)(s))[0];} |
| 163 | 164 | ||
| 164 | #define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ | 165 | #define ACPI_MOVE_32_TO_64(d,s) {(*(u64 *)(void *)(d))=0;\ |
| 165 | ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ | 166 | ((u8 *)(void *)(d))[4] = ((u8 *)(void *)(s))[3];\ |
