aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/executer/exregion.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/executer/exregion.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/executer/exregion.c')
-rw-r--r--drivers/acpi/executer/exregion.c280
1 files changed, 125 insertions, 155 deletions
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 723aaef4bb4a..9a2f5bea3afe 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -42,14 +42,11 @@
42 * POSSIBILITY OF SUCH DAMAGES. 42 * POSSIBILITY OF SUCH DAMAGES.
43 */ 43 */
44 44
45
46#include <acpi/acpi.h> 45#include <acpi/acpi.h>
47#include <acpi/acinterp.h> 46#include <acpi/acinterp.h>
48 47
49
50#define _COMPONENT ACPI_EXECUTER 48#define _COMPONENT ACPI_EXECUTER
51 ACPI_MODULE_NAME ("exregion") 49ACPI_MODULE_NAME("exregion")
52
53 50
54/******************************************************************************* 51/*******************************************************************************
55 * 52 *
@@ -68,27 +65,23 @@
68 * DESCRIPTION: Handler for the System Memory address space (Op Region) 65 * DESCRIPTION: Handler for the System Memory address space (Op Region)
69 * 66 *
70 ******************************************************************************/ 67 ******************************************************************************/
71
72acpi_status 68acpi_status
73acpi_ex_system_memory_space_handler ( 69acpi_ex_system_memory_space_handler(u32 function,
74 u32 function, 70 acpi_physical_address address,
75 acpi_physical_address address, 71 u32 bit_width,
76 u32 bit_width, 72 acpi_integer * value,
77 acpi_integer *value, 73 void *handler_context, void *region_context)
78 void *handler_context,
79 void *region_context)
80{ 74{
81 acpi_status status = AE_OK; 75 acpi_status status = AE_OK;
82 void *logical_addr_ptr = NULL; 76 void *logical_addr_ptr = NULL;
83 struct acpi_mem_space_context *mem_info = region_context; 77 struct acpi_mem_space_context *mem_info = region_context;
84 u32 length; 78 u32 length;
85 acpi_size window_size; 79 acpi_size window_size;
86#ifndef ACPI_MISALIGNED_TRANSFERS 80#ifndef ACPI_MISALIGNED_TRANSFERS
87 u32 remainder; 81 u32 remainder;
88#endif 82#endif
89 83
90 ACPI_FUNCTION_TRACE ("ex_system_memory_space_handler"); 84 ACPI_FUNCTION_TRACE("ex_system_memory_space_handler");
91
92 85
93 /* Validate and translate the bit width */ 86 /* Validate and translate the bit width */
94 87
@@ -110,9 +103,10 @@ acpi_ex_system_memory_space_handler (
110 break; 103 break;
111 104
112 default: 105 default:
113 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Invalid system_memory width %d\n", 106 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
114 bit_width)); 107 "Invalid system_memory width %d\n",
115 return_ACPI_STATUS (AE_AML_OPERAND_VALUE); 108 bit_width));
109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
116 } 110 }
117 111
118#ifndef ACPI_MISALIGNED_TRANSFERS 112#ifndef ACPI_MISALIGNED_TRANSFERS
@@ -120,9 +114,10 @@ acpi_ex_system_memory_space_handler (
120 * Hardware does not support non-aligned data transfers, we must verify 114 * Hardware does not support non-aligned data transfers, we must verify
121 * the request. 115 * the request.
122 */ 116 */
123 (void) acpi_ut_short_divide ((acpi_integer) address, length, NULL, &remainder); 117 (void)acpi_ut_short_divide((acpi_integer) address, length, NULL,
118 &remainder);
124 if (remainder != 0) { 119 if (remainder != 0) {
125 return_ACPI_STATUS (AE_AML_ALIGNMENT); 120 return_ACPI_STATUS(AE_AML_ALIGNMENT);
126 } 121 }
127#endif 122#endif
128 123
@@ -132,9 +127,10 @@ acpi_ex_system_memory_space_handler (
132 * 2) Address beyond the current mapping? 127 * 2) Address beyond the current mapping?
133 */ 128 */
134 if ((address < mem_info->mapped_physical_address) || 129 if ((address < mem_info->mapped_physical_address) ||
135 (((acpi_integer) address + length) > 130 (((acpi_integer) address + length) > ((acpi_integer)
136 ((acpi_integer) 131 mem_info->
137 mem_info->mapped_physical_address + mem_info->mapped_length))) { 132 mapped_physical_address +
133 mem_info->mapped_length))) {
138 /* 134 /*
139 * The request cannot be resolved by the current memory mapping; 135 * The request cannot be resolved by the current memory mapping;
140 * Delete the existing mapping and create a new one. 136 * Delete the existing mapping and create a new one.
@@ -142,8 +138,8 @@ acpi_ex_system_memory_space_handler (
142 if (mem_info->mapped_length) { 138 if (mem_info->mapped_length) {
143 /* Valid mapping, delete it */ 139 /* Valid mapping, delete it */
144 140
145 acpi_os_unmap_memory (mem_info->mapped_logical_address, 141 acpi_os_unmap_memory(mem_info->mapped_logical_address,
146 mem_info->mapped_length); 142 mem_info->mapped_length);
147 } 143 }
148 144
149 /* 145 /*
@@ -151,7 +147,7 @@ acpi_ex_system_memory_space_handler (
151 * constrain the maximum mapping size to something reasonable. 147 * constrain the maximum mapping size to something reasonable.
152 */ 148 */
153 window_size = (acpi_size) 149 window_size = (acpi_size)
154 ((mem_info->address + mem_info->length) - address); 150 ((mem_info->address + mem_info->length) - address);
155 151
156 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { 152 if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) {
157 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; 153 window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE;
@@ -159,14 +155,16 @@ acpi_ex_system_memory_space_handler (
159 155
160 /* Create a new mapping starting at the address given */ 156 /* Create a new mapping starting at the address given */
161 157
162 status = acpi_os_map_memory (address, window_size, 158 status = acpi_os_map_memory(address, window_size,
163 (void **) &mem_info->mapped_logical_address); 159 (void **)&mem_info->
164 if (ACPI_FAILURE (status)) { 160 mapped_logical_address);
165 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 161 if (ACPI_FAILURE(status)) {
166 "Could not map memory at %8.8X%8.8X, size %X\n", 162 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
167 ACPI_FORMAT_UINT64 (address), (u32) window_size)); 163 "Could not map memory at %8.8X%8.8X, size %X\n",
164 ACPI_FORMAT_UINT64(address),
165 (u32) window_size));
168 mem_info->mapped_length = 0; 166 mem_info->mapped_length = 0;
169 return_ACPI_STATUS (status); 167 return_ACPI_STATUS(status);
170 } 168 }
171 169
172 /* Save the physical address and mapping size */ 170 /* Save the physical address and mapping size */
@@ -180,42 +178,41 @@ acpi_ex_system_memory_space_handler (
180 * access 178 * access
181 */ 179 */
182 logical_addr_ptr = mem_info->mapped_logical_address + 180 logical_addr_ptr = mem_info->mapped_logical_address +
183 ((acpi_integer) address - 181 ((acpi_integer) address -
184 (acpi_integer) mem_info->mapped_physical_address); 182 (acpi_integer) mem_info->mapped_physical_address);
185 183
186 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 184 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
187 "system_memory %d (%d width) Address=%8.8X%8.8X\n", 185 "system_memory %d (%d width) Address=%8.8X%8.8X\n",
188 function, bit_width, 186 function, bit_width, ACPI_FORMAT_UINT64(address)));
189 ACPI_FORMAT_UINT64 (address))); 187
190 188 /*
191 /* 189 * Perform the memory read or write
192 * Perform the memory read or write 190 *
193 * 191 * Note: For machines that do not support non-aligned transfers, the target
194 * Note: For machines that do not support non-aligned transfers, the target 192 * address was checked for alignment above. We do not attempt to break the
195 * address was checked for alignment above. We do not attempt to break the 193 * transfer up into smaller (byte-size) chunks because the AML specifically
196 * transfer up into smaller (byte-size) chunks because the AML specifically 194 * asked for a transfer width that the hardware may require.
197 * asked for a transfer width that the hardware may require. 195 */
198 */
199 switch (function) { 196 switch (function) {
200 case ACPI_READ: 197 case ACPI_READ:
201 198
202 *value = 0; 199 *value = 0;
203 switch (bit_width) { 200 switch (bit_width) {
204 case 8: 201 case 8:
205 *value = (acpi_integer) *((u8 *) logical_addr_ptr); 202 *value = (acpi_integer) * ((u8 *) logical_addr_ptr);
206 break; 203 break;
207 204
208 case 16: 205 case 16:
209 *value = (acpi_integer) *((u16 *) logical_addr_ptr); 206 *value = (acpi_integer) * ((u16 *) logical_addr_ptr);
210 break; 207 break;
211 208
212 case 32: 209 case 32:
213 *value = (acpi_integer) *((u32 *) logical_addr_ptr); 210 *value = (acpi_integer) * ((u32 *) logical_addr_ptr);
214 break; 211 break;
215 212
216#if ACPI_MACHINE_WIDTH != 16 213#if ACPI_MACHINE_WIDTH != 16
217 case 64: 214 case 64:
218 *value = (acpi_integer) *((u64 *) logical_addr_ptr); 215 *value = (acpi_integer) * ((u64 *) logical_addr_ptr);
219 break; 216 break;
220#endif 217#endif
221 default: 218 default:
@@ -228,20 +225,20 @@ acpi_ex_system_memory_space_handler (
228 225
229 switch (bit_width) { 226 switch (bit_width) {
230 case 8: 227 case 8:
231 *(u8 *) logical_addr_ptr = (u8) *value; 228 *(u8 *) logical_addr_ptr = (u8) * value;
232 break; 229 break;
233 230
234 case 16: 231 case 16:
235 *(u16 *) logical_addr_ptr = (u16) *value; 232 *(u16 *) logical_addr_ptr = (u16) * value;
236 break; 233 break;
237 234
238 case 32: 235 case 32:
239 *(u32 *) logical_addr_ptr = (u32) *value; 236 *(u32 *) logical_addr_ptr = (u32) * value;
240 break; 237 break;
241 238
242#if ACPI_MACHINE_WIDTH != 16 239#if ACPI_MACHINE_WIDTH != 16
243 case 64: 240 case 64:
244 *(u64 *) logical_addr_ptr = (u64) *value; 241 *(u64 *) logical_addr_ptr = (u64) * value;
245 break; 242 break;
246#endif 243#endif
247 244
@@ -256,10 +253,9 @@ acpi_ex_system_memory_space_handler (
256 break; 253 break;
257 } 254 }
258 255
259 return_ACPI_STATUS (status); 256 return_ACPI_STATUS(status);
260} 257}
261 258
262
263/******************************************************************************* 259/*******************************************************************************
264 * 260 *
265 * FUNCTION: acpi_ex_system_io_space_handler 261 * FUNCTION: acpi_ex_system_io_space_handler
@@ -279,39 +275,35 @@ acpi_ex_system_memory_space_handler (
279 ******************************************************************************/ 275 ******************************************************************************/
280 276
281acpi_status 277acpi_status
282acpi_ex_system_io_space_handler ( 278acpi_ex_system_io_space_handler(u32 function,
283 u32 function, 279 acpi_physical_address address,
284 acpi_physical_address address, 280 u32 bit_width,
285 u32 bit_width, 281 acpi_integer * value,
286 acpi_integer *value, 282 void *handler_context, void *region_context)
287 void *handler_context,
288 void *region_context)
289{ 283{
290 acpi_status status = AE_OK; 284 acpi_status status = AE_OK;
291 u32 value32; 285 u32 value32;
292 286
287 ACPI_FUNCTION_TRACE("ex_system_io_space_handler");
293 288
294 ACPI_FUNCTION_TRACE ("ex_system_io_space_handler"); 289 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
295 290 "system_iO %d (%d width) Address=%8.8X%8.8X\n",
296 291 function, bit_width, ACPI_FORMAT_UINT64(address)));
297 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
298 "system_iO %d (%d width) Address=%8.8X%8.8X\n", function, bit_width,
299 ACPI_FORMAT_UINT64 (address)));
300 292
301 /* Decode the function parameter */ 293 /* Decode the function parameter */
302 294
303 switch (function) { 295 switch (function) {
304 case ACPI_READ: 296 case ACPI_READ:
305 297
306 status = acpi_os_read_port ((acpi_io_address) address, 298 status = acpi_os_read_port((acpi_io_address) address,
307 &value32, bit_width); 299 &value32, bit_width);
308 *value = value32; 300 *value = value32;
309 break; 301 break;
310 302
311 case ACPI_WRITE: 303 case ACPI_WRITE:
312 304
313 status = acpi_os_write_port ((acpi_io_address) address, 305 status = acpi_os_write_port((acpi_io_address) address,
314 (u32) *value, bit_width); 306 (u32) * value, bit_width);
315 break; 307 break;
316 308
317 default: 309 default:
@@ -319,10 +311,9 @@ acpi_ex_system_io_space_handler (
319 break; 311 break;
320 } 312 }
321 313
322 return_ACPI_STATUS (status); 314 return_ACPI_STATUS(status);
323} 315}
324 316
325
326/******************************************************************************* 317/*******************************************************************************
327 * 318 *
328 * FUNCTION: acpi_ex_pci_config_space_handler 319 * FUNCTION: acpi_ex_pci_config_space_handler
@@ -342,21 +333,17 @@ acpi_ex_system_io_space_handler (
342 ******************************************************************************/ 333 ******************************************************************************/
343 334
344acpi_status 335acpi_status
345acpi_ex_pci_config_space_handler ( 336acpi_ex_pci_config_space_handler(u32 function,
346 u32 function, 337 acpi_physical_address address,
347 acpi_physical_address address, 338 u32 bit_width,
348 u32 bit_width, 339 acpi_integer * value,
349 acpi_integer *value, 340 void *handler_context, void *region_context)
350 void *handler_context,
351 void *region_context)
352{ 341{
353 acpi_status status = AE_OK; 342 acpi_status status = AE_OK;
354 struct acpi_pci_id *pci_id; 343 struct acpi_pci_id *pci_id;
355 u16 pci_register; 344 u16 pci_register;
356
357
358 ACPI_FUNCTION_TRACE ("ex_pci_config_space_handler");
359 345
346 ACPI_FUNCTION_TRACE("ex_pci_config_space_handler");
360 347
361 /* 348 /*
362 * The arguments to acpi_os(Read|Write)pci_configuration are: 349 * The arguments to acpi_os(Read|Write)pci_configuration are:
@@ -370,26 +357,26 @@ acpi_ex_pci_config_space_handler (
370 * Value - input value for write, output address for read 357 * Value - input value for write, output address for read
371 * 358 *
372 */ 359 */
373 pci_id = (struct acpi_pci_id *) region_context; 360 pci_id = (struct acpi_pci_id *)region_context;
374 pci_register = (u16) (u32) address; 361 pci_register = (u16) (u32) address;
375 362
376 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 363 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
377 "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", 364 "pci_config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
378 function, bit_width, pci_id->segment, pci_id->bus, pci_id->device, 365 function, bit_width, pci_id->segment, pci_id->bus,
379 pci_id->function, pci_register)); 366 pci_id->device, pci_id->function, pci_register));
380 367
381 switch (function) { 368 switch (function) {
382 case ACPI_READ: 369 case ACPI_READ:
383 370
384 *value = 0; 371 *value = 0;
385 status = acpi_os_read_pci_configuration (pci_id, pci_register, 372 status = acpi_os_read_pci_configuration(pci_id, pci_register,
386 value, bit_width); 373 value, bit_width);
387 break; 374 break;
388 375
389 case ACPI_WRITE: 376 case ACPI_WRITE:
390 377
391 status = acpi_os_write_pci_configuration (pci_id, pci_register, 378 status = acpi_os_write_pci_configuration(pci_id, pci_register,
392 *value, bit_width); 379 *value, bit_width);
393 break; 380 break;
394 381
395 default: 382 default:
@@ -398,10 +385,9 @@ acpi_ex_pci_config_space_handler (
398 break; 385 break;
399 } 386 }
400 387
401 return_ACPI_STATUS (status); 388 return_ACPI_STATUS(status);
402} 389}
403 390
404
405/******************************************************************************* 391/*******************************************************************************
406 * 392 *
407 * FUNCTION: acpi_ex_cmos_space_handler 393 * FUNCTION: acpi_ex_cmos_space_handler
@@ -421,24 +407,19 @@ acpi_ex_pci_config_space_handler (
421 ******************************************************************************/ 407 ******************************************************************************/
422 408
423acpi_status 409acpi_status
424acpi_ex_cmos_space_handler ( 410acpi_ex_cmos_space_handler(u32 function,
425 u32 function, 411 acpi_physical_address address,
426 acpi_physical_address address, 412 u32 bit_width,
427 u32 bit_width, 413 acpi_integer * value,
428 acpi_integer *value, 414 void *handler_context, void *region_context)
429 void *handler_context,
430 void *region_context)
431{ 415{
432 acpi_status status = AE_OK; 416 acpi_status status = AE_OK;
433
434 417
435 ACPI_FUNCTION_TRACE ("ex_cmos_space_handler"); 418 ACPI_FUNCTION_TRACE("ex_cmos_space_handler");
436 419
437 420 return_ACPI_STATUS(status);
438 return_ACPI_STATUS (status);
439} 421}
440 422
441
442/******************************************************************************* 423/*******************************************************************************
443 * 424 *
444 * FUNCTION: acpi_ex_pci_bar_space_handler 425 * FUNCTION: acpi_ex_pci_bar_space_handler
@@ -458,24 +439,19 @@ acpi_ex_cmos_space_handler (
458 ******************************************************************************/ 439 ******************************************************************************/
459 440
460acpi_status 441acpi_status
461acpi_ex_pci_bar_space_handler ( 442acpi_ex_pci_bar_space_handler(u32 function,
462 u32 function, 443 acpi_physical_address address,
463 acpi_physical_address address, 444 u32 bit_width,
464 u32 bit_width, 445 acpi_integer * value,
465 acpi_integer *value, 446 void *handler_context, void *region_context)
466 void *handler_context,
467 void *region_context)
468{ 447{
469 acpi_status status = AE_OK; 448 acpi_status status = AE_OK;
470
471 449
472 ACPI_FUNCTION_TRACE ("ex_pci_bar_space_handler"); 450 ACPI_FUNCTION_TRACE("ex_pci_bar_space_handler");
473 451
474 452 return_ACPI_STATUS(status);
475 return_ACPI_STATUS (status);
476} 453}
477 454
478
479/******************************************************************************* 455/*******************************************************************************
480 * 456 *
481 * FUNCTION: acpi_ex_data_table_space_handler 457 * FUNCTION: acpi_ex_data_table_space_handler
@@ -495,24 +471,20 @@ acpi_ex_pci_bar_space_handler (
495 ******************************************************************************/ 471 ******************************************************************************/
496 472
497acpi_status 473acpi_status
498acpi_ex_data_table_space_handler ( 474acpi_ex_data_table_space_handler(u32 function,
499 u32 function, 475 acpi_physical_address address,
500 acpi_physical_address address, 476 u32 bit_width,
501 u32 bit_width, 477 acpi_integer * value,
502 acpi_integer *value, 478 void *handler_context, void *region_context)
503 void *handler_context,
504 void *region_context)
505{ 479{
506 acpi_status status = AE_OK; 480 acpi_status status = AE_OK;
507 u32 byte_width = ACPI_DIV_8 (bit_width); 481 u32 byte_width = ACPI_DIV_8(bit_width);
508 u32 i; 482 u32 i;
509 char *logical_addr_ptr; 483 char *logical_addr_ptr;
510
511 484
512 ACPI_FUNCTION_TRACE ("ex_data_table_space_handler"); 485 ACPI_FUNCTION_TRACE("ex_data_table_space_handler");
513 486
514 487 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR(address);
515 logical_addr_ptr = ACPI_PHYSADDR_TO_PTR (address);
516 488
517 /* Perform the memory read or write */ 489 /* Perform the memory read or write */
518 490
@@ -520,17 +492,15 @@ acpi_ex_data_table_space_handler (
520 case ACPI_READ: 492 case ACPI_READ:
521 493
522 for (i = 0; i < byte_width; i++) { 494 for (i = 0; i < byte_width; i++) {
523 ((char *) value) [i] = logical_addr_ptr[i]; 495 ((char *)value)[i] = logical_addr_ptr[i];
524 } 496 }
525 break; 497 break;
526 498
527 case ACPI_WRITE: 499 case ACPI_WRITE:
528 default: 500 default:
529 501
530 return_ACPI_STATUS (AE_SUPPORT); 502 return_ACPI_STATUS(AE_SUPPORT);
531 } 503 }
532 504
533 return_ACPI_STATUS (status); 505 return_ACPI_STATUS(status);
534} 506}
535
536