[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / acpi / resources / rsutils.c
blobee9ce13c053d76bc252fd8d4ee4a0a889528cd3f
1 /*******************************************************************************
3 * Module Name: rsutils - Utilities for the resource manager
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
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.
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.
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.
45 #include <acpi/acpi.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/acresrc.h>
50 #define _COMPONENT ACPI_RESOURCES
51 ACPI_MODULE_NAME ("rsutils")
54 /*******************************************************************************
56 * FUNCTION: acpi_rs_get_prt_method_data
58 * PARAMETERS: Handle - a handle to the containing object
59 * ret_buffer - a pointer to a buffer structure for the
60 * results
62 * RETURN: Status
64 * DESCRIPTION: This function is called to get the _PRT value of an object
65 * contained in an object specified by the handle passed in
67 * If the function fails an appropriate status will be returned
68 * and the contents of the callers buffer is undefined.
70 ******************************************************************************/
72 acpi_status
73 acpi_rs_get_prt_method_data (
74 acpi_handle handle,
75 struct acpi_buffer *ret_buffer)
77 union acpi_operand_object *obj_desc;
78 acpi_status status;
81 ACPI_FUNCTION_TRACE ("rs_get_prt_method_data");
84 /* Parameters guaranteed valid by caller */
87 * Execute the method, no parameters
89 status = acpi_ut_evaluate_object (handle, "_PRT", ACPI_BTYPE_PACKAGE, &obj_desc);
90 if (ACPI_FAILURE (status)) {
91 return_ACPI_STATUS (status);
95 * Create a resource linked list from the byte stream buffer that comes
96 * back from the _CRS method execution.
98 status = acpi_rs_create_pci_routing_table (obj_desc, ret_buffer);
100 /* On exit, we must delete the object returned by evaluate_object */
102 acpi_ut_remove_reference (obj_desc);
103 return_ACPI_STATUS (status);
107 /*******************************************************************************
109 * FUNCTION: acpi_rs_get_crs_method_data
111 * PARAMETERS: Handle - a handle to the containing object
112 * ret_buffer - a pointer to a buffer structure for the
113 * results
115 * RETURN: Status
117 * DESCRIPTION: This function is called to get the _CRS value of an object
118 * contained in an object specified by the handle passed in
120 * If the function fails an appropriate status will be returned
121 * and the contents of the callers buffer is undefined.
123 ******************************************************************************/
125 acpi_status
126 acpi_rs_get_crs_method_data (
127 acpi_handle handle,
128 struct acpi_buffer *ret_buffer)
130 union acpi_operand_object *obj_desc;
131 acpi_status status;
134 ACPI_FUNCTION_TRACE ("rs_get_crs_method_data");
137 /* Parameters guaranteed valid by caller */
140 * Execute the method, no parameters
142 status = acpi_ut_evaluate_object (handle, "_CRS", ACPI_BTYPE_BUFFER, &obj_desc);
143 if (ACPI_FAILURE (status)) {
144 return_ACPI_STATUS (status);
148 * Make the call to create a resource linked list from the
149 * byte stream buffer that comes back from the _CRS method
150 * execution.
152 status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
154 /* on exit, we must delete the object returned by evaluate_object */
156 acpi_ut_remove_reference (obj_desc);
157 return_ACPI_STATUS (status);
161 /*******************************************************************************
163 * FUNCTION: acpi_rs_get_prs_method_data
165 * PARAMETERS: Handle - a handle to the containing object
166 * ret_buffer - a pointer to a buffer structure for the
167 * results
169 * RETURN: Status
171 * DESCRIPTION: This function is called to get the _PRS value of an object
172 * contained in an object specified by the handle passed in
174 * If the function fails an appropriate status will be returned
175 * and the contents of the callers buffer is undefined.
177 ******************************************************************************/
178 #ifdef ACPI_FUTURE_USAGE
179 acpi_status
180 acpi_rs_get_prs_method_data (
181 acpi_handle handle,
182 struct acpi_buffer *ret_buffer)
184 union acpi_operand_object *obj_desc;
185 acpi_status status;
188 ACPI_FUNCTION_TRACE ("rs_get_prs_method_data");
191 /* Parameters guaranteed valid by caller */
194 * Execute the method, no parameters
196 status = acpi_ut_evaluate_object (handle, "_PRS", ACPI_BTYPE_BUFFER, &obj_desc);
197 if (ACPI_FAILURE (status)) {
198 return_ACPI_STATUS (status);
202 * Make the call to create a resource linked list from the
203 * byte stream buffer that comes back from the _CRS method
204 * execution.
206 status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
208 /* on exit, we must delete the object returned by evaluate_object */
210 acpi_ut_remove_reference (obj_desc);
211 return_ACPI_STATUS (status);
213 #endif /* ACPI_FUTURE_USAGE */
216 /*******************************************************************************
218 * FUNCTION: acpi_rs_get_method_data
220 * PARAMETERS: Handle - a handle to the containing object
221 * ret_buffer - a pointer to a buffer structure for the
222 * results
224 * RETURN: Status
226 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
227 * object contained in an object specified by the handle passed in
229 * If the function fails an appropriate status will be returned
230 * and the contents of the callers buffer is undefined.
232 ******************************************************************************/
234 acpi_status
235 acpi_rs_get_method_data (
236 acpi_handle handle,
237 char *path,
238 struct acpi_buffer *ret_buffer)
240 union acpi_operand_object *obj_desc;
241 acpi_status status;
244 ACPI_FUNCTION_TRACE ("rs_get_method_data");
247 /* Parameters guaranteed valid by caller */
250 * Execute the method, no parameters
252 status = acpi_ut_evaluate_object (handle, path, ACPI_BTYPE_BUFFER, &obj_desc);
253 if (ACPI_FAILURE (status)) {
254 return_ACPI_STATUS (status);
258 * Make the call to create a resource linked list from the
259 * byte stream buffer that comes back from the method
260 * execution.
262 status = acpi_rs_create_resource_list (obj_desc, ret_buffer);
264 /* On exit, we must delete the object returned by evaluate_object */
266 acpi_ut_remove_reference (obj_desc);
267 return_ACPI_STATUS (status);
270 /*******************************************************************************
272 * FUNCTION: acpi_rs_set_srs_method_data
274 * PARAMETERS: Handle - a handle to the containing object
275 * in_buffer - a pointer to a buffer structure of the
276 * parameter
278 * RETURN: Status
280 * DESCRIPTION: This function is called to set the _SRS of an object contained
281 * in an object specified by the handle passed in
283 * If the function fails an appropriate status will be returned
284 * and the contents of the callers buffer is undefined.
286 ******************************************************************************/
288 acpi_status
289 acpi_rs_set_srs_method_data (
290 acpi_handle handle,
291 struct acpi_buffer *in_buffer)
293 struct acpi_parameter_info info;
294 union acpi_operand_object *params[2];
295 acpi_status status;
296 struct acpi_buffer buffer;
299 ACPI_FUNCTION_TRACE ("rs_set_srs_method_data");
302 /* Parameters guaranteed valid by caller */
305 * The in_buffer parameter will point to a linked list of
306 * resource parameters. It needs to be formatted into a
307 * byte stream to be sent in as an input parameter to _SRS
309 * Convert the linked list into a byte stream
311 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
312 status = acpi_rs_create_byte_stream (in_buffer->pointer, &buffer);
313 if (ACPI_FAILURE (status)) {
314 return_ACPI_STATUS (status);
318 * Init the param object
320 params[0] = acpi_ut_create_internal_object (ACPI_TYPE_BUFFER);
321 if (!params[0]) {
322 acpi_os_free (buffer.pointer);
323 return_ACPI_STATUS (AE_NO_MEMORY);
327 * Set up the parameter object
329 params[0]->buffer.length = (u32) buffer.length;
330 params[0]->buffer.pointer = buffer.pointer;
331 params[0]->common.flags = AOPOBJ_DATA_VALID;
332 params[1] = NULL;
334 info.node = handle;
335 info.parameters = params;
336 info.parameter_type = ACPI_PARAM_ARGS;
339 * Execute the method, no return value
341 status = acpi_ns_evaluate_relative ("_SRS", &info);
342 if (ACPI_SUCCESS (status)) {
343 /* Delete any return object (especially if implicit_return is enabled) */
345 if (info.return_object) {
346 acpi_ut_remove_reference (info.return_object);
351 * Clean up and return the status from acpi_ns_evaluate_relative
353 acpi_ut_remove_reference (params[0]);
354 return_ACPI_STATUS (status);