- Send the SCM reply packet with the final status after completing the requested...
[reactos.git] / reactos / drivers / bus / acpi / parser / psxface.c
1 /******************************************************************************
2 *
3 * Module Name: psxface - Parser external interfaces
4 * $Revision: 1.1 $
5 *
6 *****************************************************************************/
7
8 /*
9 * Copyright (C) 2000, 2001 R. Byron Moore
10 *
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.
15 *
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.
20 *
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
24 */
25
26
27 #include <acpi.h>
28
29 #define _COMPONENT ACPI_PARSER
30 MODULE_NAME ("psxface")
31
32
33 /*****************************************************************************
34 *
35 * FUNCTION: Acpi_psx_execute
36 *
37 * PARAMETERS: Method_node - A method object containing both the AML
38 * address and length.
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
43 * method.
44 *
45 * RETURN: Status
46 *
47 * DESCRIPTION: Execute a control method
48 *
49 ****************************************************************************/
50
51 ACPI_STATUS
52 acpi_psx_execute (
53 ACPI_NAMESPACE_NODE *method_node,
54 ACPI_OPERAND_OBJECT **params,
55 ACPI_OPERAND_OBJECT **return_obj_desc)
56 {
57 ACPI_STATUS status;
58 ACPI_OPERAND_OBJECT *obj_desc;
59 u32 i;
60 ACPI_PARSE_OBJECT *op;
61
62
63 /* Validate the Node and get the attached object */
64
65 if (!method_node) {
66 return (AE_NULL_ENTRY);
67 }
68
69 obj_desc = acpi_ns_get_attached_object (method_node);
70 if (!obj_desc) {
71 return (AE_NULL_OBJECT);
72 }
73
74 /* Init for new method, wait on concurrency semaphore */
75
76 status = acpi_ds_begin_method_execution (method_node, obj_desc, NULL);
77 if (ACPI_FAILURE (status)) {
78 return (status);
79 }
80
81 if (params) {
82 /*
83 * The caller "owns" the parameters, so give each one an extra
84 * reference
85 */
86
87 for (i = 0; params[i]; i++) {
88 acpi_cm_add_reference (params[i]);
89 }
90 }
91
92 /*
93 * Perform the first pass parse of the method to enter any
94 * named objects that it creates into the namespace
95 */
96
97 /* Create and init a Root Node */
98
99 op = acpi_ps_alloc_op (AML_SCOPE_OP);
100 if (!op) {
101 return (AE_NO_MEMORY);
102 }
103
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);
110
111 /* Create and init a Root Node */
112
113 op = acpi_ps_alloc_op (AML_SCOPE_OP);
114 if (!op) {
115 return (AE_NO_MEMORY);
116 }
117
118
119 /* Init new op with the method name and pointer back to the NS node */
120
121 acpi_ps_set_name (op, method_node->name);
122 op->node = method_node;
123
124 /*
125 * The walk of the parse tree is where we actually execute the method
126 */
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);
133
134 if (params) {
135 /* Take away the extra reference that we gave the parameters above */
136
137 for (i = 0; params[i]; i++) {
138 acpi_cm_update_object_reference (params[i], REF_DECREMENT);
139 }
140 }
141
142
143 /*
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
146 * Method code)
147 */
148
149 if (*return_obj_desc) {
150 status = AE_CTRL_RETURN_VALUE;
151 }
152
153
154 return (status);
155 }
156
157