Blame view
drivers/acpi/acpica/exresnte.c
8.38 KB
1da177e4c
|
1 2 3 4 5 6 7 8 |
/****************************************************************************** * * Module Name: exresnte - AML Interpreter object resolution * *****************************************************************************/ /* |
75a44ce00
|
9 |
* Copyright (C) 2000 - 2008, Intel Corp. |
1da177e4c
|
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
* All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions, and the following disclaimer, * without modification. * 2. Redistributions in binary form must reproduce at minimum a disclaimer * substantially similar to the "NO WARRANTY" disclaimer below * ("Disclaimer") and any redistribution must be conditioned upon * including a substantially similar Disclaimer requirement for further * binary redistribution. * 3. Neither the names of the above-listed copyright holders nor the names * of any contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * Alternatively, this software may be distributed under the terms of the * GNU General Public License ("GPL") version 2 as published by the Free * Software Foundation. * * NO WARRANTY * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGES. */ |
1da177e4c
|
44 |
#include <acpi/acpi.h> |
e2f7a7772
|
45 46 47 48 |
#include "accommon.h" #include "acdispat.h" #include "acinterp.h" #include "acnamesp.h" |
1da177e4c
|
49 |
|
1da177e4c
|
50 |
#define _COMPONENT ACPI_EXECUTER |
4be44fcd3
|
51 |
ACPI_MODULE_NAME("exresnte") |
1da177e4c
|
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
/******************************************************************************* * * FUNCTION: acpi_ex_resolve_node_to_value * * PARAMETERS: object_ptr - Pointer to a location that contains * a pointer to a NS node, and will receive a * pointer to the resolved object. * walk_state - Current state. Valid only if executing AML * code. NULL if simply resolving an object * * RETURN: Status * * DESCRIPTION: Resolve a Namespace node to a valued object * * Note: for some of the data types, the pointer attached to the Node * can be either a pointer to an actual internal object or a pointer into the * AML stream itself. These types are currently: * * ACPI_TYPE_INTEGER * ACPI_TYPE_STRING * ACPI_TYPE_BUFFER * ACPI_TYPE_MUTEX * ACPI_TYPE_PACKAGE * ******************************************************************************/ |
1da177e4c
|
78 |
acpi_status |
4be44fcd3
|
79 80 |
acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr, struct acpi_walk_state *walk_state) |
1da177e4c
|
81 |
{ |
4be44fcd3
|
82 83 84 85 86 |
acpi_status status = AE_OK; union acpi_operand_object *source_desc; union acpi_operand_object *obj_desc = NULL; struct acpi_namespace_node *node; acpi_object_type entry_type; |
1da177e4c
|
87 |
|
b229cf92e
|
88 |
ACPI_FUNCTION_TRACE(ex_resolve_node_to_value); |
1da177e4c
|
89 90 91 92 93 |
/* * The stack pointer points to a struct acpi_namespace_node (Node). Get the * object that is attached to the Node. */ |
4be44fcd3
|
94 95 96 |
node = *object_ptr; source_desc = acpi_ns_get_attached_object(node); entry_type = acpi_ns_get_type((acpi_handle) node); |
1da177e4c
|
97 |
|
b229cf92e
|
98 99 |
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s] ", |
4be44fcd3
|
100 101 |
node, source_desc, acpi_ut_get_type_name(entry_type))); |
1da177e4c
|
102 103 |
if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) || |
4be44fcd3
|
104 |
(entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) { |
52fc0b026
|
105 |
|
1da177e4c
|
106 |
/* There is always exactly one level of indirection */ |
4be44fcd3
|
107 108 109 |
node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object); source_desc = acpi_ns_get_attached_object(node); entry_type = acpi_ns_get_type((acpi_handle) node); |
1da177e4c
|
110 111 112 113 114 |
*object_ptr = node; } /* * Several object types require no further processing: |
4c90ece24
|
115 |
* 1) Device/Thermal objects don't have a "real" subobject, return the Node |
1da177e4c
|
116 |
* 2) Method locals and arguments have a pseudo-Node |
b160987df
|
117 |
* 3) 10/2007: Added method type to assist with Package construction. |
1da177e4c
|
118 |
*/ |
4c90ece24
|
119 120 |
if ((entry_type == ACPI_TYPE_DEVICE) || (entry_type == ACPI_TYPE_THERMAL) || |
b160987df
|
121 |
(entry_type == ACPI_TYPE_METHOD) || |
4be44fcd3
|
122 123 |
(node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) { return_ACPI_STATUS(AE_OK); |
1da177e4c
|
124 125 126 |
} if (!source_desc) { |
b8e4d8935
|
127 |
ACPI_ERROR((AE_INFO, "No object attached to node %p", node)); |
4be44fcd3
|
128 |
return_ACPI_STATUS(AE_AML_NO_OPERAND); |
1da177e4c
|
129 130 131 132 133 134 135 136 |
} /* * Action is based on the type of the Node, which indicates the type * of the attached object or pointer */ switch (entry_type) { case ACPI_TYPE_PACKAGE: |
3371c19c2
|
137 |
if (source_desc->common.type != ACPI_TYPE_PACKAGE) { |
b8e4d8935
|
138 139 |
ACPI_ERROR((AE_INFO, "Object not a Package, type %s", acpi_ut_get_object_type_name(source_desc))); |
4be44fcd3
|
140 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
141 |
} |
4be44fcd3
|
142 143 |
status = acpi_ds_get_package_arguments(source_desc); if (ACPI_SUCCESS(status)) { |
52fc0b026
|
144 |
|
1da177e4c
|
145 146 147 |
/* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
148 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
149 150 |
} break; |
1da177e4c
|
151 |
case ACPI_TYPE_BUFFER: |
3371c19c2
|
152 |
if (source_desc->common.type != ACPI_TYPE_BUFFER) { |
b8e4d8935
|
153 154 |
ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s", acpi_ut_get_object_type_name(source_desc))); |
4be44fcd3
|
155 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
156 |
} |
4be44fcd3
|
157 158 |
status = acpi_ds_get_buffer_arguments(source_desc); if (ACPI_SUCCESS(status)) { |
52fc0b026
|
159 |
|
1da177e4c
|
160 161 162 |
/* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
163 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
164 165 |
} break; |
1da177e4c
|
166 |
case ACPI_TYPE_STRING: |
3371c19c2
|
167 |
if (source_desc->common.type != ACPI_TYPE_STRING) { |
b8e4d8935
|
168 169 |
ACPI_ERROR((AE_INFO, "Object not a String, type %s", acpi_ut_get_object_type_name(source_desc))); |
4be44fcd3
|
170 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
171 172 173 174 175 |
} /* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
176 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
177 |
break; |
1da177e4c
|
178 |
case ACPI_TYPE_INTEGER: |
3371c19c2
|
179 |
if (source_desc->common.type != ACPI_TYPE_INTEGER) { |
b8e4d8935
|
180 181 |
ACPI_ERROR((AE_INFO, "Object not a Integer, type %s", acpi_ut_get_object_type_name(source_desc))); |
4be44fcd3
|
182 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
183 184 185 186 187 |
} /* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
188 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
189 |
break; |
1da177e4c
|
190 191 192 193 |
case ACPI_TYPE_BUFFER_FIELD: case ACPI_TYPE_LOCAL_REGION_FIELD: case ACPI_TYPE_LOCAL_BANK_FIELD: case ACPI_TYPE_LOCAL_INDEX_FIELD: |
4be44fcd3
|
194 |
ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
b229cf92e
|
195 196 |
"FieldRead Node=%p SourceDesc=%p Type=%X ", |
4be44fcd3
|
197 |
node, source_desc, entry_type)); |
1da177e4c
|
198 |
|
4be44fcd3
|
199 200 201 |
status = acpi_ex_read_data_from_field(walk_state, source_desc, &obj_desc); |
1da177e4c
|
202 |
break; |
4be44fcd3
|
203 |
/* For these objects, just return the object attached to the Node */ |
44f6c0124
|
204 |
|
1da177e4c
|
205 |
case ACPI_TYPE_MUTEX: |
1da177e4c
|
206 207 |
case ACPI_TYPE_POWER: case ACPI_TYPE_PROCESSOR: |
1da177e4c
|
208 209 210 211 212 213 |
case ACPI_TYPE_EVENT: case ACPI_TYPE_REGION: /* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
214 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
215 |
break; |
4be44fcd3
|
216 |
/* TYPE_ANY is untyped, and thus there is no object associated with it */ |
1da177e4c
|
217 218 |
case ACPI_TYPE_ANY: |
b8e4d8935
|
219 220 |
ACPI_ERROR((AE_INFO, "Untyped entry %p, no attached object!", node)); |
1da177e4c
|
221 |
|
4be44fcd3
|
222 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); /* Cannot be AE_TYPE */ |
1da177e4c
|
223 224 |
case ACPI_TYPE_LOCAL_REFERENCE: |
1044f1f65
|
225 226 227 228 |
switch (source_desc->reference.class) { case ACPI_REFCLASS_TABLE: /* This is a ddb_handle */ case ACPI_REFCLASS_REFOF: case ACPI_REFCLASS_INDEX: |
1da177e4c
|
229 |
|
1da177e4c
|
230 231 232 |
/* Return an additional reference to the object */ obj_desc = source_desc; |
4be44fcd3
|
233 |
acpi_ut_add_reference(obj_desc); |
1da177e4c
|
234 235 236 237 |
break; default: /* No named references are allowed here */ |
b8e4d8935
|
238 |
ACPI_ERROR((AE_INFO, |
1044f1f65
|
239 240 |
"Unsupported Reference type %X", source_desc->reference.class)); |
1da177e4c
|
241 |
|
4be44fcd3
|
242 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
243 244 |
} break; |
1da177e4c
|
245 |
default: |
44f6c0124
|
246 |
/* Default case is for unknown types */ |
b8e4d8935
|
247 248 249 |
ACPI_ERROR((AE_INFO, "Node %p - Unknown object type %X", node, entry_type)); |
1da177e4c
|
250 |
|
4be44fcd3
|
251 |
return_ACPI_STATUS(AE_AML_OPERAND_TYPE); |
1da177e4c
|
252 |
|
4be44fcd3
|
253 |
} /* switch (entry_type) */ |
1da177e4c
|
254 |
|
44f6c0124
|
255 |
/* Return the object descriptor */ |
1da177e4c
|
256 |
|
4be44fcd3
|
257 258 |
*object_ptr = (void *)obj_desc; return_ACPI_STATUS(status); |
1da177e4c
|
259 |
} |