diff options
author | Len Brown <len.brown@intel.com> | 2009-04-24 10:42:21 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-04-24 10:42:21 -0400 |
commit | 5f855a8f0ca8f8a81a7752d6bfdc65bfca426b5a (patch) | |
tree | f14c218d4f66e766136a58f217cf317eca568833 | |
parent | 1fe94d37f9296e8884c2f4ca4e22ca3d1398f15c (diff) | |
parent | a38d75fa2e48d4960b656eac39bc8a6b584a83c0 (diff) |
Merge branch 'bugzilla-13036' into release
-rw-r--r-- | drivers/acpi/acpica/hwvalid.c | 86 |
1 files changed, 72 insertions, 14 deletions
diff --git a/drivers/acpi/acpica/hwvalid.c b/drivers/acpi/acpica/hwvalid.c index 7737afb157c3..ec33f270c5b7 100644 --- a/drivers/acpi/acpica/hwvalid.c +++ b/drivers/acpi/acpica/hwvalid.c | |||
@@ -90,6 +90,7 @@ static const struct acpi_port_info acpi_protected_ports[] = { | |||
90 | {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, | 90 | {"PIT2", 0x0048, 0x004B, ACPI_OSI_WIN_XP}, |
91 | {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, | 91 | {"RTC", 0x0070, 0x0071, ACPI_OSI_WIN_XP}, |
92 | {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, | 92 | {"CMOS", 0x0074, 0x0076, ACPI_OSI_WIN_XP}, |
93 | {"DMA1", 0x0081, 0x0083, ACPI_OSI_WIN_XP}, | ||
93 | {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, | 94 | {"DMA1L", 0x0087, 0x0087, ACPI_OSI_WIN_XP}, |
94 | {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, | 95 | {"DMA2", 0x0089, 0x008B, ACPI_OSI_WIN_XP}, |
95 | {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, | 96 | {"DMA2L", 0x008F, 0x008F, ACPI_OSI_WIN_XP}, |
@@ -151,7 +152,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
151 | ACPI_ERROR((AE_INFO, | 152 | ACPI_ERROR((AE_INFO, |
152 | "Illegal I/O port address/length above 64K: 0x%p/%X", | 153 | "Illegal I/O port address/length above 64K: 0x%p/%X", |
153 | ACPI_CAST_PTR(void, address), byte_width)); | 154 | ACPI_CAST_PTR(void, address), byte_width)); |
154 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); | 155 | return_ACPI_STATUS(AE_LIMIT); |
155 | } | 156 | } |
156 | 157 | ||
157 | /* Exit if requested address is not within the protected port table */ | 158 | /* Exit if requested address is not within the protected port table */ |
@@ -178,11 +179,12 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
178 | /* Port illegality may depend on the _OSI calls made by the BIOS */ | 179 | /* Port illegality may depend on the _OSI calls made by the BIOS */ |
179 | 180 | ||
180 | if (acpi_gbl_osi_data >= port_info->osi_dependency) { | 181 | if (acpi_gbl_osi_data >= port_info->osi_dependency) { |
181 | ACPI_ERROR((AE_INFO, | 182 | ACPI_DEBUG_PRINT((ACPI_DB_IO, |
182 | "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", | 183 | "Denied AML access to port 0x%p/%X (%s 0x%.4X-0x%.4X)", |
183 | ACPI_CAST_PTR(void, address), | 184 | ACPI_CAST_PTR(void, address), |
184 | byte_width, port_info->name, | 185 | byte_width, port_info->name, |
185 | port_info->start, port_info->end)); | 186 | port_info->start, |
187 | port_info->end)); | ||
186 | 188 | ||
187 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); | 189 | return_ACPI_STATUS(AE_AML_ILLEGAL_ADDRESS); |
188 | } | 190 | } |
@@ -206,7 +208,7 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
206 | * Value Where value is placed | 208 | * Value Where value is placed |
207 | * Width Number of bits | 209 | * Width Number of bits |
208 | * | 210 | * |
209 | * RETURN: Value read from port | 211 | * RETURN: Status and value read from port |
210 | * | 212 | * |
211 | * DESCRIPTION: Read data from an I/O port or register. This is a front-end | 213 | * DESCRIPTION: Read data from an I/O port or register. This is a front-end |
212 | * to acpi_os_read_port that performs validation on both the port | 214 | * to acpi_os_read_port that performs validation on both the port |
@@ -217,14 +219,43 @@ acpi_hw_validate_io_request(acpi_io_address address, u32 bit_width) | |||
217 | acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | 219 | acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) |
218 | { | 220 | { |
219 | acpi_status status; | 221 | acpi_status status; |
222 | u32 one_byte; | ||
223 | u32 i; | ||
224 | |||
225 | /* Validate the entire request and perform the I/O */ | ||
220 | 226 | ||
221 | status = acpi_hw_validate_io_request(address, width); | 227 | status = acpi_hw_validate_io_request(address, width); |
222 | if (ACPI_FAILURE(status)) { | 228 | if (ACPI_SUCCESS(status)) { |
229 | status = acpi_os_read_port(address, value, width); | ||
223 | return status; | 230 | return status; |
224 | } | 231 | } |
225 | 232 | ||
226 | status = acpi_os_read_port(address, value, width); | 233 | if (status != AE_AML_ILLEGAL_ADDRESS) { |
227 | return status; | 234 | return status; |
235 | } | ||
236 | |||
237 | /* | ||
238 | * There has been a protection violation within the request. Fall | ||
239 | * back to byte granularity port I/O and ignore the failing bytes. | ||
240 | * This provides Windows compatibility. | ||
241 | */ | ||
242 | for (i = 0, *value = 0; i < width; i += 8) { | ||
243 | |||
244 | /* Validate and read one byte */ | ||
245 | |||
246 | if (acpi_hw_validate_io_request(address, 8) == AE_OK) { | ||
247 | status = acpi_os_read_port(address, &one_byte, 8); | ||
248 | if (ACPI_FAILURE(status)) { | ||
249 | return status; | ||
250 | } | ||
251 | |||
252 | *value |= (one_byte << i); | ||
253 | } | ||
254 | |||
255 | address++; | ||
256 | } | ||
257 | |||
258 | return AE_OK; | ||
228 | } | 259 | } |
229 | 260 | ||
230 | /****************************************************************************** | 261 | /****************************************************************************** |
@@ -235,7 +266,7 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | |||
235 | * Value Value to write | 266 | * Value Value to write |
236 | * Width Number of bits | 267 | * Width Number of bits |
237 | * | 268 | * |
238 | * RETURN: None | 269 | * RETURN: Status |
239 | * | 270 | * |
240 | * DESCRIPTION: Write data to an I/O port or register. This is a front-end | 271 | * DESCRIPTION: Write data to an I/O port or register. This is a front-end |
241 | * to acpi_os_write_port that performs validation on both the port | 272 | * to acpi_os_write_port that performs validation on both the port |
@@ -246,12 +277,39 @@ acpi_status acpi_hw_read_port(acpi_io_address address, u32 *value, u32 width) | |||
246 | acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) | 277 | acpi_status acpi_hw_write_port(acpi_io_address address, u32 value, u32 width) |
247 | { | 278 | { |
248 | acpi_status status; | 279 | acpi_status status; |
280 | u32 i; | ||
281 | |||
282 | /* Validate the entire request and perform the I/O */ | ||
249 | 283 | ||
250 | status = acpi_hw_validate_io_request(address, width); | 284 | status = acpi_hw_validate_io_request(address, width); |
251 | if (ACPI_FAILURE(status)) { | 285 | if (ACPI_SUCCESS(status)) { |
286 | status = acpi_os_write_port(address, value, width); | ||
252 | return status; | 287 | return status; |
253 | } | 288 | } |
254 | 289 | ||
255 | status = acpi_os_write_port(address, value, width); | 290 | if (status != AE_AML_ILLEGAL_ADDRESS) { |
256 | return status; | 291 | return status; |
292 | } | ||
293 | |||
294 | /* | ||
295 | * There has been a protection violation within the request. Fall | ||
296 | * back to byte granularity port I/O and ignore the failing bytes. | ||
297 | * This provides Windows compatibility. | ||
298 | */ | ||
299 | for (i = 0; i < width; i += 8) { | ||
300 | |||
301 | /* Validate and write one byte */ | ||
302 | |||
303 | if (acpi_hw_validate_io_request(address, 8) == AE_OK) { | ||
304 | status = | ||
305 | acpi_os_write_port(address, (value >> i) & 0xFF, 8); | ||
306 | if (ACPI_FAILURE(status)) { | ||
307 | return status; | ||
308 | } | ||
309 | } | ||
310 | |||
311 | address++; | ||
312 | } | ||
313 | |||
314 | return AE_OK; | ||
257 | } | 315 | } |