aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/resources
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2006-05-26 16:36:00 -0400
committerLen Brown <len.brown@intel.com>2006-06-14 02:44:35 -0400
commit4119532c95547821dbe72d6916dfa1b2148475b3 (patch)
tree564eb8f69924fb7dc72e93526faf1547acac7d30 /drivers/acpi/resources
parentb8d35192c55fb055792ff0641408eaaec7c88988 (diff)
ACPI: ACPICA 20060526
Restructured, flattened, and simplified the internal interfaces for namespace object evaluation - resulting in smaller code, less CPU stack use, and fewer interfaces. (With assistance from Mikhail Kouzmich) Fixed a problem with the CopyObject operator where the first parameter was not typed correctly for the parser, interpreter, compiler, and disassembler. Caused various errors and unexpected behavior. Fixed a problem where a ShiftLeft or ShiftRight of more than 64 bits produced incorrect results with some C compilers. Since the behavior of C compilers when the shift value is larger than the datatype width is apparently not well defined, the interpreter now detects this condition and simply returns zero as expected in all such cases. (BZ 395) Fixed problem reports (Valery Podrezov) integrated: - Update String-to-Integer conversion to match ACPI 3.0A spec http://bugzilla.kernel.org/show_bug.cgi?id=5329 Allow interpreter to handle nested method declarations http://bugzilla.kernel.org/show_bug.cgi?id=5361 Fixed problem reports (Fiodor Suietov) integrated: - acpi_terminate() doesn't free debug memory allocation list objects (BZ 355) - After Core Subsystem shutdown, acpi_subsystem_status() returns AE_OK (BZ 356) - acpi_os_unmap_memory() for RSDP can be invoked inconsistently (BZ 357) - Resource Manager should return AE_TYPE for non-device objects (BZ 358) - Incomplete cleanup branch in AcpiNsEvaluateRelative (BZ 359) - Use acpi_os_free() instead of ACPI_FREE in acpi_rs_set_srs_method_data (BZ 360) - Incomplete cleanup branch in acpi_ps_parse_aml (BZ 361) - Incomplete cleanup branch in acpi_ds_delete_walk_state (BZ 362) - acpi_get_table_header returns AE_NO_ACPI_TABLES until DSDT is loaded (BZ 365) - Status of the Global Initialization Handler call not used (BZ 366) - Incorrect object parameter to Global Initialization Handler (BZ 367) Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/resources')
-rw-r--r--drivers/acpi/resources/rsutils.c95
-rw-r--r--drivers/acpi/resources/rsxface.c368
2 files changed, 261 insertions, 202 deletions
diff --git a/drivers/acpi/resources/rsutils.c b/drivers/acpi/resources/rsutils.c
index 0e493f2fec4d..a9cbee8e8b44 100644
--- a/drivers/acpi/resources/rsutils.c
+++ b/drivers/acpi/resources/rsutils.c
@@ -442,7 +442,7 @@ acpi_rs_set_resource_source(union aml_resource * aml,
442 * 442 *
443 * FUNCTION: acpi_rs_get_prt_method_data 443 * FUNCTION: acpi_rs_get_prt_method_data
444 * 444 *
445 * PARAMETERS: Handle - Handle to the containing object 445 * PARAMETERS: Node - Device node
446 * ret_buffer - Pointer to a buffer structure for the 446 * ret_buffer - Pointer to a buffer structure for the
447 * results 447 * results
448 * 448 *
@@ -457,7 +457,8 @@ acpi_rs_set_resource_source(union aml_resource * aml,
457 ******************************************************************************/ 457 ******************************************************************************/
458 458
459acpi_status 459acpi_status
460acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer) 460acpi_rs_get_prt_method_data(struct acpi_namespace_node * node,
461 struct acpi_buffer * ret_buffer)
461{ 462{
462 union acpi_operand_object *obj_desc; 463 union acpi_operand_object *obj_desc;
463 acpi_status status; 464 acpi_status status;
@@ -468,7 +469,7 @@ acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
468 469
469 /* Execute the method, no parameters */ 470 /* Execute the method, no parameters */
470 471
471 status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRT, 472 status = acpi_ut_evaluate_object(node, METHOD_NAME__PRT,
472 ACPI_BTYPE_PACKAGE, &obj_desc); 473 ACPI_BTYPE_PACKAGE, &obj_desc);
473 if (ACPI_FAILURE(status)) { 474 if (ACPI_FAILURE(status)) {
474 return_ACPI_STATUS(status); 475 return_ACPI_STATUS(status);
@@ -490,7 +491,7 @@ acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
490 * 491 *
491 * FUNCTION: acpi_rs_get_crs_method_data 492 * FUNCTION: acpi_rs_get_crs_method_data
492 * 493 *
493 * PARAMETERS: Handle - Handle to the containing object 494 * PARAMETERS: Node - Device node
494 * ret_buffer - Pointer to a buffer structure for the 495 * ret_buffer - Pointer to a buffer structure for the
495 * results 496 * results
496 * 497 *
@@ -505,7 +506,8 @@ acpi_rs_get_prt_method_data(acpi_handle handle, struct acpi_buffer * ret_buffer)
505 ******************************************************************************/ 506 ******************************************************************************/
506 507
507acpi_status 508acpi_status
508acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 509acpi_rs_get_crs_method_data(struct acpi_namespace_node *node,
510 struct acpi_buffer *ret_buffer)
509{ 511{
510 union acpi_operand_object *obj_desc; 512 union acpi_operand_object *obj_desc;
511 acpi_status status; 513 acpi_status status;
@@ -516,7 +518,7 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
516 518
517 /* Execute the method, no parameters */ 519 /* Execute the method, no parameters */
518 520
519 status = acpi_ut_evaluate_object(handle, METHOD_NAME__CRS, 521 status = acpi_ut_evaluate_object(node, METHOD_NAME__CRS,
520 ACPI_BTYPE_BUFFER, &obj_desc); 522 ACPI_BTYPE_BUFFER, &obj_desc);
521 if (ACPI_FAILURE(status)) { 523 if (ACPI_FAILURE(status)) {
522 return_ACPI_STATUS(status); 524 return_ACPI_STATUS(status);
@@ -539,7 +541,7 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
539 * 541 *
540 * FUNCTION: acpi_rs_get_prs_method_data 542 * FUNCTION: acpi_rs_get_prs_method_data
541 * 543 *
542 * PARAMETERS: Handle - Handle to the containing object 544 * PARAMETERS: Node - Device node
543 * ret_buffer - Pointer to a buffer structure for the 545 * ret_buffer - Pointer to a buffer structure for the
544 * results 546 * results
545 * 547 *
@@ -555,7 +557,8 @@ acpi_rs_get_crs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
555 557
556#ifdef ACPI_FUTURE_USAGE 558#ifdef ACPI_FUTURE_USAGE
557acpi_status 559acpi_status
558acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer) 560acpi_rs_get_prs_method_data(struct acpi_namespace_node *node,
561 struct acpi_buffer *ret_buffer)
559{ 562{
560 union acpi_operand_object *obj_desc; 563 union acpi_operand_object *obj_desc;
561 acpi_status status; 564 acpi_status status;
@@ -566,7 +569,7 @@ acpi_rs_get_prs_method_data(acpi_handle handle, struct acpi_buffer *ret_buffer)
566 569
567 /* Execute the method, no parameters */ 570 /* Execute the method, no parameters */
568 571
569 status = acpi_ut_evaluate_object(handle, METHOD_NAME__PRS, 572 status = acpi_ut_evaluate_object(node, METHOD_NAME__PRS,
570 ACPI_BTYPE_BUFFER, &obj_desc); 573 ACPI_BTYPE_BUFFER, &obj_desc);
571 if (ACPI_FAILURE(status)) { 574 if (ACPI_FAILURE(status)) {
572 return_ACPI_STATUS(status); 575 return_ACPI_STATUS(status);
@@ -641,7 +644,7 @@ acpi_rs_get_method_data(acpi_handle handle,
641 * 644 *
642 * FUNCTION: acpi_rs_set_srs_method_data 645 * FUNCTION: acpi_rs_set_srs_method_data
643 * 646 *
644 * PARAMETERS: Handle - Handle to the containing object 647 * PARAMETERS: Node - Device node
645 * in_buffer - Pointer to a buffer structure of the 648 * in_buffer - Pointer to a buffer structure of the
646 * parameter 649 * parameter
647 * 650 *
@@ -653,23 +656,37 @@ acpi_rs_get_method_data(acpi_handle handle,
653 * If the function fails an appropriate status will be returned 656 * If the function fails an appropriate status will be returned
654 * and the contents of the callers buffer is undefined. 657 * and the contents of the callers buffer is undefined.
655 * 658 *
659 * Note: Parameters guaranteed valid by caller
660 *
656 ******************************************************************************/ 661 ******************************************************************************/
657 662
658acpi_status 663acpi_status
659acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer) 664acpi_rs_set_srs_method_data(struct acpi_namespace_node *node,
665 struct acpi_buffer *in_buffer)
660{ 666{
661 struct acpi_parameter_info info; 667 struct acpi_evaluate_info *info;
662 union acpi_operand_object *params[2]; 668 union acpi_operand_object *args[2];
663 acpi_status status; 669 acpi_status status;
664 struct acpi_buffer buffer; 670 struct acpi_buffer buffer;
665 671
666 ACPI_FUNCTION_TRACE(rs_set_srs_method_data); 672 ACPI_FUNCTION_TRACE(rs_set_srs_method_data);
667 673
668 /* Parameters guaranteed valid by caller */ 674 /* Allocate and initialize the evaluation information block */
675
676 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
677 if (!info) {
678 return_ACPI_STATUS(AE_NO_MEMORY);
679 }
680
681 info->prefix_node = node;
682 info->pathname = METHOD_NAME__SRS;
683 info->parameters = args;
684 info->parameter_type = ACPI_PARAM_ARGS;
685 info->flags = ACPI_IGNORE_RETURN_VALUE;
669 686
670 /* 687 /*
671 * The in_buffer parameter will point to a linked list of 688 * The in_buffer parameter will point to a linked list of
672 * resource parameters. It needs to be formatted into a 689 * resource parameters. It needs to be formatted into a
673 * byte stream to be sent in as an input parameter to _SRS 690 * byte stream to be sent in as an input parameter to _SRS
674 * 691 *
675 * Convert the linked list into a byte stream 692 * Convert the linked list into a byte stream
@@ -677,42 +694,36 @@ acpi_rs_set_srs_method_data(acpi_handle handle, struct acpi_buffer *in_buffer)
677 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER; 694 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
678 status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer); 695 status = acpi_rs_create_aml_resources(in_buffer->pointer, &buffer);
679 if (ACPI_FAILURE(status)) { 696 if (ACPI_FAILURE(status)) {
680 return_ACPI_STATUS(status); 697 goto cleanup;
681 } 698 }
682 699
683 /* Init the param object */ 700 /* Create and initialize the method parameter object */
684 701
685 params[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER); 702 args[0] = acpi_ut_create_internal_object(ACPI_TYPE_BUFFER);
686 if (!params[0]) { 703 if (!args[0]) {
687 acpi_os_free(buffer.pointer); 704 /*
688 return_ACPI_STATUS(AE_NO_MEMORY); 705 * Must free the buffer allocated above (otherwise it is freed
706 * later)
707 */
708 ACPI_FREE(buffer.pointer);
709 status = AE_NO_MEMORY;
710 goto cleanup;
689 } 711 }
690 712
691 /* Set up the parameter object */ 713 args[0]->buffer.length = (u32) buffer.length;
692 714 args[0]->buffer.pointer = buffer.pointer;
693 params[0]->buffer.length = (u32) buffer.length; 715 args[0]->common.flags = AOPOBJ_DATA_VALID;
694 params[0]->buffer.pointer = buffer.pointer; 716 args[1] = NULL;
695 params[0]->common.flags = AOPOBJ_DATA_VALID;
696 params[1] = NULL;
697 717
698 info.node = handle; 718 /* Execute the method, no return value is expected */
699 info.parameters = params;
700 info.parameter_type = ACPI_PARAM_ARGS;
701 719
702 /* Execute the method, no return value */ 720 status = acpi_ns_evaluate(info);
703 721
704 status = acpi_ns_evaluate_relative(METHOD_NAME__SRS, &info); 722 /* Clean up and return the status from acpi_ns_evaluate */
705 if (ACPI_SUCCESS(status)) {
706
707 /* Delete any return object (especially if implicit_return is enabled) */
708
709 if (info.return_object) {
710 acpi_ut_remove_reference(info.return_object);
711 }
712 }
713 723
714 /* Clean up and return the status from acpi_ns_evaluate_relative */ 724 acpi_ut_remove_reference(args[0]);
715 725
716 acpi_ut_remove_reference(params[0]); 726 cleanup:
727 ACPI_FREE(info);
717 return_ACPI_STATUS(status); 728 return_ACPI_STATUS(status);
718} 729}
diff --git a/drivers/acpi/resources/rsxface.c b/drivers/acpi/resources/rsxface.c
index 8c1628c12cc8..1999e2ab7daa 100644
--- a/drivers/acpi/resources/rsxface.c
+++ b/drivers/acpi/resources/rsxface.c
@@ -43,6 +43,7 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include <acpi/acresrc.h> 45#include <acpi/acresrc.h>
46#include <acpi/acnamesp.h>
46 47
47#define _COMPONENT ACPI_RESOURCES 48#define _COMPONENT ACPI_RESOURCES
48ACPI_MODULE_NAME("rsxface") 49ACPI_MODULE_NAME("rsxface")
@@ -66,19 +67,80 @@ ACPI_MODULE_NAME("rsxface")
66static acpi_status 67static acpi_status
67acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context); 68acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
68 69
70static acpi_status
71acpi_rs_validate_parameters(acpi_handle device_handle,
72 struct acpi_buffer *buffer,
73 struct acpi_namespace_node **return_node);
74
75/*******************************************************************************
76 *
77 * FUNCTION: acpi_rs_validate_parameters
78 *
79 * PARAMETERS: device_handle - Handle to a device
80 * Buffer - Pointer to a data buffer
81 * return_node - Pointer to where the device node is returned
82 *
83 * RETURN: Status
84 *
85 * DESCRIPTION: Common parameter validation for resource interfaces
86 *
87 ******************************************************************************/
88
89static acpi_status
90acpi_rs_validate_parameters(acpi_handle device_handle,
91 struct acpi_buffer *buffer,
92 struct acpi_namespace_node **return_node)
93{
94 acpi_status status;
95 struct acpi_namespace_node *node;
96
97 ACPI_FUNCTION_TRACE(rs_validate_parameters);
98
99 /*
100 * Must have a valid handle to an ACPI device
101 */
102 if (!device_handle) {
103 return_ACPI_STATUS(AE_BAD_PARAMETER);
104 }
105
106 node = acpi_ns_map_handle_to_node(device_handle);
107 if (!node) {
108 return_ACPI_STATUS(AE_BAD_PARAMETER);
109 }
110
111 if (node->type != ACPI_TYPE_DEVICE) {
112 return_ACPI_STATUS(AE_TYPE);
113 }
114
115 /*
116 * Validate the user buffer object
117 *
118 * if there is a non-zero buffer length we also need a valid pointer in
119 * the buffer. If it's a zero buffer length, we'll be returning the
120 * needed buffer size (later), so keep going.
121 */
122 status = acpi_ut_validate_buffer(buffer);
123 if (ACPI_FAILURE(status)) {
124 return_ACPI_STATUS(status);
125 }
126
127 *return_node = node;
128 return_ACPI_STATUS(AE_OK);
129}
130
69/******************************************************************************* 131/*******************************************************************************
70 * 132 *
71 * FUNCTION: acpi_get_irq_routing_table 133 * FUNCTION: acpi_get_irq_routing_table
72 * 134 *
73 * PARAMETERS: device_handle - a handle to the Bus device we are querying 135 * PARAMETERS: device_handle - Handle to the Bus device we are querying
74 * ret_buffer - a pointer to a buffer to receive the 136 * ret_buffer - Pointer to a buffer to receive the
75 * current resources for the device 137 * current resources for the device
76 * 138 *
77 * RETURN: Status 139 * RETURN: Status
78 * 140 *
79 * DESCRIPTION: This function is called to get the IRQ routing table for a 141 * DESCRIPTION: This function is called to get the IRQ routing table for a
80 * specific bus. The caller must first acquire a handle for the 142 * specific bus. The caller must first acquire a handle for the
81 * desired bus. The routine table is placed in the buffer pointed 143 * desired bus. The routine table is placed in the buffer pointed
82 * to by the ret_buffer variable parameter. 144 * to by the ret_buffer variable parameter.
83 * 145 *
84 * If the function fails an appropriate status will be returned 146 * If the function fails an appropriate status will be returned
@@ -94,25 +156,18 @@ acpi_get_irq_routing_table(acpi_handle device_handle,
94 struct acpi_buffer *ret_buffer) 156 struct acpi_buffer *ret_buffer)
95{ 157{
96 acpi_status status; 158 acpi_status status;
159 struct acpi_namespace_node *node;
97 160
98 ACPI_FUNCTION_TRACE(acpi_get_irq_routing_table); 161 ACPI_FUNCTION_TRACE(acpi_get_irq_routing_table);
99 162
100 /* 163 /* Validate parameters then dispatch to internal routine */
101 * Must have a valid handle and buffer, So we have to have a handle
102 * and a return buffer structure, and if there is a non-zero buffer length
103 * we also need a valid pointer in the buffer. If it's a zero buffer length,
104 * we'll be returning the needed buffer size, so keep going.
105 */
106 if (!device_handle) {
107 return_ACPI_STATUS(AE_BAD_PARAMETER);
108 }
109 164
110 status = acpi_ut_validate_buffer(ret_buffer); 165 status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node);
111 if (ACPI_FAILURE(status)) { 166 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS(status); 167 return_ACPI_STATUS(status);
113 } 168 }
114 169
115 status = acpi_rs_get_prt_method_data(device_handle, ret_buffer); 170 status = acpi_rs_get_prt_method_data(node, ret_buffer);
116 return_ACPI_STATUS(status); 171 return_ACPI_STATUS(status);
117} 172}
118 173
@@ -122,16 +177,16 @@ ACPI_EXPORT_SYMBOL(acpi_get_irq_routing_table)
122 * 177 *
123 * FUNCTION: acpi_get_current_resources 178 * FUNCTION: acpi_get_current_resources
124 * 179 *
125 * PARAMETERS: device_handle - a handle to the device object for the 180 * PARAMETERS: device_handle - Handle to the device object for the
126 * device we are querying 181 * device we are querying
127 * ret_buffer - a pointer to a buffer to receive the 182 * ret_buffer - Pointer to a buffer to receive the
128 * current resources for the device 183 * current resources for the device
129 * 184 *
130 * RETURN: Status 185 * RETURN: Status
131 * 186 *
132 * DESCRIPTION: This function is called to get the current resources for a 187 * DESCRIPTION: This function is called to get the current resources for a
133 * specific device. The caller must first acquire a handle for 188 * specific device. The caller must first acquire a handle for
134 * the desired device. The resource data is placed in the buffer 189 * the desired device. The resource data is placed in the buffer
135 * pointed to by the ret_buffer variable parameter. 190 * pointed to by the ret_buffer variable parameter.
136 * 191 *
137 * If the function fails an appropriate status will be returned 192 * If the function fails an appropriate status will be returned
@@ -146,25 +201,18 @@ acpi_get_current_resources(acpi_handle device_handle,
146 struct acpi_buffer *ret_buffer) 201 struct acpi_buffer *ret_buffer)
147{ 202{
148 acpi_status status; 203 acpi_status status;
204 struct acpi_namespace_node *node;
149 205
150 ACPI_FUNCTION_TRACE(acpi_get_current_resources); 206 ACPI_FUNCTION_TRACE(acpi_get_current_resources);
151 207
152 /* 208 /* Validate parameters then dispatch to internal routine */
153 * Must have a valid handle and buffer, So we have to have a handle
154 * and a return buffer structure, and if there is a non-zero buffer length
155 * we also need a valid pointer in the buffer. If it's a zero buffer length,
156 * we'll be returning the needed buffer size, so keep going.
157 */
158 if (!device_handle) {
159 return_ACPI_STATUS(AE_BAD_PARAMETER);
160 }
161 209
162 status = acpi_ut_validate_buffer(ret_buffer); 210 status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node);
163 if (ACPI_FAILURE(status)) { 211 if (ACPI_FAILURE(status)) {
164 return_ACPI_STATUS(status); 212 return_ACPI_STATUS(status);
165 } 213 }
166 214
167 status = acpi_rs_get_crs_method_data(device_handle, ret_buffer); 215 status = acpi_rs_get_crs_method_data(node, ret_buffer);
168 return_ACPI_STATUS(status); 216 return_ACPI_STATUS(status);
169} 217}
170 218
@@ -175,16 +223,16 @@ ACPI_EXPORT_SYMBOL(acpi_get_current_resources)
175 * 223 *
176 * FUNCTION: acpi_get_possible_resources 224 * FUNCTION: acpi_get_possible_resources
177 * 225 *
178 * PARAMETERS: device_handle - a handle to the device object for the 226 * PARAMETERS: device_handle - Handle to the device object for the
179 * device we are querying 227 * device we are querying
180 * ret_buffer - a pointer to a buffer to receive the 228 * ret_buffer - Pointer to a buffer to receive the
181 * resources for the device 229 * resources for the device
182 * 230 *
183 * RETURN: Status 231 * RETURN: Status
184 * 232 *
185 * DESCRIPTION: This function is called to get a list of the possible resources 233 * DESCRIPTION: This function is called to get a list of the possible resources
186 * for a specific device. The caller must first acquire a handle 234 * for a specific device. The caller must first acquire a handle
187 * for the desired device. The resource data is placed in the 235 * for the desired device. The resource data is placed in the
188 * buffer pointed to by the ret_buffer variable. 236 * buffer pointed to by the ret_buffer variable.
189 * 237 *
190 * If the function fails an appropriate status will be returned 238 * If the function fails an appropriate status will be returned
@@ -196,25 +244,18 @@ acpi_get_possible_resources(acpi_handle device_handle,
196 struct acpi_buffer *ret_buffer) 244 struct acpi_buffer *ret_buffer)
197{ 245{
198 acpi_status status; 246 acpi_status status;
247 struct acpi_namespace_node *node;
199 248
200 ACPI_FUNCTION_TRACE(acpi_get_possible_resources); 249 ACPI_FUNCTION_TRACE(acpi_get_possible_resources);
201 250
202 /* 251 /* Validate parameters then dispatch to internal routine */
203 * Must have a valid handle and buffer, So we have to have a handle
204 * and a return buffer structure, and if there is a non-zero buffer length
205 * we also need a valid pointer in the buffer. If it's a zero buffer length,
206 * we'll be returning the needed buffer size, so keep going.
207 */
208 if (!device_handle) {
209 return_ACPI_STATUS(AE_BAD_PARAMETER);
210 }
211 252
212 status = acpi_ut_validate_buffer(ret_buffer); 253 status = acpi_rs_validate_parameters(device_handle, ret_buffer, &node);
213 if (ACPI_FAILURE(status)) { 254 if (ACPI_FAILURE(status)) {
214 return_ACPI_STATUS(status); 255 return_ACPI_STATUS(status);
215 } 256 }
216 257
217 status = acpi_rs_get_prs_method_data(device_handle, ret_buffer); 258 status = acpi_rs_get_prs_method_data(node, ret_buffer);
218 return_ACPI_STATUS(status); 259 return_ACPI_STATUS(status);
219} 260}
220 261
@@ -223,113 +264,18 @@ ACPI_EXPORT_SYMBOL(acpi_get_possible_resources)
223 264
224/******************************************************************************* 265/*******************************************************************************
225 * 266 *
226 * FUNCTION: acpi_walk_resources
227 *
228 * PARAMETERS: device_handle - Handle to the device object for the
229 * device we are querying
230 * Name - Method name of the resources we want
231 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
232 * user_function - Called for each resource
233 * Context - Passed to user_function
234 *
235 * RETURN: Status
236 *
237 * DESCRIPTION: Retrieves the current or possible resource list for the
238 * specified device. The user_function is called once for
239 * each resource in the list.
240 *
241 ******************************************************************************/
242acpi_status
243acpi_walk_resources(acpi_handle device_handle,
244 char *name,
245 acpi_walk_resource_callback user_function, void *context)
246{
247 acpi_status status;
248 struct acpi_buffer buffer;
249 struct acpi_resource *resource;
250 struct acpi_resource *resource_end;
251
252 ACPI_FUNCTION_TRACE(acpi_walk_resources);
253
254 /* Parameter validation */
255
256 if (!device_handle || !user_function || !name ||
257 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
258 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS))) {
259 return_ACPI_STATUS(AE_BAD_PARAMETER);
260 }
261
262 /* Get the _CRS or _PRS resource list */
263
264 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
265 status = acpi_rs_get_method_data(device_handle, name, &buffer);
266 if (ACPI_FAILURE(status)) {
267 return_ACPI_STATUS(status);
268 }
269
270 /* Buffer now contains the resource list */
271
272 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
273 resource_end =
274 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
275
276 /* Walk the resource list until the end_tag is found (or buffer end) */
277
278 while (resource < resource_end) {
279
280 /* Sanity check the resource */
281
282 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
283 status = AE_AML_INVALID_RESOURCE_TYPE;
284 break;
285 }
286
287 /* Invoke the user function, abort on any error returned */
288
289 status = user_function(resource, context);
290 if (ACPI_FAILURE(status)) {
291 if (status == AE_CTRL_TERMINATE) {
292
293 /* This is an OK termination by the user function */
294
295 status = AE_OK;
296 }
297 break;
298 }
299
300 /* end_tag indicates end-of-list */
301
302 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
303 break;
304 }
305
306 /* Get the next resource descriptor */
307
308 resource =
309 ACPI_ADD_PTR(struct acpi_resource, resource,
310 resource->length);
311 }
312
313 ACPI_FREE(buffer.pointer);
314 return_ACPI_STATUS(status);
315}
316
317ACPI_EXPORT_SYMBOL(acpi_walk_resources)
318
319/*******************************************************************************
320 *
321 * FUNCTION: acpi_set_current_resources 267 * FUNCTION: acpi_set_current_resources
322 * 268 *
323 * PARAMETERS: device_handle - a handle to the device object for the 269 * PARAMETERS: device_handle - Handle to the device object for the
324 * device we are changing the resources of 270 * device we are setting resources
325 * in_buffer - a pointer to a buffer containing the 271 * in_buffer - Pointer to a buffer containing the
326 * resources to be set for the device 272 * resources to be set for the device
327 * 273 *
328 * RETURN: Status 274 * RETURN: Status
329 * 275 *
330 * DESCRIPTION: This function is called to set the current resources for a 276 * DESCRIPTION: This function is called to set the current resources for a
331 * specific device. The caller must first acquire a handle for 277 * specific device. The caller must first acquire a handle for
332 * the desired device. The resource data is passed to the routine 278 * the desired device. The resource data is passed to the routine
333 * the buffer pointed to by the in_buffer variable. 279 * the buffer pointed to by the in_buffer variable.
334 * 280 *
335 ******************************************************************************/ 281 ******************************************************************************/
@@ -338,17 +284,24 @@ acpi_set_current_resources(acpi_handle device_handle,
338 struct acpi_buffer *in_buffer) 284 struct acpi_buffer *in_buffer)
339{ 285{
340 acpi_status status; 286 acpi_status status;
287 struct acpi_namespace_node *node;
341 288
342 ACPI_FUNCTION_TRACE(acpi_set_current_resources); 289 ACPI_FUNCTION_TRACE(acpi_set_current_resources);
343 290
344 /* Must have a valid handle and buffer */ 291 /* Validate the buffer, don't allow zero length */
345 292
346 if ((!device_handle) || 293 if ((!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) {
347 (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) {
348 return_ACPI_STATUS(AE_BAD_PARAMETER); 294 return_ACPI_STATUS(AE_BAD_PARAMETER);
349 } 295 }
350 296
351 status = acpi_rs_set_srs_method_data(device_handle, in_buffer); 297 /* Validate parameters then dispatch to internal routine */
298
299 status = acpi_rs_validate_parameters(device_handle, in_buffer, &node);
300 if (ACPI_FAILURE(status)) {
301 return_ACPI_STATUS(status);
302 }
303
304 status = acpi_rs_set_srs_method_data(node, in_buffer);
352 return_ACPI_STATUS(status); 305 return_ACPI_STATUS(status);
353} 306}
354 307
@@ -358,15 +311,14 @@ ACPI_EXPORT_SYMBOL(acpi_set_current_resources)
358 * 311 *
359 * FUNCTION: acpi_resource_to_address64 312 * FUNCTION: acpi_resource_to_address64
360 * 313 *
361 * PARAMETERS: Resource - Pointer to a resource 314 * PARAMETERS: Resource - Pointer to a resource
362 * Out - Pointer to the users's return 315 * Out - Pointer to the users's return buffer
363 * buffer (a struct 316 * (a struct acpi_resource_address64)
364 * struct acpi_resource_address64)
365 * 317 *
366 * RETURN: Status 318 * RETURN: Status
367 * 319 *
368 * DESCRIPTION: If the resource is an address16, address32, or address64, 320 * DESCRIPTION: If the resource is an address16, address32, or address64,
369 * copy it to the address64 return buffer. This saves the 321 * copy it to the address64 return buffer. This saves the
370 * caller from having to duplicate code for different-sized 322 * caller from having to duplicate code for different-sized
371 * addresses. 323 * addresses.
372 * 324 *
@@ -418,12 +370,12 @@ ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
418 * 370 *
419 * FUNCTION: acpi_get_vendor_resource 371 * FUNCTION: acpi_get_vendor_resource
420 * 372 *
421 * PARAMETERS: device_handle - Handle for the parent device object 373 * PARAMETERS: device_handle - Handle for the parent device object
422 * Name - Method name for the parent resource 374 * Name - Method name for the parent resource
423 * (METHOD_NAME__CRS or METHOD_NAME__PRS) 375 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
424 * Uuid - Pointer to the UUID to be matched. 376 * Uuid - Pointer to the UUID to be matched.
425 * includes both subtype and 16-byte UUID 377 * includes both subtype and 16-byte UUID
426 * ret_buffer - Where the vendor resource is returned 378 * ret_buffer - Where the vendor resource is returned
427 * 379 *
428 * RETURN: Status 380 * RETURN: Status
429 * 381 *
@@ -525,3 +477,99 @@ acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
525} 477}
526 478
527ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource) 479ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource)
480
481/*******************************************************************************
482 *
483 * FUNCTION: acpi_walk_resources
484 *
485 * PARAMETERS: device_handle - Handle to the device object for the
486 * device we are querying
487 * Name - Method name of the resources we want
488 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
489 * user_function - Called for each resource
490 * Context - Passed to user_function
491 *
492 * RETURN: Status
493 *
494 * DESCRIPTION: Retrieves the current or possible resource list for the
495 * specified device. The user_function is called once for
496 * each resource in the list.
497 *
498 ******************************************************************************/
499
500acpi_status
501acpi_walk_resources(acpi_handle device_handle,
502 char *name,
503 acpi_walk_resource_callback user_function, void *context)
504{
505 acpi_status status;
506 struct acpi_buffer buffer;
507 struct acpi_resource *resource;
508 struct acpi_resource *resource_end;
509
510 ACPI_FUNCTION_TRACE(acpi_walk_resources);
511
512 /* Parameter validation */
513
514 if (!device_handle || !user_function || !name ||
515 (!ACPI_COMPARE_NAME(name, METHOD_NAME__CRS) &&
516 !ACPI_COMPARE_NAME(name, METHOD_NAME__PRS))) {
517 return_ACPI_STATUS(AE_BAD_PARAMETER);
518 }
519
520 /* Get the _CRS or _PRS resource list */
521
522 buffer.length = ACPI_ALLOCATE_LOCAL_BUFFER;
523 status = acpi_rs_get_method_data(device_handle, name, &buffer);
524 if (ACPI_FAILURE(status)) {
525 return_ACPI_STATUS(status);
526 }
527
528 /* Buffer now contains the resource list */
529
530 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
531 resource_end =
532 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
533
534 /* Walk the resource list until the end_tag is found (or buffer end) */
535
536 while (resource < resource_end) {
537
538 /* Sanity check the resource */
539
540 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
541 status = AE_AML_INVALID_RESOURCE_TYPE;
542 break;
543 }
544
545 /* Invoke the user function, abort on any error returned */
546
547 status = user_function(resource, context);
548 if (ACPI_FAILURE(status)) {
549 if (status == AE_CTRL_TERMINATE) {
550
551 /* This is an OK termination by the user function */
552
553 status = AE_OK;
554 }
555 break;
556 }
557
558 /* end_tag indicates end-of-list */
559
560 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
561 break;
562 }
563
564 /* Get the next resource descriptor */
565
566 resource =
567 ACPI_ADD_PTR(struct acpi_resource, resource,
568 resource->length);
569 }
570
571 ACPI_FREE(buffer.pointer);
572 return_ACPI_STATUS(status);
573}
574
575ACPI_EXPORT_SYMBOL(acpi_walk_resources)