2 /******************************************************************************
4 * Module Name: amstoren - AML Interpreter object store support,
5 * Store to Node (namespace object)
8 *****************************************************************************/
11 * Copyright (C) 2000, 2001 R. Byron Moore
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
38 #define _COMPONENT ACPI_EXECUTER
39 MODULE_NAME ("amstoren")
42 /*******************************************************************************
44 * FUNCTION: Acpi_aml_resolve_object
46 * PARAMETERS: Source_desc_ptr - Pointer to the source object
47 * Target_type - Current type of the target
48 * Walk_state - Current walk state
50 * RETURN: Status, resolved object in Source_desc_ptr.
52 * DESCRIPTION: Resolve an object. If the object is a reference, dereference
53 * it and return the actual object in the Source_desc_ptr.
55 ******************************************************************************/
58 acpi_aml_resolve_object (
59 ACPI_OPERAND_OBJECT
**source_desc_ptr
,
60 OBJECT_TYPE_INTERNAL target_type
,
61 ACPI_WALK_STATE
*walk_state
)
63 ACPI_OPERAND_OBJECT
*source_desc
= *source_desc_ptr
;
64 ACPI_STATUS status
= AE_OK
;
68 * Ensure we have a Source that can be stored in the target
70 switch (target_type
) {
72 /* This case handles the "interchangeable" types Integer, String, and Buffer. */
75 * These cases all require only Integers or values that
76 * can be converted to Integers (Strings or Buffers)
78 case ACPI_TYPE_INTEGER
:
79 case ACPI_TYPE_FIELD_UNIT
:
80 case INTERNAL_TYPE_BANK_FIELD
:
81 case INTERNAL_TYPE_INDEX_FIELD
:
84 * Stores into a Field/Region or into a Buffer/String
85 * are all essentially the same.
87 case ACPI_TYPE_STRING
:
88 case ACPI_TYPE_BUFFER
:
89 case INTERNAL_TYPE_DEF_FIELD
:
92 * If Source_desc is not a valid type, try to resolve it to one.
94 if ((source_desc
->common
.type
!= ACPI_TYPE_INTEGER
) &&
95 (source_desc
->common
.type
!= ACPI_TYPE_BUFFER
) &&
96 (source_desc
->common
.type
!= ACPI_TYPE_STRING
)) {
98 * Initially not a valid type, convert
100 status
= acpi_aml_resolve_to_value (source_desc_ptr
, walk_state
);
101 if (ACPI_SUCCESS (status
) &&
102 (source_desc
->common
.type
!= ACPI_TYPE_INTEGER
) &&
103 (source_desc
->common
.type
!= ACPI_TYPE_BUFFER
) &&
104 (source_desc
->common
.type
!= ACPI_TYPE_STRING
)) {
106 * Conversion successful but still not a valid type
108 status
= AE_AML_OPERAND_TYPE
;
114 case INTERNAL_TYPE_ALIAS
:
117 * Aliases are resolved by Acpi_aml_prep_operands
119 status
= AE_AML_INTERNAL
;
123 case ACPI_TYPE_PACKAGE
:
127 * All other types than Alias and the various Fields come here,
128 * including the untyped case - ACPI_TYPE_ANY.
137 /*******************************************************************************
139 * FUNCTION: Acpi_aml_store_object
141 * PARAMETERS: Source_desc - Object to store
142 * Target_type - Current type of the target
143 * Target_desc_ptr - Pointer to the target
144 * Walk_state - Current walk state
148 * DESCRIPTION: "Store" an object to another object. This may include
149 * converting the source type to the target type (implicit
150 * conversion), and a copy of the value of the source to
153 ******************************************************************************/
156 acpi_aml_store_object (
157 ACPI_OPERAND_OBJECT
*source_desc
,
158 OBJECT_TYPE_INTERNAL target_type
,
159 ACPI_OPERAND_OBJECT
**target_desc_ptr
,
160 ACPI_WALK_STATE
*walk_state
)
162 ACPI_OPERAND_OBJECT
*target_desc
= *target_desc_ptr
;
163 ACPI_STATUS status
= AE_OK
;
167 * Perform the "implicit conversion" of the source to the current type
168 * of the target - As per the ACPI specification.
170 * If no conversion performed, Source_desc is left alone, otherwise it
171 * is updated with a new object.
173 status
= acpi_aml_convert_to_target_type (target_type
, &source_desc
, walk_state
);
174 if (ACPI_FAILURE (status
)) {
179 * We now have two objects of identical types, and we can perform a
180 * copy of the *value* of the source object.
182 switch (target_type
) {
184 case INTERNAL_TYPE_DEF_ANY
:
187 * The target namespace node is uninitialized (has no target object),
188 * and will take on the type of the source object
191 *target_desc_ptr
= source_desc
;
195 case ACPI_TYPE_INTEGER
:
197 target_desc
->integer
.value
= source_desc
->integer
.value
;
199 /* Truncate value if we are executing from a 32-bit ACPI table */
201 acpi_aml_truncate_for32bit_table (target_desc
, walk_state
);
205 case ACPI_TYPE_FIELD_UNIT
:
207 status
= acpi_aml_copy_integer_to_field_unit (source_desc
, target_desc
);
211 case INTERNAL_TYPE_BANK_FIELD
:
213 status
= acpi_aml_copy_integer_to_bank_field (source_desc
, target_desc
);
217 case INTERNAL_TYPE_INDEX_FIELD
:
219 status
= acpi_aml_copy_integer_to_index_field (source_desc
, target_desc
);
223 case ACPI_TYPE_STRING
:
225 status
= acpi_aml_copy_string_to_string (source_desc
, target_desc
);
229 case ACPI_TYPE_BUFFER
:
231 status
= acpi_aml_copy_buffer_to_buffer (source_desc
, target_desc
);
235 case ACPI_TYPE_PACKAGE
:
238 * TBD: [Unhandled] Not real sure what to do here
240 status
= AE_NOT_IMPLEMENTED
;
247 * All other types come here.
249 status
= AE_NOT_IMPLEMENTED
;