1 /******************************************************************************
3 * Module Name: psxface - Parser external interfaces
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #define _COMPONENT ACPI_PARSER
30 MODULE_NAME ("psxface")
33 /*****************************************************************************
35 * FUNCTION: Acpi_psx_execute
37 * PARAMETERS: Method_node - A method object containing both the AML
39 * **Params - List of parameters to pass to method,
40 * terminated by NULL. Params itself may be
41 * NULL if no parameters are being passed.
42 * **Return_obj_desc - Return object from execution of the
47 * DESCRIPTION: Execute a control method
49 ****************************************************************************/
53 ACPI_NAMESPACE_NODE
*method_node
,
54 ACPI_OPERAND_OBJECT
**params
,
55 ACPI_OPERAND_OBJECT
**return_obj_desc
)
58 ACPI_OPERAND_OBJECT
*obj_desc
;
60 ACPI_PARSE_OBJECT
*op
;
63 /* Validate the Node and get the attached object */
66 return (AE_NULL_ENTRY
);
69 obj_desc
= acpi_ns_get_attached_object (method_node
);
71 return (AE_NULL_OBJECT
);
74 /* Init for new method, wait on concurrency semaphore */
76 status
= acpi_ds_begin_method_execution (method_node
, obj_desc
, NULL
);
77 if (ACPI_FAILURE (status
)) {
83 * The caller "owns" the parameters, so give each one an extra
87 for (i
= 0; params
[i
]; i
++) {
88 acpi_cm_add_reference (params
[i
]);
93 * Perform the first pass parse of the method to enter any
94 * named objects that it creates into the namespace
97 /* Create and init a Root Node */
99 op
= acpi_ps_alloc_op (AML_SCOPE_OP
);
101 return (AE_NO_MEMORY
);
104 status
= acpi_ps_parse_aml (op
, obj_desc
->method
.pcode
,
105 obj_desc
->method
.pcode_length
,
106 ACPI_PARSE_LOAD_PASS1
| ACPI_PARSE_DELETE_TREE
,
107 method_node
, params
, return_obj_desc
,
108 acpi_ds_load1_begin_op
, acpi_ds_load1_end_op
);
109 acpi_ps_delete_parse_tree (op
);
111 /* Create and init a Root Node */
113 op
= acpi_ps_alloc_op (AML_SCOPE_OP
);
115 return (AE_NO_MEMORY
);
119 /* Init new op with the method name and pointer back to the NS node */
121 acpi_ps_set_name (op
, method_node
->name
);
122 op
->node
= method_node
;
125 * The walk of the parse tree is where we actually execute the method
127 status
= acpi_ps_parse_aml (op
, obj_desc
->method
.pcode
,
128 obj_desc
->method
.pcode_length
,
129 ACPI_PARSE_EXECUTE
| ACPI_PARSE_DELETE_TREE
,
130 method_node
, params
, return_obj_desc
,
131 acpi_ds_exec_begin_op
, acpi_ds_exec_end_op
);
132 acpi_ps_delete_parse_tree (op
);
135 /* Take away the extra reference that we gave the parameters above */
137 for (i
= 0; params
[i
]; i
++) {
138 acpi_cm_update_object_reference (params
[i
], REF_DECREMENT
);
144 * Normal exit is with Status == AE_RETURN_VALUE when a Return_op has been
145 * executed, or with Status == AE_PENDING at end of AML block (end of
149 if (*return_obj_desc
) {
150 status
= AE_CTRL_RETURN_VALUE
;