aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2005-11-17 13:07:00 -0500
committerLen Brown <len.brown@intel.com>2005-12-10 00:27:56 -0500
commitc51a4de85de720670f2fbc592a6f8040af72ad87 (patch)
treeccaa60c483fcc904abd63d936ff7dc380bf28e7b
parent96db255c8f014ae3497507104e8df809785a619f (diff)
[ACPI] ACPICA 20051117
Fixed a problem in the AML parser where the method thread count could be decremented below zero if any errors occurred during the method parse phase. This should eliminate AE_AML_METHOD_LIMIT exceptions seen on some machines. This also fixed a related regression with the mechanism that detects and corrects methods that cannot properly handle reentrancy (related to the deployment of the new OwnerId mechanism.) Eliminated the pre-parsing of control methods (to detect errors) during table load. Related to the problem above, this was causing unwind issues if any errors occurred during the parse, and it seemed to be overkill. A table load should not be aborted if there are problems with any single control method, thus rendering this feature rather pointless. Fixed a problem with the new table-driven resource manager where an internal buffer overflow could occur for small resource templates. Implemented a new external interface, acpi_get_vendor_resource() This interface will find and return a vendor-defined resource descriptor within a _CRS or _PRS method via an ACPI 3.0 UUID match. (from Bjorn Helgaas) Removed the length limit (200) on string objects as per the upcoming ACPI 3.0A specification. This affects the following areas of the interpreter: 1) any implicit conversion of a Buffer to a String, 2) a String object result of the ASL Concatentate operator, 3) the String object result of the ASL ToString operator. Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/dispatcher/dsinit.c25
-rw-r--r--drivers/acpi/dispatcher/dswload.c2
-rw-r--r--drivers/acpi/executer/exconvrt.c12
-rw-r--r--drivers/acpi/executer/exdump.c15
-rw-r--r--drivers/acpi/executer/exmisc.c38
-rw-r--r--drivers/acpi/executer/exnames.c2
-rw-r--r--drivers/acpi/executer/exoparg2.c10
-rw-r--r--drivers/acpi/executer/exregion.c16
-rw-r--r--drivers/acpi/executer/exstorob.c4
-rw-r--r--drivers/acpi/parser/psargs.c152
-rw-r--r--drivers/acpi/parser/psparse.c35
-rw-r--r--drivers/acpi/parser/psxface.c2
-rw-r--r--drivers/acpi/resources/rscalc.c14
-rw-r--r--drivers/acpi/resources/rsdump.c24
-rw-r--r--drivers/acpi/resources/rslist.c4
-rw-r--r--drivers/acpi/resources/rsmisc.c92
-rw-r--r--drivers/acpi/resources/rsutils.c22
-rw-r--r--drivers/acpi/resources/rsxface.c208
-rw-r--r--drivers/acpi/scan.c2
-rw-r--r--drivers/acpi/tables/tbconvrt.c4
-rw-r--r--drivers/acpi/tables/tbgetall.c4
-rw-r--r--drivers/acpi/tables/tbutils.c8
-rw-r--r--drivers/acpi/utilities/utcopy.c19
-rw-r--r--drivers/acpi/utilities/utglobal.c4
-rw-r--r--drivers/acpi/utilities/utmisc.c34
-rw-r--r--drivers/acpi/utilities/utresrc.c19
-rw-r--r--include/acpi/acconfig.h14
-rw-r--r--include/acpi/acglobal.h1
-rw-r--r--include/acpi/aclocal.h4
-rw-r--r--include/acpi/acmacros.h27
-rw-r--r--include/acpi/acpixf.h8
-rw-r--r--include/acpi/acresrc.h7
-rw-r--r--include/acpi/actypes.h23
-rw-r--r--include/acpi/platform/aclinux.h4
34 files changed, 515 insertions, 344 deletions
diff --git a/drivers/acpi/dispatcher/dsinit.c b/drivers/acpi/dispatcher/dsinit.c
index 8693c704aea6..4fa80abfe6c0 100644
--- a/drivers/acpi/dispatcher/dsinit.c
+++ b/drivers/acpi/dispatcher/dsinit.c
@@ -118,14 +118,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
118 case ACPI_TYPE_METHOD: 118 case ACPI_TYPE_METHOD:
119 119
120 /* 120 /*
121 * Print a dot for each method unless we are going to print
122 * the entire pathname
123 */
124 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
125 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
126 }
127
128 /*
129 * Set the execution data width (32 or 64) based upon the 121 * Set the execution data width (32 or 64) based upon the
130 * revision number of the parent ACPI table. 122 * revision number of the parent ACPI table.
131 * TBD: This is really for possible future support of integer width 123 * TBD: This is really for possible future support of integer width
@@ -134,6 +126,21 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
134 if (info->table_desc->pointer->revision == 1) { 126 if (info->table_desc->pointer->revision == 1) {
135 node->flags |= ANOBJ_DATA_WIDTH_32; 127 node->flags |= ANOBJ_DATA_WIDTH_32;
136 } 128 }
129#ifdef ACPI_INIT_PARSE_METHODS
130 /*
131 * Note 11/2005: Removed this code to parse all methods during table
132 * load because it causes problems if there are any errors during the
133 * parse. Also, it seems like overkill and we probably don't want to
134 * abort a table load because of an issue with a single method.
135 */
136
137 /*
138 * Print a dot for each method unless we are going to print
139 * the entire pathname
140 */
141 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
142 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
143 }
137 144
138 /* 145 /*
139 * Always parse methods to detect errors, we will delete 146 * Always parse methods to detect errors, we will delete
@@ -149,7 +156,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
149 156
150 /* This parse failed, but we will continue parsing more methods */ 157 /* This parse failed, but we will continue parsing more methods */
151 } 158 }
152 159#endif
153 info->method_count++; 160 info->method_count++;
154 break; 161 break;
155 162
diff --git a/drivers/acpi/dispatcher/dswload.c b/drivers/acpi/dispatcher/dswload.c
index 411731261c29..89d318cbc8a3 100644
--- a/drivers/acpi/dispatcher/dswload.c
+++ b/drivers/acpi/dispatcher/dswload.c
@@ -311,7 +311,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
311 op->named.name = node->name.integer; 311 op->named.name = node->name.integer;
312 312
313#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY)) 313#if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
314 op->named.path = (u8 *) path; 314 op->named.path = ACPI_CAST_PTR(u8, path);
315#endif 315#endif
316 316
317 /* 317 /*
diff --git a/drivers/acpi/executer/exconvrt.c b/drivers/acpi/executer/exconvrt.c
index 04e5194989a6..fa9e75d4ec65 100644
--- a/drivers/acpi/executer/exconvrt.c
+++ b/drivers/acpi/executer/exconvrt.c
@@ -504,18 +504,12 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
504 } 504 }
505 505
506 /* 506 /*
507 * Perform the conversion. 507 * Create a new string object and string buffer
508 * (-1 because of extra separator included in string_length from above) 508 * (-1 because of extra separator included in string_length from above)
509 */ 509 */
510 string_length--;
511 if (string_length > ACPI_MAX_STRING_CONVERSION) { /* ACPI limit */
512 return_ACPI_STATUS(AE_AML_STRING_LIMIT);
513 }
514
515 /* Create a new string object and string buffer */
516
517 return_desc = 510 return_desc =
518 acpi_ut_create_string_object((acpi_size) string_length); 511 acpi_ut_create_string_object((acpi_size)
512 (string_length - 1));
519 if (!return_desc) { 513 if (!return_desc) {
520 return_ACPI_STATUS(AE_NO_MEMORY); 514 return_ACPI_STATUS(AE_NO_MEMORY);
521 } 515 }
diff --git a/drivers/acpi/executer/exdump.c b/drivers/acpi/executer/exdump.c
index 5a4cca171af6..17c79cd91b31 100644
--- a/drivers/acpi/executer/exdump.c
+++ b/drivers/acpi/executer/exdump.c
@@ -117,12 +117,13 @@ static struct acpi_exdump_info acpi_ex_dump_event[2] = {
117 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"} 117 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
118}; 118};
119 119
120static struct acpi_exdump_info acpi_ex_dump_method[7] = { 120static struct acpi_exdump_info acpi_ex_dump_method[8] = {
121 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL}, 121 {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
122 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"}, 122 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"},
123 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"}, 123 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
124 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"}, 124 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"}, 125 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
126 {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
126 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"}, 127 {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
127 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"} 128 {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
128}; 129};
@@ -339,7 +340,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
339 count = info->offset; 340 count = info->offset;
340 341
341 while (count) { 342 while (count) {
342 target = ((u8 *) obj_desc) + info->offset; 343 target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
343 name = info->name; 344 name = info->name;
344 345
345 switch (info->opcode) { 346 switch (info->opcode) {
@@ -360,20 +361,19 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
360 case ACPI_EXD_UINT16: 361 case ACPI_EXD_UINT16:
361 362
362 acpi_os_printf("%20s : %4.4X\n", name, 363 acpi_os_printf("%20s : %4.4X\n", name,
363 *ACPI_CAST_PTR(u16, target)); 364 ACPI_GET16(target));
364 break; 365 break;
365 366
366 case ACPI_EXD_UINT32: 367 case ACPI_EXD_UINT32:
367 368
368 acpi_os_printf("%20s : %8.8X\n", name, 369 acpi_os_printf("%20s : %8.8X\n", name,
369 *ACPI_CAST_PTR(u32, target)); 370 ACPI_GET32(target));
370 break; 371 break;
371 372
372 case ACPI_EXD_UINT64: 373 case ACPI_EXD_UINT64:
373 374
374 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value", 375 acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
375 ACPI_FORMAT_UINT64(*ACPI_CAST_PTR 376 ACPI_FORMAT_UINT64(ACPI_GET64(target)));
376 (u64, target)));
377 break; 377 break;
378 378
379 case ACPI_EXD_POINTER: 379 case ACPI_EXD_POINTER:
@@ -969,7 +969,8 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
969 acpi_os_printf("[Buffer] Length %.2X = ", 969 acpi_os_printf("[Buffer] Length %.2X = ",
970 obj_desc->buffer.length); 970 obj_desc->buffer.length);
971 if (obj_desc->buffer.length) { 971 if (obj_desc->buffer.length) {
972 acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer, 972 acpi_ut_dump_buffer(ACPI_CAST_PTR
973 (u8, obj_desc->buffer.pointer),
973 obj_desc->buffer.length, 974 obj_desc->buffer.length,
974 DB_DWORD_DISPLAY, _COMPONENT); 975 DB_DWORD_DISPLAY, _COMPONENT);
975 } else { 976 } else {
diff --git a/drivers/acpi/executer/exmisc.c b/drivers/acpi/executer/exmisc.c
index 00a25f8188f4..0778bff632bf 100644
--- a/drivers/acpi/executer/exmisc.c
+++ b/drivers/acpi/executer/exmisc.c
@@ -205,11 +205,9 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
205 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0); 205 ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
206 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1); 206 ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
207 207
208 /* Compute the new checksum */ 208 /* Set the end_tag checksum to zero, means "ignore checksum" */
209 209
210 new_buf[return_desc->buffer.length - 1] = 210 new_buf[return_desc->buffer.length - 1] = 0;
211 acpi_ut_generate_checksum(return_desc->buffer.pointer,
212 (return_desc->buffer.length - 1));
213 211
214 /* Return the completed resource template */ 212 /* Return the completed resource template */
215 213
@@ -242,7 +240,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
242 union acpi_operand_object *return_desc; 240 union acpi_operand_object *return_desc;
243 char *new_buf; 241 char *new_buf;
244 acpi_status status; 242 acpi_status status;
245 acpi_size new_length;
246 243
247 ACPI_FUNCTION_TRACE("ex_do_concatenate"); 244 ACPI_FUNCTION_TRACE("ex_do_concatenate");
248 245
@@ -269,7 +266,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
269 break; 266 break;
270 267
271 default: 268 default:
272 ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n", 269 ACPI_REPORT_ERROR(("Concatanate - invalid object type: %X\n",
273 ACPI_GET_OBJECT_TYPE(operand0))); 270 ACPI_GET_OBJECT_TYPE(operand0)));
274 status = AE_AML_INTERNAL; 271 status = AE_AML_INTERNAL;
275 } 272 }
@@ -309,8 +306,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
309 306
310 /* Copy the first integer, LSB first */ 307 /* Copy the first integer, LSB first */
311 308
312 ACPI_MEMCPY(new_buf, 309 ACPI_MEMCPY(new_buf, &operand0->integer.value,
313 &operand0->integer.value,
314 acpi_gbl_integer_byte_width); 310 acpi_gbl_integer_byte_width);
315 311
316 /* Copy the second integer (LSB first) after the first */ 312 /* Copy the second integer (LSB first) after the first */
@@ -324,14 +320,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
324 320
325 /* Result of two Strings is a String */ 321 /* Result of two Strings is a String */
326 322
327 new_length = (acpi_size) operand0->string.length + 323 return_desc = acpi_ut_create_string_object((acpi_size)
328 (acpi_size) local_operand1->string.length; 324 (operand0->string.
329 if (new_length > ACPI_MAX_STRING_CONVERSION) { 325 length +
330 status = AE_AML_STRING_LIMIT; 326 local_operand1->
331 goto cleanup; 327 string.length));
332 }
333
334 return_desc = acpi_ut_create_string_object(new_length);
335 if (!return_desc) { 328 if (!return_desc) {
336 status = AE_NO_MEMORY; 329 status = AE_NO_MEMORY;
337 goto cleanup; 330 goto cleanup;
@@ -351,11 +344,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
351 /* Result of two Buffers is a Buffer */ 344 /* Result of two Buffers is a Buffer */
352 345
353 return_desc = acpi_ut_create_buffer_object((acpi_size) 346 return_desc = acpi_ut_create_buffer_object((acpi_size)
354 operand0->buffer. 347 (operand0->buffer.
355 length + 348 length +
356 (acpi_size) 349 local_operand1->
357 local_operand1-> 350 buffer.length));
358 buffer.length);
359 if (!return_desc) { 351 if (!return_desc) {
360 status = AE_NO_MEMORY; 352 status = AE_NO_MEMORY;
361 goto cleanup; 353 goto cleanup;
@@ -365,8 +357,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
365 357
366 /* Concatenate the buffers */ 358 /* Concatenate the buffers */
367 359
368 ACPI_MEMCPY(new_buf, 360 ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
369 operand0->buffer.pointer, operand0->buffer.length); 361 operand0->buffer.length);
370 ACPI_MEMCPY(new_buf + operand0->buffer.length, 362 ACPI_MEMCPY(new_buf + operand0->buffer.length,
371 local_operand1->buffer.pointer, 363 local_operand1->buffer.pointer,
372 local_operand1->buffer.length); 364 local_operand1->buffer.length);
diff --git a/drivers/acpi/executer/exnames.c b/drivers/acpi/executer/exnames.c
index dff41121a304..7bb5e17b5680 100644
--- a/drivers/acpi/executer/exnames.c
+++ b/drivers/acpi/executer/exnames.c
@@ -216,7 +216,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
216 *aml_address, aml_address)); 216 *aml_address, aml_address));
217 } 217 }
218 218
219 *in_aml_address = (u8 *) aml_address; 219 *in_aml_address = ACPI_CAST_PTR(u8, aml_address);
220 return_ACPI_STATUS(status); 220 return_ACPI_STATUS(status);
221} 221}
222 222
diff --git a/drivers/acpi/executer/exoparg2.c b/drivers/acpi/executer/exoparg2.c
index 8d70c6beef00..d8472842c1fd 100644
--- a/drivers/acpi/executer/exoparg2.c
+++ b/drivers/acpi/executer/exoparg2.c
@@ -344,10 +344,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
344 (length < operand[1]->integer.value) && 344 (length < operand[1]->integer.value) &&
345 (operand[0]->buffer.pointer[length])) { 345 (operand[0]->buffer.pointer[length])) {
346 length++; 346 length++;
347 if (length > ACPI_MAX_STRING_CONVERSION) {
348 status = AE_AML_STRING_LIMIT;
349 goto cleanup;
350 }
351 } 347 }
352 348
353 /* Allocate a new string object */ 349 /* Allocate a new string object */
@@ -358,8 +354,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
358 goto cleanup; 354 goto cleanup;
359 } 355 }
360 356
361 /* Copy the raw buffer data with no transform. NULL terminated already */ 357 /*
362 358 * Copy the raw buffer data with no transform.
359 * (NULL terminated already)
360 */
363 ACPI_MEMCPY(return_desc->string.pointer, 361 ACPI_MEMCPY(return_desc->string.pointer,
364 operand[0]->buffer.pointer, length); 362 operand[0]->buffer.pointer, length);
365 break; 363 break;
diff --git a/drivers/acpi/executer/exregion.c b/drivers/acpi/executer/exregion.c
index 1897379b5f90..80118be3f544 100644
--- a/drivers/acpi/executer/exregion.c
+++ b/drivers/acpi/executer/exregion.c
@@ -199,20 +199,20 @@ acpi_ex_system_memory_space_handler(u32 function,
199 *value = 0; 199 *value = 0;
200 switch (bit_width) { 200 switch (bit_width) {
201 case 8: 201 case 8:
202 *value = (acpi_integer) * ((u8 *) logical_addr_ptr); 202 *value = (acpi_integer) ACPI_GET8(logical_addr_ptr);
203 break; 203 break;
204 204
205 case 16: 205 case 16:
206 *value = (acpi_integer) * ((u16 *) logical_addr_ptr); 206 *value = (acpi_integer) ACPI_GET16(logical_addr_ptr);
207 break; 207 break;
208 208
209 case 32: 209 case 32:
210 *value = (acpi_integer) * ((u32 *) logical_addr_ptr); 210 *value = (acpi_integer) ACPI_GET32(logical_addr_ptr);
211 break; 211 break;
212 212
213#if ACPI_MACHINE_WIDTH != 16 213#if ACPI_MACHINE_WIDTH != 16
214 case 64: 214 case 64:
215 *value = (acpi_integer) * ((u64 *) logical_addr_ptr); 215 *value = (acpi_integer) ACPI_GET64(logical_addr_ptr);
216 break; 216 break;
217#endif 217#endif
218 default: 218 default:
@@ -225,20 +225,20 @@ acpi_ex_system_memory_space_handler(u32 function,
225 225
226 switch (bit_width) { 226 switch (bit_width) {
227 case 8: 227 case 8:
228 *(u8 *) logical_addr_ptr = (u8) * value; 228 ACPI_SET8(logical_addr_ptr) = (u8) * value;
229 break; 229 break;
230 230
231 case 16: 231 case 16:
232 *(u16 *) logical_addr_ptr = (u16) * value; 232 ACPI_SET16(logical_addr_ptr) = (u16) * value;
233 break; 233 break;
234 234
235 case 32: 235 case 32:
236 *(u32 *) logical_addr_ptr = (u32) * value; 236 ACPI_SET32(logical_addr_ptr) = (u32) * value;
237 break; 237 break;
238 238
239#if ACPI_MACHINE_WIDTH != 16 239#if ACPI_MACHINE_WIDTH != 16
240 case 64: 240 case 64:
241 *(u64 *) logical_addr_ptr = (u64) * value; 241 ACPI_SET64(logical_addr_ptr) = (u64) * value;
242 break; 242 break;
243#endif 243#endif
244 244
diff --git a/drivers/acpi/executer/exstorob.c b/drivers/acpi/executer/exstorob.c
index c4ff654a6697..855db7130751 100644
--- a/drivers/acpi/executer/exstorob.c
+++ b/drivers/acpi/executer/exstorob.c
@@ -71,7 +71,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
71 71
72 /* We know that source_desc is a buffer by now */ 72 /* We know that source_desc is a buffer by now */
73 73
74 buffer = (u8 *) source_desc->buffer.pointer; 74 buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
75 length = source_desc->buffer.length; 75 length = source_desc->buffer.length;
76 76
77 /* 77 /*
@@ -160,7 +160,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
160 160
161 /* We know that source_desc is a string by now */ 161 /* We know that source_desc is a string by now */
162 162
163 buffer = (u8 *) source_desc->string.pointer; 163 buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
164 length = source_desc->string.length; 164 length = source_desc->string.length;
165 165
166 /* 166 /*
diff --git a/drivers/acpi/parser/psargs.c b/drivers/acpi/parser/psargs.c
index 562d0f822ab1..6eae35febccd 100644
--- a/drivers/acpi/parser/psargs.c
+++ b/drivers/acpi/parser/psargs.c
@@ -62,61 +62,51 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
62 * 62 *
63 * PARAMETERS: parser_state - Current parser state object 63 * PARAMETERS: parser_state - Current parser state object
64 * 64 *
65 * RETURN: Decoded package length. On completion, the AML pointer points 65 * RETURN: Decoded package length. On completion, the AML pointer points
66 * past the length byte or bytes. 66 * past the length byte or bytes.
67 * 67 *
68 * DESCRIPTION: Decode and return a package length field 68 * DESCRIPTION: Decode and return a package length field.
69 * Note: Largest package length is 28 bits, from ACPI specification
69 * 70 *
70 ******************************************************************************/ 71 ******************************************************************************/
71 72
72static u32 73static u32
73acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state) 74acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
74{ 75{
75 u32 encoded_length; 76 u8 *aml = parser_state->aml;
76 u32 length = 0; 77 u32 package_length = 0;
78 acpi_native_uint byte_count;
79 u8 byte_zero_mask = 0x3F; /* Default [0:5] */
77 80
78 ACPI_FUNCTION_TRACE("ps_get_next_package_length"); 81 ACPI_FUNCTION_TRACE("ps_get_next_package_length");
79 82
80 encoded_length = (u32) ACPI_GET8(parser_state->aml); 83 /*
81 parser_state->aml++; 84 * Byte 0 bits [6:7] contain the number of additional bytes
82 85 * used to encode the package length, either 0,1,2, or 3
83 switch (encoded_length >> 6) { /* bits 6-7 contain encoding scheme */ 86 */
84 case 0: /* 1-byte encoding (bits 0-5) */ 87 byte_count = (aml[0] >> 6);
85 88 parser_state->aml += (byte_count + 1);
86 length = (encoded_length & 0x3F);
87 break;
88
89 case 1: /* 2-byte encoding (next byte + bits 0-3) */
90
91 length = ((ACPI_GET8(parser_state->aml) << 04) |
92 (encoded_length & 0x0F));
93 parser_state->aml++;
94 break;
95
96 case 2: /* 3-byte encoding (next 2 bytes + bits 0-3) */
97
98 length = ((ACPI_GET8(parser_state->aml + 1) << 12) |
99 (ACPI_GET8(parser_state->aml) << 04) |
100 (encoded_length & 0x0F));
101 parser_state->aml += 2;
102 break;
103
104 case 3: /* 4-byte encoding (next 3 bytes + bits 0-3) */
105 89
106 length = ((ACPI_GET8(parser_state->aml + 2) << 20) | 90 /* Get bytes 3, 2, 1 as needed */
107 (ACPI_GET8(parser_state->aml + 1) << 12) |
108 (ACPI_GET8(parser_state->aml) << 04) |
109 (encoded_length & 0x0F));
110 parser_state->aml += 3;
111 break;
112 91
113 default: 92 while (byte_count) {
93 /*
94 * Final bit positions for the package length bytes:
95 * Byte3->[20:27]
96 * Byte2->[12:19]
97 * Byte1->[04:11]
98 * Byte0->[00:03]
99 */
100 package_length |= (aml[byte_count] << ((byte_count << 3) - 4));
114 101
115 /* Can't get here, only 2 bits / 4 cases */ 102 byte_zero_mask = 0x0F; /* Use bits [0:3] of byte 0 */
116 break; 103 byte_count--;
117 } 104 }
118 105
119 return_UINT32(length); 106 /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
107
108 package_length |= (aml[0] & byte_zero_mask);
109 return_UINT32(package_length);
120} 110}
121 111
122/******************************************************************************* 112/*******************************************************************************
@@ -135,16 +125,15 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
135u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state) 125u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
136{ 126{
137 u8 *start = parser_state->aml; 127 u8 *start = parser_state->aml;
138 acpi_native_uint length; 128 u32 package_length;
139 129
140 ACPI_FUNCTION_TRACE("ps_get_next_package_end"); 130 ACPI_FUNCTION_TRACE("ps_get_next_package_end");
141 131
142 /* Function below changes parser_state->Aml */ 132 /* Function below updates parser_state->Aml */
143 133
144 length = 134 package_length = acpi_ps_get_next_package_length(parser_state);
145 (acpi_native_uint) acpi_ps_get_next_package_length(parser_state);
146 135
147 return_PTR(start + length); /* end of package */ 136 return_PTR(start + package_length); /* end of package */
148} 137}
149 138
150/******************************************************************************* 139/*******************************************************************************
@@ -169,17 +158,15 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
169 158
170 ACPI_FUNCTION_TRACE("ps_get_next_namestring"); 159 ACPI_FUNCTION_TRACE("ps_get_next_namestring");
171 160
172 /* Handle multiple prefix characters */ 161 /* Point past any namestring prefix characters (backslash or carat) */
173
174 while (acpi_ps_is_prefix_char(ACPI_GET8(end))) {
175 /* Include prefix '\\' or '^' */
176 162
163 while (acpi_ps_is_prefix_char(*end)) {
177 end++; 164 end++;
178 } 165 }
179 166
180 /* Decode the path */ 167 /* Decode the path prefix character */
181 168
182 switch (ACPI_GET8(end)) { 169 switch (*end) {
183 case 0: 170 case 0:
184 171
185 /* null_name */ 172 /* null_name */
@@ -199,9 +186,9 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
199 186
200 case AML_MULTI_NAME_PREFIX_OP: 187 case AML_MULTI_NAME_PREFIX_OP:
201 188
202 /* Multiple name segments, 4 chars each */ 189 /* Multiple name segments, 4 chars each, count in next byte */
203 190
204 end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE); 191 end += 2 + (*(end + 1) * ACPI_NAME_SIZE);
205 break; 192 break;
206 193
207 default: 194 default:
@@ -212,7 +199,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
212 break; 199 break;
213 } 200 }
214 201
215 parser_state->aml = (u8 *) end; 202 parser_state->aml = end;
216 return_PTR((char *)start); 203 return_PTR((char *)start);
217} 204}
218 205
@@ -342,7 +329,6 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
342 ("search_node %p start_node %p return_node %p\n", 329 ("search_node %p start_node %p return_node %p\n",
343 scope_info.scope.node, 330 scope_info.scope.node,
344 parser_state->start_node, node); 331 parser_state->start_node, node);
345
346 } else { 332 } else {
347 /* 333 /*
348 * We got a NOT_FOUND during table load or we encountered 334 * We got a NOT_FOUND during table load or we encountered
@@ -382,59 +368,63 @@ void
382acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state, 368acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
383 u32 arg_type, union acpi_parse_object *arg) 369 u32 arg_type, union acpi_parse_object *arg)
384{ 370{
371 u32 length;
372 u16 opcode;
373 u8 *aml = parser_state->aml;
385 374
386 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type); 375 ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type);
387 376
388 switch (arg_type) { 377 switch (arg_type) {
389 case ARGP_BYTEDATA: 378 case ARGP_BYTEDATA:
390 379
391 acpi_ps_init_op(arg, AML_BYTE_OP); 380 /* Get 1 byte from the AML stream */
392 arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml); 381
393 parser_state->aml++; 382 opcode = AML_BYTE_OP;
383 arg->common.value.integer = (acpi_integer) * aml;
384 length = 1;
394 break; 385 break;
395 386
396 case ARGP_WORDDATA: 387 case ARGP_WORDDATA:
397 388
398 acpi_ps_init_op(arg, AML_WORD_OP);
399
400 /* Get 2 bytes from the AML stream */ 389 /* Get 2 bytes from the AML stream */
401 390
402 ACPI_MOVE_16_TO_32(&arg->common.value.integer, 391 opcode = AML_WORD_OP;
403 parser_state->aml); 392 ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml);
404 parser_state->aml += 2; 393 length = 2;
405 break; 394 break;
406 395
407 case ARGP_DWORDDATA: 396 case ARGP_DWORDDATA:
408 397
409 acpi_ps_init_op(arg, AML_DWORD_OP);
410
411 /* Get 4 bytes from the AML stream */ 398 /* Get 4 bytes from the AML stream */
412 399
413 ACPI_MOVE_32_TO_32(&arg->common.value.integer, 400 opcode = AML_DWORD_OP;
414 parser_state->aml); 401 ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml);
415 parser_state->aml += 4; 402 length = 4;
416 break; 403 break;
417 404
418 case ARGP_QWORDDATA: 405 case ARGP_QWORDDATA:
419 406
420 acpi_ps_init_op(arg, AML_QWORD_OP);
421
422 /* Get 8 bytes from the AML stream */ 407 /* Get 8 bytes from the AML stream */
423 408
424 ACPI_MOVE_64_TO_64(&arg->common.value.integer, 409 opcode = AML_QWORD_OP;
425 parser_state->aml); 410 ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml);
426 parser_state->aml += 8; 411 length = 8;
427 break; 412 break;
428 413
429 case ARGP_CHARLIST: 414 case ARGP_CHARLIST:
430 415
431 acpi_ps_init_op(arg, AML_STRING_OP); 416 /* Get a pointer to the string, point past the string */
432 arg->common.value.string = (char *)parser_state->aml; 417
418 opcode = AML_STRING_OP;
419 arg->common.value.string = ACPI_CAST_PTR(char, aml);
433 420
434 while (ACPI_GET8(parser_state->aml) != '\0') { 421 /* Find the null terminator */
435 parser_state->aml++; 422
423 length = 0;
424 while (aml[length]) {
425 length++;
436 } 426 }
437 parser_state->aml++; 427 length++;
438 break; 428 break;
439 429
440 case ARGP_NAME: 430 case ARGP_NAME:
@@ -443,14 +433,16 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
443 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP); 433 acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
444 arg->common.value.name = 434 arg->common.value.name =
445 acpi_ps_get_next_namestring(parser_state); 435 acpi_ps_get_next_namestring(parser_state);
446 break; 436 return_VOID;
447 437
448 default: 438 default:
449 439
450 ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type)); 440 ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type));
451 break; 441 return_VOID;
452 } 442 }
453 443
444 acpi_ps_init_op(arg, opcode);
445 parser_state->aml += length;
454 return_VOID; 446 return_VOID;
455} 447}
456 448
@@ -540,7 +532,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
540 * access_type is first operand, access_attribute is second 532 * access_type is first operand, access_attribute is second
541 */ 533 */
542 field->common.value.integer = 534 field->common.value.integer =
543 (ACPI_GET8(parser_state->aml) << 8); 535 (((u32) ACPI_GET8(parser_state->aml) << 8));
544 parser_state->aml++; 536 parser_state->aml++;
545 field->common.value.integer |= ACPI_GET8(parser_state->aml); 537 field->common.value.integer |= ACPI_GET8(parser_state->aml);
546 parser_state->aml++; 538 parser_state->aml++;
diff --git a/drivers/acpi/parser/psparse.c b/drivers/acpi/parser/psparse.c
index 76d4d640d83c..7cfa7eb0dfc7 100644
--- a/drivers/acpi/parser/psparse.c
+++ b/drivers/acpi/parser/psparse.c
@@ -503,22 +503,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
503 } else if (status == AE_CTRL_TERMINATE) { 503 } else if (status == AE_CTRL_TERMINATE) {
504 status = AE_OK; 504 status = AE_OK;
505 } else if ((status != AE_OK) && (walk_state->method_desc)) { 505 } else if ((status != AE_OK) && (walk_state->method_desc)) {
506 ACPI_REPORT_METHOD_ERROR("Method execution failed", 506 /* Either the method parse or actual execution failed */
507 walk_state->method_node, NULL,
508 status);
509 507
510 /* Ensure proper cleanup */ 508 ACPI_REPORT_METHOD_ERROR
511 509 ("Method parse/execution failed",
512 walk_state->parse_flags |= ACPI_PARSE_EXECUTE; 510 walk_state->method_node, NULL, status);
513 511
514 /* Check for possible multi-thread reentrancy problem */ 512 /* Check for possible multi-thread reentrancy problem */
515 513
516 if ((status == AE_ALREADY_EXISTS) && 514 if ((status == AE_ALREADY_EXISTS) &&
517 (!walk_state->method_desc->method.semaphore)) { 515 (!walk_state->method_desc->method.semaphore)) {
518 /* 516 /*
519 * This method is marked not_serialized, but it tried to create 517 * Method tried to create an object twice. The probable cause is
518 * that the method cannot handle reentrancy.
519 *
520 * The method is marked not_serialized, but it tried to create
520 * a named object, causing the second thread entrance to fail. 521 * a named object, causing the second thread entrance to fail.
521 * We will workaround this by marking the method permanently 522 * Workaround this problem by marking the method permanently
522 * as Serialized. 523 * as Serialized.
523 */ 524 */
524 walk_state->method_desc->method.method_flags |= 525 walk_state->method_desc->method.method_flags |=
@@ -536,15 +537,22 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
536 acpi_ds_scope_stack_clear(walk_state); 537 acpi_ds_scope_stack_clear(walk_state);
537 538
538 /* 539 /*
539 * If we just returned from the execution of a control method, 540 * If we just returned from the execution of a control method or if we
540 * there's lots of cleanup to do 541 * encountered an error during the method parse phase, there's lots of
542 * cleanup to do
541 */ 543 */
542 if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) == 544 if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
543 ACPI_PARSE_EXECUTE) { 545 ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) {
544 if (walk_state->method_desc) { 546 if (walk_state->method_desc) {
545 /* Decrement the thread count on the method parse tree */ 547 /* Decrement the thread count on the method parse tree */
546 548
547 walk_state->method_desc->method.thread_count--; 549 if (walk_state->method_desc->method.
550 thread_count) {
551 walk_state->method_desc->method.
552 thread_count--;
553 } else {
554 ACPI_REPORT_ERROR(("Invalid zero thread count in method\n"));
555 }
548 } 556 }
549 557
550 acpi_ds_terminate_control_method(walk_state); 558 acpi_ds_terminate_control_method(walk_state);
@@ -553,7 +561,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
553 /* Delete this walk state and all linked control states */ 561 /* Delete this walk state and all linked control states */
554 562
555 acpi_ps_cleanup_scope(&walk_state->parser_state); 563 acpi_ps_cleanup_scope(&walk_state->parser_state);
556
557 previous_walk_state = walk_state; 564 previous_walk_state = walk_state;
558 565
559 ACPI_DEBUG_PRINT((ACPI_DB_PARSE, 566 ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index 4c426f4c6af6..14d544d60867 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -87,7 +87,7 @@ acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
87 87
88 /* TBDs: Validate name, allow full path or just nameseg */ 88 /* TBDs: Validate name, allow full path or just nameseg */
89 89
90 acpi_gbl_trace_method_name = *(u32 *) name; 90 acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name);
91 acpi_gbl_trace_flags = flags; 91 acpi_gbl_trace_flags = flags;
92 92
93 if (debug_level) { 93 if (debug_level) {
diff --git a/drivers/acpi/resources/rscalc.c b/drivers/acpi/resources/rscalc.c
index eca7439ee9da..c2c4d9079c6c 100644
--- a/drivers/acpi/resources/rscalc.c
+++ b/drivers/acpi/resources/rscalc.c
@@ -300,7 +300,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
300 /* Point to the next object */ 300 /* Point to the next object */
301 301
302 resource = 302 resource =
303 ACPI_PTR_ADD(struct acpi_resource, resource, 303 ACPI_ADD_PTR(struct acpi_resource, resource,
304 resource->length); 304 resource->length);
305 } 305 }
306 306
@@ -374,8 +374,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
374 * Get the number of bits set in the 16-bit IRQ mask 374 * Get the number of bits set in the 16-bit IRQ mask
375 */ 375 */
376 ACPI_MOVE_16_TO_16(&temp16, buffer); 376 ACPI_MOVE_16_TO_16(&temp16, buffer);
377 extra_struct_bytes = 377 extra_struct_bytes = acpi_rs_count_set_bits(temp16);
378 acpi_rs_count_set_bits(temp16) * sizeof(u32);
379 break; 378 break;
380 379
381 case ACPI_RESOURCE_NAME_DMA: 380 case ACPI_RESOURCE_NAME_DMA:
@@ -383,8 +382,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
383 * DMA Resource: 382 * DMA Resource:
384 * Get the number of bits set in the 8-bit DMA mask 383 * Get the number of bits set in the 8-bit DMA mask
385 */ 384 */
386 extra_struct_bytes = 385 extra_struct_bytes = acpi_rs_count_set_bits(*buffer);
387 acpi_rs_count_set_bits(*buffer) * sizeof(u32);
388 break; 386 break;
389 387
390 case ACPI_RESOURCE_NAME_VENDOR_SMALL: 388 case ACPI_RESOURCE_NAME_VENDOR_SMALL:
@@ -399,9 +397,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
399 397
400 case ACPI_RESOURCE_NAME_END_TAG: 398 case ACPI_RESOURCE_NAME_END_TAG:
401 /* 399 /*
402 * End Tag: This is the normal exit 400 * End Tag: This is the normal exit, add size of end_tag
403 */ 401 */
404 *size_needed = buffer_size; 402 *size_needed = buffer_size + ACPI_RS_SIZE_MIN;
405 return_ACPI_STATUS(AE_OK); 403 return_ACPI_STATUS(AE_OK);
406 404
407 case ACPI_RESOURCE_NAME_VENDOR_LARGE: 405 case ACPI_RESOURCE_NAME_VENDOR_LARGE:
@@ -466,7 +464,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
466 464
467 temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] + 465 temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] +
468 extra_struct_bytes); 466 extra_struct_bytes);
469 buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16); 467 buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16);
470 468
471 /* 469 /*
472 * Point to the next resource within the stream 470 * Point to the next resource within the stream
diff --git a/drivers/acpi/resources/rsdump.c b/drivers/acpi/resources/rsdump.c
index f617ca80c5a6..cebd890d3db5 100644
--- a/drivers/acpi/resources/rsdump.c
+++ b/drivers/acpi/resources/rsdump.c
@@ -383,7 +383,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
383 383
384 while (count) { 384 while (count) {
385 previous_target = target; 385 previous_target = target;
386 target = ((u8 *) resource) + table->offset; 386 target = ACPI_ADD_PTR(u8, resource, table->offset);
387 name = table->name; 387 name = table->name;
388 388
389 switch (table->opcode) { 389 switch (table->opcode) {
@@ -410,22 +410,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
410 /* Data items, 8/16/32/64 bit */ 410 /* Data items, 8/16/32/64 bit */
411 411
412 case ACPI_RSD_UINT8: 412 case ACPI_RSD_UINT8:
413 acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target)); 413 acpi_rs_out_integer8(name, ACPI_GET8(target));
414 break; 414 break;
415 415
416 case ACPI_RSD_UINT16: 416 case ACPI_RSD_UINT16:
417 acpi_rs_out_integer16(name, 417 acpi_rs_out_integer16(name, ACPI_GET16(target));
418 *ACPI_CAST_PTR(u16, target));
419 break; 418 break;
420 419
421 case ACPI_RSD_UINT32: 420 case ACPI_RSD_UINT32:
422 acpi_rs_out_integer32(name, 421 acpi_rs_out_integer32(name, ACPI_GET32(target));
423 *ACPI_CAST_PTR(u32, target));
424 break; 422 break;
425 423
426 case ACPI_RSD_UINT64: 424 case ACPI_RSD_UINT64:
427 acpi_rs_out_integer64(name, 425 acpi_rs_out_integer64(name, ACPI_GET64(target));
428 *ACPI_CAST_PTR(u64, target));
429 break; 426 break;
430 427
431 /* Flags: 1-bit and 2-bit flags supported */ 428 /* Flags: 1-bit and 2-bit flags supported */
@@ -462,8 +459,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
462 * Note: The list length is obtained from the previous table entry 459 * Note: The list length is obtained from the previous table entry
463 */ 460 */
464 if (previous_target) { 461 if (previous_target) {
465 acpi_rs_dump_byte_list(*ACPI_CAST_PTR 462 acpi_rs_dump_byte_list(ACPI_GET16
466 (u16, previous_target), 463 (previous_target),
467 target); 464 target);
468 } 465 }
469 break; 466 break;
@@ -634,7 +631,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
634 /* Point to the next resource structure */ 631 /* Point to the next resource structure */
635 632
636 resource_list = 633 resource_list =
637 ACPI_PTR_ADD(struct acpi_resource, resource_list, 634 ACPI_ADD_PTR(struct acpi_resource, resource_list,
638 resource_list->length); 635 resource_list->length);
639 636
640 /* Exit when END_TAG descriptor is reached */ 637 /* Exit when END_TAG descriptor is reached */
@@ -675,9 +672,8 @@ void acpi_rs_dump_irq_list(u8 * route_table)
675 count); 672 count);
676 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt); 673 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
677 674
678 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, 675 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
679 ((u8 *) prt_element) + 676 prt_element, prt_element->length);
680 prt_element->length);
681 } 677 }
682} 678}
683 679
diff --git a/drivers/acpi/resources/rslist.c b/drivers/acpi/resources/rslist.c
index b83996233c1d..573c06705641 100644
--- a/drivers/acpi/resources/rslist.c
+++ b/drivers/acpi/resources/rslist.c
@@ -112,7 +112,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
112 /* Point to the next structure in the output buffer */ 112 /* Point to the next structure in the output buffer */
113 113
114 resource = 114 resource =
115 ACPI_PTR_ADD(struct acpi_resource, resource, 115 ACPI_ADD_PTR(struct acpi_resource, resource,
116 resource->length); 116 resource->length);
117 } 117 }
118 118
@@ -201,7 +201,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
201 /* Point to the next input resource descriptor */ 201 /* Point to the next input resource descriptor */
202 202
203 resource = 203 resource =
204 ACPI_PTR_ADD(struct acpi_resource, resource, 204 ACPI_ADD_PTR(struct acpi_resource, resource,
205 resource->length); 205 resource->length);
206 } 206 }
207 207
diff --git a/drivers/acpi/resources/rsmisc.c b/drivers/acpi/resources/rsmisc.c
index 16ad3bfbee2a..e1b5aa2af9a5 100644
--- a/drivers/acpi/resources/rsmisc.c
+++ b/drivers/acpi/resources/rsmisc.c
@@ -104,8 +104,9 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
104 * Source is the external AML byte stream buffer, 104 * Source is the external AML byte stream buffer,
105 * destination is the internal resource descriptor 105 * destination is the internal resource descriptor
106 */ 106 */
107 source = ((u8 *) aml) + info->aml_offset; 107 source = ACPI_ADD_PTR(void, aml, info->aml_offset);
108 destination = ((u8 *) resource) + info->resource_offset; 108 destination =
109 ACPI_ADD_PTR(void, resource, info->resource_offset);
109 110
110 switch (info->opcode) { 111 switch (info->opcode) {
111 case ACPI_RSC_INITGET: 112 case ACPI_RSC_INITGET:
@@ -129,22 +130,22 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
129 /* 130 /*
130 * Mask and shift the flag bit 131 * Mask and shift the flag bit
131 */ 132 */
132 *((u8 *) destination) = (u8) 133 ACPI_SET8(destination) = (u8)
133 ((*((u8 *) source) >> info->value) & 0x01); 134 ((ACPI_GET8(source) >> info->value) & 0x01);
134 break; 135 break;
135 136
136 case ACPI_RSC_2BITFLAG: 137 case ACPI_RSC_2BITFLAG:
137 /* 138 /*
138 * Mask and shift the flag bits 139 * Mask and shift the flag bits
139 */ 140 */
140 *((u8 *) destination) = (u8) 141 ACPI_SET8(destination) = (u8)
141 ((*((u8 *) source) >> info->value) & 0x03); 142 ((ACPI_GET8(source) >> info->value) & 0x03);
142 break; 143 break;
143 144
144 case ACPI_RSC_COUNT: 145 case ACPI_RSC_COUNT:
145 146
146 item_count = *((u8 *) source); 147 item_count = ACPI_GET8(source);
147 *((u8 *) destination) = (u8) item_count; 148 ACPI_SET8(destination) = (u8) item_count;
148 149
149 resource->length = resource->length + 150 resource->length = resource->length +
150 (info->value * (item_count - 1)); 151 (info->value * (item_count - 1));
@@ -153,7 +154,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
153 case ACPI_RSC_COUNT16: 154 case ACPI_RSC_COUNT16:
154 155
155 item_count = aml_resource_length; 156 item_count = aml_resource_length;
156 *((u16 *) destination) = item_count; 157 ACPI_SET16(destination) = item_count;
157 158
158 resource->length = resource->length + 159 resource->length = resource->length +
159 (info->value * (item_count - 1)); 160 (info->value * (item_count - 1));
@@ -186,9 +187,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
186 187
187 case ACPI_RSC_DATA8: 188 case ACPI_RSC_DATA8:
188 189
189 target = ((char *)resource) + info->value; 190 target = ACPI_ADD_PTR(char, resource, info->value);
190 ACPI_MEMCPY(destination, source, 191 ACPI_MEMCPY(destination, source, ACPI_GET16(target));
191 *(ACPI_CAST_PTR(u16, target)));
192 break; 192 break;
193 193
194 case ACPI_RSC_ADDRESS: 194 case ACPI_RSC_ADDRESS:
@@ -217,8 +217,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
217 * complicated case used by the Interrupt() macro 217 * complicated case used by the Interrupt() macro
218 */ 218 */
219 target = 219 target =
220 ((char *)resource) + info->aml_offset + 220 ACPI_ADD_PTR(char, resource,
221 (item_count * 4); 221 info->aml_offset + (item_count * 4));
222 222
223 resource->length += 223 resource->length +=
224 acpi_rs_get_resource_source(aml_resource_length, 224 acpi_rs_get_resource_source(aml_resource_length,
@@ -230,15 +230,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
230 * 8-bit encoded bitmask (DMA macro) 230 * 8-bit encoded bitmask (DMA macro)
231 */ 231 */
232 item_count = 232 item_count =
233 acpi_rs_decode_bitmask(*((u8 *) source), 233 acpi_rs_decode_bitmask(ACPI_GET8(source),
234 destination); 234 destination);
235 if (item_count) { 235 if (item_count) {
236 resource->length += 236 resource->length += (item_count - 1);
237 resource->length + (item_count - 1);
238 } 237 }
239 238
240 target = ((char *)resource) + info->value; 239 target = ACPI_ADD_PTR(char, resource, info->value);
241 *((u8 *) target) = (u8) item_count; 240 ACPI_SET8(target) = (u8) item_count;
242 break; 241 break;
243 242
244 case ACPI_RSC_BITMASK16: 243 case ACPI_RSC_BITMASK16:
@@ -250,12 +249,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
250 item_count = 249 item_count =
251 acpi_rs_decode_bitmask(temp16, destination); 250 acpi_rs_decode_bitmask(temp16, destination);
252 if (item_count) { 251 if (item_count) {
253 resource->length = 252 resource->length += (item_count - 1);
254 resource->length + (item_count - 1);
255 } 253 }
256 254
257 target = ((char *)resource) + info->value; 255 target = ACPI_ADD_PTR(char, resource, info->value);
258 *((u8 *) target) = (u8) item_count; 256 ACPI_SET8(target) = (u8) item_count;
259 break; 257 break;
260 258
261 case ACPI_RSC_EXIT_NE: 259 case ACPI_RSC_EXIT_NE:
@@ -270,7 +268,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
270 break; 268 break;
271 269
272 case ACPI_RSC_COMPARE_VALUE: 270 case ACPI_RSC_COMPARE_VALUE:
273 if (*((u8 *) source) != info->value) { 271 if (ACPI_GET8(source) != info->value) {
274 goto exit; 272 goto exit;
275 } 273 }
276 break; 274 break;
@@ -349,8 +347,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
349 * Source is the internal resource descriptor, 347 * Source is the internal resource descriptor,
350 * destination is the external AML byte stream buffer 348 * destination is the external AML byte stream buffer
351 */ 349 */
352 source = ((u8 *) resource) + info->resource_offset; 350 source = ACPI_ADD_PTR(void, resource, info->resource_offset);
353 destination = ((u8 *) aml) + info->aml_offset; 351 destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
354 352
355 switch (info->opcode) { 353 switch (info->opcode) {
356 case ACPI_RSC_INITSET: 354 case ACPI_RSC_INITSET:
@@ -368,37 +366,38 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
368 /* 366 /*
369 * Clear the flag byte 367 * Clear the flag byte
370 */ 368 */
371 *((u8 *) destination) = 0; 369 ACPI_SET8(destination) = 0;
372 break; 370 break;
373 371
374 case ACPI_RSC_1BITFLAG: 372 case ACPI_RSC_1BITFLAG:
375 /* 373 /*
376 * Mask and shift the flag bit 374 * Mask and shift the flag bit
377 */ 375 */
378 *((u8 *) destination) |= (u8) 376 ACPI_SET8(destination) |= (u8)
379 ((*((u8 *) source) & 0x01) << info->value); 377 ((ACPI_GET8(source) & 0x01) << info->value);
380 break; 378 break;
381 379
382 case ACPI_RSC_2BITFLAG: 380 case ACPI_RSC_2BITFLAG:
383 /* 381 /*
384 * Mask and shift the flag bits 382 * Mask and shift the flag bits
385 */ 383 */
386 *((u8 *) destination) |= (u8) 384 ACPI_SET8(destination) |= (u8)
387 ((*((u8 *) source) & 0x03) << info->value); 385 ((ACPI_GET8(source) & 0x03) << info->value);
388 break; 386 break;
389 387
390 case ACPI_RSC_COUNT: 388 case ACPI_RSC_COUNT:
391 389
392 item_count = *((u8 *) source); 390 item_count = ACPI_GET8(source);
393 *((u8 *) destination) = (u8) item_count; 391 ACPI_SET8(destination) = (u8) item_count;
394 392
395 aml_length = (u16) (aml_length + 393 aml_length =
396 (info->value * (item_count - 1))); 394 (u16) (aml_length +
395 (info->value * (item_count - 1)));
397 break; 396 break;
398 397
399 case ACPI_RSC_COUNT16: 398 case ACPI_RSC_COUNT16:
400 399
401 item_count = *((u16 *) source); 400 item_count = ACPI_GET16(source);
402 aml_length = (u16) (aml_length + item_count); 401 aml_length = (u16) (aml_length + item_count);
403 acpi_rs_set_resource_length(aml_length, aml); 402 acpi_rs_set_resource_length(aml_length, aml);
404 break; 403 break;
@@ -453,20 +452,21 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
453 /* 452 /*
454 * 8-bit encoded bitmask (DMA macro) 453 * 8-bit encoded bitmask (DMA macro)
455 */ 454 */
456 *((u8 *) destination) = (u8) 455 ACPI_SET8(destination) = (u8)
457 acpi_rs_encode_bitmask(source, 456 acpi_rs_encode_bitmask(source,
458 *(((u8 *) resource) + 457 *ACPI_ADD_PTR(u8, resource,
459 info->value)); 458 info->value));
460 break; 459 break;
461 460
462 case ACPI_RSC_BITMASK16: 461 case ACPI_RSC_BITMASK16:
463 /* 462 /*
464 * 16-bit encoded bitmask (IRQ macro) 463 * 16-bit encoded bitmask (IRQ macro)
465 */ 464 */
466 temp16 = 465 temp16 = acpi_rs_encode_bitmask(source,
467 acpi_rs_encode_bitmask(source, 466 *ACPI_ADD_PTR(u8,
468 *(((u8 *) resource) + 467 resource,
469 info->value)); 468 info->
469 value));
470 ACPI_MOVE_16_TO_16(destination, &temp16); 470 ACPI_MOVE_16_TO_16(destination, &temp16);
471 break; 471 break;
472 472
@@ -485,9 +485,9 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
485 */ 485 */
486 switch (COMPARE_OPCODE(info)) { 486 switch (COMPARE_OPCODE(info)) {
487 case ACPI_RSC_COMPARE_VALUE: 487 case ACPI_RSC_COMPARE_VALUE:
488 if (* 488
489 ((u8 *) (((u8 *) resource) + 489 if (*ACPI_ADD_PTR(u8, resource,
490 COMPARE_TARGET(info))) != 490 COMPARE_TARGET(info)) !=
491 COMPARE_VALUE(info)) { 491 COMPARE_VALUE(info)) {
492 goto exit; 492 goto exit;
493 } 493 }
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index a1eac0f1df54..2236a0c90daa 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -152,18 +152,18 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
152 * misaligned memory transfers 152 * misaligned memory transfers
153 */ 153 */
154 case ACPI_RSC_MOVE16: 154 case ACPI_RSC_MOVE16:
155 ACPI_MOVE_16_TO_16(&((u16 *) destination)[i], 155 ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
156 &((u16 *) source)[i]); 156 &ACPI_CAST_PTR(u16, source)[i]);
157 break; 157 break;
158 158
159 case ACPI_RSC_MOVE32: 159 case ACPI_RSC_MOVE32:
160 ACPI_MOVE_32_TO_32(&((u32 *) destination)[i], 160 ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
161 &((u32 *) source)[i]); 161 &ACPI_CAST_PTR(u32, source)[i]);
162 break; 162 break;
163 163
164 case ACPI_RSC_MOVE64: 164 case ACPI_RSC_MOVE64:
165 ACPI_MOVE_64_TO_64(&((u64 *) destination)[i], 165 ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
166 &((u64 *) source)[i]); 166 &ACPI_CAST_PTR(u64, source)[i]);
167 break; 167 break;
168 168
169 default: 169 default:
@@ -318,7 +318,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
318 318
319 total_length = 319 total_length =
320 resource_length + sizeof(struct aml_resource_large_header); 320 resource_length + sizeof(struct aml_resource_large_header);
321 aml_resource_source = ((u8 *) aml) + minimum_length; 321 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
322 322
323 /* 323 /*
324 * resource_source is present if the length of the descriptor is longer than 324 * resource_source is present if the length of the descriptor is longer than
@@ -338,9 +338,9 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
338 * String destination pointer is not specified; Set the String 338 * String destination pointer is not specified; Set the String
339 * pointer to the end of the current resource_source structure. 339 * pointer to the end of the current resource_source structure.
340 */ 340 */
341 resource_source->string_ptr = (char *) 341 resource_source->string_ptr =
342 ((u8 *) resource_source) + 342 ACPI_ADD_PTR(char, resource_source,
343 sizeof(struct acpi_resource_source); 343 sizeof(struct acpi_resource_source));
344 } 344 }
345 345
346 /* 346 /*
@@ -407,7 +407,7 @@ acpi_rs_set_resource_source(union aml_resource * aml,
407 if (resource_source->string_length) { 407 if (resource_source->string_length) {
408 /* Point to the end of the AML descriptor */ 408 /* Point to the end of the AML descriptor */
409 409
410 aml_resource_source = ((u8 *) aml) + minimum_length; 410 aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
411 411
412 /* Copy the resource_source_index */ 412 /* Copy the resource_source_index */
413 413
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index 09d250ab9872..50a956b705b0 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -64,6 +64,10 @@ ACPI_MODULE_NAME("rsxface")
64 ACPI_COPY_FIELD(out, in, translation_offset); \ 64 ACPI_COPY_FIELD(out, in, translation_offset); \
65 ACPI_COPY_FIELD(out, in, address_length); \ 65 ACPI_COPY_FIELD(out, in, address_length); \
66 ACPI_COPY_FIELD(out, in, resource_source); 66 ACPI_COPY_FIELD(out, in, resource_source);
67/* Local prototypes */
68static acpi_status
69acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
70
67/******************************************************************************* 71/*******************************************************************************
68 * 72 *
69 * FUNCTION: acpi_get_irq_routing_table 73 * FUNCTION: acpi_get_irq_routing_table
@@ -86,6 +90,7 @@ ACPI_MODULE_NAME("rsxface")
86 * the object indicated by the passed device_handle. 90 * the object indicated by the passed device_handle.
87 * 91 *
88 ******************************************************************************/ 92 ******************************************************************************/
93
89acpi_status 94acpi_status
90acpi_get_irq_routing_table(acpi_handle device_handle, 95acpi_get_irq_routing_table(acpi_handle device_handle,
91 struct acpi_buffer *ret_buffer) 96 struct acpi_buffer *ret_buffer)
@@ -222,12 +227,12 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
222 * 227 *
223 * FUNCTION: acpi_walk_resources 228 * FUNCTION: acpi_walk_resources
224 * 229 *
225 * PARAMETERS: device_handle - a handle to the device object for the 230 * PARAMETERS: device_handle - Handle to the device object for the
226 * device we are querying 231 * device we are querying
227 * Path - method name of the resources we want 232 * Name - Method name of the resources we want
228 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 233 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
229 * user_function - called for each resource 234 * user_function - Called for each resource
230 * Context - passed to user_function 235 * Context - Passed to user_function
231 * 236 *
232 * RETURN: Status 237 * RETURN: Status
233 * 238 *
@@ -239,79 +244,74 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
239 244
240acpi_status 245acpi_status
241acpi_walk_resources(acpi_handle device_handle, 246acpi_walk_resources(acpi_handle device_handle,
242 char *path, 247 char *name,
243 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context) 248 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
244{ 249{
245 acpi_status status; 250 acpi_status status;
246 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; 251 struct acpi_buffer buffer;
247 struct acpi_resource *resource; 252 struct acpi_resource *resource;
248 struct acpi_resource *buffer_end; 253 struct acpi_resource *resource_end;
249 254
250 ACPI_FUNCTION_TRACE("acpi_walk_resources"); 255 ACPI_FUNCTION_TRACE("acpi_walk_resources");
251 256
252 if (!device_handle || 257 /* Parameter validation */
253 (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) && 258
254 ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) { 259 if (!device_handle || !user_function || !name ||
260 (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
261 ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
255 return_ACPI_STATUS(AE_BAD_PARAMETER); 262 return_ACPI_STATUS(AE_BAD_PARAMETER);
256 } 263 }
257 264
258 status = acpi_rs_get_method_data(device_handle, path, &buffer); 265 /* Get the _CRS or _PRS resource list */
266
267 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
268 status = acpi_rs_get_method_data(device_handle, name, &buffer);
259 if (ACPI_FAILURE(status)) { 269 if (ACPI_FAILURE(status)) {
260 return_ACPI_STATUS(status); 270 return_ACPI_STATUS(status);
261 } 271 }
262 272
263 /* Setup pointers */ 273 /* Buffer now contains the resource list */
264 274
265 resource = (struct acpi_resource *)buffer.pointer; 275 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
266 buffer_end = ACPI_CAST_PTR(struct acpi_resource, 276 resource_end =
267 ((u8 *) buffer.pointer + buffer.length)); 277 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
268 278
269 /* Walk the resource list */ 279 /* Walk the resource list until the end_tag is found (or buffer end) */
270 280
271 for (;;) { 281 while (resource < resource_end) {
272 if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) { 282 /* Sanity check the resource */
283
284 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
285 status = AE_AML_INVALID_RESOURCE_TYPE;
273 break; 286 break;
274 } 287 }
275 288
276 status = user_function(resource, context); 289 /* Invoke the user function, abort on any error returned */
277
278 switch (status) {
279 case AE_OK:
280 case AE_CTRL_DEPTH:
281 290
282 /* Just keep going */ 291 status = user_function(resource, context);
292 if (ACPI_FAILURE(status)) {
293 if (status == AE_CTRL_TERMINATE) {
294 /* This is an OK termination by the user function */
283 295
284 status = AE_OK; 296 status = AE_OK;
297 }
285 break; 298 break;
299 }
286 300
287 case AE_CTRL_TERMINATE: 301 /* end_tag indicates end-of-list */
288
289 /* Exit now, with OK stats */
290
291 status = AE_OK;
292 goto cleanup;
293
294 default:
295
296 /* All others are valid exceptions */
297 302
298 goto cleanup; 303 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
304 break;
299 } 305 }
300 306
301 /* Get the next resource descriptor */ 307 /* Get the next resource descriptor */
302 308
303 resource = ACPI_NEXT_RESOURCE(resource); 309 resource =
304 310 ACPI_ADD_PTR(struct acpi_resource, resource,
305 /* Check for end-of-buffer */ 311 resource->length);
306
307 if (resource >= buffer_end) {
308 goto cleanup;
309 }
310 } 312 }
311 313
312 cleanup: 314 ACPI_MEM_FREE(buffer.pointer);
313
314 acpi_os_free(buffer.pointer);
315 return_ACPI_STATUS(status); 315 return_ACPI_STATUS(status);
316} 316}
317 317
@@ -381,6 +381,12 @@ acpi_resource_to_address64(struct acpi_resource *resource,
381 struct acpi_resource_address16 *address16; 381 struct acpi_resource_address16 *address16;
382 struct acpi_resource_address32 *address32; 382 struct acpi_resource_address32 *address32;
383 383
384 if (!resource || !out) {
385 return (AE_BAD_PARAMETER);
386 }
387
388 /* Convert 16 or 32 address descriptor to 64 */
389
384 switch (resource->type) { 390 switch (resource->type) {
385 case ACPI_RESOURCE_TYPE_ADDRESS16: 391 case ACPI_RESOURCE_TYPE_ADDRESS16:
386 392
@@ -410,3 +416,113 @@ acpi_resource_to_address64(struct acpi_resource *resource,
410} 416}
411 417
412EXPORT_SYMBOL(acpi_resource_to_address64); 418EXPORT_SYMBOL(acpi_resource_to_address64);
419
420/*******************************************************************************
421 *
422 * FUNCTION: acpi_get_vendor_resource
423 *
424 * PARAMETERS: device_handle - Handle for the parent device object
425 * Name - Method name for the parent resource
426 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
427 * Uuid - Pointer to the UUID to be matched.
428 * includes both subtype and 16-byte UUID
429 * ret_buffer - Where the vendor resource is returned
430 *
431 * RETURN: Status
432 *
433 * DESCRIPTION: Walk a resource template for the specified evice to find a
434 * vendor-defined resource that matches the supplied UUID and
435 * UUID subtype. Returns a struct acpi_resource of type Vendor.
436 *
437 ******************************************************************************/
438
439acpi_status
440acpi_get_vendor_resource(acpi_handle device_handle,
441 char *name,
442 struct acpi_vendor_uuid * uuid,
443 struct acpi_buffer * ret_buffer)
444{
445 struct acpi_vendor_walk_info info;
446 acpi_status status;
447
448 /* Other parameters are validated by acpi_walk_resources */
449
450 if (!uuid || !ret_buffer) {
451 return (AE_BAD_PARAMETER);
452 }
453
454 info.uuid = uuid;
455 info.buffer = ret_buffer;
456 info.status = AE_NOT_EXIST;
457
458 /* Walk the _CRS or _PRS resource list for this device */
459
460 status =
461 acpi_walk_resources(device_handle, name,
462 acpi_rs_match_vendor_resource, &info);
463 if (ACPI_FAILURE(status)) {
464 return (status);
465 }
466
467 return (info.status);
468}
469
470/*******************************************************************************
471 *
472 * FUNCTION: acpi_rs_match_vendor_resource
473 *
474 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
475 *
476 * RETURN: Status
477 *
478 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
479 *
480 ******************************************************************************/
481
482static acpi_status
483acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
484{
485 struct acpi_vendor_walk_info *info = context;
486 struct acpi_resource_vendor_typed *vendor;
487 struct acpi_buffer *buffer;
488 acpi_status status;
489
490 /* Ignore all descriptors except Vendor */
491
492 if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) {
493 return (AE_OK);
494 }
495
496 vendor = &resource->data.vendor_typed;
497
498 /*
499 * For a valid match, these conditions must hold:
500 *
501 * 1) Length of descriptor data must be at least as long as a UUID struct
502 * 2) The UUID subtypes must match
503 * 3) The UUID data must match
504 */
505 if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) ||
506 (vendor->uuid_subtype != info->uuid->subtype) ||
507 (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) {
508 return (AE_OK);
509 }
510
511 /* Validate/Allocate/Clear caller buffer */
512
513 buffer = info->buffer;
514 status = acpi_ut_initialize_buffer(buffer, resource->length);
515 if (ACPI_FAILURE(status)) {
516 return (status);
517 }
518
519 /* Found the correct resource, copy and return it */
520
521 ACPI_MEMCPY(buffer->pointer, resource, resource->length);
522 buffer->length = resource->length;
523
524 /* Found the desired descriptor, terminate resource walk */
525
526 info->status = AE_OK;
527 return (AE_CTRL_TERMINATE);
528}
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 31218e1d2a18..e332306ae2b9 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -844,7 +844,7 @@ static void acpi_device_set_id(struct acpi_device *device,
844 * ---- 844 * ----
845 * Fix for the system root bus device -- the only root-level device. 845 * Fix for the system root bus device -- the only root-level device.
846 */ 846 */
847 if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) { 847 if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
848 hid = ACPI_BUS_HID; 848 hid = ACPI_BUS_HID;
849 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME); 849 strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
850 strcpy(device->pnp.device_class, ACPI_BUS_CLASS); 850 strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
diff --git a/drivers/acpi/tables/tbconvrt.c b/drivers/acpi/tables/tbconvrt.c
index a03939399fa9..cd33397d9231 100644
--- a/drivers/acpi/tables/tbconvrt.c
+++ b/drivers/acpi/tables/tbconvrt.c
@@ -554,7 +554,9 @@ acpi_status acpi_tb_convert_table_fadt(void)
554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES, 554 ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
555 "Hex dump of common internal FADT, size %d (%X)\n", 555 "Hex dump of common internal FADT, size %d (%X)\n",
556 acpi_gbl_FADT->length, acpi_gbl_FADT->length)); 556 acpi_gbl_FADT->length, acpi_gbl_FADT->length));
557 ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); 557
558 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
559 acpi_gbl_FADT->length);
558 560
559 return_ACPI_STATUS(AE_OK); 561 return_ACPI_STATUS(AE_OK);
560} 562}
diff --git a/drivers/acpi/tables/tbgetall.c b/drivers/acpi/tables/tbgetall.c
index 8d72343537e7..33c9ed8a6f99 100644
--- a/drivers/acpi/tables/tbgetall.c
+++ b/drivers/acpi/tables/tbgetall.c
@@ -292,7 +292,9 @@ acpi_status acpi_tb_get_required_tables(void)
292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", 292 "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, 293 acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
294 acpi_gbl_integer_bit_width)); 294 acpi_gbl_integer_bit_width));
295 ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); 295
296 ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_DSDT),
297 acpi_gbl_DSDT->length);
296 298
297 /* Always delete the RSDP mapping, we are done with it */ 299 /* Always delete the RSDP mapping, we are done with it */
298 300
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c
index e6dfe688b76b..9d0bf536d674 100644
--- a/drivers/acpi/tables/tbutils.c
+++ b/drivers/acpi/tables/tbutils.c
@@ -240,16 +240,16 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
240 240
241u8 acpi_tb_generate_checksum(void *buffer, u32 length) 241u8 acpi_tb_generate_checksum(void *buffer, u32 length)
242{ 242{
243 const u8 *limit; 243 u8 *end_buffer;
244 const u8 *rover; 244 u8 *rover;
245 u8 sum = 0; 245 u8 sum = 0;
246 246
247 if (buffer && length) { 247 if (buffer && length) {
248 /* Buffer and Length are valid */ 248 /* Buffer and Length are valid */
249 249
250 limit = (u8 *) buffer + length; 250 end_buffer = ACPI_ADD_PTR(u8, buffer, length);
251 251
252 for (rover = buffer; rover < limit; rover++) { 252 for (rover = buffer; rover < end_buffer; rover++) {
253 sum = (u8) (sum + *rover); 253 sum = (u8) (sum + *rover);
254 } 254 }
255 } 255 }
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 5442b32de611..568df9e42f89 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
398 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
399 */ 399 */
400 status = acpi_ut_copy_isimple_to_esimple(internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
401 (union acpi_object *) 401 ACPI_CAST_PTR(union
402 ret_buffer->pointer, 402 acpi_object,
403 ((u8 *) ret_buffer-> 403 ret_buffer->
404 pointer + 404 pointer),
405 ACPI_ROUND_UP_TO_NATIVE_WORD 405 ACPI_ADD_PTR(u8,
406 (sizeof 406 ret_buffer->
407 (union 407 pointer,
408 acpi_object))), 408 ACPI_ROUND_UP_TO_NATIVE_WORD
409 (sizeof
410 (union
411 acpi_object))),
409 &ret_buffer->length); 412 &ret_buffer->length);
410 /* 413 /*
411 * build simple does not include the object size in the length 414 * build simple does not include the object size in the length
diff --git a/drivers/acpi/utilities/utglobal.c b/drivers/acpi/utilities/utglobal.c
index 413e1dd8ae36..d6813d88a104 100644
--- a/drivers/acpi/utilities/utglobal.c
+++ b/drivers/acpi/utilities/utglobal.c
@@ -638,7 +638,7 @@ char *acpi_ut_get_node_name(void *object)
638 638
639 /* Name must be a valid ACPI name */ 639 /* Name must be a valid ACPI name */
640 640
641 if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) { 641 if (!acpi_ut_valid_acpi_name(node->name.integer)) {
642 return ("????"); 642 return ("????");
643 } 643 }
644 644
@@ -831,6 +831,7 @@ void acpi_ut_init_globals(void)
831 acpi_gbl_ps_find_count = 0; 831 acpi_gbl_ps_find_count = 0;
832 acpi_gbl_acpi_hardware_present = TRUE; 832 acpi_gbl_acpi_hardware_present = TRUE;
833 acpi_gbl_owner_id_mask = 0; 833 acpi_gbl_owner_id_mask = 0;
834 acpi_gbl_last_owner_id = 0;
834 acpi_gbl_trace_method_name = 0; 835 acpi_gbl_trace_method_name = 0;
835 acpi_gbl_trace_dbg_level = 0; 836 acpi_gbl_trace_dbg_level = 0;
836 acpi_gbl_trace_dbg_layer = 0; 837 acpi_gbl_trace_dbg_layer = 0;
@@ -845,7 +846,6 @@ void acpi_ut_init_globals(void)
845 /* Namespace */ 846 /* Namespace */
846 847
847 acpi_gbl_root_node = NULL; 848 acpi_gbl_root_node = NULL;
848
849 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME; 849 acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
850 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED; 850 acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
851 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE; 851 acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
diff --git a/drivers/acpi/utilities/utmisc.c b/drivers/acpi/utilities/utmisc.c
index 2a9110c06391..89efba7bf449 100644
--- a/drivers/acpi/utilities/utmisc.c
+++ b/drivers/acpi/utilities/utmisc.c
@@ -63,6 +63,7 @@ ACPI_MODULE_NAME("utmisc")
63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id) 63acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
64{ 64{
65 acpi_native_uint i; 65 acpi_native_uint i;
66 acpi_native_uint j;
66 acpi_status status; 67 acpi_status status;
67 68
68 ACPI_FUNCTION_TRACE("ut_allocate_owner_id"); 69 ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
@@ -82,29 +83,46 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
82 return_ACPI_STATUS(status); 83 return_ACPI_STATUS(status);
83 } 84 }
84 85
85 /* Find a free owner ID */ 86 /*
87 * Find a free owner ID, cycle through all possible IDs on repeated
88 * allocations. Note: Index for next possible ID is equal to the value
89 * of the last allocated ID.
90 */
91 for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) {
92 if (j >= 32) {
93 j = 0; /* Wraparound to ID start */
94 }
95
96 if (!(acpi_gbl_owner_id_mask & (1 << j))) {
97 /*
98 * Found a free ID. The actual ID is the bit index plus one,
99 * making zero an invalid Owner ID. Save this as the last ID
100 * allocated and update the global ID mask.
101 */
102 acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1);
103 *owner_id = acpi_gbl_last_owner_id;
86 104
87 for (i = 0; i < 32; i++) {
88 if (!(acpi_gbl_owner_id_mask & (1 << i))) {
89 ACPI_DEBUG_PRINT((ACPI_DB_VALUES, 105 ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
90 "Current owner_id mask: %8.8X New ID: %2.2X\n", 106 "Current owner_id mask: %8.8X New ID: %2.2X\n",
91 acpi_gbl_owner_id_mask, 107 acpi_gbl_owner_id_mask,
92 (unsigned int)(i + 1))); 108 (unsigned int)
109 acpi_gbl_last_owner_id));
93 110
94 acpi_gbl_owner_id_mask |= (1 << i); 111 acpi_gbl_owner_id_mask |= (1 << j);
95 *owner_id = (acpi_owner_id) (i + 1);
96 goto exit; 112 goto exit;
97 } 113 }
98 } 114 }
99 115
100 /* 116 /*
101 * If we are here, all owner_ids have been allocated. This probably should 117 * All owner_ids have been allocated. This typically should
102 * not happen since the IDs are reused after deallocation. The IDs are 118 * not happen since the IDs are reused after deallocation. The IDs are
103 * allocated upon table load (one per table) and method execution, and 119 * allocated upon table load (one per table) and method execution, and
104 * they are released when a table is unloaded or a method completes 120 * they are released when a table is unloaded or a method completes
105 * execution. 121 * execution.
122 *
123 * If this error happens, there may be very deep nesting of invoked control
124 * methods, or there may be a bug where the IDs are not released.
106 */ 125 */
107 *owner_id = 0;
108 status = AE_OWNER_ID_LIMIT; 126 status = AE_OWNER_ID_LIMIT;
109 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n")); 127 ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
110 128
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
index 07a314c710d8..6c0ce7b12194 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/utilities/utresrc.c
@@ -157,7 +157,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
157 /* 157 /*
158 * 1) Validate the resource_type field (Byte 0) 158 * 1) Validate the resource_type field (Byte 0)
159 */ 159 */
160 resource_type = *((u8 *) aml); 160 resource_type = ACPI_GET8(aml);
161 161
162 /* 162 /*
163 * Byte 0 contains the descriptor name (Resource Type) 163 * Byte 0 contains the descriptor name (Resource Type)
@@ -266,14 +266,14 @@ u8 acpi_ut_get_resource_type(void *aml)
266 * Byte 0 contains the descriptor name (Resource Type) 266 * Byte 0 contains the descriptor name (Resource Type)
267 * Examine the large/small bit in the resource header 267 * Examine the large/small bit in the resource header
268 */ 268 */
269 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 269 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
270 /* Large Resource Type -- bits 6:0 contain the name */ 270 /* Large Resource Type -- bits 6:0 contain the name */
271 271
272 return (*((u8 *) aml)); 272 return (ACPI_GET8(aml));
273 } else { 273 } else {
274 /* Small Resource Type -- bits 6:3 contain the name */ 274 /* Small Resource Type -- bits 6:3 contain the name */
275 275
276 return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK)); 276 return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
277 } 277 }
278} 278}
279 279
@@ -301,15 +301,15 @@ u16 acpi_ut_get_resource_length(void *aml)
301 * Byte 0 contains the descriptor name (Resource Type) 301 * Byte 0 contains the descriptor name (Resource Type)
302 * Examine the large/small bit in the resource header 302 * Examine the large/small bit in the resource header
303 */ 303 */
304 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 304 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
305 /* Large Resource type -- bytes 1-2 contain the 16-bit length */ 305 /* Large Resource type -- bytes 1-2 contain the 16-bit length */
306 306
307 ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]); 307 ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
308 308
309 } else { 309 } else {
310 /* Small Resource type -- bits 2:0 of byte 0 contain the length */ 310 /* Small Resource type -- bits 2:0 of byte 0 contain the length */
311 311
312 resource_length = (u16) (*((u8 *) aml) & 312 resource_length = (u16) (ACPI_GET8(aml) &
313 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK); 313 ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
314 } 314 }
315 315
@@ -334,7 +334,7 @@ u8 acpi_ut_get_resource_header_length(void *aml)
334 334
335 /* Examine the large/small bit in the resource header */ 335 /* Examine the large/small bit in the resource header */
336 336
337 if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) { 337 if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
338 return (sizeof(struct aml_resource_large_header)); 338 return (sizeof(struct aml_resource_large_header));
339 } else { 339 } else {
340 return (sizeof(struct aml_resource_small_header)); 340 return (sizeof(struct aml_resource_small_header));
@@ -372,8 +372,9 @@ u32 acpi_ut_get_descriptor_length(void *aml)
372 * FUNCTION: acpi_ut_get_resource_end_tag 372 * FUNCTION: acpi_ut_get_resource_end_tag
373 * 373 *
374 * PARAMETERS: obj_desc - The resource template buffer object 374 * PARAMETERS: obj_desc - The resource template buffer object
375 * end_tag - Where the pointer to the end_tag is returned
375 * 376 *
376 * RETURN: Pointer to the end tag 377 * RETURN: Status, pointer to the end tag
377 * 378 *
378 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template 379 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
379 * 380 *
diff --git a/include/acpi/acconfig.h b/include/acpi/acconfig.h
index d371ec6b9812..08eafece3eed 100644
--- a/include/acpi/acconfig.h
+++ b/include/acpi/acconfig.h
@@ -63,7 +63,7 @@
63 63
64/* Current ACPICA subsystem version in YYYYMMDD format */ 64/* Current ACPICA subsystem version in YYYYMMDD format */
65 65
66#define ACPI_CA_VERSION 0x20051102 66#define ACPI_CA_VERSION 0x20051117
67 67
68/* 68/*
69 * OS name, used for the _OS object. The _OS object is essentially obsolete, 69 * OS name, used for the _OS object. The _OS object is essentially obsolete,
@@ -98,11 +98,6 @@
98 98
99#define ACPI_CA_SUPPORT_LEVEL 3 99#define ACPI_CA_SUPPORT_LEVEL 3
100 100
101/* String size constants */
102
103#define ACPI_MAX_STRING_LENGTH 512
104#define ACPI_PATHNAME_MAX 256 /* A full namespace pathname */
105
106/* Maximum count for a semaphore object */ 101/* Maximum count for a semaphore object */
107 102
108#define ACPI_MAX_SEMAPHORE_COUNT 256 103#define ACPI_MAX_SEMAPHORE_COUNT 256
@@ -134,14 +129,11 @@
134#define ACPI_METHOD_NUM_ARGS 7 129#define ACPI_METHOD_NUM_ARGS 7
135#define ACPI_METHOD_MAX_ARG 6 130#define ACPI_METHOD_MAX_ARG 6
136 131
137/* Maximum length of resulting string when converting from a buffer */ 132/* Length of _HID, _UID, _CID, and UUID values */
138
139#define ACPI_MAX_STRING_CONVERSION 200
140
141/* Length of _HID, _UID, and _CID values */
142 133
143#define ACPI_DEVICE_ID_LENGTH 0x09 134#define ACPI_DEVICE_ID_LENGTH 0x09
144#define ACPI_MAX_CID_LENGTH 48 135#define ACPI_MAX_CID_LENGTH 48
136#define ACPI_UUID_LENGTH 16
145 137
146/* 138/*
147 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG 139 * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
diff --git a/include/acpi/acglobal.h b/include/acpi/acglobal.h
index cef51b1ddf94..bd344e51313b 100644
--- a/include/acpi/acglobal.h
+++ b/include/acpi/acglobal.h
@@ -223,6 +223,7 @@ ACPI_EXTERN u32 acpi_gbl_ps_find_count;
223ACPI_EXTERN u32 acpi_gbl_owner_id_mask; 223ACPI_EXTERN u32 acpi_gbl_owner_id_mask;
224ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save; 224ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
225ACPI_EXTERN u16 acpi_gbl_global_lock_handle; 225ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
226ACPI_EXTERN u8 acpi_gbl_last_owner_id;
226ACPI_EXTERN u8 acpi_gbl_debugger_configuration; 227ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
227ACPI_EXTERN u8 acpi_gbl_global_lock_acquired; 228ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
228ACPI_EXTERN u8 acpi_gbl_step_to_next_call; 229ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
diff --git a/include/acpi/aclocal.h b/include/acpi/aclocal.h
index dca0d40ea395..0cb61a72d971 100644
--- a/include/acpi/aclocal.h
+++ b/include/acpi/aclocal.h
@@ -573,6 +573,8 @@ struct acpi_parse_obj_named {
573 573
574/* The parse node is the fundamental element of the parse tree */ 574/* The parse node is the fundamental element of the parse tree */
575 575
576#define ACPI_MAX_PARSEOP_NAME 20
577
576struct acpi_parse_obj_asl { 578struct acpi_parse_obj_asl {
577 ACPI_PARSE_COMMON union acpi_parse_object *child; 579 ACPI_PARSE_COMMON union acpi_parse_object *child;
578 union acpi_parse_object *parent_method; 580 union acpi_parse_object *parent_method;
@@ -597,7 +599,7 @@ struct acpi_parse_obj_asl {
597 u8 aml_opcode_length; 599 u8 aml_opcode_length;
598 u8 aml_pkg_len_bytes; 600 u8 aml_pkg_len_bytes;
599 u8 extra; 601 u8 extra;
600 char parse_op_name[12]; 602 char parse_op_name[ACPI_MAX_PARSEOP_NAME];
601}; 603};
602 604
603union acpi_parse_object { 605union acpi_parse_object {
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
diff --git a/include/acpi/acpixf.h b/include/acpi/acpixf.h
index 02f00a8fee03..2a88429bc4ec 100644
--- a/include/acpi/acpixf.h
+++ b/include/acpi/acpixf.h
@@ -272,6 +272,12 @@ acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource,
272 void *context); 272 void *context);
273 273
274acpi_status 274acpi_status
275acpi_get_vendor_resource(acpi_handle device_handle,
276 char *name,
277 struct acpi_vendor_uuid *uuid,
278 struct acpi_buffer *ret_buffer);
279
280acpi_status
275acpi_get_current_resources(acpi_handle device_handle, 281acpi_get_current_resources(acpi_handle device_handle,
276 struct acpi_buffer *ret_buffer); 282 struct acpi_buffer *ret_buffer);
277 283
@@ -283,7 +289,7 @@ acpi_get_possible_resources(acpi_handle device_handle,
283 289
284acpi_status 290acpi_status
285acpi_walk_resources(acpi_handle device_handle, 291acpi_walk_resources(acpi_handle device_handle,
286 char *path, 292 char *name,
287 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context); 293 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context);
288 294
289acpi_status 295acpi_status
diff --git a/include/acpi/acresrc.h b/include/acpi/acresrc.h
index 2bf53940f259..ba281f7740a0 100644
--- a/include/acpi/acresrc.h
+++ b/include/acpi/acresrc.h
@@ -137,9 +137,14 @@ extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
137 137
138/* Resource tables indexed by raw AML resource descriptor type */ 138/* Resource tables indexed by raw AML resource descriptor type */
139 139
140extern const u8 acpi_gbl_resource_struct_sizes[];
140extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[]; 141extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
141 142
142extern const u8 acpi_gbl_resource_struct_sizes[]; 143struct acpi_vendor_walk_info {
144 struct acpi_vendor_uuid *uuid;
145 struct acpi_buffer *buffer;
146 acpi_status status;
147};
143 148
144/* 149/*
145 * rscreate 150 * rscreate
diff --git a/include/acpi/actypes.h b/include/acpi/actypes.h
index 29b887017b18..11847592ed1b 100644
--- a/include/acpi/actypes.h
+++ b/include/acpi/actypes.h
@@ -326,7 +326,7 @@ typedef u64 acpi_integer;
326/* 326/*
327 * Constants with special meanings 327 * Constants with special meanings
328 */ 328 */
329#define ACPI_ROOT_OBJECT (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR) 329#define ACPI_ROOT_OBJECT ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
330 330
331/* 331/*
332 * Initialization sequence 332 * Initialization sequence
@@ -986,6 +986,17 @@ typedef u32 acpi_rsdesc_size; /* Max Resource Descriptor size is (length+3) = (6
986#pragma pack(1) 986#pragma pack(1)
987#endif 987#endif
988 988
989/* UUID data structures for use in vendor-defined resource descriptors */
990
991struct acpi_uuid {
992 u8 data[ACPI_UUID_LENGTH];
993};
994
995struct acpi_vendor_uuid {
996 u8 subtype;
997 u8 data[ACPI_UUID_LENGTH];
998};
999
989/* 1000/*
990 * Structures used to describe device resources 1001 * Structures used to describe device resources
991 */ 1002 */
@@ -1033,6 +1044,15 @@ struct acpi_resource_vendor {
1033 u8 byte_data[1]; 1044 u8 byte_data[1];
1034}; 1045};
1035 1046
1047/* Vendor resource with UUID info (introduced in ACPI 3.0) */
1048
1049struct acpi_resource_vendor_typed {
1050 u16 byte_length;
1051 u8 uuid_subtype;
1052 u8 uuid[ACPI_UUID_LENGTH];
1053 u8 byte_data[1];
1054};
1055
1036struct acpi_resource_end_tag { 1056struct acpi_resource_end_tag {
1037 u8 checksum; 1057 u8 checksum;
1038}; 1058};
@@ -1184,6 +1204,7 @@ union acpi_resource_data {
1184 struct acpi_resource_io io; 1204 struct acpi_resource_io io;
1185 struct acpi_resource_fixed_io fixed_io; 1205 struct acpi_resource_fixed_io fixed_io;
1186 struct acpi_resource_vendor vendor; 1206 struct acpi_resource_vendor vendor;
1207 struct acpi_resource_vendor_typed vendor_typed;
1187 struct acpi_resource_end_tag end_tag; 1208 struct acpi_resource_end_tag end_tag;
1188 struct acpi_resource_memory24 memory24; 1209 struct acpi_resource_memory24 memory24;
1189 struct acpi_resource_memory32 memory32; 1210 struct acpi_resource_memory32 memory32;
diff --git a/include/acpi/platform/aclinux.h b/include/acpi/platform/aclinux.h
index c93e6562f0e1..1b9cbf05b79e 100644
--- a/include/acpi/platform/aclinux.h
+++ b/include/acpi/platform/aclinux.h
@@ -71,6 +71,10 @@
71#define acpi_cache_t kmem_cache_t 71#define acpi_cache_t kmem_cache_t
72#endif 72#endif
73 73
74/* Full namespace pathname length limit - arbitrary */
75
76#define ACPI_PATHNAME_MAX 256
77
74#else /* !__KERNEL__ */ 78#else /* !__KERNEL__ */
75 79
76#include <stdarg.h> 80#include <stdarg.h>