rsxface.c revision 1.3.4.2 1 1.3.4.2 rmind /*******************************************************************************
2 1.3.4.2 rmind *
3 1.3.4.2 rmind * Module Name: rsxface - Public interfaces to the resource manager
4 1.3.4.2 rmind *
5 1.3.4.2 rmind ******************************************************************************/
6 1.3.4.2 rmind
7 1.3.4.2 rmind /*
8 1.3.4.2 rmind * Copyright (C) 2000 - 2011, Intel Corp.
9 1.3.4.2 rmind * All rights reserved.
10 1.3.4.2 rmind *
11 1.3.4.2 rmind * Redistribution and use in source and binary forms, with or without
12 1.3.4.2 rmind * modification, are permitted provided that the following conditions
13 1.3.4.2 rmind * are met:
14 1.3.4.2 rmind * 1. Redistributions of source code must retain the above copyright
15 1.3.4.2 rmind * notice, this list of conditions, and the following disclaimer,
16 1.3.4.2 rmind * without modification.
17 1.3.4.2 rmind * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3.4.2 rmind * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3.4.2 rmind * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3.4.2 rmind * including a substantially similar Disclaimer requirement for further
21 1.3.4.2 rmind * binary redistribution.
22 1.3.4.2 rmind * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3.4.2 rmind * of any contributors may be used to endorse or promote products derived
24 1.3.4.2 rmind * from this software without specific prior written permission.
25 1.3.4.2 rmind *
26 1.3.4.2 rmind * Alternatively, this software may be distributed under the terms of the
27 1.3.4.2 rmind * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3.4.2 rmind * Software Foundation.
29 1.3.4.2 rmind *
30 1.3.4.2 rmind * NO WARRANTY
31 1.3.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3.4.2 rmind * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3.4.2 rmind * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3.4.2 rmind * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3.4.2 rmind * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3.4.2 rmind * POSSIBILITY OF SUCH DAMAGES.
42 1.3.4.2 rmind */
43 1.3.4.2 rmind
44 1.3.4.2 rmind
45 1.3.4.2 rmind #define __RSXFACE_C__
46 1.3.4.2 rmind
47 1.3.4.2 rmind #include "acpi.h"
48 1.3.4.2 rmind #include "accommon.h"
49 1.3.4.2 rmind #include "acresrc.h"
50 1.3.4.2 rmind #include "acnamesp.h"
51 1.3.4.2 rmind
52 1.3.4.2 rmind #define _COMPONENT ACPI_RESOURCES
53 1.3.4.2 rmind ACPI_MODULE_NAME ("rsxface")
54 1.3.4.2 rmind
55 1.3.4.2 rmind /* Local macros for 16,32-bit to 64-bit conversion */
56 1.3.4.2 rmind
57 1.3.4.2 rmind #define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field)
58 1.3.4.2 rmind #define ACPI_COPY_ADDRESS(Out, In) \
59 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, ResourceType); \
60 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
61 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, Decode); \
62 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
63 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
64 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, Info); \
65 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, Granularity); \
66 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, Minimum); \
67 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, Maximum); \
68 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, TranslationOffset); \
69 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, AddressLength); \
70 1.3.4.2 rmind ACPI_COPY_FIELD(Out, In, ResourceSource);
71 1.3.4.2 rmind
72 1.3.4.2 rmind
73 1.3.4.2 rmind /* Local prototypes */
74 1.3.4.2 rmind
75 1.3.4.2 rmind static ACPI_STATUS
76 1.3.4.2 rmind AcpiRsMatchVendorResource (
77 1.3.4.2 rmind ACPI_RESOURCE *Resource,
78 1.3.4.2 rmind void *Context);
79 1.3.4.2 rmind
80 1.3.4.2 rmind static ACPI_STATUS
81 1.3.4.2 rmind AcpiRsValidateParameters (
82 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
83 1.3.4.2 rmind ACPI_BUFFER *Buffer,
84 1.3.4.2 rmind ACPI_NAMESPACE_NODE **ReturnNode);
85 1.3.4.2 rmind
86 1.3.4.2 rmind
87 1.3.4.2 rmind /*******************************************************************************
88 1.3.4.2 rmind *
89 1.3.4.2 rmind * FUNCTION: AcpiRsValidateParameters
90 1.3.4.2 rmind *
91 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to a device
92 1.3.4.2 rmind * Buffer - Pointer to a data buffer
93 1.3.4.2 rmind * ReturnNode - Pointer to where the device node is returned
94 1.3.4.2 rmind *
95 1.3.4.2 rmind * RETURN: Status
96 1.3.4.2 rmind *
97 1.3.4.2 rmind * DESCRIPTION: Common parameter validation for resource interfaces
98 1.3.4.2 rmind *
99 1.3.4.2 rmind ******************************************************************************/
100 1.3.4.2 rmind
101 1.3.4.2 rmind static ACPI_STATUS
102 1.3.4.2 rmind AcpiRsValidateParameters (
103 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
104 1.3.4.2 rmind ACPI_BUFFER *Buffer,
105 1.3.4.2 rmind ACPI_NAMESPACE_NODE **ReturnNode)
106 1.3.4.2 rmind {
107 1.3.4.2 rmind ACPI_STATUS Status;
108 1.3.4.2 rmind ACPI_NAMESPACE_NODE *Node;
109 1.3.4.2 rmind
110 1.3.4.2 rmind
111 1.3.4.2 rmind ACPI_FUNCTION_TRACE (RsValidateParameters);
112 1.3.4.2 rmind
113 1.3.4.2 rmind
114 1.3.4.2 rmind /*
115 1.3.4.2 rmind * Must have a valid handle to an ACPI device
116 1.3.4.2 rmind */
117 1.3.4.2 rmind if (!DeviceHandle)
118 1.3.4.2 rmind {
119 1.3.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
120 1.3.4.2 rmind }
121 1.3.4.2 rmind
122 1.3.4.2 rmind Node = AcpiNsValidateHandle (DeviceHandle);
123 1.3.4.2 rmind if (!Node)
124 1.3.4.2 rmind {
125 1.3.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
126 1.3.4.2 rmind }
127 1.3.4.2 rmind
128 1.3.4.2 rmind if (Node->Type != ACPI_TYPE_DEVICE)
129 1.3.4.2 rmind {
130 1.3.4.2 rmind return_ACPI_STATUS (AE_TYPE);
131 1.3.4.2 rmind }
132 1.3.4.2 rmind
133 1.3.4.2 rmind /*
134 1.3.4.2 rmind * Validate the user buffer object
135 1.3.4.2 rmind *
136 1.3.4.2 rmind * if there is a non-zero buffer length we also need a valid pointer in
137 1.3.4.2 rmind * the buffer. If it's a zero buffer length, we'll be returning the
138 1.3.4.2 rmind * needed buffer size (later), so keep going.
139 1.3.4.2 rmind */
140 1.3.4.2 rmind Status = AcpiUtValidateBuffer (Buffer);
141 1.3.4.2 rmind if (ACPI_FAILURE (Status))
142 1.3.4.2 rmind {
143 1.3.4.2 rmind return_ACPI_STATUS (Status);
144 1.3.4.2 rmind }
145 1.3.4.2 rmind
146 1.3.4.2 rmind *ReturnNode = Node;
147 1.3.4.2 rmind return_ACPI_STATUS (AE_OK);
148 1.3.4.2 rmind }
149 1.3.4.2 rmind
150 1.3.4.2 rmind
151 1.3.4.2 rmind /*******************************************************************************
152 1.3.4.2 rmind *
153 1.3.4.2 rmind * FUNCTION: AcpiGetIrqRoutingTable
154 1.3.4.2 rmind *
155 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying
156 1.3.4.2 rmind * RetBuffer - Pointer to a buffer to receive the
157 1.3.4.2 rmind * current resources for the device
158 1.3.4.2 rmind *
159 1.3.4.2 rmind * RETURN: Status
160 1.3.4.2 rmind *
161 1.3.4.2 rmind * DESCRIPTION: This function is called to get the IRQ routing table for a
162 1.3.4.2 rmind * specific bus. The caller must first acquire a handle for the
163 1.3.4.2 rmind * desired bus. The routine table is placed in the buffer pointed
164 1.3.4.2 rmind * to by the RetBuffer variable parameter.
165 1.3.4.2 rmind *
166 1.3.4.2 rmind * If the function fails an appropriate status will be returned
167 1.3.4.2 rmind * and the value of RetBuffer is undefined.
168 1.3.4.2 rmind *
169 1.3.4.2 rmind * This function attempts to execute the _PRT method contained in
170 1.3.4.2 rmind * the object indicated by the passed DeviceHandle.
171 1.3.4.2 rmind *
172 1.3.4.2 rmind ******************************************************************************/
173 1.3.4.2 rmind
174 1.3.4.2 rmind ACPI_STATUS
175 1.3.4.2 rmind AcpiGetIrqRoutingTable (
176 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
177 1.3.4.2 rmind ACPI_BUFFER *RetBuffer)
178 1.3.4.2 rmind {
179 1.3.4.2 rmind ACPI_STATUS Status;
180 1.3.4.2 rmind ACPI_NAMESPACE_NODE *Node;
181 1.3.4.2 rmind
182 1.3.4.2 rmind
183 1.3.4.2 rmind ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
184 1.3.4.2 rmind
185 1.3.4.2 rmind
186 1.3.4.2 rmind /* Validate parameters then dispatch to internal routine */
187 1.3.4.2 rmind
188 1.3.4.2 rmind Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
189 1.3.4.2 rmind if (ACPI_FAILURE (Status))
190 1.3.4.2 rmind {
191 1.3.4.2 rmind return_ACPI_STATUS (Status);
192 1.3.4.2 rmind }
193 1.3.4.2 rmind
194 1.3.4.2 rmind Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
195 1.3.4.2 rmind return_ACPI_STATUS (Status);
196 1.3.4.2 rmind }
197 1.3.4.2 rmind
198 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
199 1.3.4.2 rmind
200 1.3.4.2 rmind
201 1.3.4.2 rmind /*******************************************************************************
202 1.3.4.2 rmind *
203 1.3.4.2 rmind * FUNCTION: AcpiGetCurrentResources
204 1.3.4.2 rmind *
205 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to the device object for the
206 1.3.4.2 rmind * device we are querying
207 1.3.4.2 rmind * RetBuffer - Pointer to a buffer to receive the
208 1.3.4.2 rmind * current resources for the device
209 1.3.4.2 rmind *
210 1.3.4.2 rmind * RETURN: Status
211 1.3.4.2 rmind *
212 1.3.4.2 rmind * DESCRIPTION: This function is called to get the current resources for a
213 1.3.4.2 rmind * specific device. The caller must first acquire a handle for
214 1.3.4.2 rmind * the desired device. The resource data is placed in the buffer
215 1.3.4.2 rmind * pointed to by the RetBuffer variable parameter.
216 1.3.4.2 rmind *
217 1.3.4.2 rmind * If the function fails an appropriate status will be returned
218 1.3.4.2 rmind * and the value of RetBuffer is undefined.
219 1.3.4.2 rmind *
220 1.3.4.2 rmind * This function attempts to execute the _CRS method contained in
221 1.3.4.2 rmind * the object indicated by the passed DeviceHandle.
222 1.3.4.2 rmind *
223 1.3.4.2 rmind ******************************************************************************/
224 1.3.4.2 rmind
225 1.3.4.2 rmind ACPI_STATUS
226 1.3.4.2 rmind AcpiGetCurrentResources (
227 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
228 1.3.4.2 rmind ACPI_BUFFER *RetBuffer)
229 1.3.4.2 rmind {
230 1.3.4.2 rmind ACPI_STATUS Status;
231 1.3.4.2 rmind ACPI_NAMESPACE_NODE *Node;
232 1.3.4.2 rmind
233 1.3.4.2 rmind
234 1.3.4.2 rmind ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
235 1.3.4.2 rmind
236 1.3.4.2 rmind
237 1.3.4.2 rmind /* Validate parameters then dispatch to internal routine */
238 1.3.4.2 rmind
239 1.3.4.2 rmind Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
240 1.3.4.2 rmind if (ACPI_FAILURE (Status))
241 1.3.4.2 rmind {
242 1.3.4.2 rmind return_ACPI_STATUS (Status);
243 1.3.4.2 rmind }
244 1.3.4.2 rmind
245 1.3.4.2 rmind Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
246 1.3.4.2 rmind return_ACPI_STATUS (Status);
247 1.3.4.2 rmind }
248 1.3.4.2 rmind
249 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
250 1.3.4.2 rmind
251 1.3.4.2 rmind
252 1.3.4.2 rmind /*******************************************************************************
253 1.3.4.2 rmind *
254 1.3.4.2 rmind * FUNCTION: AcpiGetPossibleResources
255 1.3.4.2 rmind *
256 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to the device object for the
257 1.3.4.2 rmind * device we are querying
258 1.3.4.2 rmind * RetBuffer - Pointer to a buffer to receive the
259 1.3.4.2 rmind * resources for the device
260 1.3.4.2 rmind *
261 1.3.4.2 rmind * RETURN: Status
262 1.3.4.2 rmind *
263 1.3.4.2 rmind * DESCRIPTION: This function is called to get a list of the possible resources
264 1.3.4.2 rmind * for a specific device. The caller must first acquire a handle
265 1.3.4.2 rmind * for the desired device. The resource data is placed in the
266 1.3.4.2 rmind * buffer pointed to by the RetBuffer variable.
267 1.3.4.2 rmind *
268 1.3.4.2 rmind * If the function fails an appropriate status will be returned
269 1.3.4.2 rmind * and the value of RetBuffer is undefined.
270 1.3.4.2 rmind *
271 1.3.4.2 rmind ******************************************************************************/
272 1.3.4.2 rmind
273 1.3.4.2 rmind ACPI_STATUS
274 1.3.4.2 rmind AcpiGetPossibleResources (
275 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
276 1.3.4.2 rmind ACPI_BUFFER *RetBuffer)
277 1.3.4.2 rmind {
278 1.3.4.2 rmind ACPI_STATUS Status;
279 1.3.4.2 rmind ACPI_NAMESPACE_NODE *Node;
280 1.3.4.2 rmind
281 1.3.4.2 rmind
282 1.3.4.2 rmind ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
283 1.3.4.2 rmind
284 1.3.4.2 rmind
285 1.3.4.2 rmind /* Validate parameters then dispatch to internal routine */
286 1.3.4.2 rmind
287 1.3.4.2 rmind Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
288 1.3.4.2 rmind if (ACPI_FAILURE (Status))
289 1.3.4.2 rmind {
290 1.3.4.2 rmind return_ACPI_STATUS (Status);
291 1.3.4.2 rmind }
292 1.3.4.2 rmind
293 1.3.4.2 rmind Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
294 1.3.4.2 rmind return_ACPI_STATUS (Status);
295 1.3.4.2 rmind }
296 1.3.4.2 rmind
297 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
298 1.3.4.2 rmind
299 1.3.4.2 rmind
300 1.3.4.2 rmind /*******************************************************************************
301 1.3.4.2 rmind *
302 1.3.4.2 rmind * FUNCTION: AcpiSetCurrentResources
303 1.3.4.2 rmind *
304 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to the device object for the
305 1.3.4.2 rmind * device we are setting resources
306 1.3.4.2 rmind * InBuffer - Pointer to a buffer containing the
307 1.3.4.2 rmind * resources to be set for the device
308 1.3.4.2 rmind *
309 1.3.4.2 rmind * RETURN: Status
310 1.3.4.2 rmind *
311 1.3.4.2 rmind * DESCRIPTION: This function is called to set the current resources for a
312 1.3.4.2 rmind * specific device. The caller must first acquire a handle for
313 1.3.4.2 rmind * the desired device. The resource data is passed to the routine
314 1.3.4.2 rmind * the buffer pointed to by the InBuffer variable.
315 1.3.4.2 rmind *
316 1.3.4.2 rmind ******************************************************************************/
317 1.3.4.2 rmind
318 1.3.4.2 rmind ACPI_STATUS
319 1.3.4.2 rmind AcpiSetCurrentResources (
320 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
321 1.3.4.2 rmind ACPI_BUFFER *InBuffer)
322 1.3.4.2 rmind {
323 1.3.4.2 rmind ACPI_STATUS Status;
324 1.3.4.2 rmind ACPI_NAMESPACE_NODE *Node;
325 1.3.4.2 rmind
326 1.3.4.2 rmind
327 1.3.4.2 rmind ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
328 1.3.4.2 rmind
329 1.3.4.2 rmind
330 1.3.4.2 rmind /* Validate the buffer, don't allow zero length */
331 1.3.4.2 rmind
332 1.3.4.2 rmind if ((!InBuffer) ||
333 1.3.4.2 rmind (!InBuffer->Pointer) ||
334 1.3.4.2 rmind (!InBuffer->Length))
335 1.3.4.2 rmind {
336 1.3.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
337 1.3.4.2 rmind }
338 1.3.4.2 rmind
339 1.3.4.2 rmind /* Validate parameters then dispatch to internal routine */
340 1.3.4.2 rmind
341 1.3.4.2 rmind Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
342 1.3.4.2 rmind if (ACPI_FAILURE (Status))
343 1.3.4.2 rmind {
344 1.3.4.2 rmind return_ACPI_STATUS (Status);
345 1.3.4.2 rmind }
346 1.3.4.2 rmind
347 1.3.4.2 rmind Status = AcpiRsSetSrsMethodData (Node, InBuffer);
348 1.3.4.2 rmind return_ACPI_STATUS (Status);
349 1.3.4.2 rmind }
350 1.3.4.2 rmind
351 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
352 1.3.4.2 rmind
353 1.3.4.2 rmind
354 1.3.4.2 rmind /******************************************************************************
355 1.3.4.2 rmind *
356 1.3.4.2 rmind * FUNCTION: AcpiResourceToAddress64
357 1.3.4.2 rmind *
358 1.3.4.2 rmind * PARAMETERS: Resource - Pointer to a resource
359 1.3.4.2 rmind * Out - Pointer to the users's return buffer
360 1.3.4.2 rmind * (a struct acpi_resource_address64)
361 1.3.4.2 rmind *
362 1.3.4.2 rmind * RETURN: Status
363 1.3.4.2 rmind *
364 1.3.4.2 rmind * DESCRIPTION: If the resource is an address16, address32, or address64,
365 1.3.4.2 rmind * copy it to the address64 return buffer. This saves the
366 1.3.4.2 rmind * caller from having to duplicate code for different-sized
367 1.3.4.2 rmind * addresses.
368 1.3.4.2 rmind *
369 1.3.4.2 rmind ******************************************************************************/
370 1.3.4.2 rmind
371 1.3.4.2 rmind ACPI_STATUS
372 1.3.4.2 rmind AcpiResourceToAddress64 (
373 1.3.4.2 rmind ACPI_RESOURCE *Resource,
374 1.3.4.2 rmind ACPI_RESOURCE_ADDRESS64 *Out)
375 1.3.4.2 rmind {
376 1.3.4.2 rmind ACPI_RESOURCE_ADDRESS16 *Address16;
377 1.3.4.2 rmind ACPI_RESOURCE_ADDRESS32 *Address32;
378 1.3.4.2 rmind
379 1.3.4.2 rmind
380 1.3.4.2 rmind if (!Resource || !Out)
381 1.3.4.2 rmind {
382 1.3.4.2 rmind return (AE_BAD_PARAMETER);
383 1.3.4.2 rmind }
384 1.3.4.2 rmind
385 1.3.4.2 rmind /* Convert 16 or 32 address descriptor to 64 */
386 1.3.4.2 rmind
387 1.3.4.2 rmind switch (Resource->Type)
388 1.3.4.2 rmind {
389 1.3.4.2 rmind case ACPI_RESOURCE_TYPE_ADDRESS16:
390 1.3.4.2 rmind
391 1.3.4.2 rmind Address16 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS16, &Resource->Data);
392 1.3.4.2 rmind ACPI_COPY_ADDRESS (Out, Address16);
393 1.3.4.2 rmind break;
394 1.3.4.2 rmind
395 1.3.4.2 rmind case ACPI_RESOURCE_TYPE_ADDRESS32:
396 1.3.4.2 rmind
397 1.3.4.2 rmind Address32 = ACPI_CAST_PTR (ACPI_RESOURCE_ADDRESS32, &Resource->Data);
398 1.3.4.2 rmind ACPI_COPY_ADDRESS (Out, Address32);
399 1.3.4.2 rmind break;
400 1.3.4.2 rmind
401 1.3.4.2 rmind case ACPI_RESOURCE_TYPE_ADDRESS64:
402 1.3.4.2 rmind
403 1.3.4.2 rmind /* Simple copy for 64 bit source */
404 1.3.4.2 rmind
405 1.3.4.2 rmind ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
406 1.3.4.2 rmind break;
407 1.3.4.2 rmind
408 1.3.4.2 rmind default:
409 1.3.4.2 rmind return (AE_BAD_PARAMETER);
410 1.3.4.2 rmind }
411 1.3.4.2 rmind
412 1.3.4.2 rmind return (AE_OK);
413 1.3.4.2 rmind }
414 1.3.4.2 rmind
415 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
416 1.3.4.2 rmind
417 1.3.4.2 rmind
418 1.3.4.2 rmind /*******************************************************************************
419 1.3.4.2 rmind *
420 1.3.4.2 rmind * FUNCTION: AcpiGetVendorResource
421 1.3.4.2 rmind *
422 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle for the parent device object
423 1.3.4.2 rmind * Name - Method name for the parent resource
424 1.3.4.2 rmind * (METHOD_NAME__CRS or METHOD_NAME__PRS)
425 1.3.4.2 rmind * Uuid - Pointer to the UUID to be matched.
426 1.3.4.2 rmind * includes both subtype and 16-byte UUID
427 1.3.4.2 rmind * RetBuffer - Where the vendor resource is returned
428 1.3.4.2 rmind *
429 1.3.4.2 rmind * RETURN: Status
430 1.3.4.2 rmind *
431 1.3.4.2 rmind * DESCRIPTION: Walk a resource template for the specified evice to find a
432 1.3.4.2 rmind * vendor-defined resource that matches the supplied UUID and
433 1.3.4.2 rmind * UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
434 1.3.4.2 rmind *
435 1.3.4.2 rmind ******************************************************************************/
436 1.3.4.2 rmind
437 1.3.4.2 rmind ACPI_STATUS
438 1.3.4.2 rmind AcpiGetVendorResource (
439 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
440 1.3.4.2 rmind char *Name,
441 1.3.4.2 rmind ACPI_VENDOR_UUID *Uuid,
442 1.3.4.2 rmind ACPI_BUFFER *RetBuffer)
443 1.3.4.2 rmind {
444 1.3.4.2 rmind ACPI_VENDOR_WALK_INFO Info;
445 1.3.4.2 rmind ACPI_STATUS Status;
446 1.3.4.2 rmind
447 1.3.4.2 rmind
448 1.3.4.2 rmind /* Other parameters are validated by AcpiWalkResources */
449 1.3.4.2 rmind
450 1.3.4.2 rmind if (!Uuid || !RetBuffer)
451 1.3.4.2 rmind {
452 1.3.4.2 rmind return (AE_BAD_PARAMETER);
453 1.3.4.2 rmind }
454 1.3.4.2 rmind
455 1.3.4.2 rmind Info.Uuid = Uuid;
456 1.3.4.2 rmind Info.Buffer = RetBuffer;
457 1.3.4.2 rmind Info.Status = AE_NOT_EXIST;
458 1.3.4.2 rmind
459 1.3.4.2 rmind /* Walk the _CRS or _PRS resource list for this device */
460 1.3.4.2 rmind
461 1.3.4.2 rmind Status = AcpiWalkResources (DeviceHandle, Name, AcpiRsMatchVendorResource,
462 1.3.4.2 rmind &Info);
463 1.3.4.2 rmind if (ACPI_FAILURE (Status))
464 1.3.4.2 rmind {
465 1.3.4.2 rmind return (Status);
466 1.3.4.2 rmind }
467 1.3.4.2 rmind
468 1.3.4.2 rmind return (Info.Status);
469 1.3.4.2 rmind }
470 1.3.4.2 rmind
471 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
472 1.3.4.2 rmind
473 1.3.4.2 rmind
474 1.3.4.2 rmind /*******************************************************************************
475 1.3.4.2 rmind *
476 1.3.4.2 rmind * FUNCTION: AcpiRsMatchVendorResource
477 1.3.4.2 rmind *
478 1.3.4.2 rmind * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
479 1.3.4.2 rmind *
480 1.3.4.2 rmind * RETURN: Status
481 1.3.4.2 rmind *
482 1.3.4.2 rmind * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
483 1.3.4.2 rmind *
484 1.3.4.2 rmind ******************************************************************************/
485 1.3.4.2 rmind
486 1.3.4.2 rmind static ACPI_STATUS
487 1.3.4.2 rmind AcpiRsMatchVendorResource (
488 1.3.4.2 rmind ACPI_RESOURCE *Resource,
489 1.3.4.2 rmind void *Context)
490 1.3.4.2 rmind {
491 1.3.4.2 rmind ACPI_VENDOR_WALK_INFO *Info = Context;
492 1.3.4.2 rmind ACPI_RESOURCE_VENDOR_TYPED *Vendor;
493 1.3.4.2 rmind ACPI_BUFFER *Buffer;
494 1.3.4.2 rmind ACPI_STATUS Status;
495 1.3.4.2 rmind
496 1.3.4.2 rmind
497 1.3.4.2 rmind /* Ignore all descriptors except Vendor */
498 1.3.4.2 rmind
499 1.3.4.2 rmind if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
500 1.3.4.2 rmind {
501 1.3.4.2 rmind return (AE_OK);
502 1.3.4.2 rmind }
503 1.3.4.2 rmind
504 1.3.4.2 rmind Vendor = &Resource->Data.VendorTyped;
505 1.3.4.2 rmind
506 1.3.4.2 rmind /*
507 1.3.4.2 rmind * For a valid match, these conditions must hold:
508 1.3.4.2 rmind *
509 1.3.4.2 rmind * 1) Length of descriptor data must be at least as long as a UUID struct
510 1.3.4.2 rmind * 2) The UUID subtypes must match
511 1.3.4.2 rmind * 3) The UUID data must match
512 1.3.4.2 rmind */
513 1.3.4.2 rmind if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
514 1.3.4.2 rmind (Vendor->UuidSubtype != Info->Uuid->Subtype) ||
515 1.3.4.2 rmind (ACPI_MEMCMP (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
516 1.3.4.2 rmind {
517 1.3.4.2 rmind return (AE_OK);
518 1.3.4.2 rmind }
519 1.3.4.2 rmind
520 1.3.4.2 rmind /* Validate/Allocate/Clear caller buffer */
521 1.3.4.2 rmind
522 1.3.4.2 rmind Buffer = Info->Buffer;
523 1.3.4.2 rmind Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
524 1.3.4.2 rmind if (ACPI_FAILURE (Status))
525 1.3.4.2 rmind {
526 1.3.4.2 rmind return (Status);
527 1.3.4.2 rmind }
528 1.3.4.2 rmind
529 1.3.4.2 rmind /* Found the correct resource, copy and return it */
530 1.3.4.2 rmind
531 1.3.4.2 rmind ACPI_MEMCPY (Buffer->Pointer, Resource, Resource->Length);
532 1.3.4.2 rmind Buffer->Length = Resource->Length;
533 1.3.4.2 rmind
534 1.3.4.2 rmind /* Found the desired descriptor, terminate resource walk */
535 1.3.4.2 rmind
536 1.3.4.2 rmind Info->Status = AE_OK;
537 1.3.4.2 rmind return (AE_CTRL_TERMINATE);
538 1.3.4.2 rmind }
539 1.3.4.2 rmind
540 1.3.4.2 rmind
541 1.3.4.2 rmind /*******************************************************************************
542 1.3.4.2 rmind *
543 1.3.4.2 rmind * FUNCTION: AcpiWalkResources
544 1.3.4.2 rmind *
545 1.3.4.2 rmind * PARAMETERS: DeviceHandle - Handle to the device object for the
546 1.3.4.2 rmind * device we are querying
547 1.3.4.2 rmind * Name - Method name of the resources we want
548 1.3.4.2 rmind * (METHOD_NAME__CRS or METHOD_NAME__PRS)
549 1.3.4.2 rmind * UserFunction - Called for each resource
550 1.3.4.2 rmind * Context - Passed to UserFunction
551 1.3.4.2 rmind *
552 1.3.4.2 rmind * RETURN: Status
553 1.3.4.2 rmind *
554 1.3.4.2 rmind * DESCRIPTION: Retrieves the current or possible resource list for the
555 1.3.4.2 rmind * specified device. The UserFunction is called once for
556 1.3.4.2 rmind * each resource in the list.
557 1.3.4.2 rmind *
558 1.3.4.2 rmind ******************************************************************************/
559 1.3.4.2 rmind
560 1.3.4.2 rmind ACPI_STATUS
561 1.3.4.2 rmind AcpiWalkResources (
562 1.3.4.2 rmind ACPI_HANDLE DeviceHandle,
563 1.3.4.2 rmind const char *Name,
564 1.3.4.2 rmind ACPI_WALK_RESOURCE_CALLBACK UserFunction,
565 1.3.4.2 rmind void *Context)
566 1.3.4.2 rmind {
567 1.3.4.2 rmind ACPI_STATUS Status;
568 1.3.4.2 rmind ACPI_BUFFER Buffer;
569 1.3.4.2 rmind ACPI_RESOURCE *Resource;
570 1.3.4.2 rmind ACPI_RESOURCE *ResourceEnd;
571 1.3.4.2 rmind char *UName = __UNCONST(Name);
572 1.3.4.2 rmind
573 1.3.4.2 rmind ACPI_FUNCTION_TRACE (AcpiWalkResources);
574 1.3.4.2 rmind
575 1.3.4.2 rmind
576 1.3.4.2 rmind /* Parameter validation */
577 1.3.4.2 rmind
578 1.3.4.2 rmind if (!DeviceHandle || !UserFunction || !Name ||
579 1.3.4.2 rmind (!ACPI_COMPARE_NAME (UName, METHOD_NAME__CRS) &&
580 1.3.4.2 rmind !ACPI_COMPARE_NAME (UName, METHOD_NAME__PRS)))
581 1.3.4.2 rmind {
582 1.3.4.2 rmind return_ACPI_STATUS (AE_BAD_PARAMETER);
583 1.3.4.2 rmind }
584 1.3.4.2 rmind
585 1.3.4.2 rmind /* Get the _CRS or _PRS resource list */
586 1.3.4.2 rmind
587 1.3.4.2 rmind Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
588 1.3.4.2 rmind Status = AcpiRsGetMethodData (DeviceHandle, UName, &Buffer);
589 1.3.4.2 rmind if (ACPI_FAILURE (Status))
590 1.3.4.2 rmind {
591 1.3.4.2 rmind return_ACPI_STATUS (Status);
592 1.3.4.2 rmind }
593 1.3.4.2 rmind
594 1.3.4.2 rmind /* Buffer now contains the resource list */
595 1.3.4.2 rmind
596 1.3.4.2 rmind Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer.Pointer);
597 1.3.4.2 rmind ResourceEnd = ACPI_ADD_PTR (ACPI_RESOURCE, Buffer.Pointer, Buffer.Length);
598 1.3.4.2 rmind
599 1.3.4.2 rmind /* Walk the resource list until the EndTag is found (or buffer end) */
600 1.3.4.2 rmind
601 1.3.4.2 rmind while (Resource < ResourceEnd)
602 1.3.4.2 rmind {
603 1.3.4.2 rmind /* Sanity check the resource */
604 1.3.4.2 rmind
605 1.3.4.2 rmind if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
606 1.3.4.2 rmind {
607 1.3.4.2 rmind Status = AE_AML_INVALID_RESOURCE_TYPE;
608 1.3.4.2 rmind break;
609 1.3.4.2 rmind }
610 1.3.4.2 rmind
611 1.3.4.2 rmind /* Invoke the user function, abort on any error returned */
612 1.3.4.2 rmind
613 1.3.4.2 rmind Status = UserFunction (Resource, Context);
614 1.3.4.2 rmind if (ACPI_FAILURE (Status))
615 1.3.4.2 rmind {
616 1.3.4.2 rmind if (Status == AE_CTRL_TERMINATE)
617 1.3.4.2 rmind {
618 1.3.4.2 rmind /* This is an OK termination by the user function */
619 1.3.4.2 rmind
620 1.3.4.2 rmind Status = AE_OK;
621 1.3.4.2 rmind }
622 1.3.4.2 rmind break;
623 1.3.4.2 rmind }
624 1.3.4.2 rmind
625 1.3.4.2 rmind /* EndTag indicates end-of-list */
626 1.3.4.2 rmind
627 1.3.4.2 rmind if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
628 1.3.4.2 rmind {
629 1.3.4.2 rmind break;
630 1.3.4.2 rmind }
631 1.3.4.2 rmind
632 1.3.4.2 rmind /* Get the next resource descriptor */
633 1.3.4.2 rmind
634 1.3.4.2 rmind Resource = ACPI_ADD_PTR (ACPI_RESOURCE, Resource, Resource->Length);
635 1.3.4.2 rmind }
636 1.3.4.2 rmind
637 1.3.4.2 rmind ACPI_FREE (Buffer.Pointer);
638 1.3.4.2 rmind return_ACPI_STATUS (Status);
639 1.3.4.2 rmind }
640 1.3.4.2 rmind
641 1.3.4.2 rmind ACPI_EXPORT_SYMBOL (AcpiWalkResources)
642