1 /*******************************************************************************
3 * Module Name: rsutils - Utilities for the resource manager
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acnamesp.h>
46 #include <acpi/acresrc.h>
48 #define _COMPONENT ACPI_RESOURCES
49 ACPI_MODULE_NAME("rsutils")
51 /*******************************************************************************
53 * FUNCTION: acpi_rs_get_prt_method_data
55 * PARAMETERS: Handle - a handle to the containing object
56 * ret_buffer - a pointer to a buffer structure for the
61 * DESCRIPTION: This function is called to get the _PRT value of an object
62 * contained in an object specified by the handle passed in
64 * If the function fails an appropriate status will be returned
65 * and the contents of the callers buffer is undefined.
67 ******************************************************************************/
69 acpi_rs_get_prt_method_data(acpi_handle handle
, struct acpi_buffer
*ret_buffer
)
71 union acpi_operand_object
*obj_desc
;
74 ACPI_FUNCTION_TRACE("rs_get_prt_method_data");
76 /* Parameters guaranteed valid by caller */
78 /* Execute the method, no parameters */
80 status
= acpi_ut_evaluate_object(handle
, METHOD_NAME__PRT
,
81 ACPI_BTYPE_PACKAGE
, &obj_desc
);
82 if (ACPI_FAILURE(status
)) {
83 return_ACPI_STATUS(status
);
87 * Create a resource linked list from the byte stream buffer that comes
88 * back from the _CRS method execution.
90 status
= acpi_rs_create_pci_routing_table(obj_desc
, ret_buffer
);
92 /* On exit, we must delete the object returned by evaluate_object */
94 acpi_ut_remove_reference(obj_desc
);
95 return_ACPI_STATUS(status
);
98 /*******************************************************************************
100 * FUNCTION: acpi_rs_get_crs_method_data
102 * PARAMETERS: Handle - a handle to the containing object
103 * ret_buffer - a pointer to a buffer structure for the
108 * DESCRIPTION: This function is called to get the _CRS value of an object
109 * contained in an object specified by the handle passed in
111 * If the function fails an appropriate status will be returned
112 * and the contents of the callers buffer is undefined.
114 ******************************************************************************/
117 acpi_rs_get_crs_method_data(acpi_handle handle
, struct acpi_buffer
*ret_buffer
)
119 union acpi_operand_object
*obj_desc
;
122 ACPI_FUNCTION_TRACE("rs_get_crs_method_data");
124 /* Parameters guaranteed valid by caller */
126 /* Execute the method, no parameters */
128 status
= acpi_ut_evaluate_object(handle
, METHOD_NAME__CRS
,
129 ACPI_BTYPE_BUFFER
, &obj_desc
);
130 if (ACPI_FAILURE(status
)) {
131 return_ACPI_STATUS(status
);
135 * Make the call to create a resource linked list from the
136 * byte stream buffer that comes back from the _CRS method
139 status
= acpi_rs_create_resource_list(obj_desc
, ret_buffer
);
141 /* on exit, we must delete the object returned by evaluate_object */
143 acpi_ut_remove_reference(obj_desc
);
144 return_ACPI_STATUS(status
);
147 /*******************************************************************************
149 * FUNCTION: acpi_rs_get_prs_method_data
151 * PARAMETERS: Handle - a handle to the containing object
152 * ret_buffer - a pointer to a buffer structure for the
157 * DESCRIPTION: This function is called to get the _PRS value of an object
158 * contained in an object specified by the handle passed in
160 * If the function fails an appropriate status will be returned
161 * and the contents of the callers buffer is undefined.
163 ******************************************************************************/
165 #ifdef ACPI_FUTURE_USAGE
167 acpi_rs_get_prs_method_data(acpi_handle handle
, struct acpi_buffer
*ret_buffer
)
169 union acpi_operand_object
*obj_desc
;
172 ACPI_FUNCTION_TRACE("rs_get_prs_method_data");
174 /* Parameters guaranteed valid by caller */
176 /* Execute the method, no parameters */
178 status
= acpi_ut_evaluate_object(handle
, METHOD_NAME__PRS
,
179 ACPI_BTYPE_BUFFER
, &obj_desc
);
180 if (ACPI_FAILURE(status
)) {
181 return_ACPI_STATUS(status
);
185 * Make the call to create a resource linked list from the
186 * byte stream buffer that comes back from the _CRS method
189 status
= acpi_rs_create_resource_list(obj_desc
, ret_buffer
);
191 /* on exit, we must delete the object returned by evaluate_object */
193 acpi_ut_remove_reference(obj_desc
);
194 return_ACPI_STATUS(status
);
196 #endif /* ACPI_FUTURE_USAGE */
198 /*******************************************************************************
200 * FUNCTION: acpi_rs_get_method_data
202 * PARAMETERS: Handle - a handle to the containing object
203 * Path - Path to method, relative to Handle
204 * ret_buffer - a pointer to a buffer structure for the
209 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
210 * object contained in an object specified by the handle passed in
212 * If the function fails an appropriate status will be returned
213 * and the contents of the callers buffer is undefined.
215 ******************************************************************************/
218 acpi_rs_get_method_data(acpi_handle handle
,
219 char *path
, struct acpi_buffer
*ret_buffer
)
221 union acpi_operand_object
*obj_desc
;
224 ACPI_FUNCTION_TRACE("rs_get_method_data");
226 /* Parameters guaranteed valid by caller */
228 /* Execute the method, no parameters */
231 acpi_ut_evaluate_object(handle
, path
, ACPI_BTYPE_BUFFER
, &obj_desc
);
232 if (ACPI_FAILURE(status
)) {
233 return_ACPI_STATUS(status
);
237 * Make the call to create a resource linked list from the
238 * byte stream buffer that comes back from the method
241 status
= acpi_rs_create_resource_list(obj_desc
, ret_buffer
);
243 /* On exit, we must delete the object returned by evaluate_object */
245 acpi_ut_remove_reference(obj_desc
);
246 return_ACPI_STATUS(status
);
249 /*******************************************************************************
251 * FUNCTION: acpi_rs_set_srs_method_data
253 * PARAMETERS: Handle - a handle to the containing object
254 * in_buffer - a pointer to a buffer structure of the
259 * DESCRIPTION: This function is called to set the _SRS of an object contained
260 * in an object specified by the handle passed in
262 * If the function fails an appropriate status will be returned
263 * and the contents of the callers buffer is undefined.
265 ******************************************************************************/
268 acpi_rs_set_srs_method_data(acpi_handle handle
, struct acpi_buffer
*in_buffer
)
270 struct acpi_parameter_info info
;
271 union acpi_operand_object
*params
[2];
273 struct acpi_buffer buffer
;
275 ACPI_FUNCTION_TRACE("rs_set_srs_method_data");
277 /* Parameters guaranteed valid by caller */
280 * The in_buffer parameter will point to a linked list of
281 * resource parameters. It needs to be formatted into a
282 * byte stream to be sent in as an input parameter to _SRS
284 * Convert the linked list into a byte stream
286 buffer
.length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
287 status
= acpi_rs_create_byte_stream(in_buffer
->pointer
, &buffer
);
288 if (ACPI_FAILURE(status
)) {
289 return_ACPI_STATUS(status
);
292 /* Init the param object */
294 params
[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER
);
296 acpi_os_free(buffer
.pointer
);
297 return_ACPI_STATUS(AE_NO_MEMORY
);
300 /* Set up the parameter object */
302 params
[0]->buffer
.length
= (u32
) buffer
.length
;
303 params
[0]->buffer
.pointer
= buffer
.pointer
;
304 params
[0]->common
.flags
= AOPOBJ_DATA_VALID
;
308 info
.parameters
= params
;
309 info
.parameter_type
= ACPI_PARAM_ARGS
;
311 /* Execute the method, no return value */
313 status
= acpi_ns_evaluate_relative(METHOD_NAME__SRS
, &info
);
314 if (ACPI_SUCCESS(status
)) {
315 /* Delete any return object (especially if implicit_return is enabled) */
317 if (info
.return_object
) {
318 acpi_ut_remove_reference(info
.return_object
);
322 /* Clean up and return the status from acpi_ns_evaluate_relative */
324 acpi_ut_remove_reference(params
[0]);
325 return_ACPI_STATUS(status
);