aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/parser/psxface.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/parser/psxface.c')
-rw-r--r--drivers/acpi/parser/psxface.c241
1 files changed, 138 insertions, 103 deletions
diff --git a/drivers/acpi/parser/psxface.c b/drivers/acpi/parser/psxface.c
index dba893648e84..d1541fabaf0a 100644
--- a/drivers/acpi/parser/psxface.c
+++ b/drivers/acpi/parser/psxface.c
@@ -46,19 +46,30 @@
46#include <acpi/acparser.h> 46#include <acpi/acparser.h>
47#include <acpi/acdispat.h> 47#include <acpi/acdispat.h>
48#include <acpi/acinterp.h> 48#include <acpi/acinterp.h>
49#include <acpi/acnamesp.h>
50 49
51 50
52#define _COMPONENT ACPI_PARSER 51#define _COMPONENT ACPI_PARSER
53 ACPI_MODULE_NAME ("psxface") 52 ACPI_MODULE_NAME ("psxface")
54 53
54/* Local Prototypes */
55
56static acpi_status
57acpi_ps_execute_pass (
58 struct acpi_parameter_info *info);
59
60static void
61acpi_ps_update_parameter_list (
62 struct acpi_parameter_info *info,
63 u16 action);
64
55 65
56/******************************************************************************* 66/*******************************************************************************
57 * 67 *
58 * FUNCTION: acpi_psx_execute 68 * FUNCTION: acpi_ps_execute_method
59 * 69 *
60 * PARAMETERS: Info - Method info block, contains: 70 * PARAMETERS: Info - Method info block, contains:
61 * Node - Method Node to execute 71 * Node - Method Node to execute
72 * obj_desc - Method object
62 * Parameters - List of parameters to pass to the method, 73 * Parameters - List of parameters to pass to the method,
63 * terminated by NULL. Params itself may be 74 * terminated by NULL. Params itself may be
64 * NULL if no parameters are being passed. 75 * NULL if no parameters are being passed.
@@ -67,6 +78,7 @@
67 * parameter_type - Type of Parameter list 78 * parameter_type - Type of Parameter list
68 * return_object - Where to put method's return value (if 79 * return_object - Where to put method's return value (if
69 * any). If NULL, no value is returned. 80 * any). If NULL, no value is returned.
81 * pass_number - Parse or execute pass
70 * 82 *
71 * RETURN: Status 83 * RETURN: Status
72 * 84 *
@@ -75,171 +87,194 @@
75 ******************************************************************************/ 87 ******************************************************************************/
76 88
77acpi_status 89acpi_status
78acpi_psx_execute ( 90acpi_ps_execute_method (
79 struct acpi_parameter_info *info) 91 struct acpi_parameter_info *info)
80{ 92{
81 acpi_status status; 93 acpi_status status;
82 union acpi_operand_object *obj_desc;
83 u32 i;
84 union acpi_parse_object *op;
85 struct acpi_walk_state *walk_state;
86 94
87 95
88 ACPI_FUNCTION_TRACE ("psx_execute"); 96 ACPI_FUNCTION_TRACE ("ps_execute_method");
89 97
90 98
91 /* Validate the Node and get the attached object */ 99 /* Validate the Info and method Node */
92 100
93 if (!info || !info->node) { 101 if (!info || !info->node) {
94 return_ACPI_STATUS (AE_NULL_ENTRY); 102 return_ACPI_STATUS (AE_NULL_ENTRY);
95 } 103 }
96 104
97 obj_desc = acpi_ns_get_attached_object (info->node);
98 if (!obj_desc) {
99 return_ACPI_STATUS (AE_NULL_OBJECT);
100 }
101
102 /* Init for new method, wait on concurrency semaphore */ 105 /* Init for new method, wait on concurrency semaphore */
103 106
104 status = acpi_ds_begin_method_execution (info->node, obj_desc, NULL); 107 status = acpi_ds_begin_method_execution (info->node, info->obj_desc, NULL);
105 if (ACPI_FAILURE (status)) { 108 if (ACPI_FAILURE (status)) {
106 return_ACPI_STATUS (status); 109 return_ACPI_STATUS (status);
107 } 110 }
108 111
109 if ((info->parameter_type == ACPI_PARAM_ARGS) &&
110 (info->parameters)) {
111 /*
112 * The caller "owns" the parameters, so give each one an extra
113 * reference
114 */
115 for (i = 0; info->parameters[i]; i++) {
116 acpi_ut_add_reference (info->parameters[i]);
117 }
118 }
119
120 /*
121 * 1) Perform the first pass parse of the method to enter any
122 * named objects that it creates into the namespace
123 */
124 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
125 "**** Begin Method Parse **** Entry=%p obj=%p\n",
126 info->node, obj_desc));
127
128 /* Create and init a Root Node */
129
130 op = acpi_ps_create_scope_op ();
131 if (!op) {
132 status = AE_NO_MEMORY;
133 goto cleanup1;
134 }
135
136 /* 112 /*
137 * Get a new owner_id for objects created by this method. Namespace 113 * Get a new owner_id for objects created by this method. Namespace
138 * objects (such as Operation Regions) can be created during the 114 * objects (such as Operation Regions) can be created during the
139 * first pass parse. 115 * first pass parse.
140 */ 116 */
141 obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD); 117 status = acpi_ut_allocate_owner_id (&info->obj_desc->method.owner_id);
142
143 /* Create and initialize a new walk state */
144
145 walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
146 NULL, NULL, NULL);
147 if (!walk_state) {
148 status = AE_NO_MEMORY;
149 goto cleanup2;
150 }
151
152 status = acpi_ds_init_aml_walk (walk_state, op, info->node,
153 obj_desc->method.aml_start,
154 obj_desc->method.aml_length, NULL, 1);
155 if (ACPI_FAILURE (status)) { 118 if (ACPI_FAILURE (status)) {
156 goto cleanup3; 119 return_ACPI_STATUS (status);
157 } 120 }
158 121
159 /* Parse the AML */ 122 /*
123 * The caller "owns" the parameters, so give each one an extra
124 * reference
125 */
126 acpi_ps_update_parameter_list (info, REF_INCREMENT);
160 127
161 status = acpi_ps_parse_aml (walk_state); 128 /*
162 acpi_ps_delete_parse_tree (op); 129 * 1) Perform the first pass parse of the method to enter any
130 * named objects that it creates into the namespace
131 */
132 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
133 "**** Begin Method Parse **** Entry=%p obj=%p\n",
134 info->node, info->obj_desc));
135
136 info->pass_number = 1;
137 status = acpi_ps_execute_pass (info);
163 if (ACPI_FAILURE (status)) { 138 if (ACPI_FAILURE (status)) {
164 goto cleanup1; /* Walk state is already deleted */ 139 goto cleanup;
165 } 140 }
166 141
167 /* 142 /*
168 * 2) Execute the method. Performs second pass parse simultaneously 143 * 2) Execute the method. Performs second pass parse simultaneously
169 */ 144 */
170 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, 145 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
171 "**** Begin Method Execution **** Entry=%p obj=%p\n", 146 "**** Begin Method Execution **** Entry=%p obj=%p\n",
172 info->node, obj_desc)); 147 info->node, info->obj_desc));
173 148
174 /* Create and init a Root Node */ 149 info->pass_number = 3;
150 status = acpi_ps_execute_pass (info);
175 151
176 op = acpi_ps_create_scope_op (); 152
177 if (!op) { 153cleanup:
178 status = AE_NO_MEMORY; 154 if (info->obj_desc->method.owner_id) {
179 goto cleanup1; 155 acpi_ut_release_owner_id (&info->obj_desc->method.owner_id);
180 } 156 }
181 157
182 /* Init new op with the method name and pointer back to the NS node */ 158 /* Take away the extra reference that we gave the parameters above */
183 159
184 acpi_ps_set_name (op, info->node->name.integer); 160 acpi_ps_update_parameter_list (info, REF_DECREMENT);
185 op->common.node = info->node;
186 161
187 /* Create and initialize a new walk state */ 162 /* Exit now if error above */
188 163
189 walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL); 164 if (ACPI_FAILURE (status)) {
190 if (!walk_state) { 165 return_ACPI_STATUS (status);
191 status = AE_NO_MEMORY;
192 goto cleanup2;
193 } 166 }
194 167
195 status = acpi_ds_init_aml_walk (walk_state, op, info->node, 168 /*
196 obj_desc->method.aml_start, 169 * If the method has returned an object, signal this to the caller with
197 obj_desc->method.aml_length, info, 3); 170 * a control exception code
198 if (ACPI_FAILURE (status)) { 171 */
199 goto cleanup3; 172 if (info->return_object) {
173 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
174 info->return_object));
175 ACPI_DUMP_STACK_ENTRY (info->return_object);
176
177 status = AE_CTRL_RETURN_VALUE;
200 } 178 }
201 179
202 /* The walk of the parse tree is where we actually execute the method */ 180 return_ACPI_STATUS (status);
181}
203 182
204 status = acpi_ps_parse_aml (walk_state);
205 goto cleanup2; /* Walk state already deleted */
206 183
184/*******************************************************************************
185 *
186 * FUNCTION: acpi_ps_update_parameter_list
187 *
188 * PARAMETERS: Info - See struct acpi_parameter_info
189 * (Used: parameter_type and Parameters)
190 * Action - Add or Remove reference
191 *
192 * RETURN: Status
193 *
194 * DESCRIPTION: Update reference count on all method parameter objects
195 *
196 ******************************************************************************/
207 197
208cleanup3: 198static void
209 acpi_ds_delete_walk_state (walk_state); 199acpi_ps_update_parameter_list (
200 struct acpi_parameter_info *info,
201 u16 action)
202{
203 acpi_native_uint i;
210 204
211cleanup2:
212 acpi_ps_delete_parse_tree (op);
213 205
214cleanup1:
215 if ((info->parameter_type == ACPI_PARAM_ARGS) && 206 if ((info->parameter_type == ACPI_PARAM_ARGS) &&
216 (info->parameters)) { 207 (info->parameters)) {
217 /* Take away the extra reference that we gave the parameters above */ 208 /* Update reference count for each parameter */
218 209
219 for (i = 0; info->parameters[i]; i++) { 210 for (i = 0; info->parameters[i]; i++) {
220 /* Ignore errors, just do them all */ 211 /* Ignore errors, just do them all */
221 212
222 (void) acpi_ut_update_object_reference ( 213 (void) acpi_ut_update_object_reference (info->parameters[i], action);
223 info->parameters[i], REF_DECREMENT);
224 } 214 }
225 } 215 }
216}
226 217
227 if (ACPI_FAILURE (status)) { 218
228 return_ACPI_STATUS (status); 219/*******************************************************************************
220 *
221 * FUNCTION: acpi_ps_execute_pass
222 *
223 * PARAMETERS: Info - See struct acpi_parameter_info
224 * (Used: pass_number, Node, and obj_desc)
225 *
226 * RETURN: Status
227 *
228 * DESCRIPTION: Single AML pass: Parse or Execute a control method
229 *
230 ******************************************************************************/
231
232static acpi_status
233acpi_ps_execute_pass (
234 struct acpi_parameter_info *info)
235{
236 acpi_status status;
237 union acpi_parse_object *op;
238 struct acpi_walk_state *walk_state;
239
240
241 ACPI_FUNCTION_TRACE ("ps_execute_pass");
242
243
244 /* Create and init a Root Node */
245
246 op = acpi_ps_create_scope_op ();
247 if (!op) {
248 return_ACPI_STATUS (AE_NO_MEMORY);
229 } 249 }
230 250
231 /* 251 /* Create and initialize a new walk state */
232 * If the method has returned an object, signal this to the caller with
233 * a control exception code
234 */
235 if (info->return_object) {
236 ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
237 info->return_object));
238 ACPI_DUMP_STACK_ENTRY (info->return_object);
239 252
240 status = AE_CTRL_RETURN_VALUE; 253 walk_state = acpi_ds_create_walk_state (
254 info->obj_desc->method.owner_id, NULL, NULL, NULL);
255 if (!walk_state) {
256 status = AE_NO_MEMORY;
257 goto cleanup;
258 }
259
260 status = acpi_ds_init_aml_walk (walk_state, op, info->node,
261 info->obj_desc->method.aml_start,
262 info->obj_desc->method.aml_length,
263 info->pass_number == 1 ? NULL : info,
264 info->pass_number);
265 if (ACPI_FAILURE (status)) {
266 acpi_ds_delete_walk_state (walk_state);
267 goto cleanup;
241 } 268 }
242 269
270 /* Parse the AML */
271
272 status = acpi_ps_parse_aml (walk_state);
273
274 /* Walk state was deleted by parse_aml */
275
276cleanup:
277 acpi_ps_delete_parse_tree (op);
243 return_ACPI_STATUS (status); 278 return_ACPI_STATUS (status);
244} 279}
245 280