m68k: dnfb doesnt check for Apollo
[safe/jmp/linux-2.6] / drivers / acpi / executer / excreate.c
index da313da..60e62c4 100644 (file)
@@ -5,7 +5,7 @@
  *****************************************************************************/
 
 /*
- * Copyright (C) 2000 - 2006, R. Byron Moore
+ * Copyright (C) 2000 - 2008, Intel Corp.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,6 @@
 
 #define _COMPONENT          ACPI_EXECUTER
 ACPI_MODULE_NAME("excreate")
-
 #ifndef ACPI_NO_METHOD_EXECUTION
 /*******************************************************************************
  *
@@ -69,7 +68,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
        struct acpi_namespace_node *alias_node;
        acpi_status status = AE_OK;
 
-       ACPI_FUNCTION_TRACE("ex_create_alias");
+       ACPI_FUNCTION_TRACE(ex_create_alias);
 
        /* Get the source/alias operands (both namespace nodes) */
 
@@ -97,6 +96,9 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
         * to the original Node.
         */
        switch (target_node->type) {
+
+               /* For these types, the sub-object can change dynamically via a Store */
+
        case ACPI_TYPE_INTEGER:
        case ACPI_TYPE_STRING:
        case ACPI_TYPE_BUFFER:
@@ -104,9 +106,18 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
        case ACPI_TYPE_BUFFER_FIELD:
 
                /*
+                * These types open a new scope, so we need the NS node in order to access
+                * any children.
+                */
+       case ACPI_TYPE_DEVICE:
+       case ACPI_TYPE_POWER:
+       case ACPI_TYPE_PROCESSOR:
+       case ACPI_TYPE_THERMAL:
+       case ACPI_TYPE_LOCAL_SCOPE:
+
+               /*
                 * The new alias has the type ALIAS and points to the original
-                * NS node, not the object itself.  This is because for these
-                * types, the object can change dynamically via a Store.
+                * NS node, not the object itself.
                 */
                alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
                alias_node->object =
@@ -116,9 +127,7 @@ acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
        case ACPI_TYPE_METHOD:
 
                /*
-                * The new alias has the type ALIAS and points to the original
-                * NS node, not the object itself.  This is because for these
-                * types, the object can change dynamically via a Store.
+                * Control method aliases need to be differentiated
                 */
                alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
                alias_node->object =
@@ -164,7 +173,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
        acpi_status status;
        union acpi_operand_object *obj_desc;
 
-       ACPI_FUNCTION_TRACE("ex_create_event");
+       ACPI_FUNCTION_TRACE(ex_create_event);
 
        obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT);
        if (!obj_desc) {
@@ -177,7 +186,7 @@ acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
         * that the event is created in an unsignalled state
         */
        status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
-                                         &obj_desc->event.semaphore);
+                                         &obj_desc->event.os_semaphore);
        if (ACPI_FAILURE(status)) {
                goto cleanup;
        }
@@ -216,7 +225,7 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
        acpi_status status = AE_OK;
        union acpi_operand_object *obj_desc;
 
-       ACPI_FUNCTION_TRACE_PTR("ex_create_mutex", ACPI_WALK_OPERANDS);
+       ACPI_FUNCTION_TRACE_PTR(ex_create_mutex, ACPI_WALK_OPERANDS);
 
        /* Create the new mutex object */
 
@@ -226,12 +235,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
                goto cleanup;
        }
 
-       /*
-        * Create the actual OS semaphore.
-        * One unit max to make it a mutex, with one initial unit to allow
-        * the mutex to be acquired.
-        */
-       status = acpi_os_create_semaphore(1, 1, &obj_desc->mutex.semaphore);
+       /* Create the actual OS Mutex */
+
+       status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);
        if (ACPI_FAILURE(status)) {
                goto cleanup;
        }
@@ -243,8 +249,9 @@ acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
        obj_desc->mutex.node =
            (struct acpi_namespace_node *)walk_state->operands[0];
 
-       status = acpi_ns_attach_object(obj_desc->mutex.node,
-                                      obj_desc, ACPI_TYPE_MUTEX);
+       status =
+           acpi_ns_attach_object(obj_desc->mutex.node, obj_desc,
+                                 ACPI_TYPE_MUTEX);
 
       cleanup:
        /*
@@ -280,7 +287,7 @@ acpi_ex_create_region(u8 * aml_start,
        struct acpi_namespace_node *node;
        union acpi_operand_object *region_obj2;
 
-       ACPI_FUNCTION_TRACE("ex_create_region");
+       ACPI_FUNCTION_TRACE(ex_create_region);
 
        /* Get the Namespace Node */
 
@@ -300,8 +307,8 @@ acpi_ex_create_region(u8 * aml_start,
         */
        if ((region_space >= ACPI_NUM_PREDEFINED_REGIONS) &&
            (region_space < ACPI_USER_REGION_BEGIN)) {
-               ACPI_REPORT_ERROR(("Invalid address_space type %X\n",
-                                  region_space));
+               ACPI_ERROR((AE_INFO, "Invalid AddressSpace type %X",
+                           region_space));
                return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
        }
 
@@ -345,95 +352,6 @@ acpi_ex_create_region(u8 * aml_start,
 
 /*******************************************************************************
  *
- * FUNCTION:    acpi_ex_create_table_region
- *
- * PARAMETERS:  walk_state          - Current state
- *
- * RETURN:      Status
- *
- * DESCRIPTION: Create a new data_table_region object
- *
- ******************************************************************************/
-
-acpi_status acpi_ex_create_table_region(struct acpi_walk_state *walk_state)
-{
-       acpi_status status;
-       union acpi_operand_object **operand = &walk_state->operands[0];
-       union acpi_operand_object *obj_desc;
-       struct acpi_namespace_node *node;
-       struct acpi_table_header *table;
-       union acpi_operand_object *region_obj2;
-
-       ACPI_FUNCTION_TRACE("ex_create_table_region");
-
-       /* Get the Node from the object stack  */
-
-       node = walk_state->op->common.node;
-
-       /*
-        * If the region object is already attached to this node,
-        * just return
-        */
-       if (acpi_ns_get_attached_object(node)) {
-               return_ACPI_STATUS(AE_OK);
-       }
-
-       /* Find the ACPI table */
-
-       status = acpi_tb_find_table(operand[1]->string.pointer,
-                                   operand[2]->string.pointer,
-                                   operand[3]->string.pointer, &table);
-       if (ACPI_FAILURE(status)) {
-               return_ACPI_STATUS(status);
-       }
-
-       /* Create the region descriptor */
-
-       obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
-       if (!obj_desc) {
-               return_ACPI_STATUS(AE_NO_MEMORY);
-       }
-
-       region_obj2 = obj_desc->common.next_object;
-       region_obj2->extra.region_context = NULL;
-
-       /* Init the region from the operands */
-
-       obj_desc->region.space_id = REGION_DATA_TABLE;
-       obj_desc->region.address =
-           (acpi_physical_address) ACPI_TO_INTEGER(table);
-       obj_desc->region.length = table->length;
-       obj_desc->region.node = node;
-       obj_desc->region.flags = AOPOBJ_DATA_VALID;
-
-       /* Install the new region object in the parent Node */
-
-       status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
-       if (ACPI_FAILURE(status)) {
-               goto cleanup;
-       }
-
-       status = acpi_ev_initialize_region(obj_desc, FALSE);
-       if (ACPI_FAILURE(status)) {
-               if (status == AE_NOT_EXIST) {
-                       status = AE_OK;
-               } else {
-                       goto cleanup;
-               }
-       }
-
-       obj_desc->region.flags |= AOPOBJ_SETUP_COMPLETE;
-
-      cleanup:
-
-       /* Remove local reference to the object */
-
-       acpi_ut_remove_reference(obj_desc);
-       return_ACPI_STATUS(status);
-}
-
-/*******************************************************************************
- *
  * FUNCTION:    acpi_ex_create_processor
  *
  * PARAMETERS:  walk_state          - Current state
@@ -452,7 +370,7 @@ acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
        union acpi_operand_object *obj_desc;
        acpi_status status;
 
-       ACPI_FUNCTION_TRACE_PTR("ex_create_processor", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ex_create_processor, walk_state);
 
        /* Create the processor object */
 
@@ -464,9 +382,9 @@ acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
        /* Initialize the processor object from the operands */
 
        obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
+       obj_desc->processor.length = (u8) operand[3]->integer.value;
        obj_desc->processor.address =
            (acpi_io_address) operand[2]->integer.value;
-       obj_desc->processor.length = (u8) operand[3]->integer.value;
 
        /* Install the processor object in the parent Node */
 
@@ -499,7 +417,7 @@ acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state)
        acpi_status status;
        union acpi_operand_object *obj_desc;
 
-       ACPI_FUNCTION_TRACE_PTR("ex_create_power_resource", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ex_create_power_resource, walk_state);
 
        /* Create the power resource object */
 
@@ -549,13 +467,14 @@ acpi_ex_create_method(u8 * aml_start,
        acpi_status status;
        u8 method_flags;
 
-       ACPI_FUNCTION_TRACE_PTR("ex_create_method", walk_state);
+       ACPI_FUNCTION_TRACE_PTR(ex_create_method, walk_state);
 
        /* Create a new method object */
 
        obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
        if (!obj_desc) {
-               return_ACPI_STATUS(AE_NO_MEMORY);
+               status = AE_NO_MEMORY;
+               goto exit;
        }
 
        /* Save the method's AML pointer and length  */
@@ -564,7 +483,7 @@ acpi_ex_create_method(u8 * aml_start,
        obj_desc->method.aml_length = aml_length;
 
        /*
-        * Disassemble the method flags.  Split off the Arg Count
+        * Disassemble the method flags. Split off the Arg Count
         * for efficiency
         */
        method_flags = (u8) operand[1]->integer.value;
@@ -575,21 +494,16 @@ acpi_ex_create_method(u8 * aml_start,
            (u8) (method_flags & AML_METHOD_ARG_COUNT);
 
        /*
-        * Get the concurrency count.  If required, a semaphore will be
+        * Get the sync_level. If method is serialized, a mutex will be
         * created for this method when it is parsed.
         */
-       if (acpi_gbl_all_methods_serialized) {
-               obj_desc->method.concurrency = 1;
-               obj_desc->method.method_flags |= AML_METHOD_SERIALIZED;
-       } else if (method_flags & AML_METHOD_SERIALIZED) {
+       if (method_flags & AML_METHOD_SERIALIZED) {
                /*
-                * ACPI 1.0: Concurrency = 1
-                * ACPI 2.0: Concurrency = (sync_level (in method declaration) + 1)
+                * ACPI 1.0: sync_level = 0
+                * ACPI 2.0: sync_level = sync_level in method declaration
                 */
-               obj_desc->method.concurrency = (u8)
-                   (((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4) + 1);
-       } else {
-               obj_desc->method.concurrency = ACPI_INFINITE_CONCURRENCY;
+               obj_desc->method.sync_level = (u8)
+                   ((method_flags & AML_METHOD_SYNCH_LEVEL) >> 4);
        }
 
        /* Attach the new object to the method Node */
@@ -601,6 +515,7 @@ acpi_ex_create_method(u8 * aml_start,
 
        acpi_ut_remove_reference(obj_desc);
 
+      exit:
        /* Remove a reference to the operand */
 
        acpi_ut_remove_reference(operand[1]);