1 |
1275 |
phoenix |
/******************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* Module Name: psxface - Parser external interfaces
|
4 |
|
|
*
|
5 |
|
|
*****************************************************************************/
|
6 |
|
|
|
7 |
|
|
/*
|
8 |
|
|
* Copyright (C) 2000 - 2004, R. Byron Moore
|
9 |
|
|
* All rights reserved.
|
10 |
|
|
*
|
11 |
|
|
* Redistribution and use in source and binary forms, with or without
|
12 |
|
|
* modification, are permitted provided that the following conditions
|
13 |
|
|
* are met:
|
14 |
|
|
* 1. Redistributions of source code must retain the above copyright
|
15 |
|
|
* notice, this list of conditions, and the following disclaimer,
|
16 |
|
|
* without modification.
|
17 |
|
|
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
|
18 |
|
|
* substantially similar to the "NO WARRANTY" disclaimer below
|
19 |
|
|
* ("Disclaimer") and any redistribution must be conditioned upon
|
20 |
|
|
* including a substantially similar Disclaimer requirement for further
|
21 |
|
|
* binary redistribution.
|
22 |
|
|
* 3. Neither the names of the above-listed copyright holders nor the names
|
23 |
|
|
* of any contributors may be used to endorse or promote products derived
|
24 |
|
|
* from this software without specific prior written permission.
|
25 |
|
|
*
|
26 |
|
|
* Alternatively, this software may be distributed under the terms of the
|
27 |
|
|
* GNU General Public License ("GPL") version 2 as published by the Free
|
28 |
|
|
* Software Foundation.
|
29 |
|
|
*
|
30 |
|
|
* NO WARRANTY
|
31 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
32 |
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
33 |
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
|
34 |
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
35 |
|
|
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
36 |
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
37 |
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
38 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
39 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
40 |
|
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
41 |
|
|
* POSSIBILITY OF SUCH DAMAGES.
|
42 |
|
|
*/
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
#include <acpi/acpi.h>
|
46 |
|
|
#include <acpi/acparser.h>
|
47 |
|
|
#include <acpi/acdispat.h>
|
48 |
|
|
#include <acpi/acinterp.h>
|
49 |
|
|
#include <acpi/acnamesp.h>
|
50 |
|
|
|
51 |
|
|
|
52 |
|
|
#define _COMPONENT ACPI_PARSER
|
53 |
|
|
ACPI_MODULE_NAME ("psxface")
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
/*******************************************************************************
|
57 |
|
|
*
|
58 |
|
|
* FUNCTION: acpi_psx_execute
|
59 |
|
|
*
|
60 |
|
|
* PARAMETERS: method_node - A method object containing both the AML
|
61 |
|
|
* address and length.
|
62 |
|
|
* **Params - List of parameters to pass to method,
|
63 |
|
|
* terminated by NULL. Params itself may be
|
64 |
|
|
* NULL if no parameters are being passed.
|
65 |
|
|
* **return_obj_desc - Return object from execution of the
|
66 |
|
|
* method.
|
67 |
|
|
*
|
68 |
|
|
* RETURN: Status
|
69 |
|
|
*
|
70 |
|
|
* DESCRIPTION: Execute a control method
|
71 |
|
|
*
|
72 |
|
|
******************************************************************************/
|
73 |
|
|
|
74 |
|
|
acpi_status
|
75 |
|
|
acpi_psx_execute (
|
76 |
|
|
struct acpi_namespace_node *method_node,
|
77 |
|
|
union acpi_operand_object **params,
|
78 |
|
|
union acpi_operand_object **return_obj_desc)
|
79 |
|
|
{
|
80 |
|
|
acpi_status status;
|
81 |
|
|
union acpi_operand_object *obj_desc;
|
82 |
|
|
u32 i;
|
83 |
|
|
union acpi_parse_object *op;
|
84 |
|
|
struct acpi_walk_state *walk_state;
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
ACPI_FUNCTION_TRACE ("psx_execute");
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
/* Validate the Node and get the attached object */
|
91 |
|
|
|
92 |
|
|
if (!method_node) {
|
93 |
|
|
return_ACPI_STATUS (AE_NULL_ENTRY);
|
94 |
|
|
}
|
95 |
|
|
|
96 |
|
|
obj_desc = acpi_ns_get_attached_object (method_node);
|
97 |
|
|
if (!obj_desc) {
|
98 |
|
|
return_ACPI_STATUS (AE_NULL_OBJECT);
|
99 |
|
|
}
|
100 |
|
|
|
101 |
|
|
/* Init for new method, wait on concurrency semaphore */
|
102 |
|
|
|
103 |
|
|
status = acpi_ds_begin_method_execution (method_node, obj_desc, NULL);
|
104 |
|
|
if (ACPI_FAILURE (status)) {
|
105 |
|
|
return_ACPI_STATUS (status);
|
106 |
|
|
}
|
107 |
|
|
|
108 |
|
|
if (params) {
|
109 |
|
|
/*
|
110 |
|
|
* The caller "owns" the parameters, so give each one an extra
|
111 |
|
|
* reference
|
112 |
|
|
*/
|
113 |
|
|
for (i = 0; params[i]; i++) {
|
114 |
|
|
acpi_ut_add_reference (params[i]);
|
115 |
|
|
}
|
116 |
|
|
}
|
117 |
|
|
|
118 |
|
|
/*
|
119 |
|
|
* 1) Perform the first pass parse of the method to enter any
|
120 |
|
|
* named objects that it creates into the namespace
|
121 |
|
|
*/
|
122 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
123 |
|
|
"**** Begin Method Parse **** Entry=%p obj=%p\n",
|
124 |
|
|
method_node, obj_desc));
|
125 |
|
|
|
126 |
|
|
/* Create and init a Root Node */
|
127 |
|
|
|
128 |
|
|
op = acpi_ps_create_scope_op ();
|
129 |
|
|
if (!op) {
|
130 |
|
|
status = AE_NO_MEMORY;
|
131 |
|
|
goto cleanup1;
|
132 |
|
|
}
|
133 |
|
|
|
134 |
|
|
/*
|
135 |
|
|
* Get a new owner_id for objects created by this method. Namespace
|
136 |
|
|
* objects (such as Operation Regions) can be created during the
|
137 |
|
|
* first pass parse.
|
138 |
|
|
*/
|
139 |
|
|
obj_desc->method.owning_id = acpi_ut_allocate_owner_id (ACPI_OWNER_TYPE_METHOD);
|
140 |
|
|
|
141 |
|
|
/* Create and initialize a new walk state */
|
142 |
|
|
|
143 |
|
|
walk_state = acpi_ds_create_walk_state (obj_desc->method.owning_id,
|
144 |
|
|
NULL, NULL, NULL);
|
145 |
|
|
if (!walk_state) {
|
146 |
|
|
status = AE_NO_MEMORY;
|
147 |
|
|
goto cleanup2;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
|
|
status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
|
151 |
|
|
obj_desc->method.aml_length, NULL, NULL, 1);
|
152 |
|
|
if (ACPI_FAILURE (status)) {
|
153 |
|
|
goto cleanup3;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
/* Parse the AML */
|
157 |
|
|
|
158 |
|
|
status = acpi_ps_parse_aml (walk_state);
|
159 |
|
|
acpi_ps_delete_parse_tree (op);
|
160 |
|
|
if (ACPI_FAILURE (status)) {
|
161 |
|
|
goto cleanup1; /* Walk state is already deleted */
|
162 |
|
|
|
163 |
|
|
}
|
164 |
|
|
|
165 |
|
|
/*
|
166 |
|
|
* 2) Execute the method. Performs second pass parse simultaneously
|
167 |
|
|
*/
|
168 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE,
|
169 |
|
|
"**** Begin Method Execution **** Entry=%p obj=%p\n",
|
170 |
|
|
method_node, obj_desc));
|
171 |
|
|
|
172 |
|
|
/* Create and init a Root Node */
|
173 |
|
|
|
174 |
|
|
op = acpi_ps_create_scope_op ();
|
175 |
|
|
if (!op) {
|
176 |
|
|
status = AE_NO_MEMORY;
|
177 |
|
|
goto cleanup1;
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
/* Init new op with the method name and pointer back to the NS node */
|
181 |
|
|
|
182 |
|
|
acpi_ps_set_name (op, method_node->name.integer);
|
183 |
|
|
op->common.node = method_node;
|
184 |
|
|
|
185 |
|
|
/* Create and initialize a new walk state */
|
186 |
|
|
|
187 |
|
|
walk_state = acpi_ds_create_walk_state (0, NULL, NULL, NULL);
|
188 |
|
|
if (!walk_state) {
|
189 |
|
|
status = AE_NO_MEMORY;
|
190 |
|
|
goto cleanup2;
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
status = acpi_ds_init_aml_walk (walk_state, op, method_node, obj_desc->method.aml_start,
|
194 |
|
|
obj_desc->method.aml_length, params, return_obj_desc, 3);
|
195 |
|
|
if (ACPI_FAILURE (status)) {
|
196 |
|
|
goto cleanup3;
|
197 |
|
|
}
|
198 |
|
|
|
199 |
|
|
/*
|
200 |
|
|
* The walk of the parse tree is where we actually execute the method
|
201 |
|
|
*/
|
202 |
|
|
status = acpi_ps_parse_aml (walk_state);
|
203 |
|
|
goto cleanup2; /* Walk state already deleted */
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
cleanup3:
|
207 |
|
|
acpi_ds_delete_walk_state (walk_state);
|
208 |
|
|
|
209 |
|
|
cleanup2:
|
210 |
|
|
acpi_ps_delete_parse_tree (op);
|
211 |
|
|
|
212 |
|
|
cleanup1:
|
213 |
|
|
if (params) {
|
214 |
|
|
/* Take away the extra reference that we gave the parameters above */
|
215 |
|
|
|
216 |
|
|
for (i = 0; params[i]; i++) {
|
217 |
|
|
/* Ignore errors, just do them all */
|
218 |
|
|
|
219 |
|
|
(void) acpi_ut_update_object_reference (params[i], REF_DECREMENT);
|
220 |
|
|
}
|
221 |
|
|
}
|
222 |
|
|
|
223 |
|
|
if (ACPI_FAILURE (status)) {
|
224 |
|
|
return_ACPI_STATUS (status);
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
/*
|
228 |
|
|
* If the method has returned an object, signal this to the caller with
|
229 |
|
|
* a control exception code
|
230 |
|
|
*/
|
231 |
|
|
if (*return_obj_desc) {
|
232 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "Method returned obj_desc=%p\n",
|
233 |
|
|
*return_obj_desc));
|
234 |
|
|
ACPI_DUMP_STACK_ENTRY (*return_obj_desc);
|
235 |
|
|
|
236 |
|
|
status = AE_CTRL_RETURN_VALUE;
|
237 |
|
|
}
|
238 |
|
|
|
239 |
|
|
return_ACPI_STATUS (status);
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
|