1 /*******************************************************************************
3 * Module Name: rsutils - Utilities for the resource manager
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_RESOURCES
30 MODULE_NAME ("rsutils")
33 /*******************************************************************************
35 * FUNCTION: Acpi_rs_get_prt_method_data
37 * PARAMETERS: Handle - a handle to the containing object
38 * Ret_buffer - a pointer to a buffer structure for the
41 * RETURN: Status - the status of the call
43 * DESCRIPTION: This function is called to get the _PRT value of an object
44 * contained in an object specified by the handle passed in
46 * If the function fails an appropriate status will be returned
47 * and the contents of the callers buffer is undefined.
49 ******************************************************************************/
52 acpi_rs_get_prt_method_data (
54 ACPI_BUFFER
*ret_buffer
)
56 ACPI_OPERAND_OBJECT
*ret_obj
;
58 u32 buffer_space_needed
;
61 /* already validated params, so we won't repeat here */
63 buffer_space_needed
= ret_buffer
->length
;
66 * Execute the method, no parameters
68 status
= acpi_ns_evaluate_relative (handle
, "_PRT", NULL
, &ret_obj
);
69 if (ACPI_FAILURE (status
)) {
74 /* Return object is required */
81 * The return object will be a package, so check the
82 * parameters. If the return object is not a package,
83 * then the underlying AML code is corrupt or improperly
86 if (ACPI_TYPE_PACKAGE
!= ret_obj
->common
.type
) {
87 status
= AE_AML_OPERAND_TYPE
;
92 * Make the call to create a resource linked list from the
93 * byte stream buffer that comes back from the _CRS method
96 status
= acpi_rs_create_pci_routing_table (ret_obj
,
98 &buffer_space_needed
);
101 * Tell the user how much of the buffer we have used or is needed
102 * and return the final status.
104 ret_buffer
->length
= buffer_space_needed
;
107 /* On exit, we must delete the object returned by evaluate_object */
111 acpi_cm_remove_reference (ret_obj
);
117 /*******************************************************************************
119 * FUNCTION: Acpi_rs_get_crs_method_data
121 * PARAMETERS: Handle - a handle to the containing object
122 * Ret_buffer - a pointer to a buffer structure for the
125 * RETURN: Status - the status of the call
127 * DESCRIPTION: This function is called to get the _CRS value of an object
128 * contained in an object specified by the handle passed in
130 * If the function fails an appropriate status will be returned
131 * and the contents of the callers buffer is undefined.
133 ******************************************************************************/
136 acpi_rs_get_crs_method_data (
138 ACPI_BUFFER
*ret_buffer
)
140 ACPI_OPERAND_OBJECT
*ret_obj
;
142 u32 buffer_space_needed
= ret_buffer
->length
;
145 /* already validated params, so we won't repeat here */
148 * Execute the method, no parameters
150 status
= acpi_ns_evaluate_relative (handle
, "_CRS", NULL
, &ret_obj
);
151 if (ACPI_FAILURE (status
)) {
156 /* Return object is required */
162 * The return object will be a buffer, but check the
163 * parameters. If the return object is not a buffer,
164 * then the underlying AML code is corrupt or improperly
167 if (ACPI_TYPE_BUFFER
!= ret_obj
->common
.type
) {
168 status
= AE_AML_OPERAND_TYPE
;
173 * Make the call to create a resource linked list from the
174 * byte stream buffer that comes back from the _CRS method
177 status
= acpi_rs_create_resource_list (ret_obj
,
179 &buffer_space_needed
);
184 * Tell the user how much of the buffer we have used or is needed
185 * and return the final status.
187 ret_buffer
->length
= buffer_space_needed
;
190 /* On exit, we must delete the object returned by evaluate_object */
194 acpi_cm_remove_reference (ret_obj
);
200 /*******************************************************************************
202 * FUNCTION: Acpi_rs_get_prs_method_data
204 * PARAMETERS: Handle - a handle to the containing object
205 * Ret_buffer - a pointer to a buffer structure for the
208 * RETURN: Status - the status of the call
210 * DESCRIPTION: This function is called to get the _PRS value of an object
211 * contained in an object specified by the handle passed in
213 * If the function fails an appropriate status will be returned
214 * and the contents of the callers buffer is undefined.
216 ******************************************************************************/
219 acpi_rs_get_prs_method_data (
221 ACPI_BUFFER
*ret_buffer
)
223 ACPI_OPERAND_OBJECT
*ret_obj
;
225 u32 buffer_space_needed
= ret_buffer
->length
;
228 /* already validated params, so we won't repeat here */
231 * Execute the method, no parameters
233 status
= acpi_ns_evaluate_relative (handle
, "_PRS", NULL
, &ret_obj
);
234 if (ACPI_FAILURE (status
)) {
239 /* Return object is required */
245 * The return object will be a buffer, but check the
246 * parameters. If the return object is not a buffer,
247 * then the underlying AML code is corrupt or improperly
250 if (ACPI_TYPE_BUFFER
!= ret_obj
->common
.type
) {
251 status
= AE_AML_OPERAND_TYPE
;
256 * Make the call to create a resource linked list from the
257 * byte stream buffer that comes back from the _CRS method
260 status
= acpi_rs_create_resource_list (ret_obj
,
262 &buffer_space_needed
);
265 * Tell the user how much of the buffer we have used or is needed
266 * and return the final status.
268 ret_buffer
->length
= buffer_space_needed
;
271 /* On exit, we must delete the object returned by evaluate_object */
275 acpi_cm_remove_reference (ret_obj
);
281 /*******************************************************************************
283 * FUNCTION: Acpi_rs_set_srs_method_data
285 * PARAMETERS: Handle - a handle to the containing object
286 * In_buffer - a pointer to a buffer structure of the
289 * RETURN: Status - the status of the call
291 * DESCRIPTION: This function is called to set the _SRS of an object contained
292 * in an object specified by the handle passed in
294 * If the function fails an appropriate status will be returned
295 * and the contents of the callers buffer is undefined.
297 ******************************************************************************/
300 acpi_rs_set_srs_method_data (
302 ACPI_BUFFER
*in_buffer
)
304 ACPI_OPERAND_OBJECT
*params
[2];
305 ACPI_OPERAND_OBJECT param_obj
;
307 u8
*byte_stream
= NULL
;
308 u32 buffer_size_needed
= 0;
311 /* already validated params, so we won't repeat here */
314 * The In_buffer parameter will point to a linked list of
315 * resource parameters. It needs to be formatted into a
316 * byte stream to be sent in as an input parameter.
318 buffer_size_needed
= 0;
321 * First call is to get the buffer size needed
323 status
= acpi_rs_create_byte_stream (in_buffer
->pointer
,
325 &buffer_size_needed
);
327 * We expect a return of AE_BUFFER_OVERFLOW
328 * if not, exit with the error
330 if (AE_BUFFER_OVERFLOW
!= status
) {
335 * Allocate the buffer needed
337 byte_stream
= acpi_cm_callocate(buffer_size_needed
);
338 if (NULL
== byte_stream
) {
339 return (AE_NO_MEMORY
);
343 * Now call to convert the linked list into a byte stream
345 status
= acpi_rs_create_byte_stream (in_buffer
->pointer
,
347 &buffer_size_needed
);
348 if (ACPI_FAILURE (status
)) {
353 * Init the param object
355 acpi_cm_init_static_object (¶m_obj
);
358 * Method requires one parameter. Set it up
360 params
[0] = ¶m_obj
;
364 * Set up the parameter object
366 param_obj
.common
.type
= ACPI_TYPE_BUFFER
;
367 param_obj
.buffer
.length
= buffer_size_needed
;
368 param_obj
.buffer
.pointer
= byte_stream
;
371 * Execute the method, no return value
373 status
= acpi_ns_evaluate_relative (handle
, "_SRS", params
, NULL
);
376 * Clean up and return the status from Acpi_ns_evaluate_relative
381 acpi_cm_free (byte_stream
);