]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[ACPI] ACPICA 20051117
authorBob Moore <robert.moore@intel.com>
Thu, 17 Nov 2005 18:07:00 +0000 (13:07 -0500)
committerLen Brown <len.brown@intel.com>
Sat, 10 Dec 2005 05:27:56 +0000 (00:27 -0500)
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>
34 files changed:
drivers/acpi/dispatcher/dsinit.c
drivers/acpi/dispatcher/dswload.c
drivers/acpi/executer/exconvrt.c
drivers/acpi/executer/exdump.c
drivers/acpi/executer/exmisc.c
drivers/acpi/executer/exnames.c
drivers/acpi/executer/exoparg2.c
drivers/acpi/executer/exregion.c
drivers/acpi/executer/exstorob.c
drivers/acpi/parser/psargs.c
drivers/acpi/parser/psparse.c
drivers/acpi/parser/psxface.c
drivers/acpi/resources/rscalc.c
drivers/acpi/resources/rsdump.c
drivers/acpi/resources/rslist.c
drivers/acpi/resources/rsmisc.c
drivers/acpi/resources/rsutils.c
drivers/acpi/resources/rsxface.c
drivers/acpi/scan.c
drivers/acpi/tables/tbconvrt.c
drivers/acpi/tables/tbgetall.c
drivers/acpi/tables/tbutils.c
drivers/acpi/utilities/utcopy.c
drivers/acpi/utilities/utglobal.c
drivers/acpi/utilities/utmisc.c
drivers/acpi/utilities/utresrc.c
include/acpi/acconfig.h
include/acpi/acglobal.h
include/acpi/aclocal.h
include/acpi/acmacros.h
include/acpi/acpixf.h
include/acpi/acresrc.h
include/acpi/actypes.h
include/acpi/platform/aclinux.h

index 8693c704aea611a6e9495fb3b7ee8ce7fe5ca017..4fa80abfe6c06ebe52d46dae85ffe9e45c79395d 100644 (file)
@@ -117,14 +117,6 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
 
        case ACPI_TYPE_METHOD:
 
-               /*
-                * Print a dot for each method unless we are going to print
-                * the entire pathname
-                */
-               if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
-                       ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
-               }
-
                /*
                 * Set the execution data width (32 or 64) based upon the
                 * revision number of the parent ACPI table.
@@ -134,6 +126,21 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
                if (info->table_desc->pointer->revision == 1) {
                        node->flags |= ANOBJ_DATA_WIDTH_32;
                }
+#ifdef ACPI_INIT_PARSE_METHODS
+               /*
+                * Note 11/2005: Removed this code to parse all methods during table
+                * load because it causes problems if there are any errors during the
+                * parse. Also, it seems like overkill and we probably don't want to
+                * abort a table load because of an issue with a single method.
+                */
+
+               /*
+                * Print a dot for each method unless we are going to print
+                * the entire pathname
+                */
+               if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
+                       ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
+               }
 
                /*
                 * Always parse methods to detect errors, we will delete
@@ -149,7 +156,7 @@ acpi_ds_init_one_object(acpi_handle obj_handle,
 
                        /* This parse failed, but we will continue parsing more methods */
                }
-
+#endif
                info->method_count++;
                break;
 
index 411731261c2986b2c19e01104bd0e48e89be6131..89d318cbc8a3dace02b6c8437a5356f82c9afb1d 100644 (file)
@@ -311,7 +311,7 @@ acpi_ds_load1_begin_op(struct acpi_walk_state * walk_state,
        op->named.name = node->name.integer;
 
 #if (defined (ACPI_NO_METHOD_EXECUTION) || defined (ACPI_CONSTANT_EVAL_ONLY))
-       op->named.path = (u8 *) path;
+       op->named.path = ACPI_CAST_PTR(u8, path);
 #endif
 
        /*
index 04e5194989a6ffe51a718f370dedc85ba9e6aadd..fa9e75d4ec656e331c11a48d8deceb666021f4a7 100644 (file)
@@ -504,18 +504,12 @@ acpi_ex_convert_to_string(union acpi_operand_object * obj_desc,
                }
 
                /*
-                * Perform the conversion.
+                * Create a new string object and string buffer
                 * (-1 because of extra separator included in string_length from above)
                 */
-               string_length--;
-               if (string_length > ACPI_MAX_STRING_CONVERSION) {       /* ACPI limit */
-                       return_ACPI_STATUS(AE_AML_STRING_LIMIT);
-               }
-
-               /* Create a new string object and string buffer */
-
                return_desc =
-                   acpi_ut_create_string_object((acpi_size) string_length);
+                   acpi_ut_create_string_object((acpi_size)
+                                                (string_length - 1));
                if (!return_desc) {
                        return_ACPI_STATUS(AE_NO_MEMORY);
                }
index 5a4cca171af6c1ea616098bda759599be74a983a..17c79cd91b31b16fb27a82d6892704160bc01407 100644 (file)
@@ -117,12 +117,13 @@ static struct acpi_exdump_info acpi_ex_dump_event[2] = {
        {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(event.semaphore), "Semaphore"}
 };
 
-static struct acpi_exdump_info acpi_ex_dump_method[7] = {
+static struct acpi_exdump_info acpi_ex_dump_method[8] = {
        {ACPI_EXD_INIT, ACPI_EXD_TABLE_SIZE(acpi_ex_dump_method), NULL},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.param_count), "param_count"},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.concurrency), "Concurrency"},
        {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.semaphore), "Semaphore"},
        {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.owner_id), "Owner Id"},
+       {ACPI_EXD_UINT8, ACPI_EXD_OFFSET(method.thread_count), "Thread Count"},
        {ACPI_EXD_UINT32, ACPI_EXD_OFFSET(method.aml_length), "Aml Length"},
        {ACPI_EXD_POINTER, ACPI_EXD_OFFSET(method.aml_start), "Aml Start"}
 };
@@ -339,7 +340,7 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
        count = info->offset;
 
        while (count) {
-               target = ((u8 *) obj_desc) + info->offset;
+               target = ACPI_ADD_PTR(u8, obj_desc, info->offset);
                name = info->name;
 
                switch (info->opcode) {
@@ -360,20 +361,19 @@ acpi_ex_dump_object(union acpi_operand_object *obj_desc,
                case ACPI_EXD_UINT16:
 
                        acpi_os_printf("%20s : %4.4X\n", name,
-                                      *ACPI_CAST_PTR(u16, target));
+                                      ACPI_GET16(target));
                        break;
 
                case ACPI_EXD_UINT32:
 
                        acpi_os_printf("%20s : %8.8X\n", name,
-                                      *ACPI_CAST_PTR(u32, target));
+                                      ACPI_GET32(target));
                        break;
 
                case ACPI_EXD_UINT64:
 
                        acpi_os_printf("%20s : %8.8X%8.8X\n", "Value",
-                                      ACPI_FORMAT_UINT64(*ACPI_CAST_PTR
-                                                         (u64, target)));
+                                      ACPI_FORMAT_UINT64(ACPI_GET64(target)));
                        break;
 
                case ACPI_EXD_POINTER:
@@ -969,7 +969,8 @@ acpi_ex_dump_package_obj(union acpi_operand_object *obj_desc,
                acpi_os_printf("[Buffer] Length %.2X = ",
                               obj_desc->buffer.length);
                if (obj_desc->buffer.length) {
-                       acpi_ut_dump_buffer((u8 *) obj_desc->buffer.pointer,
+                       acpi_ut_dump_buffer(ACPI_CAST_PTR
+                                           (u8, obj_desc->buffer.pointer),
                                            obj_desc->buffer.length,
                                            DB_DWORD_DISPLAY, _COMPONENT);
                } else {
index 00a25f8188f4ba4ce8b17c559bd371e696ab5b50..0778bff632bf10a4a4c080adcd79d4d7f6d1b282 100644 (file)
@@ -205,11 +205,9 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
        ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
        ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
 
-       /* Compute the new checksum */
+       /* Set the end_tag checksum to zero, means "ignore checksum" */
 
-       new_buf[return_desc->buffer.length - 1] =
-           acpi_ut_generate_checksum(return_desc->buffer.pointer,
-                                     (return_desc->buffer.length - 1));
+       new_buf[return_desc->buffer.length - 1] = 0;
 
        /* Return the completed resource template */
 
@@ -242,7 +240,6 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
        union acpi_operand_object *return_desc;
        char *new_buf;
        acpi_status status;
-       acpi_size new_length;
 
        ACPI_FUNCTION_TRACE("ex_do_concatenate");
 
@@ -269,7 +266,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
                break;
 
        default:
-               ACPI_REPORT_ERROR(("Concat - invalid obj type: %X\n",
+               ACPI_REPORT_ERROR(("Concatanate - invalid object type: %X\n",
                                   ACPI_GET_OBJECT_TYPE(operand0)));
                status = AE_AML_INTERNAL;
        }
@@ -309,8 +306,7 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
 
                /* Copy the first integer, LSB first */
 
-               ACPI_MEMCPY(new_buf,
-                           &operand0->integer.value,
+               ACPI_MEMCPY(new_buf, &operand0->integer.value,
                            acpi_gbl_integer_byte_width);
 
                /* Copy the second integer (LSB first) after the first */
@@ -324,14 +320,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
 
                /* Result of two Strings is a String */
 
-               new_length = (acpi_size) operand0->string.length +
-                   (acpi_size) local_operand1->string.length;
-               if (new_length > ACPI_MAX_STRING_CONVERSION) {
-                       status = AE_AML_STRING_LIMIT;
-                       goto cleanup;
-               }
-
-               return_desc = acpi_ut_create_string_object(new_length);
+               return_desc = acpi_ut_create_string_object((acpi_size)
+                                                          (operand0->string.
+                                                           length +
+                                                           local_operand1->
+                                                           string.length));
                if (!return_desc) {
                        status = AE_NO_MEMORY;
                        goto cleanup;
@@ -351,11 +344,10 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
                /* Result of two Buffers is a Buffer */
 
                return_desc = acpi_ut_create_buffer_object((acpi_size)
-                                                          operand0->buffer.
-                                                          length +
-                                                          (acpi_size)
-                                                          local_operand1->
-                                                          buffer.length);
+                                                          (operand0->buffer.
+                                                           length +
+                                                           local_operand1->
+                                                           buffer.length));
                if (!return_desc) {
                        status = AE_NO_MEMORY;
                        goto cleanup;
@@ -365,8 +357,8 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
 
                /* Concatenate the buffers */
 
-               ACPI_MEMCPY(new_buf,
-                           operand0->buffer.pointer, operand0->buffer.length);
+               ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
+                           operand0->buffer.length);
                ACPI_MEMCPY(new_buf + operand0->buffer.length,
                            local_operand1->buffer.pointer,
                            local_operand1->buffer.length);
index dff41121a3041e5ddc5350af2f700db95cb04cee..7bb5e17b5680ba639625615da048755a43dbef8b 100644 (file)
@@ -216,7 +216,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
                                  *aml_address, aml_address));
        }
 
-       *in_aml_address = (u8 *) aml_address;
+       *in_aml_address = ACPI_CAST_PTR(u8, aml_address);
        return_ACPI_STATUS(status);
 }
 
index 8d70c6beef00c9f6d875320c0ea3c7e6d3b352b7..d8472842c1fd5f4782b8b06159ead42c178b9ded 100644 (file)
@@ -344,10 +344,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
                       (length < operand[1]->integer.value) &&
                       (operand[0]->buffer.pointer[length])) {
                        length++;
-                       if (length > ACPI_MAX_STRING_CONVERSION) {
-                               status = AE_AML_STRING_LIMIT;
-                               goto cleanup;
-                       }
                }
 
                /* Allocate a new string object */
@@ -358,8 +354,10 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
                        goto cleanup;
                }
 
-               /* Copy the raw buffer data with no transform. NULL terminated already */
-
+               /*
+                * Copy the raw buffer data with no transform.
+                * (NULL terminated already)
+                */
                ACPI_MEMCPY(return_desc->string.pointer,
                            operand[0]->buffer.pointer, length);
                break;
index 1897379b5f90f598df94903371f4efa6e98e7b1b..80118be3f544495e5cf21be734ebf91d04dad8f9 100644 (file)
@@ -199,20 +199,20 @@ acpi_ex_system_memory_space_handler(u32 function,
                *value = 0;
                switch (bit_width) {
                case 8:
-                       *value = (acpi_integer) * ((u8 *) logical_addr_ptr);
+                       *value = (acpi_integer) ACPI_GET8(logical_addr_ptr);
                        break;
 
                case 16:
-                       *value = (acpi_integer) * ((u16 *) logical_addr_ptr);
+                       *value = (acpi_integer) ACPI_GET16(logical_addr_ptr);
                        break;
 
                case 32:
-                       *value = (acpi_integer) * ((u32 *) logical_addr_ptr);
+                       *value = (acpi_integer) ACPI_GET32(logical_addr_ptr);
                        break;
 
 #if ACPI_MACHINE_WIDTH != 16
                case 64:
-                       *value = (acpi_integer) * ((u64 *) logical_addr_ptr);
+                       *value = (acpi_integer) ACPI_GET64(logical_addr_ptr);
                        break;
 #endif
                default:
@@ -225,20 +225,20 @@ acpi_ex_system_memory_space_handler(u32 function,
 
                switch (bit_width) {
                case 8:
-                       *(u8 *) logical_addr_ptr = (u8) * value;
+                       ACPI_SET8(logical_addr_ptr) = (u8) * value;
                        break;
 
                case 16:
-                       *(u16 *) logical_addr_ptr = (u16) * value;
+                       ACPI_SET16(logical_addr_ptr) = (u16) * value;
                        break;
 
                case 32:
-                       *(u32 *) logical_addr_ptr = (u32) * value;
+                       ACPI_SET32(logical_addr_ptr) = (u32) * value;
                        break;
 
 #if ACPI_MACHINE_WIDTH != 16
                case 64:
-                       *(u64 *) logical_addr_ptr = (u64) * value;
+                       ACPI_SET64(logical_addr_ptr) = (u64) * value;
                        break;
 #endif
 
index c4ff654a669717637baf578766d9524fd062fb40..855db713075134ab319f3b955ded22e6c62e1cd0 100644 (file)
@@ -71,7 +71,7 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
 
        /* We know that source_desc is a buffer by now */
 
-       buffer = (u8 *) source_desc->buffer.pointer;
+       buffer = ACPI_CAST_PTR(u8, source_desc->buffer.pointer);
        length = source_desc->buffer.length;
 
        /*
@@ -160,7 +160,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
 
        /* We know that source_desc is a string by now */
 
-       buffer = (u8 *) source_desc->string.pointer;
+       buffer = ACPI_CAST_PTR(u8, source_desc->string.pointer);
        length = source_desc->string.length;
 
        /*
index 562d0f822ab192f19426d79e4f3fa35a22321a2a..6eae35febccd378f50c200003286fa82c27ead99 100644 (file)
@@ -62,61 +62,51 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
  *
  * PARAMETERS:  parser_state        - Current parser state object
  *
- * RETURN:      Decoded package length.  On completion, the AML pointer points
+ * RETURN:      Decoded package length. On completion, the AML pointer points
  *              past the length byte or bytes.
  *
- * DESCRIPTION: Decode and return a package length field
+ * DESCRIPTION: Decode and return a package length field.
+ *              Note: Largest package length is 28 bits, from ACPI specification
  *
  ******************************************************************************/
 
 static u32
 acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
 {
-       u32 encoded_length;
-       u32 length = 0;
+       u8 *aml = parser_state->aml;
+       u32 package_length = 0;
+       acpi_native_uint byte_count;
+       u8 byte_zero_mask = 0x3F;       /* Default [0:5] */
 
        ACPI_FUNCTION_TRACE("ps_get_next_package_length");
 
-       encoded_length = (u32) ACPI_GET8(parser_state->aml);
-       parser_state->aml++;
-
-       switch (encoded_length >> 6) {  /* bits 6-7 contain encoding scheme */
-       case 0:         /* 1-byte encoding (bits 0-5) */
-
-               length = (encoded_length & 0x3F);
-               break;
-
-       case 1:         /* 2-byte encoding (next byte + bits 0-3) */
-
-               length = ((ACPI_GET8(parser_state->aml) << 04) |
-                         (encoded_length & 0x0F));
-               parser_state->aml++;
-               break;
-
-       case 2:         /* 3-byte encoding (next 2 bytes + bits 0-3) */
-
-               length = ((ACPI_GET8(parser_state->aml + 1) << 12) |
-                         (ACPI_GET8(parser_state->aml) << 04) |
-                         (encoded_length & 0x0F));
-               parser_state->aml += 2;
-               break;
-
-       case 3:         /* 4-byte encoding (next 3 bytes + bits 0-3) */
+       /*
+        * Byte 0 bits [6:7] contain the number of additional bytes
+        * used to encode the package length, either 0,1,2, or 3
+        */
+       byte_count = (aml[0] >> 6);
+       parser_state->aml += (byte_count + 1);
 
-               length = ((ACPI_GET8(parser_state->aml + 2) << 20) |
-                         (ACPI_GET8(parser_state->aml + 1) << 12) |
-                         (ACPI_GET8(parser_state->aml) << 04) |
-                         (encoded_length & 0x0F));
-               parser_state->aml += 3;
-               break;
+       /* Get bytes 3, 2, 1 as needed */
 
-       default:
+       while (byte_count) {
+               /*
+                * Final bit positions for the package length bytes:
+                *      Byte3->[20:27]
+                *      Byte2->[12:19]
+                *      Byte1->[04:11]
+                *      Byte0->[00:03]
+                */
+               package_length |= (aml[byte_count] << ((byte_count << 3) - 4));
 
-               /* Can't get here, only 2 bits / 4 cases */
-               break;
+               byte_zero_mask = 0x0F;  /* Use bits [0:3] of byte 0 */
+               byte_count--;
        }
 
-       return_UINT32(length);
+       /* Byte 0 is a special case, either bits [0:3] or [0:5] are used */
+
+       package_length |= (aml[0] & byte_zero_mask);
+       return_UINT32(package_length);
 }
 
 /*******************************************************************************
@@ -135,16 +125,15 @@ acpi_ps_get_next_package_length(struct acpi_parse_state *parser_state)
 u8 *acpi_ps_get_next_package_end(struct acpi_parse_state *parser_state)
 {
        u8 *start = parser_state->aml;
-       acpi_native_uint length;
+       u32 package_length;
 
        ACPI_FUNCTION_TRACE("ps_get_next_package_end");
 
-       /* Function below changes parser_state->Aml */
+       /* Function below updates parser_state->Aml */
 
-       length =
-           (acpi_native_uint) acpi_ps_get_next_package_length(parser_state);
+       package_length = acpi_ps_get_next_package_length(parser_state);
 
-       return_PTR(start + length);     /* end of package */
+       return_PTR(start + package_length);     /* end of package */
 }
 
 /*******************************************************************************
@@ -169,17 +158,15 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
 
        ACPI_FUNCTION_TRACE("ps_get_next_namestring");
 
-       /* Handle multiple prefix characters */
-
-       while (acpi_ps_is_prefix_char(ACPI_GET8(end))) {
-               /* Include prefix '\\' or '^' */
+       /* Point past any namestring prefix characters (backslash or carat) */
 
+       while (acpi_ps_is_prefix_char(*end)) {
                end++;
        }
 
-       /* Decode the path */
+       /* Decode the path prefix character */
 
-       switch (ACPI_GET8(end)) {
+       switch (*end) {
        case 0:
 
                /* null_name */
@@ -199,9 +186,9 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
 
        case AML_MULTI_NAME_PREFIX_OP:
 
-               /* Multiple name segments, 4 chars each */
+               /* Multiple name segments, 4 chars each, count in next byte */
 
-               end += 2 + ((acpi_size) ACPI_GET8(end + 1) * ACPI_NAME_SIZE);
+               end += 2 + (*(end + 1) * ACPI_NAME_SIZE);
                break;
 
        default:
@@ -212,7 +199,7 @@ char *acpi_ps_get_next_namestring(struct acpi_parse_state *parser_state)
                break;
        }
 
-       parser_state->aml = (u8 *) end;
+       parser_state->aml = end;
        return_PTR((char *)start);
 }
 
@@ -342,7 +329,6 @@ acpi_ps_get_next_namepath(struct acpi_walk_state *walk_state,
                                    ("search_node %p start_node %p return_node %p\n",
                                     scope_info.scope.node,
                                     parser_state->start_node, node);
-
                        } else {
                                /*
                                 * We got a NOT_FOUND during table load or we encountered
@@ -382,59 +368,63 @@ void
 acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
                            u32 arg_type, union acpi_parse_object *arg)
 {
+       u32 length;
+       u16 opcode;
+       u8 *aml = parser_state->aml;
 
        ACPI_FUNCTION_TRACE_U32("ps_get_next_simple_arg", arg_type);
 
        switch (arg_type) {
        case ARGP_BYTEDATA:
 
-               acpi_ps_init_op(arg, AML_BYTE_OP);
-               arg->common.value.integer = (u32) ACPI_GET8(parser_state->aml);
-               parser_state->aml++;
+               /* Get 1 byte from the AML stream */
+
+               opcode = AML_BYTE_OP;
+               arg->common.value.integer = (acpi_integer) * aml;
+               length = 1;
                break;
 
        case ARGP_WORDDATA:
 
-               acpi_ps_init_op(arg, AML_WORD_OP);
-
                /* Get 2 bytes from the AML stream */
 
-               ACPI_MOVE_16_TO_32(&arg->common.value.integer,
-                                  parser_state->aml);
-               parser_state->aml += 2;
+               opcode = AML_WORD_OP;
+               ACPI_MOVE_16_TO_64(&arg->common.value.integer, aml);
+               length = 2;
                break;
 
        case ARGP_DWORDDATA:
 
-               acpi_ps_init_op(arg, AML_DWORD_OP);
-
                /* Get 4 bytes from the AML stream */
 
-               ACPI_MOVE_32_TO_32(&arg->common.value.integer,
-                                  parser_state->aml);
-               parser_state->aml += 4;
+               opcode = AML_DWORD_OP;
+               ACPI_MOVE_32_TO_64(&arg->common.value.integer, aml);
+               length = 4;
                break;
 
        case ARGP_QWORDDATA:
 
-               acpi_ps_init_op(arg, AML_QWORD_OP);
-
                /* Get 8 bytes from the AML stream */
 
-               ACPI_MOVE_64_TO_64(&arg->common.value.integer,
-                                  parser_state->aml);
-               parser_state->aml += 8;
+               opcode = AML_QWORD_OP;
+               ACPI_MOVE_64_TO_64(&arg->common.value.integer, aml);
+               length = 8;
                break;
 
        case ARGP_CHARLIST:
 
-               acpi_ps_init_op(arg, AML_STRING_OP);
-               arg->common.value.string = (char *)parser_state->aml;
+               /* Get a pointer to the string, point past the string */
+
+               opcode = AML_STRING_OP;
+               arg->common.value.string = ACPI_CAST_PTR(char, aml);
 
-               while (ACPI_GET8(parser_state->aml) != '\0') {
-                       parser_state->aml++;
+               /* Find the null terminator */
+
+               length = 0;
+               while (aml[length]) {
+                       length++;
                }
-               parser_state->aml++;
+               length++;
                break;
 
        case ARGP_NAME:
@@ -443,14 +433,16 @@ acpi_ps_get_next_simple_arg(struct acpi_parse_state *parser_state,
                acpi_ps_init_op(arg, AML_INT_NAMEPATH_OP);
                arg->common.value.name =
                    acpi_ps_get_next_namestring(parser_state);
-               break;
+               return_VOID;
 
        default:
 
                ACPI_REPORT_ERROR(("Invalid arg_type %X\n", arg_type));
-               break;
+               return_VOID;
        }
 
+       acpi_ps_init_op(arg, opcode);
+       parser_state->aml += length;
        return_VOID;
 }
 
@@ -540,7 +532,7 @@ static union acpi_parse_object *acpi_ps_get_next_field(struct acpi_parse_state
                 * access_type is first operand, access_attribute is second
                 */
                field->common.value.integer =
-                   (ACPI_GET8(parser_state->aml) << 8);
+                   (((u32) ACPI_GET8(parser_state->aml) << 8));
                parser_state->aml++;
                field->common.value.integer |= ACPI_GET8(parser_state->aml);
                parser_state->aml++;
index 76d4d640d83cdebaa7362742258b2daac841e2d9..7cfa7eb0dfc706d9d356de7adc0199051468b3cc 100644 (file)
@@ -503,22 +503,23 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                } else if (status == AE_CTRL_TERMINATE) {
                        status = AE_OK;
                } else if ((status != AE_OK) && (walk_state->method_desc)) {
-                       ACPI_REPORT_METHOD_ERROR("Method execution failed",
-                                                walk_state->method_node, NULL,
-                                                status);
+                       /* Either the method parse or actual execution failed */
 
-                       /* Ensure proper cleanup */
-
-                       walk_state->parse_flags |= ACPI_PARSE_EXECUTE;
+                       ACPI_REPORT_METHOD_ERROR
+                           ("Method parse/execution failed",
+                            walk_state->method_node, NULL, status);
 
                        /* Check for possible multi-thread reentrancy problem */
 
                        if ((status == AE_ALREADY_EXISTS) &&
                            (!walk_state->method_desc->method.semaphore)) {
                                /*
-                                * This method is marked not_serialized, but it tried to create
+                                * Method tried to create an object twice. The probable cause is
+                                * that the method cannot handle reentrancy.
+                                *
+                                * The method is marked not_serialized, but it tried to create
                                 * a named object, causing the second thread entrance to fail.
-                                * We will workaround this by marking the method permanently
+                                * Workaround this problem by marking the method permanently
                                 * as Serialized.
                                 */
                                walk_state->method_desc->method.method_flags |=
@@ -536,15 +537,22 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                acpi_ds_scope_stack_clear(walk_state);
 
                /*
-                * If we just returned from the execution of a control method,
-                * there's lots of cleanup to do
+                * If we just returned from the execution of a control method or if we
+                * encountered an error during the method parse phase, there's lots of
+                * cleanup to do
                 */
-               if ((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
-                   ACPI_PARSE_EXECUTE) {
+               if (((walk_state->parse_flags & ACPI_PARSE_MODE_MASK) ==
+                    ACPI_PARSE_EXECUTE) || (ACPI_FAILURE(status))) {
                        if (walk_state->method_desc) {
                                /* Decrement the thread count on the method parse tree */
 
-                               walk_state->method_desc->method.thread_count--;
+                               if (walk_state->method_desc->method.
+                                   thread_count) {
+                                       walk_state->method_desc->method.
+                                           thread_count--;
+                               } else {
+                                       ACPI_REPORT_ERROR(("Invalid zero thread count in method\n"));
+                               }
                        }
 
                        acpi_ds_terminate_control_method(walk_state);
@@ -553,7 +561,6 @@ acpi_status acpi_ps_parse_aml(struct acpi_walk_state *walk_state)
                /* Delete this walk state and all linked control states */
 
                acpi_ps_cleanup_scope(&walk_state->parser_state);
-
                previous_walk_state = walk_state;
 
                ACPI_DEBUG_PRINT((ACPI_DB_PARSE,
index 4c426f4c6af6d37af8e665c4ace5e540dca2f9c8..14d544d60867a0f6ec5fc84cdaee3a70a4224a85 100644 (file)
@@ -87,7 +87,7 @@ acpi_debug_trace(char *name, u32 debug_level, u32 debug_layer, u32 flags)
 
        /* TBDs: Validate name, allow full path or just nameseg */
 
-       acpi_gbl_trace_method_name = *(u32 *) name;
+       acpi_gbl_trace_method_name = *ACPI_CAST_PTR(u32, name);
        acpi_gbl_trace_flags = flags;
 
        if (debug_level) {
index eca7439ee9da259c839e6465875e79df3cb439d1..c2c4d9079c6cfe08a8140bc8976cb8be0f993378 100644 (file)
@@ -300,7 +300,7 @@ acpi_rs_get_aml_length(struct acpi_resource * resource, acpi_size * size_needed)
                /* Point to the next object */
 
                resource =
-                   ACPI_PTR_ADD(struct acpi_resource, resource,
+                   ACPI_ADD_PTR(struct acpi_resource, resource,
                                 resource->length);
        }
 
@@ -374,8 +374,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
                         * Get the number of bits set in the 16-bit IRQ mask
                         */
                        ACPI_MOVE_16_TO_16(&temp16, buffer);
-                       extra_struct_bytes =
-                           acpi_rs_count_set_bits(temp16) * sizeof(u32);
+                       extra_struct_bytes = acpi_rs_count_set_bits(temp16);
                        break;
 
                case ACPI_RESOURCE_NAME_DMA:
@@ -383,8 +382,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
                         * DMA Resource:
                         * Get the number of bits set in the 8-bit DMA mask
                         */
-                       extra_struct_bytes =
-                           acpi_rs_count_set_bits(*buffer) * sizeof(u32);
+                       extra_struct_bytes = acpi_rs_count_set_bits(*buffer);
                        break;
 
                case ACPI_RESOURCE_NAME_VENDOR_SMALL:
@@ -399,9 +397,9 @@ acpi_rs_get_list_length(u8 * aml_buffer,
 
                case ACPI_RESOURCE_NAME_END_TAG:
                        /*
-                        * End Tag: This is the normal exit
+                        * End Tag: This is the normal exit, add size of end_tag
                         */
-                       *size_needed = buffer_size;
+                       *size_needed = buffer_size + ACPI_RS_SIZE_MIN;
                        return_ACPI_STATUS(AE_OK);
 
                case ACPI_RESOURCE_NAME_VENDOR_LARGE:
@@ -466,7 +464,7 @@ acpi_rs_get_list_length(u8 * aml_buffer,
 
                temp16 = (u16) (acpi_gbl_resource_struct_sizes[resource_index] +
                                extra_struct_bytes);
-               buffer_size += (u32) ACPI_ALIGN_RESOURCE_SIZE(temp16);
+               buffer_size += (u32) ACPI_ROUND_UP_TO_NATIVE_WORD(temp16);
 
                /*
                 * Point to the next resource within the stream
index f617ca80c5a6c7cf390ae8fbdfb87724197e6643..cebd890d3db5c3b009daf8052f6d72b05485f8c2 100644 (file)
@@ -383,7 +383,7 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
 
        while (count) {
                previous_target = target;
-               target = ((u8 *) resource) + table->offset;
+               target = ACPI_ADD_PTR(u8, resource, table->offset);
                name = table->name;
 
                switch (table->opcode) {
@@ -410,22 +410,19 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
                        /* Data items, 8/16/32/64 bit */
 
                case ACPI_RSD_UINT8:
-                       acpi_rs_out_integer8(name, *ACPI_CAST_PTR(u8, target));
+                       acpi_rs_out_integer8(name, ACPI_GET8(target));
                        break;
 
                case ACPI_RSD_UINT16:
-                       acpi_rs_out_integer16(name,
-                                             *ACPI_CAST_PTR(u16, target));
+                       acpi_rs_out_integer16(name, ACPI_GET16(target));
                        break;
 
                case ACPI_RSD_UINT32:
-                       acpi_rs_out_integer32(name,
-                                             *ACPI_CAST_PTR(u32, target));
+                       acpi_rs_out_integer32(name, ACPI_GET32(target));
                        break;
 
                case ACPI_RSD_UINT64:
-                       acpi_rs_out_integer64(name,
-                                             *ACPI_CAST_PTR(u64, target));
+                       acpi_rs_out_integer64(name, ACPI_GET64(target));
                        break;
 
                        /* Flags: 1-bit and 2-bit flags supported */
@@ -462,8 +459,8 @@ acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
                         * Note: The list length is obtained from the previous table entry
                         */
                        if (previous_target) {
-                               acpi_rs_dump_byte_list(*ACPI_CAST_PTR
-                                                      (u16, previous_target),
+                               acpi_rs_dump_byte_list(ACPI_GET16
+                                                      (previous_target),
                                                       target);
                        }
                        break;
@@ -634,7 +631,7 @@ void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
                /* Point to the next resource structure */
 
                resource_list =
-                   ACPI_PTR_ADD(struct acpi_resource, resource_list,
+                   ACPI_ADD_PTR(struct acpi_resource, resource_list,
                                 resource_list->length);
 
                /* Exit when END_TAG descriptor is reached */
@@ -675,9 +672,8 @@ void acpi_rs_dump_irq_list(u8 * route_table)
                               count);
                acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
 
-               prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table,
-                                           ((u8 *) prt_element) +
-                                           prt_element->length);
+               prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
+                                          prt_element, prt_element->length);
        }
 }
 
index b83996233c1d2e80d1d682c4c7ad2e4050c5db86..573c06705641651e50568ce893bd973238238735 100644 (file)
@@ -112,7 +112,7 @@ acpi_rs_convert_aml_to_resources(u8 * aml, u32 aml_length, u8 * output_buffer)
                /* Point to the next structure in the output buffer */
 
                resource =
-                   ACPI_PTR_ADD(struct acpi_resource, resource,
+                   ACPI_ADD_PTR(struct acpi_resource, resource,
                                 resource->length);
        }
 
@@ -201,7 +201,7 @@ acpi_rs_convert_resources_to_aml(struct acpi_resource *resource,
                /* Point to the next input resource descriptor */
 
                resource =
-                   ACPI_PTR_ADD(struct acpi_resource, resource,
+                   ACPI_ADD_PTR(struct acpi_resource, resource,
                                 resource->length);
        }
 
index 16ad3bfbee2ad85b4d044b364933fd43ce53c999..e1b5aa2af9a5236a97899465413c55ca26baae11 100644 (file)
@@ -104,8 +104,9 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                 * Source is the external AML byte stream buffer,
                 * destination is the internal resource descriptor
                 */
-               source = ((u8 *) aml) + info->aml_offset;
-               destination = ((u8 *) resource) + info->resource_offset;
+               source = ACPI_ADD_PTR(void, aml, info->aml_offset);
+               destination =
+                   ACPI_ADD_PTR(void, resource, info->resource_offset);
 
                switch (info->opcode) {
                case ACPI_RSC_INITGET:
@@ -129,22 +130,22 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                        /*
                         * Mask and shift the flag bit
                         */
-                       *((u8 *) destination) = (u8)
-                           ((*((u8 *) source) >> info->value) & 0x01);
+                       ACPI_SET8(destination) = (u8)
+                           ((ACPI_GET8(source) >> info->value) & 0x01);
                        break;
 
                case ACPI_RSC_2BITFLAG:
                        /*
                         * Mask and shift the flag bits
                         */
-                       *((u8 *) destination) = (u8)
-                           ((*((u8 *) source) >> info->value) & 0x03);
+                       ACPI_SET8(destination) = (u8)
+                           ((ACPI_GET8(source) >> info->value) & 0x03);
                        break;
 
                case ACPI_RSC_COUNT:
 
-                       item_count = *((u8 *) source);
-                       *((u8 *) destination) = (u8) item_count;
+                       item_count = ACPI_GET8(source);
+                       ACPI_SET8(destination) = (u8) item_count;
 
                        resource->length = resource->length +
                            (info->value * (item_count - 1));
@@ -153,7 +154,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                case ACPI_RSC_COUNT16:
 
                        item_count = aml_resource_length;
-                       *((u16 *) destination) = item_count;
+                       ACPI_SET16(destination) = item_count;
 
                        resource->length = resource->length +
                            (info->value * (item_count - 1));
@@ -186,9 +187,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
 
                case ACPI_RSC_DATA8:
 
-                       target = ((char *)resource) + info->value;
-                       ACPI_MEMCPY(destination, source,
-                                   *(ACPI_CAST_PTR(u16, target)));
+                       target = ACPI_ADD_PTR(char, resource, info->value);
+                       ACPI_MEMCPY(destination, source, ACPI_GET16(target));
                        break;
 
                case ACPI_RSC_ADDRESS:
@@ -217,8 +217,8 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                         * complicated case used by the Interrupt() macro
                         */
                        target =
-                           ((char *)resource) + info->aml_offset +
-                           (item_count * 4);
+                           ACPI_ADD_PTR(char, resource,
+                                        info->aml_offset + (item_count * 4));
 
                        resource->length +=
                            acpi_rs_get_resource_source(aml_resource_length,
@@ -230,15 +230,14 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                         * 8-bit encoded bitmask (DMA macro)
                         */
                        item_count =
-                           acpi_rs_decode_bitmask(*((u8 *) source),
+                           acpi_rs_decode_bitmask(ACPI_GET8(source),
                                                   destination);
                        if (item_count) {
-                               resource->length +=
-                                   resource->length + (item_count - 1);
+                               resource->length += (item_count - 1);
                        }
 
-                       target = ((char *)resource) + info->value;
-                       *((u8 *) target) = (u8) item_count;
+                       target = ACPI_ADD_PTR(char, resource, info->value);
+                       ACPI_SET8(target) = (u8) item_count;
                        break;
 
                case ACPI_RSC_BITMASK16:
@@ -250,12 +249,11 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                        item_count =
                            acpi_rs_decode_bitmask(temp16, destination);
                        if (item_count) {
-                               resource->length =
-                                   resource->length + (item_count - 1);
+                               resource->length += (item_count - 1);
                        }
 
-                       target = ((char *)resource) + info->value;
-                       *((u8 *) target) = (u8) item_count;
+                       target = ACPI_ADD_PTR(char, resource, info->value);
+                       ACPI_SET8(target) = (u8) item_count;
                        break;
 
                case ACPI_RSC_EXIT_NE:
@@ -270,7 +268,7 @@ acpi_rs_convert_aml_to_resource(struct acpi_resource *resource,
                                break;
 
                        case ACPI_RSC_COMPARE_VALUE:
-                               if (*((u8 *) source) != info->value) {
+                               if (ACPI_GET8(source) != info->value) {
                                        goto exit;
                                }
                                break;
@@ -349,8 +347,8 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
                 * Source is the internal resource descriptor,
                 * destination is the external AML byte stream buffer
                 */
-               source = ((u8 *) resource) + info->resource_offset;
-               destination = ((u8 *) aml) + info->aml_offset;
+               source = ACPI_ADD_PTR(void, resource, info->resource_offset);
+               destination = ACPI_ADD_PTR(void, aml, info->aml_offset);
 
                switch (info->opcode) {
                case ACPI_RSC_INITSET:
@@ -368,37 +366,38 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
                        /*
                         * Clear the flag byte
                         */
-                       *((u8 *) destination) = 0;
+                       ACPI_SET8(destination) = 0;
                        break;
 
                case ACPI_RSC_1BITFLAG:
                        /*
                         * Mask and shift the flag bit
                         */
-                       *((u8 *) destination) |= (u8)
-                           ((*((u8 *) source) & 0x01) << info->value);
+                       ACPI_SET8(destination) |= (u8)
+                           ((ACPI_GET8(source) & 0x01) << info->value);
                        break;
 
                case ACPI_RSC_2BITFLAG:
                        /*
                         * Mask and shift the flag bits
                         */
-                       *((u8 *) destination) |= (u8)
-                           ((*((u8 *) source) & 0x03) << info->value);
+                       ACPI_SET8(destination) |= (u8)
+                           ((ACPI_GET8(source) & 0x03) << info->value);
                        break;
 
                case ACPI_RSC_COUNT:
 
-                       item_count = *((u8 *) source);
-                       *((u8 *) destination) = (u8) item_count;
+                       item_count = ACPI_GET8(source);
+                       ACPI_SET8(destination) = (u8) item_count;
 
-                       aml_length = (u16) (aml_length +
-                                           (info->value * (item_count - 1)));
+                       aml_length =
+                           (u16) (aml_length +
+                                  (info->value * (item_count - 1)));
                        break;
 
                case ACPI_RSC_COUNT16:
 
-                       item_count = *((u16 *) source);
+                       item_count = ACPI_GET16(source);
                        aml_length = (u16) (aml_length + item_count);
                        acpi_rs_set_resource_length(aml_length, aml);
                        break;
@@ -453,20 +452,21 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
                        /*
                         * 8-bit encoded bitmask (DMA macro)
                         */
-                       *((u8 *) destination) = (u8)
+                       ACPI_SET8(destination) = (u8)
                            acpi_rs_encode_bitmask(source,
-                                                  *(((u8 *) resource) +
-                                                    info->value));
+                                                  *ACPI_ADD_PTR(u8, resource,
+                                                                info->value));
                        break;
 
                case ACPI_RSC_BITMASK16:
                        /*
                         * 16-bit encoded bitmask (IRQ macro)
                         */
-                       temp16 =
-                           acpi_rs_encode_bitmask(source,
-                                                  *(((u8 *) resource) +
-                                                    info->value));
+                       temp16 = acpi_rs_encode_bitmask(source,
+                                                       *ACPI_ADD_PTR(u8,
+                                                                     resource,
+                                                                     info->
+                                                                     value));
                        ACPI_MOVE_16_TO_16(destination, &temp16);
                        break;
 
@@ -485,9 +485,9 @@ acpi_rs_convert_resource_to_aml(struct acpi_resource *resource,
                         */
                        switch (COMPARE_OPCODE(info)) {
                        case ACPI_RSC_COMPARE_VALUE:
-                               if (*
-                                   ((u8 *) (((u8 *) resource) +
-                                            COMPARE_TARGET(info))) !=
+
+                               if (*ACPI_ADD_PTR(u8, resource,
+                                                 COMPARE_TARGET(info)) !=
                                    COMPARE_VALUE(info)) {
                                        goto exit;
                                }
index a1eac0f1df54ec637c9b273945b520f1953e4623..2236a0c90daa3f29fab19dab704eea6e2110fe88 100644 (file)
@@ -152,18 +152,18 @@ acpi_rs_move_data(void *destination, void *source, u16 item_count, u8 move_type)
                         * misaligned memory transfers
                         */
                case ACPI_RSC_MOVE16:
-                       ACPI_MOVE_16_TO_16(&((u16 *) destination)[i],
-                                          &((u16 *) source)[i]);
+                       ACPI_MOVE_16_TO_16(&ACPI_CAST_PTR(u16, destination)[i],
+                                          &ACPI_CAST_PTR(u16, source)[i]);
                        break;
 
                case ACPI_RSC_MOVE32:
-                       ACPI_MOVE_32_TO_32(&((u32 *) destination)[i],
-                                          &((u32 *) source)[i]);
+                       ACPI_MOVE_32_TO_32(&ACPI_CAST_PTR(u32, destination)[i],
+                                          &ACPI_CAST_PTR(u32, source)[i]);
                        break;
 
                case ACPI_RSC_MOVE64:
-                       ACPI_MOVE_64_TO_64(&((u64 *) destination)[i],
-                                          &((u64 *) source)[i]);
+                       ACPI_MOVE_64_TO_64(&ACPI_CAST_PTR(u64, destination)[i],
+                                          &ACPI_CAST_PTR(u64, source)[i]);
                        break;
 
                default:
@@ -318,7 +318,7 @@ acpi_rs_get_resource_source(acpi_rs_length resource_length,
 
        total_length =
            resource_length + sizeof(struct aml_resource_large_header);
-       aml_resource_source = ((u8 *) aml) + minimum_length;
+       aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
 
        /*
         * 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,
                         * String destination pointer is not specified; Set the String
                         * pointer to the end of the current resource_source structure.
                         */
-                       resource_source->string_ptr = (char *)
-                           ((u8 *) resource_source) +
-                           sizeof(struct acpi_resource_source);
+                       resource_source->string_ptr =
+                           ACPI_ADD_PTR(char, resource_source,
+                                        sizeof(struct acpi_resource_source));
                }
 
                /*
@@ -407,7 +407,7 @@ acpi_rs_set_resource_source(union aml_resource * aml,
        if (resource_source->string_length) {
                /* Point to the end of the AML descriptor */
 
-               aml_resource_source = ((u8 *) aml) + minimum_length;
+               aml_resource_source = ACPI_ADD_PTR(u8, aml, minimum_length);
 
                /* Copy the resource_source_index */
 
index 09d250ab9872b8c7dab522a5c7fed4bff8a31803..50a956b705b00164275ae6c9ef2b9d563055f624 100644 (file)
@@ -64,6 +64,10 @@ ACPI_MODULE_NAME("rsxface")
        ACPI_COPY_FIELD(out, in, translation_offset);        \
        ACPI_COPY_FIELD(out, in, address_length);            \
        ACPI_COPY_FIELD(out, in, resource_source);
+/* Local prototypes */
+static acpi_status
+acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
+
 /*******************************************************************************
  *
  * FUNCTION:    acpi_get_irq_routing_table
@@ -86,6 +90,7 @@ ACPI_MODULE_NAME("rsxface")
  *              the object indicated by the passed device_handle.
  *
  ******************************************************************************/
+
 acpi_status
 acpi_get_irq_routing_table(acpi_handle device_handle,
                           struct acpi_buffer *ret_buffer)
@@ -222,12 +227,12 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
  *
  * FUNCTION:    acpi_walk_resources
  *
- * PARAMETERS:  device_handle   - a handle to the device object for the
+ * PARAMETERS:  device_handle   - Handle to the device object for the
  *                                device we are querying
- *              Path            - method name of the resources we want
+ *              Name            - Method name of the resources we want
  *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
- *              user_function   - called for each resource
- *              Context         - passed to user_function
+ *              user_function   - Called for each resource
+ *              Context         - Passed to user_function
  *
  * RETURN:      Status
  *
@@ -239,79 +244,74 @@ EXPORT_SYMBOL(acpi_get_possible_resources);
 
 acpi_status
 acpi_walk_resources(acpi_handle device_handle,
-                   char *path,
+                   char *name,
                    ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
 {
        acpi_status status;
-       struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
+       struct acpi_buffer buffer;
        struct acpi_resource *resource;
-       struct acpi_resource *buffer_end;
+       struct acpi_resource *resource_end;
 
        ACPI_FUNCTION_TRACE("acpi_walk_resources");
 
-       if (!device_handle ||
-           (ACPI_STRNCMP(path, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
-            ACPI_STRNCMP(path, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
+       /* Parameter validation */
+
+       if (!device_handle || !user_function || !name ||
+           (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
+            ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
                return_ACPI_STATUS(AE_BAD_PARAMETER);
        }
 
-       status = acpi_rs_get_method_data(device_handle, path, &buffer);
+       /* Get the _CRS or _PRS resource list */
+
+       buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
+       status = acpi_rs_get_method_data(device_handle, name, &buffer);
        if (ACPI_FAILURE(status)) {
                return_ACPI_STATUS(status);
        }
 
-       /* Setup pointers */
+       /* Buffer now contains the resource list */
 
-       resource = (struct acpi_resource *)buffer.pointer;
-       buffer_end = ACPI_CAST_PTR(struct acpi_resource,
-                                  ((u8 *) buffer.pointer + buffer.length));
+       resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
+       resource_end =
+           ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
 
-       /* Walk the resource list */
+       /* Walk the resource list until the end_tag is found (or buffer end) */
 
-       for (;;) {
-               if (!resource || resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
+       while (resource < resource_end) {
+               /* Sanity check the resource */
+
+               if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
+                       status = AE_AML_INVALID_RESOURCE_TYPE;
                        break;
                }
 
-               status = user_function(resource, context);
-
-               switch (status) {
-               case AE_OK:
-               case AE_CTRL_DEPTH:
+               /* Invoke the user function, abort on any error returned */
 
-                       /* Just keep going */
+               status = user_function(resource, context);
+               if (ACPI_FAILURE(status)) {
+                       if (status == AE_CTRL_TERMINATE) {
+                               /* This is an OK termination by the user function */
 
-                       status = AE_OK;
+                               status = AE_OK;
+                       }
                        break;
+               }
 
-               case AE_CTRL_TERMINATE:
-
-                       /* Exit now, with OK stats */
-
-                       status = AE_OK;
-                       goto cleanup;
-
-               default:
-
-                       /* All others are valid exceptions */
+               /* end_tag indicates end-of-list */
 
-                       goto cleanup;
+               if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
+                       break;
                }
 
                /* Get the next resource descriptor */
 
-               resource = ACPI_NEXT_RESOURCE(resource);
-
-               /* Check for end-of-buffer */
-
-               if (resource >= buffer_end) {
-                       goto cleanup;
-               }
+               resource =
+                   ACPI_ADD_PTR(struct acpi_resource, resource,
+                                resource->length);
        }
 
-      cleanup:
-
-       acpi_os_free(buffer.pointer);
+       ACPI_MEM_FREE(buffer.pointer);
        return_ACPI_STATUS(status);
 }
 
@@ -381,6 +381,12 @@ acpi_resource_to_address64(struct acpi_resource *resource,
        struct acpi_resource_address16 *address16;
        struct acpi_resource_address32 *address32;
 
+       if (!resource || !out) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       /* Convert 16 or 32 address descriptor to 64 */
+
        switch (resource->type) {
        case ACPI_RESOURCE_TYPE_ADDRESS16:
 
@@ -410,3 +416,113 @@ acpi_resource_to_address64(struct acpi_resource *resource,
 }
 
 EXPORT_SYMBOL(acpi_resource_to_address64);
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_get_vendor_resource
+ *
+ * PARAMETERS:  device_handle       - Handle for the parent device object
+ *              Name                - Method name for the parent resource
+ *                                    (METHOD_NAME__CRS or METHOD_NAME__PRS)
+ *              Uuid                - Pointer to the UUID to be matched.
+ *                                    includes both subtype and 16-byte UUID
+ *              ret_buffer          - Where the vendor resource is returned
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Walk a resource template for the specified evice to find a
+ *              vendor-defined resource that matches the supplied UUID and
+ *              UUID subtype. Returns a struct acpi_resource of type Vendor.
+ *
+ ******************************************************************************/
+
+acpi_status
+acpi_get_vendor_resource(acpi_handle device_handle,
+                        char *name,
+                        struct acpi_vendor_uuid * uuid,
+                        struct acpi_buffer * ret_buffer)
+{
+       struct acpi_vendor_walk_info info;
+       acpi_status status;
+
+       /* Other parameters are validated by acpi_walk_resources */
+
+       if (!uuid || !ret_buffer) {
+               return (AE_BAD_PARAMETER);
+       }
+
+       info.uuid = uuid;
+       info.buffer = ret_buffer;
+       info.status = AE_NOT_EXIST;
+
+       /* Walk the _CRS or _PRS resource list for this device */
+
+       status =
+           acpi_walk_resources(device_handle, name,
+                               acpi_rs_match_vendor_resource, &info);
+       if (ACPI_FAILURE(status)) {
+               return (status);
+       }
+
+       return (info.status);
+}
+
+/*******************************************************************************
+ *
+ * FUNCTION:    acpi_rs_match_vendor_resource
+ *
+ * PARAMETERS:  ACPI_WALK_RESOURCE_CALLBACK
+ *
+ * RETURN:      Status
+ *
+ * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
+ *
+ ******************************************************************************/
+
+static acpi_status
+acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
+{
+       struct acpi_vendor_walk_info *info = context;
+       struct acpi_resource_vendor_typed *vendor;
+       struct acpi_buffer *buffer;
+       acpi_status status;
+
+       /* Ignore all descriptors except Vendor */
+
+       if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) {
+               return (AE_OK);
+       }
+
+       vendor = &resource->data.vendor_typed;
+
+       /*
+        * For a valid match, these conditions must hold:
+        *
+        * 1) Length of descriptor data must be at least as long as a UUID struct
+        * 2) The UUID subtypes must match
+        * 3) The UUID data must match
+        */
+       if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) ||
+           (vendor->uuid_subtype != info->uuid->subtype) ||
+           (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) {
+               return (AE_OK);
+       }
+
+       /* Validate/Allocate/Clear caller buffer */
+
+       buffer = info->buffer;
+       status = acpi_ut_initialize_buffer(buffer, resource->length);
+       if (ACPI_FAILURE(status)) {
+               return (status);
+       }
+
+       /* Found the correct resource, copy and return it */
+
+       ACPI_MEMCPY(buffer->pointer, resource, resource->length);
+       buffer->length = resource->length;
+
+       /* Found the desired descriptor, terminate resource walk */
+
+       info->status = AE_OK;
+       return (AE_CTRL_TERMINATE);
+}
index 31218e1d2a18313a8ea9410c3bbab5934bb7b396..e332306ae2b9d6b21a703b4f533e2fd42dc7a8a0 100644 (file)
@@ -844,7 +844,7 @@ static void acpi_device_set_id(struct acpi_device *device,
         * ----
         * Fix for the system root bus device -- the only root-level device.
         */
-       if ((parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
+       if (((acpi_handle)parent == ACPI_ROOT_OBJECT) && (type == ACPI_BUS_TYPE_DEVICE)) {
                hid = ACPI_BUS_HID;
                strcpy(device->pnp.device_name, ACPI_BUS_DEVICE_NAME);
                strcpy(device->pnp.device_class, ACPI_BUS_CLASS);
index a03939399fa9e309c7ef63ada9c01b90a0d4e2ad..cd33397d92310984ffdef669e9214b445f21a9d3 100644 (file)
@@ -554,7 +554,9 @@ acpi_status acpi_tb_convert_table_fadt(void)
        ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
                          "Hex dump of common internal FADT, size %d (%X)\n",
                          acpi_gbl_FADT->length, acpi_gbl_FADT->length));
-       ACPI_DUMP_BUFFER((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length);
+
+       ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_FADT),
+                        acpi_gbl_FADT->length);
 
        return_ACPI_STATUS(AE_OK);
 }
index 8d72343537e74719e3592a66db22a27212b9245c..33c9ed8a6f99a635f025478d2dff4c0dac61f8ad 100644 (file)
@@ -292,7 +292,9 @@ acpi_status acpi_tb_get_required_tables(void)
                          "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
                          acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
                          acpi_gbl_integer_bit_width));
-       ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
+
+       ACPI_DUMP_BUFFER(ACPI_CAST_PTR(u8, acpi_gbl_DSDT),
+                        acpi_gbl_DSDT->length);
 
        /* Always delete the RSDP mapping, we are done with it */
 
index e6dfe688b76b2fd8e18b89a20594e804720b3b3a..9d0bf536d67420016682b899e349ef59e0a23668 100644 (file)
@@ -240,16 +240,16 @@ acpi_tb_verify_table_checksum(struct acpi_table_header * table_header)
 
 u8 acpi_tb_generate_checksum(void *buffer, u32 length)
 {
-       const u8 *limit;
-       const u8 *rover;
+       u8 *end_buffer;
+       u8 *rover;
        u8 sum = 0;
 
        if (buffer && length) {
                /*  Buffer and Length are valid   */
 
-               limit = (u8 *) buffer + length;
+               end_buffer = ACPI_ADD_PTR(u8, buffer, length);
 
-               for (rover = buffer; rover < limit; rover++) {
+               for (rover = buffer; rover < end_buffer; rover++) {
                        sum = (u8) (sum + *rover);
                }
        }
index 5442b32de61156a70a852e7a31d67360746d6b57..568df9e42f896d563aa7724857b91196371b989e 100644 (file)
@@ -398,14 +398,17 @@ acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
                 * Build a simple object (no nested objects)
                 */
                status = acpi_ut_copy_isimple_to_esimple(internal_object,
-                                                        (union acpi_object *)
-                                                        ret_buffer->pointer,
-                                                        ((u8 *) ret_buffer->
-                                                         pointer +
-                                                         ACPI_ROUND_UP_TO_NATIVE_WORD
-                                                         (sizeof
-                                                          (union
-                                                           acpi_object))),
+                                                        ACPI_CAST_PTR(union
+                                                                      acpi_object,
+                                                                      ret_buffer->
+                                                                      pointer),
+                                                        ACPI_ADD_PTR(u8,
+                                                                     ret_buffer->
+                                                                     pointer,
+                                                                     ACPI_ROUND_UP_TO_NATIVE_WORD
+                                                                     (sizeof
+                                                                      (union
+                                                                       acpi_object))),
                                                         &ret_buffer->length);
                /*
                 * build simple does not include the object size in the length
index 413e1dd8ae36223aadf5cebcabc6167e30c82b1e..d6813d88a104daa4f8a6fc3b3a178a44be6782bc 100644 (file)
@@ -638,7 +638,7 @@ char *acpi_ut_get_node_name(void *object)
 
        /* Name must be a valid ACPI name */
 
-       if (!acpi_ut_valid_acpi_name(*(u32 *) node->name.ascii)) {
+       if (!acpi_ut_valid_acpi_name(node->name.integer)) {
                return ("????");
        }
 
@@ -831,6 +831,7 @@ void acpi_ut_init_globals(void)
        acpi_gbl_ps_find_count = 0;
        acpi_gbl_acpi_hardware_present = TRUE;
        acpi_gbl_owner_id_mask = 0;
+       acpi_gbl_last_owner_id = 0;
        acpi_gbl_trace_method_name = 0;
        acpi_gbl_trace_dbg_level = 0;
        acpi_gbl_trace_dbg_layer = 0;
@@ -845,7 +846,6 @@ void acpi_ut_init_globals(void)
        /* Namespace */
 
        acpi_gbl_root_node = NULL;
-
        acpi_gbl_root_node_struct.name.integer = ACPI_ROOT_NAME;
        acpi_gbl_root_node_struct.descriptor = ACPI_DESC_TYPE_NAMED;
        acpi_gbl_root_node_struct.type = ACPI_TYPE_DEVICE;
index 2a9110c0639160d7cbab4f220c674662455a8d8b..89efba7bf44948dab2567a38091f9be086f37183 100644 (file)
@@ -63,6 +63,7 @@ ACPI_MODULE_NAME("utmisc")
 acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
 {
        acpi_native_uint i;
+       acpi_native_uint j;
        acpi_status status;
 
        ACPI_FUNCTION_TRACE("ut_allocate_owner_id");
@@ -82,29 +83,46 @@ acpi_status acpi_ut_allocate_owner_id(acpi_owner_id * owner_id)
                return_ACPI_STATUS(status);
        }
 
-       /* Find a free owner ID */
+       /*
+        * Find a free owner ID, cycle through all possible IDs on repeated
+        * allocations. Note: Index for next possible ID is equal to the value
+        * of the last allocated ID.
+        */
+       for (i = 0, j = acpi_gbl_last_owner_id; i < 32; i++, j++) {
+               if (j >= 32) {
+                       j = 0;  /* Wraparound to ID start */
+               }
+
+               if (!(acpi_gbl_owner_id_mask & (1 << j))) {
+                       /*
+                        * Found a free ID. The actual ID is the bit index plus one,
+                        * making zero an invalid Owner ID. Save this as the last ID
+                        * allocated and update the global ID mask.
+                        */
+                       acpi_gbl_last_owner_id = (acpi_owner_id) (j + 1);
+                       *owner_id = acpi_gbl_last_owner_id;
 
-       for (i = 0; i < 32; i++) {
-               if (!(acpi_gbl_owner_id_mask & (1 << i))) {
                        ACPI_DEBUG_PRINT((ACPI_DB_VALUES,
                                          "Current owner_id mask: %8.8X New ID: %2.2X\n",
                                          acpi_gbl_owner_id_mask,
-                                         (unsigned int)(i + 1)));
+                                         (unsigned int)
+                                         acpi_gbl_last_owner_id));
 
-                       acpi_gbl_owner_id_mask |= (1 << i);
-                       *owner_id = (acpi_owner_id) (i + 1);
+                       acpi_gbl_owner_id_mask |= (1 << j);
                        goto exit;
                }
        }
 
        /*
-        * If we are here, all owner_ids have been allocated. This probably should
+        * All owner_ids have been allocated. This typically should
         * not happen since the IDs are reused after deallocation. The IDs are
         * allocated upon table load (one per table) and method execution, and
         * they are released when a table is unloaded or a method completes
         * execution.
+        *
+        * If this error happens, there may be very deep nesting of invoked control
+        * methods, or there may be a bug where the IDs are not released.
         */
-       *owner_id = 0;
        status = AE_OWNER_ID_LIMIT;
        ACPI_REPORT_ERROR(("Could not allocate new owner_id (32 max), AE_OWNER_ID_LIMIT\n"));
 
index 07a314c710d8f7f8978b246d8ee3c33770cc30f0..6c0ce7b121940d7fe2d27135718c635cfcc01ffe 100644 (file)
@@ -157,7 +157,7 @@ acpi_status acpi_ut_validate_resource(void *aml, u8 * return_index)
        /*
         * 1) Validate the resource_type field (Byte 0)
         */
-       resource_type = *((u8 *) aml);
+       resource_type = ACPI_GET8(aml);
 
        /*
         * Byte 0 contains the descriptor name (Resource Type)
@@ -266,14 +266,14 @@ u8 acpi_ut_get_resource_type(void *aml)
         * Byte 0 contains the descriptor name (Resource Type)
         * Examine the large/small bit in the resource header
         */
-       if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
+       if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
                /* Large Resource Type -- bits 6:0 contain the name */
 
-               return (*((u8 *) aml));
+               return (ACPI_GET8(aml));
        } else {
                /* Small Resource Type -- bits 6:3 contain the name */
 
-               return ((u8) (*((u8 *) aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
+               return ((u8) (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_SMALL_MASK));
        }
 }
 
@@ -301,15 +301,15 @@ u16 acpi_ut_get_resource_length(void *aml)
         * Byte 0 contains the descriptor name (Resource Type)
         * Examine the large/small bit in the resource header
         */
-       if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
+       if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
                /* Large Resource type -- bytes 1-2 contain the 16-bit length */
 
-               ACPI_MOVE_16_TO_16(&resource_length, &((u8 *) aml)[1]);
+               ACPI_MOVE_16_TO_16(&resource_length, ACPI_ADD_PTR(u8, aml, 1));
 
        } else {
                /* Small Resource type -- bits 2:0 of byte 0 contain the length */
 
-               resource_length = (u16) (*((u8 *) aml) &
+               resource_length = (u16) (ACPI_GET8(aml) &
                                         ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK);
        }
 
@@ -334,7 +334,7 @@ u8 acpi_ut_get_resource_header_length(void *aml)
 
        /* Examine the large/small bit in the resource header */
 
-       if (*((u8 *) aml) & ACPI_RESOURCE_NAME_LARGE) {
+       if (ACPI_GET8(aml) & ACPI_RESOURCE_NAME_LARGE) {
                return (sizeof(struct aml_resource_large_header));
        } else {
                return (sizeof(struct aml_resource_small_header));
@@ -372,8 +372,9 @@ u32 acpi_ut_get_descriptor_length(void *aml)
  * FUNCTION:    acpi_ut_get_resource_end_tag
  *
  * PARAMETERS:  obj_desc        - The resource template buffer object
+ *              end_tag         - Where the pointer to the end_tag is returned
  *
- * RETURN:      Pointer to the end tag
+ * RETURN:      Status, pointer to the end tag
  *
  * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
  *
index d371ec6b9812cbffd13fe71ee00c632064bdd8c9..08eafece3eed900d8c6f124fa7023b2bb2126a7b 100644 (file)
@@ -63,7 +63,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20051102
+#define ACPI_CA_VERSION                 0x20051117
 
 /*
  * OS name, used for the _OS object.  The _OS object is essentially obsolete,
 
 #define ACPI_CA_SUPPORT_LEVEL           3
 
-/* String size constants */
-
-#define ACPI_MAX_STRING_LENGTH          512
-#define ACPI_PATHNAME_MAX               256    /* A full namespace pathname */
-
 /* Maximum count for a semaphore object */
 
 #define ACPI_MAX_SEMAPHORE_COUNT        256
 #define ACPI_METHOD_NUM_ARGS            7
 #define ACPI_METHOD_MAX_ARG             6
 
-/* Maximum length of resulting string when converting from a buffer */
-
-#define ACPI_MAX_STRING_CONVERSION      200
-
-/* Length of _HID, _UID, and _CID values */
+/* Length of _HID, _UID, _CID, and UUID values */
 
 #define ACPI_DEVICE_ID_LENGTH           0x09
 #define ACPI_MAX_CID_LENGTH             48
+#define ACPI_UUID_LENGTH                16
 
 /*
  * Operand Stack (in WALK_STATE), Must be large enough to contain METHOD_MAX_ARG
index cef51b1ddf947b15987b205e37e33c435dbf5f40..bd344e51313bffd623b1967ff3112e7ea52f85df 100644 (file)
@@ -223,6 +223,7 @@ ACPI_EXTERN u32 acpi_gbl_ps_find_count;
 ACPI_EXTERN u32 acpi_gbl_owner_id_mask;
 ACPI_EXTERN u16 acpi_gbl_pm1_enable_register_save;
 ACPI_EXTERN u16 acpi_gbl_global_lock_handle;
+ACPI_EXTERN u8 acpi_gbl_last_owner_id;
 ACPI_EXTERN u8 acpi_gbl_debugger_configuration;
 ACPI_EXTERN u8 acpi_gbl_global_lock_acquired;
 ACPI_EXTERN u8 acpi_gbl_step_to_next_call;
index dca0d40ea3955a6518fe1899fafba91b74e128af..0cb61a72d97157d46c1a45e5b10161413f2da493 100644 (file)
@@ -573,6 +573,8 @@ struct acpi_parse_obj_named {
 
 /* The parse node is the fundamental element of the parse tree */
 
+#define ACPI_MAX_PARSEOP_NAME   20
+
 struct acpi_parse_obj_asl {
        ACPI_PARSE_COMMON union acpi_parse_object *child;
        union acpi_parse_object *parent_method;
@@ -597,7 +599,7 @@ struct acpi_parse_obj_asl {
        u8 aml_opcode_length;
        u8 aml_pkg_len_bytes;
        u8 extra;
-       char parse_op_name[12];
+       char parse_op_name[ACPI_MAX_PARSEOP_NAME];
 };
 
 union acpi_parse_object {
index e42222c3d34cde066b63eb6f71fde10f9c9a1054..5b78ff4091b9ddd16d0a58cbb1540cda2b69dbfe 100644 (file)
  * Extract a byte of data using a pointer.  Any more than a byte and we
  * get into potential aligment issues -- see the STORE macros below
  */
-#define ACPI_GET8(addr)                 (*(u8*)(addr))
+#define ACPI_GET8(ptr)                  *ACPI_CAST_PTR (u8, ptr)
+#define ACPI_GET16(ptr)                 *ACPI_CAST_PTR (u16, ptr)
+#define ACPI_GET32(ptr)                 *ACPI_CAST_PTR (u32, ptr)
+#define ACPI_GET64(ptr)                 *ACPI_CAST_PTR (u64, ptr)
+#define ACPI_SET8(ptr)                  *ACPI_CAST_PTR (u8, ptr)
+#define ACPI_SET16(ptr)                 *ACPI_CAST_PTR (u16, ptr)
+#define ACPI_SET32(ptr)                 *ACPI_CAST_PTR (u32, ptr)
+#define ACPI_SET64(ptr)                 *ACPI_CAST_PTR (u64, ptr)
 
-/* Pointer arithmetic */
+/* Pointer manipulation */
 
-#define ACPI_PTR_ADD(t,a,b)             (t *) (void *)((char *)(a) + (acpi_native_uint)(b))
+#define ACPI_CAST_PTR(t, p)             ((t *)(void *)(p))
+#define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **)(void *)(p))
+#define ACPI_ADD_PTR(t,a,b)             ACPI_CAST_PTR (t, (ACPI_CAST_PTR (u8, (a)) + (acpi_native_uint)(b)))
 #define ACPI_PTR_DIFF(a,b)              (acpi_native_uint) ((char *)(a) - (char *)(b))
 
 /* Pointer/Integer type conversions */
 
-#define ACPI_TO_POINTER(i)              ACPI_PTR_ADD (void, (void *) NULL,(acpi_native_uint)i)
+#define ACPI_TO_POINTER(i)              ACPI_ADD_PTR (void, (void *) NULL,(acpi_native_uint)i)
 #define ACPI_TO_INTEGER(p)              ACPI_PTR_DIFF (p,(void *) NULL)
 #define ACPI_OFFSET(d,f)                (acpi_size) ACPI_PTR_DIFF (&(((d *)0)->f),(void *) NULL)
 #define ACPI_FADT_OFFSET(f)             ACPI_OFFSET (FADT_DESCRIPTOR, f)
 
-#define ACPI_CAST_PTR(t, p)             ((t *)(void *)(p))
-#define ACPI_CAST_INDIRECT_PTR(t, p)    ((t **)(void *)(p))
-
 #if ACPI_MACHINE_WIDTH == 16
 #define ACPI_STORE_POINTER(d,s)         ACPI_MOVE_32_TO_32(d,s)
 #define ACPI_PHYSADDR_TO_PTR(i)         (void *)(i)
 #define ACPI_REGISTER_PREPARE_BITS(val, pos, mask)      ((val << pos) & mask)
 #define ACPI_REGISTER_INSERT_VALUE(reg, pos, mask, val)  reg = (reg & (~(mask))) | ACPI_REGISTER_PREPARE_BITS(val, pos, mask)
 
+/* Generate a UUID */
+
+#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, \
+                                                                                                 (b) & 0xFF, ((b) >> 8) & 0xFF, \
+                                                                                                 (c) & 0xFF, ((c) >> 8) & 0xFF, \
+                                                                                                 (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7)
+
 /*
  * An struct acpi_namespace_node * can appear in some contexts,
  * where a pointer to an union acpi_operand_object    can also
index 02f00a8fee031f7e9054f13e49b10b94571849c7..2a88429bc4ec00b2f4fc175a6784af64fd6940f2 100644 (file)
@@ -271,6 +271,12 @@ typedef
 acpi_status(*ACPI_WALK_RESOURCE_CALLBACK) (struct acpi_resource * resource,
                                           void *context);
 
+acpi_status
+acpi_get_vendor_resource(acpi_handle device_handle,
+                        char *name,
+                        struct acpi_vendor_uuid *uuid,
+                        struct acpi_buffer *ret_buffer);
+
 acpi_status
 acpi_get_current_resources(acpi_handle device_handle,
                           struct acpi_buffer *ret_buffer);
@@ -283,7 +289,7 @@ acpi_get_possible_resources(acpi_handle device_handle,
 
 acpi_status
 acpi_walk_resources(acpi_handle device_handle,
-                   char *path,
+                   char *name,
                    ACPI_WALK_RESOURCE_CALLBACK user_function, void *context);
 
 acpi_status
index 2bf53940f2597ecf4bd6ec3d697fad482f82569c..ba281f7740a054a256c2bacc77ce0b4d6486baa8 100644 (file)
@@ -137,9 +137,14 @@ extern struct acpi_rsconvert_info *acpi_gbl_set_resource_dispatch[];
 
 /* Resource tables indexed by raw AML resource descriptor type */
 
+extern const u8 acpi_gbl_resource_struct_sizes[];
 extern struct acpi_rsconvert_info *acpi_gbl_get_resource_dispatch[];
 
-extern const u8 acpi_gbl_resource_struct_sizes[];
+struct acpi_vendor_walk_info {
+       struct acpi_vendor_uuid *uuid;
+       struct acpi_buffer *buffer;
+       acpi_status status;
+};
 
 /*
  * rscreate
index 29b887017b18e8fbab2f91588913619121559337..11847592ed1b39bf5251ecf6019f0b3044642c2e 100644 (file)
@@ -326,7 +326,7 @@ typedef u64 acpi_integer;
 /*
  * Constants with special meanings
  */
-#define ACPI_ROOT_OBJECT                (acpi_handle) ACPI_PTR_ADD (char, NULL, ACPI_MAX_PTR)
+#define ACPI_ROOT_OBJECT                ACPI_ADD_PTR (acpi_handle, NULL, ACPI_MAX_PTR)
 
 /*
  * Initialization sequence
@@ -986,6 +986,17 @@ typedef u32 acpi_rsdesc_size;      /* Max Resource Descriptor size is (length+3) = (6
 #pragma pack(1)
 #endif
 
+/* UUID data structures for use in vendor-defined resource descriptors */
+
+struct acpi_uuid {
+       u8 data[ACPI_UUID_LENGTH];
+};
+
+struct acpi_vendor_uuid {
+       u8 subtype;
+       u8 data[ACPI_UUID_LENGTH];
+};
+
 /*
  *  Structures used to describe device resources
  */
@@ -1033,6 +1044,15 @@ struct acpi_resource_vendor {
        u8 byte_data[1];
 };
 
+/* Vendor resource with UUID info (introduced in ACPI 3.0) */
+
+struct acpi_resource_vendor_typed {
+       u16 byte_length;
+       u8 uuid_subtype;
+       u8 uuid[ACPI_UUID_LENGTH];
+       u8 byte_data[1];
+};
+
 struct acpi_resource_end_tag {
        u8 checksum;
 };
@@ -1184,6 +1204,7 @@ union acpi_resource_data {
        struct acpi_resource_io io;
        struct acpi_resource_fixed_io fixed_io;
        struct acpi_resource_vendor vendor;
+       struct acpi_resource_vendor_typed vendor_typed;
        struct acpi_resource_end_tag end_tag;
        struct acpi_resource_memory24 memory24;
        struct acpi_resource_memory32 memory32;
index c93e6562f0e1312ef857a715db84c3379de2d138..1b9cbf05b79eacb0213f5b478fb66e833343f4db 100644 (file)
 #define acpi_cache_t   kmem_cache_t
 #endif
 
+/* Full namespace pathname length limit - arbitrary */
+
+#define ACPI_PATHNAME_MAX              256
+
 #else                          /* !__KERNEL__ */
 
 #include <stdarg.h>