blob: b3feebbd8ca2de0214590ab5433b2d7e7e0e7cfe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*******************************************************************************
2 *
3 * Module Name: rsxface - Public interfaces to the resource manager
4 *
5 ******************************************************************************/
6
7/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05008 * Copyright (C) 2000 - 2006, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * All rights reserved.
10 *
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.
25 *
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.
29 *
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.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/acresrc.h>
46
47#define _COMPONENT ACPI_RESOURCES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("rsxface")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Robert Moore44f6c012005-04-18 22:49:35 -040050/* Local macros for 16,32-bit to 64-bit conversion */
Robert Moore44f6c012005-04-18 22:49:35 -040051#define ACPI_COPY_FIELD(out, in, field) ((out)->field = (in)->field)
52#define ACPI_COPY_ADDRESS(out, in) \
53 ACPI_COPY_FIELD(out, in, resource_type); \
54 ACPI_COPY_FIELD(out, in, producer_consumer); \
55 ACPI_COPY_FIELD(out, in, decode); \
56 ACPI_COPY_FIELD(out, in, min_address_fixed); \
57 ACPI_COPY_FIELD(out, in, max_address_fixed); \
Bob Moore08978312005-10-21 00:00:00 -040058 ACPI_COPY_FIELD(out, in, info); \
Robert Moore44f6c012005-04-18 22:49:35 -040059 ACPI_COPY_FIELD(out, in, granularity); \
Bob Moore50eca3e2005-09-30 19:03:00 -040060 ACPI_COPY_FIELD(out, in, minimum); \
61 ACPI_COPY_FIELD(out, in, maximum); \
62 ACPI_COPY_FIELD(out, in, translation_offset); \
Robert Moore44f6c012005-04-18 22:49:35 -040063 ACPI_COPY_FIELD(out, in, address_length); \
64 ACPI_COPY_FIELD(out, in, resource_source);
Bob Moorec51a4de2005-11-17 13:07:00 -050065/* Local prototypes */
66static acpi_status
67acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context);
68
Linus Torvalds1da177e2005-04-16 15:20:36 -070069/*******************************************************************************
70 *
71 * FUNCTION: acpi_get_irq_routing_table
72 *
73 * PARAMETERS: device_handle - a handle to the Bus device we are querying
74 * ret_buffer - a pointer to a buffer to receive the
75 * current resources for the device
76 *
77 * RETURN: Status
78 *
79 * 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
81 * desired bus. The routine table is placed in the buffer pointed
82 * to by the ret_buffer variable parameter.
83 *
84 * If the function fails an appropriate status will be returned
85 * and the value of ret_buffer is undefined.
86 *
87 * This function attempts to execute the _PRT method contained in
88 * the object indicated by the passed device_handle.
89 *
90 ******************************************************************************/
Bob Moorec51a4de2005-11-17 13:07:00 -050091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040093acpi_get_irq_routing_table(acpi_handle device_handle,
94 struct acpi_buffer *ret_buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -070095{
Len Brown4be44fc2005-08-05 00:44:28 -040096 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
Len Brown4be44fc2005-08-05 00:44:28 -040098 ACPI_FUNCTION_TRACE("acpi_get_irq_routing_table ");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 /*
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) {
Len Brown4be44fc2005-08-05 00:44:28 -0400107 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 }
109
Len Brown4be44fc2005-08-05 00:44:28 -0400110 status = acpi_ut_validate_buffer(ret_buffer);
111 if (ACPI_FAILURE(status)) {
112 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
114
Len Brown4be44fc2005-08-05 00:44:28 -0400115 status = acpi_rs_get_prt_method_data(device_handle, ret_buffer);
116 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117}
118
Bob Moore83135242006-10-03 00:00:00 -0400119ACPI_EXPORT_SYMBOL(acpi_get_irq_routing_table)
120
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121/*******************************************************************************
122 *
123 * FUNCTION: acpi_get_current_resources
124 *
125 * PARAMETERS: device_handle - a handle to the device object for the
126 * device we are querying
127 * ret_buffer - a pointer to a buffer to receive the
128 * current resources for the device
129 *
130 * RETURN: Status
131 *
132 * DESCRIPTION: This function is called to get the current resources for a
133 * specific device. The caller must first acquire a handle for
134 * the desired device. The resource data is placed in the buffer
135 * pointed to by the ret_buffer variable parameter.
136 *
137 * If the function fails an appropriate status will be returned
138 * and the value of ret_buffer is undefined.
139 *
140 * This function attempts to execute the _CRS method contained in
141 * the object indicated by the passed device_handle.
142 *
143 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400145acpi_get_current_resources(acpi_handle device_handle,
146 struct acpi_buffer *ret_buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147{
Len Brown4be44fc2005-08-05 00:44:28 -0400148 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Len Brown4be44fc2005-08-05 00:44:28 -0400150 ACPI_FUNCTION_TRACE("acpi_get_current_resources");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151
152 /*
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) {
Len Brown4be44fc2005-08-05 00:44:28 -0400159 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 }
161
Len Brown4be44fc2005-08-05 00:44:28 -0400162 status = acpi_ut_validate_buffer(ret_buffer);
163 if (ACPI_FAILURE(status)) {
164 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 }
166
Len Brown4be44fc2005-08-05 00:44:28 -0400167 status = acpi_rs_get_crs_method_data(device_handle, ret_buffer);
168 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Bob Moore83135242006-10-03 00:00:00 -0400171ACPI_EXPORT_SYMBOL(acpi_get_current_resources)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Bob Moore83135242006-10-03 00:00:00 -0400173#ifdef ACPI_FUTURE_USAGE
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174/*******************************************************************************
175 *
176 * FUNCTION: acpi_get_possible_resources
177 *
178 * PARAMETERS: device_handle - a handle to the device object for the
179 * device we are querying
180 * ret_buffer - a pointer to a buffer to receive the
181 * resources for the device
182 *
183 * RETURN: Status
184 *
185 * 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
187 * for the desired device. The resource data is placed in the
188 * buffer pointed to by the ret_buffer variable.
189 *
190 * If the function fails an appropriate status will be returned
191 * and the value of ret_buffer is undefined.
192 *
193 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400195acpi_get_possible_resources(acpi_handle device_handle,
196 struct acpi_buffer *ret_buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197{
Len Brown4be44fc2005-08-05 00:44:28 -0400198 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Len Brown4be44fc2005-08-05 00:44:28 -0400200 ACPI_FUNCTION_TRACE("acpi_get_possible_resources");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
202 /*
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) {
Len Brown4be44fc2005-08-05 00:44:28 -0400209 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 }
211
Len Brown4be44fc2005-08-05 00:44:28 -0400212 status = acpi_ut_validate_buffer(ret_buffer);
213 if (ACPI_FAILURE(status)) {
214 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 }
216
Len Brown4be44fc2005-08-05 00:44:28 -0400217 status = acpi_rs_get_prs_method_data(device_handle, ret_buffer);
218 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Bob Moore83135242006-10-03 00:00:00 -0400221ACPI_EXPORT_SYMBOL(acpi_get_possible_resources)
Len Brown4be44fc2005-08-05 00:44:28 -0400222#endif /* ACPI_FUTURE_USAGE */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224/*******************************************************************************
225 *
226 * FUNCTION: acpi_walk_resources
227 *
Bob Moorec51a4de2005-11-17 13:07:00 -0500228 * PARAMETERS: device_handle - Handle to the device object for the
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 * device we are querying
Bob Moorec51a4de2005-11-17 13:07:00 -0500230 * Name - Method name of the resources we want
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
Bob Moorec51a4de2005-11-17 13:07:00 -0500232 * user_function - Called for each resource
233 * Context - Passed to user_function
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 *
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 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400243acpi_walk_resources(acpi_handle device_handle,
Bob Moorec51a4de2005-11-17 13:07:00 -0500244 char *name,
Len Brown4be44fc2005-08-05 00:44:28 -0400245 ACPI_WALK_RESOURCE_CALLBACK user_function, void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246{
Len Brown4be44fc2005-08-05 00:44:28 -0400247 acpi_status status;
Bob Moorec51a4de2005-11-17 13:07:00 -0500248 struct acpi_buffer buffer;
Len Brown4be44fc2005-08-05 00:44:28 -0400249 struct acpi_resource *resource;
Bob Moorec51a4de2005-11-17 13:07:00 -0500250 struct acpi_resource *resource_end;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Len Brown4be44fc2005-08-05 00:44:28 -0400252 ACPI_FUNCTION_TRACE("acpi_walk_resources");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
Bob Moorec51a4de2005-11-17 13:07:00 -0500254 /* Parameter validation */
255
256 if (!device_handle || !user_function || !name ||
257 (ACPI_STRNCMP(name, METHOD_NAME__CRS, sizeof(METHOD_NAME__CRS)) &&
258 ACPI_STRNCMP(name, METHOD_NAME__PRS, sizeof(METHOD_NAME__PRS)))) {
Len Brown4be44fc2005-08-05 00:44:28 -0400259 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 }
261
Bob Moorec51a4de2005-11-17 13:07:00 -0500262 /* 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);
Len Brown4be44fc2005-08-05 00:44:28 -0400266 if (ACPI_FAILURE(status)) {
267 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 }
269
Bob Moorec51a4de2005-11-17 13:07:00 -0500270 /* Buffer now contains the resource list */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271
Bob Moorec51a4de2005-11-17 13:07:00 -0500272 resource = ACPI_CAST_PTR(struct acpi_resource, buffer.pointer);
273 resource_end =
274 ACPI_ADD_PTR(struct acpi_resource, buffer.pointer, buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275
Bob Moorec51a4de2005-11-17 13:07:00 -0500276 /* Walk the resource list until the end_tag is found (or buffer end) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277
Bob Moorec51a4de2005-11-17 13:07:00 -0500278 while (resource < resource_end) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400279
Bob Moorec51a4de2005-11-17 13:07:00 -0500280 /* Sanity check the resource */
281
282 if (resource->type > ACPI_RESOURCE_TYPE_MAX) {
283 status = AE_AML_INVALID_RESOURCE_TYPE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284 break;
285 }
286
Bob Moorec51a4de2005-11-17 13:07:00 -0500287 /* Invoke the user function, abort on any error returned */
288
Len Brown4be44fc2005-08-05 00:44:28 -0400289 status = user_function(resource, context);
Bob Moorec51a4de2005-11-17 13:07:00 -0500290 if (ACPI_FAILURE(status)) {
291 if (status == AE_CTRL_TERMINATE) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400292
Bob Moorec51a4de2005-11-17 13:07:00 -0500293 /* This is an OK termination by the user function */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294
Bob Moorec51a4de2005-11-17 13:07:00 -0500295 status = AE_OK;
296 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 break;
Bob Moorec51a4de2005-11-17 13:07:00 -0500298 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Len Brown2ae41172006-01-16 15:22:45 -0500300 /* end_tag indicates end-of-list */
301
302 if (resource->type == ACPI_RESOURCE_TYPE_END_TAG) {
303 break;
304 }
305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 /* Get the next resource descriptor */
307
Bob Moorec51a4de2005-11-17 13:07:00 -0500308 resource =
309 ACPI_ADD_PTR(struct acpi_resource, resource,
310 resource->length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311 }
312
Bob Moore83135242006-10-03 00:00:00 -0400313 ACPI_FREE(buffer.pointer);
Len Brown4be44fc2005-08-05 00:44:28 -0400314 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
Bob Moore83135242006-10-03 00:00:00 -0400317ACPI_EXPORT_SYMBOL(acpi_walk_resources)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319/*******************************************************************************
320 *
321 * FUNCTION: acpi_set_current_resources
322 *
323 * PARAMETERS: device_handle - a handle to the device object for the
324 * device we are changing the resources of
325 * in_buffer - a pointer to a buffer containing the
326 * resources to be set for the device
327 *
328 * RETURN: Status
329 *
330 * DESCRIPTION: This function is called to set the current resources for a
331 * specific device. The caller must first acquire a handle for
332 * the desired device. The resource data is passed to the routine
333 * the buffer pointed to by the in_buffer variable.
334 *
335 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400337acpi_set_current_resources(acpi_handle device_handle,
338 struct acpi_buffer *in_buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339{
Len Brown4be44fc2005-08-05 00:44:28 -0400340 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
Len Brown4be44fc2005-08-05 00:44:28 -0400342 ACPI_FUNCTION_TRACE("acpi_set_current_resources");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Robert Moore44f6c012005-04-18 22:49:35 -0400344 /* Must have a valid handle and buffer */
345
Len Brown4be44fc2005-08-05 00:44:28 -0400346 if ((!device_handle) ||
347 (!in_buffer) || (!in_buffer->pointer) || (!in_buffer->length)) {
348 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 }
350
Len Brown4be44fc2005-08-05 00:44:28 -0400351 status = acpi_rs_set_srs_method_data(device_handle, in_buffer);
352 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354
Bob Moore83135242006-10-03 00:00:00 -0400355ACPI_EXPORT_SYMBOL(acpi_set_current_resources)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357/******************************************************************************
358 *
359 * FUNCTION: acpi_resource_to_address64
360 *
Robert Moorebda663d2005-09-16 16:51:15 -0400361 * PARAMETERS: Resource - Pointer to a resource
362 * Out - Pointer to the users's return
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 * buffer (a struct
364 * struct acpi_resource_address64)
365 *
366 * RETURN: Status
367 *
368 * DESCRIPTION: If the resource is an address16, address32, or address64,
369 * copy it to the address64 return buffer. This saves the
370 * caller from having to duplicate code for different-sized
371 * addresses.
372 *
373 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400375acpi_resource_to_address64(struct acpi_resource *resource,
376 struct acpi_resource_address64 *out)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377{
Len Brown4be44fc2005-08-05 00:44:28 -0400378 struct acpi_resource_address16 *address16;
379 struct acpi_resource_address32 *address32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
Bob Moorec51a4de2005-11-17 13:07:00 -0500381 if (!resource || !out) {
382 return (AE_BAD_PARAMETER);
383 }
384
385 /* Convert 16 or 32 address descriptor to 64 */
386
Robert Moorebda663d2005-09-16 16:51:15 -0400387 switch (resource->type) {
Bob Moore50eca3e2005-09-30 19:03:00 -0400388 case ACPI_RESOURCE_TYPE_ADDRESS16:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Len Brown4be44fc2005-08-05 00:44:28 -0400390 address16 = (struct acpi_resource_address16 *)&resource->data;
391 ACPI_COPY_ADDRESS(out, address16);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 break;
393
Bob Moore50eca3e2005-09-30 19:03:00 -0400394 case ACPI_RESOURCE_TYPE_ADDRESS32:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Len Brown4be44fc2005-08-05 00:44:28 -0400396 address32 = (struct acpi_resource_address32 *)&resource->data;
397 ACPI_COPY_ADDRESS(out, address32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 break;
399
Bob Moore50eca3e2005-09-30 19:03:00 -0400400 case ACPI_RESOURCE_TYPE_ADDRESS64:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401
402 /* Simple copy for 64 bit source */
403
Len Brown4be44fc2005-08-05 00:44:28 -0400404 ACPI_MEMCPY(out, &resource->data,
405 sizeof(struct acpi_resource_address64));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 break;
407
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 default:
409 return (AE_BAD_PARAMETER);
410 }
411
412 return (AE_OK);
413}
Len Brown4be44fc2005-08-05 00:44:28 -0400414
Bob Moore83135242006-10-03 00:00:00 -0400415ACPI_EXPORT_SYMBOL(acpi_resource_to_address64)
Bob Moorec51a4de2005-11-17 13:07:00 -0500416
417/*******************************************************************************
418 *
419 * FUNCTION: acpi_get_vendor_resource
420 *
421 * PARAMETERS: device_handle - Handle for the parent device object
422 * Name - Method name for the parent resource
423 * (METHOD_NAME__CRS or METHOD_NAME__PRS)
424 * Uuid - Pointer to the UUID to be matched.
425 * includes both subtype and 16-byte UUID
426 * ret_buffer - Where the vendor resource is returned
427 *
428 * RETURN: Status
429 *
430 * DESCRIPTION: Walk a resource template for the specified evice to find a
431 * vendor-defined resource that matches the supplied UUID and
432 * UUID subtype. Returns a struct acpi_resource of type Vendor.
433 *
434 ******************************************************************************/
Bob Moorec51a4de2005-11-17 13:07:00 -0500435acpi_status
436acpi_get_vendor_resource(acpi_handle device_handle,
437 char *name,
438 struct acpi_vendor_uuid * uuid,
439 struct acpi_buffer * ret_buffer)
440{
441 struct acpi_vendor_walk_info info;
442 acpi_status status;
443
444 /* Other parameters are validated by acpi_walk_resources */
445
446 if (!uuid || !ret_buffer) {
447 return (AE_BAD_PARAMETER);
448 }
449
450 info.uuid = uuid;
451 info.buffer = ret_buffer;
452 info.status = AE_NOT_EXIST;
453
454 /* Walk the _CRS or _PRS resource list for this device */
455
456 status =
457 acpi_walk_resources(device_handle, name,
458 acpi_rs_match_vendor_resource, &info);
459 if (ACPI_FAILURE(status)) {
460 return (status);
461 }
462
463 return (info.status);
464}
465
Bob Moore83135242006-10-03 00:00:00 -0400466ACPI_EXPORT_SYMBOL(acpi_get_vendor_resource)
467
Bob Moorec51a4de2005-11-17 13:07:00 -0500468/*******************************************************************************
469 *
470 * FUNCTION: acpi_rs_match_vendor_resource
471 *
472 * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
473 *
474 * RETURN: Status
475 *
476 * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
477 *
478 ******************************************************************************/
Bob Moorec51a4de2005-11-17 13:07:00 -0500479static acpi_status
480acpi_rs_match_vendor_resource(struct acpi_resource *resource, void *context)
481{
482 struct acpi_vendor_walk_info *info = context;
483 struct acpi_resource_vendor_typed *vendor;
484 struct acpi_buffer *buffer;
485 acpi_status status;
486
487 /* Ignore all descriptors except Vendor */
488
489 if (resource->type != ACPI_RESOURCE_TYPE_VENDOR) {
490 return (AE_OK);
491 }
492
493 vendor = &resource->data.vendor_typed;
494
495 /*
496 * For a valid match, these conditions must hold:
497 *
498 * 1) Length of descriptor data must be at least as long as a UUID struct
499 * 2) The UUID subtypes must match
500 * 3) The UUID data must match
501 */
502 if ((vendor->byte_length < (ACPI_UUID_LENGTH + 1)) ||
503 (vendor->uuid_subtype != info->uuid->subtype) ||
504 (ACPI_MEMCMP(vendor->uuid, info->uuid->data, ACPI_UUID_LENGTH))) {
505 return (AE_OK);
506 }
507
508 /* Validate/Allocate/Clear caller buffer */
509
510 buffer = info->buffer;
511 status = acpi_ut_initialize_buffer(buffer, resource->length);
512 if (ACPI_FAILURE(status)) {
513 return (status);
514 }
515
516 /* Found the correct resource, copy and return it */
517
518 ACPI_MEMCPY(buffer->pointer, resource, resource->length);
519 buffer->length = resource->length;
520
521 /* Found the desired descriptor, terminate resource walk */
522
523 info->status = AE_OK;
524 return (AE_CTRL_TERMINATE);
525}
Bob Moore83135242006-10-03 00:00:00 -0400526
527ACPI_EXPORT_SYMBOL(acpi_rs_match_vendor_resource)