Merge with Linux 2.5.56.
[linux-2.6/linux-mips.git] / drivers / acpi / resources / rsutils.c
blobfb61e73d3b325e6ff13c2cb8a5002dbdea0a955d
1 /*******************************************************************************
3 * Module Name: rsutils - Utilities for the resource manager
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2003, R. Byron Moore
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "acpi.h"
27 #include "acnamesp.h"
28 #include "acresrc.h"
31 #define _COMPONENT ACPI_RESOURCES
32 ACPI_MODULE_NAME ("rsutils")
35 /*******************************************************************************
37 * FUNCTION: acpi_rs_get_prt_method_data
39 * PARAMETERS: Handle - a handle to the containing object
40 * ret_buffer - a pointer to a buffer structure for the
41 * results
43 * RETURN: Status
45 * DESCRIPTION: This function is called to get the _PRT value of an object
46 * contained in an object specified by the handle passed in
48 * If the function fails an appropriate status will be returned
49 * and the contents of the callers buffer is undefined.
51 ******************************************************************************/
53 acpi_status
54 acpi_rs_get_prt_method_data (
55 acpi_handle handle,
56 struct acpi_buffer *ret_buffer)
58 union acpi_operand_object *obj_desc;
59 acpi_status status;
62 ACPI_FUNCTION_TRACE ("rs_get_prt_method_data");
65 /* Parameters guaranteed valid by caller */
68 * Execute the method, no parameters
70 status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc);
71 if (ACPI_FAILURE (status)) {
72 return_ACPI_STATUS (status);
76 * Create a resource linked list from the byte stream buffer that comes
77 * back from the _CRS method execution.
79 status = acpi_rs_create_pci_routing_table (obj_desc, ret_buffer);
81 /* On exit, we must delete the object returned by evaluate_object */
83 acpi_ut_remove_reference (obj_desc);
84 return_ACPI_STATUS (status);
88 /*******************************************************************************
90 * FUNCTION: acpi_rs_get_crs_method_data
92 * PARAMETERS: Handle - a handle to the containing object
93 * ret_buffer - a pointer to a buffer structure for the
94 * results
96 * RETURN: Status
98 * DESCRIPTION: This function is called to get the _CRS value of an object
99 * contained in an object specified by the handle passed in
101 * If the function fails an appropriate status will be returned
102 * and the contents of the callers buffer is undefined.
104 ******************************************************************************/
106 acpi_status
107 acpi_rs_get_crs_method_data (
108 acpi_handle handle,
109 struct acpi_buffer *ret_buffer)
111 union acpi_operand_object *obj_desc;
112 acpi_status status;
115 ACPI_FUNCTION_TRACE ("rs_get_crs_method_data");
118 /* Parameters guaranteed valid by caller */
121 * Execute the method, no parameters
123 status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc);
124 if (ACPI_FAILURE (status)) {
125 return_ACPI_STATUS (status);
129 * Make the call to create a resource linked list from the
130 * byte stream buffer that comes back from the _CRS method
131 * execution.
133 status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
135 /* on exit, we must delete the object returned by evaluate_object */
137 acpi_ut_remove_reference (obj_desc);
138 return_ACPI_STATUS (status);
142 /*******************************************************************************
144 * FUNCTION: acpi_rs_get_prs_method_data
146 * PARAMETERS: Handle - a handle to the containing object
147 * ret_buffer - a pointer to a buffer structure for the
148 * results
150 * RETURN: Status
152 * DESCRIPTION: This function is called to get the _PRS value of an object
153 * contained in an object specified by the handle passed in
155 * If the function fails an appropriate status will be returned
156 * and the contents of the callers buffer is undefined.
158 ******************************************************************************/
160 acpi_status
161 acpi_rs_get_prs_method_data (
162 acpi_handle handle,
163 struct acpi_buffer *ret_buffer)
165 union acpi_operand_object *obj_desc;
166 acpi_status status;
169 ACPI_FUNCTION_TRACE ("rs_get_prs_method_data");
172 /* Parameters guaranteed valid by caller */
175 * Execute the method, no parameters
177 status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc);
178 if (ACPI_FAILURE (status)) {
179 return_ACPI_STATUS (status);
183 * Make the call to create a resource linked list from the
184 * byte stream buffer that comes back from the _CRS method
185 * execution.
187 status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
189 /* on exit, we must delete the object returned by evaluate_object */
191 acpi_ut_remove_reference (obj_desc);
192 return_ACPI_STATUS (status);
196 /*******************************************************************************
198 * FUNCTION: acpi_rs_set_srs_method_data
200 * PARAMETERS: Handle - a handle to the containing object
201 * in_buffer - a pointer to a buffer structure of the
202 * parameter
204 * RETURN: Status
206 * DESCRIPTION: This function is called to set the _SRS of an object contained
207 * in an object specified by the handle passed in
209 * If the function fails an appropriate status will be returned
210 * and the contents of the callers buffer is undefined.
212 ******************************************************************************/
214 acpi_status
215 acpi_rs_set_srs_method_data (
216 acpi_handle handle,
217 struct acpi_buffer *in_buffer)
219 union acpi_operand_object *params[2];
220 acpi_status status;
221 struct acpi_buffer buffer;
224 ACPI_FUNCTION_TRACE ("rs_set_srs_method_data");
227 /* Parameters guaranteed valid by caller */
230 * The in_buffer parameter will point to a linked list of
231 * resource parameters. It needs to be formatted into a
232 * byte stream to be sent in as an input parameter to _SRS
234 * Convert the linked list into a byte stream
236 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
237 status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer);
238 if (ACPI_FAILURE (status)) {
239 return_ACPI_STATUS (status);
243 * Init the param object
245 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
246 if (!params[0]) {
247 acpi_os_free (buffer.pointer);
248 return_ACPI_STATUS (AE_NO_MEMORY);
252 * Set up the parameter object
254 params[0]->buffer.length = (u32) buffer.length;
255 params[0]->buffer.pointer = buffer.pointer;
256 params[0]->common.flags = AOPOBJ_DATA_VALID;
257 params[1] = NULL;
260 * Execute the method, no return value
262 status = acpi_ns_evaluate_relative (handle, "_SRS", params, NULL);
265 * Clean up and return the status from acpi_ns_evaluate_relative
267 acpi_ut_remove_reference (params[0]);
268 return_ACPI_STATUS (status);