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