Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /****************************************************************************** |
| 3 | * |
| 4 | * Module Name: excreate - Named object creation |
| 5 | * |
Bob Moore | 840c02c | 2019-01-14 09:55:25 -0800 | [diff] [blame] | 6 | * Copyright (C) 2000 - 2019, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
Erik Schmauss | 9585763 | 2018-03-14 16:13:07 -0700 | [diff] [blame] | 8 | *****************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 11 | #include "accommon.h" |
| 12 | #include "acinterp.h" |
| 13 | #include "amlcode.h" |
| 14 | #include "acnamesp.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #define _COMPONENT ACPI_EXECUTER |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 17 | ACPI_MODULE_NAME("excreate") |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 18 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | * |
| 20 | * FUNCTION: acpi_ex_create_alias |
| 21 | * |
| 22 | * PARAMETERS: walk_state - Current state, contains operands |
| 23 | * |
| 24 | * RETURN: Status |
| 25 | * |
| 26 | * DESCRIPTION: Create a new named alias |
| 27 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 28 | ******************************************************************************/ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 29 | acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 31 | struct acpi_namespace_node *target_node; |
| 32 | struct acpi_namespace_node *alias_node; |
| 33 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 35 | ACPI_FUNCTION_TRACE(ex_create_alias); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
| 37 | /* Get the source/alias operands (both namespace nodes) */ |
| 38 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 39 | alias_node = (struct acpi_namespace_node *)walk_state->operands[0]; |
| 40 | target_node = (struct acpi_namespace_node *)walk_state->operands[1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) || |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 43 | (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | /* |
| 45 | * Dereference an existing alias so that we don't create a chain |
Bob Moore | 73a3090 | 2012-10-31 02:26:55 +0000 | [diff] [blame] | 46 | * of aliases. With this code, we guarantee that an alias is |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | * always exactly one level of indirection away from the |
| 48 | * actual aliased name. |
| 49 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | target_node = |
| 51 | ACPI_CAST_PTR(struct acpi_namespace_node, |
| 52 | target_node->object); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Alex James | 4e6cbe5 | 2017-07-10 15:24:02 +0800 | [diff] [blame] | 55 | /* Ensure that the target node is valid */ |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 56 | |
Alex James | 4e6cbe5 | 2017-07-10 15:24:02 +0800 | [diff] [blame] | 57 | if (!target_node) { |
| 58 | return_ACPI_STATUS(AE_NULL_OBJECT); |
| 59 | } |
| 60 | |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 61 | /* Construct the alias object (a namespace node) */ |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | switch (target_node->type) { |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 64 | case ACPI_TYPE_METHOD: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | /* |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 66 | * Control method aliases need to be differentiated with |
| 67 | * a special type |
Bob Moore | 53cf174 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 68 | */ |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 69 | alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS; |
| 70 | break; |
| 71 | |
| 72 | default: |
Bob Moore | 53cf174 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 73 | /* |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 74 | * All other object types. |
| 75 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | * The new alias has the type ALIAS and points to the original |
Bob Moore | 53cf174 | 2008-04-10 19:06:39 +0400 | [diff] [blame] | 77 | * NS node, not the object itself. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | */ |
| 79 | alias_node->type = ACPI_TYPE_LOCAL_ALIAS; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 80 | alias_node->object = |
| 81 | ACPI_CAST_PTR(union acpi_operand_object, target_node); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | /* Since both operands are Nodes, we don't need to delete them */ |
| 86 | |
Bob Moore | a5b6e98 | 2017-08-03 14:27:09 +0800 | [diff] [blame] | 87 | alias_node->object = |
| 88 | ACPI_CAST_PTR(union acpi_operand_object, target_node); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 89 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 92 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | * |
| 94 | * FUNCTION: acpi_ex_create_event |
| 95 | * |
| 96 | * PARAMETERS: walk_state - Current state |
| 97 | * |
| 98 | * RETURN: Status |
| 99 | * |
| 100 | * DESCRIPTION: Create a new event object |
| 101 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 102 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 104 | acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 106 | acpi_status status; |
| 107 | union acpi_operand_object *obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 109 | ACPI_FUNCTION_TRACE(ex_create_event); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 111 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | if (!obj_desc) { |
| 113 | status = AE_NO_MEMORY; |
| 114 | goto cleanup; |
| 115 | } |
| 116 | |
| 117 | /* |
| 118 | * Create the actual OS semaphore, with zero initial units -- meaning |
| 119 | * that the event is created in an unsignalled state |
| 120 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 121 | status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0, |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 122 | &obj_desc->event.os_semaphore); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 123 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | goto cleanup; |
| 125 | } |
| 126 | |
| 127 | /* Attach object to the Node */ |
| 128 | |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 129 | status = acpi_ns_attach_object((struct acpi_namespace_node *) |
| 130 | walk_state->operands[0], obj_desc, |
| 131 | ACPI_TYPE_EVENT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 133 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | /* |
| 135 | * Remove local reference to the object (on error, will cause deletion |
| 136 | * of both object and semaphore if present.) |
| 137 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 138 | acpi_ut_remove_reference(obj_desc); |
| 139 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | } |
| 141 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 142 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | * |
| 144 | * FUNCTION: acpi_ex_create_mutex |
| 145 | * |
| 146 | * PARAMETERS: walk_state - Current state |
| 147 | * |
| 148 | * RETURN: Status |
| 149 | * |
| 150 | * DESCRIPTION: Create a new mutex object |
| 151 | * |
| 152 | * Mutex (Name[0], sync_level[1]) |
| 153 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 154 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 156 | acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 158 | acpi_status status = AE_OK; |
| 159 | union acpi_operand_object *obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 160 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 161 | ACPI_FUNCTION_TRACE_PTR(ex_create_mutex, ACPI_WALK_OPERANDS); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
| 163 | /* Create the new mutex object */ |
| 164 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 165 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | if (!obj_desc) { |
| 167 | status = AE_NO_MEMORY; |
| 168 | goto cleanup; |
| 169 | } |
| 170 | |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 171 | /* Create the actual OS Mutex */ |
| 172 | |
| 173 | status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 174 | if (ACPI_FAILURE(status)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | goto cleanup; |
| 176 | } |
| 177 | |
| 178 | /* Init object and attach to NS node */ |
| 179 | |
Lv Zheng | 1f86e8c | 2012-10-31 02:25:45 +0000 | [diff] [blame] | 180 | obj_desc->mutex.sync_level = (u8)walk_state->operands[1]->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 181 | obj_desc->mutex.node = |
| 182 | (struct acpi_namespace_node *)walk_state->operands[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 184 | status = |
| 185 | acpi_ns_attach_object(obj_desc->mutex.node, obj_desc, |
| 186 | ACPI_TYPE_MUTEX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 188 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | /* |
| 190 | * Remove local reference to the object (on error, will cause deletion |
| 191 | * of both object and semaphore if present.) |
| 192 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 193 | acpi_ut_remove_reference(obj_desc); |
| 194 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 197 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | * |
| 199 | * FUNCTION: acpi_ex_create_region |
| 200 | * |
| 201 | * PARAMETERS: aml_start - Pointer to the region declaration AML |
| 202 | * aml_length - Max length of the declaration AML |
Bob Moore | ec46366 | 2011-11-30 09:35:05 +0800 | [diff] [blame] | 203 | * space_id - Address space ID for the region |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | * walk_state - Current state |
| 205 | * |
| 206 | * RETURN: Status |
| 207 | * |
| 208 | * DESCRIPTION: Create a new operation region object |
| 209 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 210 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | |
| 212 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | acpi_ex_create_region(u8 * aml_start, |
| 214 | u32 aml_length, |
Bob Moore | ec46366 | 2011-11-30 09:35:05 +0800 | [diff] [blame] | 215 | u8 space_id, struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 217 | acpi_status status; |
| 218 | union acpi_operand_object *obj_desc; |
| 219 | struct acpi_namespace_node *node; |
| 220 | union acpi_operand_object *region_obj2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 222 | ACPI_FUNCTION_TRACE(ex_create_region); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
| 224 | /* Get the Namespace Node */ |
| 225 | |
| 226 | node = walk_state->op->common.node; |
| 227 | |
| 228 | /* |
| 229 | * If the region object is already attached to this node, |
| 230 | * just return |
| 231 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | if (acpi_ns_get_attached_object(node)) { |
| 233 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | /* |
| 237 | * Space ID must be one of the predefined IDs, or in the user-defined |
| 238 | * range |
| 239 | */ |
Bob Moore | ec46366 | 2011-11-30 09:35:05 +0800 | [diff] [blame] | 240 | if (!acpi_is_valid_space_id(space_id)) { |
| 241 | /* |
| 242 | * Print an error message, but continue. We don't want to abort |
| 243 | * a table load for this exception. Instead, if the region is |
| 244 | * actually used at runtime, abort the executing method. |
| 245 | */ |
| 246 | ACPI_ERROR((AE_INFO, |
| 247 | "Invalid/unknown Address Space ID: 0x%2.2X", |
| 248 | space_id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Bob Moore | f6a22b0 | 2010-03-05 17:56:40 +0800 | [diff] [blame] | 251 | ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n", |
Bob Moore | ec46366 | 2011-11-30 09:35:05 +0800 | [diff] [blame] | 252 | acpi_ut_get_region_name(space_id), space_id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | |
| 254 | /* Create the region descriptor */ |
| 255 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 256 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | if (!obj_desc) { |
| 258 | status = AE_NO_MEMORY; |
| 259 | goto cleanup; |
| 260 | } |
| 261 | |
| 262 | /* |
| 263 | * Remember location in AML stream of address & length |
| 264 | * operands since they need to be evaluated at run time. |
| 265 | */ |
Lv Zheng | 849c257 | 2015-12-29 14:02:58 +0800 | [diff] [blame] | 266 | region_obj2 = acpi_ns_get_secondary_object(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | region_obj2->extra.aml_start = aml_start; |
| 268 | region_obj2->extra.aml_length = aml_length; |
Lv Zheng | 849c257 | 2015-12-29 14:02:58 +0800 | [diff] [blame] | 269 | region_obj2->extra.method_REG = NULL; |
Lin Ming | 8931d9e | 2011-11-28 09:46:02 +0800 | [diff] [blame] | 270 | if (walk_state->scope_info) { |
| 271 | region_obj2->extra.scope_node = |
| 272 | walk_state->scope_info->scope.node; |
| 273 | } else { |
| 274 | region_obj2->extra.scope_node = node; |
| 275 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | /* Init the region from the operands */ |
| 278 | |
Bob Moore | ec46366 | 2011-11-30 09:35:05 +0800 | [diff] [blame] | 279 | obj_desc->region.space_id = space_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | obj_desc->region.address = 0; |
| 281 | obj_desc->region.length = 0; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 | obj_desc->region.node = node; |
Lv Zheng | 849c257 | 2015-12-29 14:02:58 +0800 | [diff] [blame] | 283 | obj_desc->region.handler = NULL; |
| 284 | obj_desc->common.flags &= |
Lv Zheng | efaed9b | 2015-12-29 14:03:08 +0800 | [diff] [blame] | 285 | ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED | |
| 286 | AOPOBJ_OBJECT_INITIALIZED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
| 288 | /* Install the new region object in the parent Node */ |
| 289 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 290 | status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 292 | cleanup: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
| 294 | /* Remove local reference to the object */ |
| 295 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 296 | acpi_ut_remove_reference(obj_desc); |
| 297 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 300 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | * FUNCTION: acpi_ex_create_processor |
| 303 | * |
| 304 | * PARAMETERS: walk_state - Current state |
| 305 | * |
| 306 | * RETURN: Status |
| 307 | * |
| 308 | * DESCRIPTION: Create a new processor object and populate the fields |
| 309 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 310 | * Processor (Name[0], cpu_ID[1], pblock_addr[2], pblock_length[3]) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 312 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 314 | acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 316 | union acpi_operand_object **operand = &walk_state->operands[0]; |
| 317 | union acpi_operand_object *obj_desc; |
| 318 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 320 | ACPI_FUNCTION_TRACE_PTR(ex_create_processor, walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | |
| 322 | /* Create the processor object */ |
| 323 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 324 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PROCESSOR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
| 328 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 329 | /* Initialize the processor object from the operands */ |
| 330 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 331 | obj_desc->processor.proc_id = (u8) operand[1]->integer.value; |
Bob Moore | 61686124 | 2006-03-17 16:44:00 -0500 | [diff] [blame] | 332 | obj_desc->processor.length = (u8) operand[3]->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 333 | obj_desc->processor.address = |
Lv Zheng | f5c1e1c | 2016-05-05 12:57:53 +0800 | [diff] [blame] | 334 | (acpi_io_address)operand[2]->integer.value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | |
| 336 | /* Install the processor object in the parent Node */ |
| 337 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 338 | status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], |
| 339 | obj_desc, ACPI_TYPE_PROCESSOR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
| 341 | /* Remove local reference to the object */ |
| 342 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 343 | acpi_ut_remove_reference(obj_desc); |
| 344 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 347 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | * |
| 349 | * FUNCTION: acpi_ex_create_power_resource |
| 350 | * |
| 351 | * PARAMETERS: walk_state - Current state |
| 352 | * |
| 353 | * RETURN: Status |
| 354 | * |
| 355 | * DESCRIPTION: Create a new power_resource object and populate the fields |
| 356 | * |
| 357 | * power_resource (Name[0], system_level[1], resource_order[2]) |
| 358 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 359 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 360 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 361 | acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 362 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | union acpi_operand_object **operand = &walk_state->operands[0]; |
| 364 | acpi_status status; |
| 365 | union acpi_operand_object *obj_desc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 367 | ACPI_FUNCTION_TRACE_PTR(ex_create_power_resource, walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 368 | |
| 369 | /* Create the power resource object */ |
| 370 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_POWER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 372 | if (!obj_desc) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 373 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | } |
| 375 | |
| 376 | /* Initialize the power object from the operands */ |
| 377 | |
| 378 | obj_desc->power_resource.system_level = (u8) operand[1]->integer.value; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 379 | obj_desc->power_resource.resource_order = |
| 380 | (u16) operand[2]->integer.value; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
| 382 | /* Install the power resource object in the parent Node */ |
| 383 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 384 | status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], |
| 385 | obj_desc, ACPI_TYPE_POWER); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | |
| 387 | /* Remove local reference to the object */ |
| 388 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 389 | acpi_ut_remove_reference(obj_desc); |
| 390 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 393 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 394 | * |
| 395 | * FUNCTION: acpi_ex_create_method |
| 396 | * |
| 397 | * PARAMETERS: aml_start - First byte of the method's AML |
| 398 | * aml_length - AML byte count for this method |
| 399 | * walk_state - Current state |
| 400 | * |
| 401 | * RETURN: Status |
| 402 | * |
| 403 | * DESCRIPTION: Create a new method object |
| 404 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 405 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | |
| 407 | acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 408 | acpi_ex_create_method(u8 * aml_start, |
| 409 | u32 aml_length, struct acpi_walk_state *walk_state) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 411 | union acpi_operand_object **operand = &walk_state->operands[0]; |
| 412 | union acpi_operand_object *obj_desc; |
| 413 | acpi_status status; |
| 414 | u8 method_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | |
Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 416 | ACPI_FUNCTION_TRACE_PTR(ex_create_method, walk_state); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | |
| 418 | /* Create a new method object */ |
| 419 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 420 | obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | if (!obj_desc) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 422 | status = AE_NO_MEMORY; |
| 423 | goto exit; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | /* Save the method's AML pointer and length */ |
| 427 | |
| 428 | obj_desc->method.aml_start = aml_start; |
| 429 | obj_desc->method.aml_length = aml_length; |
Lv Zheng | 07b9c91 | 2015-07-23 12:52:31 +0800 | [diff] [blame] | 430 | obj_desc->method.node = operand[0]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 431 | |
| 432 | /* |
Lin Ming | 2629484 | 2011-01-12 09:19:43 +0800 | [diff] [blame] | 433 | * Disassemble the method flags. Split off the arg_count, Serialized |
| 434 | * flag, and sync_level for efficiency. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | */ |
Lv Zheng | 5431b65 | 2015-12-29 13:52:32 +0800 | [diff] [blame] | 436 | method_flags = (u8)operand[1]->integer.value; |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 437 | obj_desc->method.param_count = (u8) |
| 438 | (method_flags & AML_METHOD_ARG_COUNT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 439 | |
| 440 | /* |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 441 | * Get the sync_level. If method is serialized, a mutex will be |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 442 | * created for this method when it is parsed. |
| 443 | */ |
Len Brown | 4d2acd9 | 2007-05-09 22:56:38 -0400 | [diff] [blame] | 444 | if (method_flags & AML_METHOD_SERIALIZED) { |
Lin Ming | 2629484 | 2011-01-12 09:19:43 +0800 | [diff] [blame] | 445 | obj_desc->method.info_flags = ACPI_METHOD_SERIALIZED; |
| 446 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | /* |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 448 | * ACPI 1.0: sync_level = 0 |
| 449 | * ACPI 2.0: sync_level = sync_level in method declaration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | */ |
Bob Moore | 967440e3 | 2006-06-23 17:04:00 -0400 | [diff] [blame] | 451 | obj_desc->method.sync_level = (u8) |
Lin Ming | b2f7ddc | 2009-05-21 10:42:09 +0800 | [diff] [blame] | 452 | ((method_flags & AML_METHOD_SYNC_LEVEL) >> 4); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | } |
| 454 | |
| 455 | /* Attach the new object to the method Node */ |
| 456 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 457 | status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0], |
| 458 | obj_desc, ACPI_TYPE_METHOD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | |
| 460 | /* Remove local reference to the object */ |
| 461 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 462 | acpi_ut_remove_reference(obj_desc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 463 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 464 | exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | /* Remove a reference to the operand */ |
| 466 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 467 | acpi_ut_remove_reference(operand[1]); |
| 468 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 469 | } |