0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <acpi/acpi.h>
0011 #include "accommon.h"
0012 #include "acinterp.h"
0013 #include "amlcode.h"
0014 #include "acnamesp.h"
0015
0016 #define _COMPONENT ACPI_EXECUTER
0017 ACPI_MODULE_NAME("excreate")
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029 acpi_status acpi_ex_create_alias(struct acpi_walk_state *walk_state)
0030 {
0031 struct acpi_namespace_node *target_node;
0032 struct acpi_namespace_node *alias_node;
0033 acpi_status status = AE_OK;
0034
0035 ACPI_FUNCTION_TRACE(ex_create_alias);
0036
0037
0038
0039 alias_node = (struct acpi_namespace_node *)walk_state->operands[0];
0040 target_node = (struct acpi_namespace_node *)walk_state->operands[1];
0041
0042 if ((target_node->type == ACPI_TYPE_LOCAL_ALIAS) ||
0043 (target_node->type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
0044
0045
0046
0047
0048
0049
0050 target_node =
0051 ACPI_CAST_PTR(struct acpi_namespace_node,
0052 target_node->object);
0053 }
0054
0055
0056
0057 if (!target_node) {
0058 return_ACPI_STATUS(AE_NULL_OBJECT);
0059 }
0060
0061
0062
0063 switch (target_node->type) {
0064 case ACPI_TYPE_METHOD:
0065
0066
0067
0068
0069 alias_node->type = ACPI_TYPE_LOCAL_METHOD_ALIAS;
0070 break;
0071
0072 default:
0073
0074
0075
0076
0077
0078
0079 alias_node->type = ACPI_TYPE_LOCAL_ALIAS;
0080 alias_node->object =
0081 ACPI_CAST_PTR(union acpi_operand_object, target_node);
0082 break;
0083 }
0084
0085
0086
0087 alias_node->object =
0088 ACPI_CAST_PTR(union acpi_operand_object, target_node);
0089 return_ACPI_STATUS(status);
0090 }
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104 acpi_status acpi_ex_create_event(struct acpi_walk_state *walk_state)
0105 {
0106 acpi_status status;
0107 union acpi_operand_object *obj_desc;
0108
0109 ACPI_FUNCTION_TRACE(ex_create_event);
0110
0111 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_EVENT);
0112 if (!obj_desc) {
0113 status = AE_NO_MEMORY;
0114 goto cleanup;
0115 }
0116
0117
0118
0119
0120
0121 status = acpi_os_create_semaphore(ACPI_NO_UNIT_LIMIT, 0,
0122 &obj_desc->event.os_semaphore);
0123 if (ACPI_FAILURE(status)) {
0124 goto cleanup;
0125 }
0126
0127
0128
0129 status = acpi_ns_attach_object((struct acpi_namespace_node *)
0130 walk_state->operands[0], obj_desc,
0131 ACPI_TYPE_EVENT);
0132
0133 cleanup:
0134
0135
0136
0137
0138 acpi_ut_remove_reference(obj_desc);
0139 return_ACPI_STATUS(status);
0140 }
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156 acpi_status acpi_ex_create_mutex(struct acpi_walk_state *walk_state)
0157 {
0158 acpi_status status = AE_OK;
0159 union acpi_operand_object *obj_desc;
0160
0161 ACPI_FUNCTION_TRACE_PTR(ex_create_mutex, ACPI_WALK_OPERANDS);
0162
0163
0164
0165 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_MUTEX);
0166 if (!obj_desc) {
0167 status = AE_NO_MEMORY;
0168 goto cleanup;
0169 }
0170
0171
0172
0173 status = acpi_os_create_mutex(&obj_desc->mutex.os_mutex);
0174 if (ACPI_FAILURE(status)) {
0175 goto cleanup;
0176 }
0177
0178
0179
0180 obj_desc->mutex.sync_level = (u8)walk_state->operands[1]->integer.value;
0181 obj_desc->mutex.node =
0182 (struct acpi_namespace_node *)walk_state->operands[0];
0183
0184 status =
0185 acpi_ns_attach_object(obj_desc->mutex.node, obj_desc,
0186 ACPI_TYPE_MUTEX);
0187
0188 cleanup:
0189
0190
0191
0192
0193 acpi_ut_remove_reference(obj_desc);
0194 return_ACPI_STATUS(status);
0195 }
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212 acpi_status
0213 acpi_ex_create_region(u8 * aml_start,
0214 u32 aml_length,
0215 u8 space_id, struct acpi_walk_state *walk_state)
0216 {
0217 acpi_status status;
0218 union acpi_operand_object *obj_desc;
0219 struct acpi_namespace_node *node;
0220 union acpi_operand_object *region_obj2;
0221
0222 ACPI_FUNCTION_TRACE(ex_create_region);
0223
0224
0225
0226 node = walk_state->op->common.node;
0227
0228
0229
0230
0231
0232 if (acpi_ns_get_attached_object(node)) {
0233 return_ACPI_STATUS(AE_OK);
0234 }
0235
0236
0237
0238
0239
0240 if (!acpi_is_valid_space_id(space_id)) {
0241
0242
0243
0244
0245
0246 ACPI_ERROR((AE_INFO,
0247 "Invalid/unknown Address Space ID: 0x%2.2X",
0248 space_id));
0249 }
0250
0251 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "Region Type - %s (0x%X)\n",
0252 acpi_ut_get_region_name(space_id), space_id));
0253
0254
0255
0256 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_REGION);
0257 if (!obj_desc) {
0258 status = AE_NO_MEMORY;
0259 goto cleanup;
0260 }
0261
0262
0263
0264
0265
0266 region_obj2 = acpi_ns_get_secondary_object(obj_desc);
0267 region_obj2->extra.aml_start = aml_start;
0268 region_obj2->extra.aml_length = aml_length;
0269 region_obj2->extra.method_REG = NULL;
0270 if (walk_state->scope_info) {
0271 region_obj2->extra.scope_node =
0272 walk_state->scope_info->scope.node;
0273 } else {
0274 region_obj2->extra.scope_node = node;
0275 }
0276
0277
0278
0279 obj_desc->region.space_id = space_id;
0280 obj_desc->region.address = 0;
0281 obj_desc->region.length = 0;
0282 obj_desc->region.pointer = NULL;
0283 obj_desc->region.node = node;
0284 obj_desc->region.handler = NULL;
0285 obj_desc->common.flags &=
0286 ~(AOPOBJ_SETUP_COMPLETE | AOPOBJ_REG_CONNECTED |
0287 AOPOBJ_OBJECT_INITIALIZED);
0288
0289
0290
0291 status = acpi_ns_attach_object(node, obj_desc, ACPI_TYPE_REGION);
0292
0293 cleanup:
0294
0295
0296
0297 acpi_ut_remove_reference(obj_desc);
0298 return_ACPI_STATUS(status);
0299 }
0300
0301
0302
0303
0304
0305
0306
0307
0308
0309
0310
0311
0312
0313
0314
0315 acpi_status acpi_ex_create_processor(struct acpi_walk_state *walk_state)
0316 {
0317 union acpi_operand_object **operand = &walk_state->operands[0];
0318 union acpi_operand_object *obj_desc;
0319 acpi_status status;
0320
0321 ACPI_FUNCTION_TRACE_PTR(ex_create_processor, walk_state);
0322
0323
0324
0325 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_PROCESSOR);
0326 if (!obj_desc) {
0327 return_ACPI_STATUS(AE_NO_MEMORY);
0328 }
0329
0330
0331
0332 obj_desc->processor.proc_id = (u8) operand[1]->integer.value;
0333 obj_desc->processor.length = (u8) operand[3]->integer.value;
0334 obj_desc->processor.address =
0335 (acpi_io_address)operand[2]->integer.value;
0336
0337
0338
0339 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
0340 obj_desc, ACPI_TYPE_PROCESSOR);
0341
0342
0343
0344 acpi_ut_remove_reference(obj_desc);
0345 return_ACPI_STATUS(status);
0346 }
0347
0348
0349
0350
0351
0352
0353
0354
0355
0356
0357
0358
0359
0360
0361
0362 acpi_status acpi_ex_create_power_resource(struct acpi_walk_state *walk_state)
0363 {
0364 union acpi_operand_object **operand = &walk_state->operands[0];
0365 acpi_status status;
0366 union acpi_operand_object *obj_desc;
0367
0368 ACPI_FUNCTION_TRACE_PTR(ex_create_power_resource, walk_state);
0369
0370
0371
0372 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_POWER);
0373 if (!obj_desc) {
0374 return_ACPI_STATUS(AE_NO_MEMORY);
0375 }
0376
0377
0378
0379 obj_desc->power_resource.system_level = (u8) operand[1]->integer.value;
0380 obj_desc->power_resource.resource_order =
0381 (u16) operand[2]->integer.value;
0382
0383
0384
0385 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
0386 obj_desc, ACPI_TYPE_POWER);
0387
0388
0389
0390 acpi_ut_remove_reference(obj_desc);
0391 return_ACPI_STATUS(status);
0392 }
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405
0406
0407
0408 acpi_status
0409 acpi_ex_create_method(u8 * aml_start,
0410 u32 aml_length, struct acpi_walk_state *walk_state)
0411 {
0412 union acpi_operand_object **operand = &walk_state->operands[0];
0413 union acpi_operand_object *obj_desc;
0414 acpi_status status;
0415 u8 method_flags;
0416
0417 ACPI_FUNCTION_TRACE_PTR(ex_create_method, walk_state);
0418
0419
0420
0421 obj_desc = acpi_ut_create_internal_object(ACPI_TYPE_METHOD);
0422 if (!obj_desc) {
0423 status = AE_NO_MEMORY;
0424 goto exit;
0425 }
0426
0427
0428
0429 obj_desc->method.aml_start = aml_start;
0430 obj_desc->method.aml_length = aml_length;
0431 obj_desc->method.node = operand[0];
0432
0433
0434
0435
0436
0437 method_flags = (u8)operand[1]->integer.value;
0438 obj_desc->method.param_count = (u8)
0439 (method_flags & AML_METHOD_ARG_COUNT);
0440
0441
0442
0443
0444
0445 if (method_flags & AML_METHOD_SERIALIZED) {
0446 obj_desc->method.info_flags = ACPI_METHOD_SERIALIZED;
0447
0448
0449
0450
0451
0452 obj_desc->method.sync_level = (u8)
0453 ((method_flags & AML_METHOD_SYNC_LEVEL) >> 4);
0454 }
0455
0456
0457
0458 status = acpi_ns_attach_object((struct acpi_namespace_node *)operand[0],
0459 obj_desc, ACPI_TYPE_METHOD);
0460
0461
0462
0463 acpi_ut_remove_reference(obj_desc);
0464
0465 exit:
0466
0467
0468 acpi_ut_remove_reference(operand[1]);
0469 return_ACPI_STATUS(status);
0470 }