1 /*******************************************************************************
2 *
3 * Module Name: rsutils - Utilities for the resource manager
4 *
5 ******************************************************************************/
6
7 /******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2021, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************
115 *
116 * Alternatively, you may choose to be licensed under the terms of the
117 * following license:
118 *
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
133 *
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145 *
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
149 *
150 *****************************************************************************/
151
152 #include "acpi.h"
153 #include "accommon.h"
154 #include "acnamesp.h"
155 #include "acresrc.h"
156
157
158 #define _COMPONENT ACPI_RESOURCES
159 ACPI_MODULE_NAME ("rsutils")
160
161
162 /*******************************************************************************
163 *
164 * FUNCTION: AcpiRsDecodeBitmask
165 *
166 * PARAMETERS: Mask - Bitmask to decode
167 * List - Where the converted list is returned
168 *
169 * RETURN: Count of bits set (length of list)
170 *
171 * DESCRIPTION: Convert a bit mask into a list of values
172 *
173 ******************************************************************************/
174
175 UINT8
AcpiRsDecodeBitmask(UINT16 Mask,UINT8 * List)176 AcpiRsDecodeBitmask (
177 UINT16 Mask,
178 UINT8 *List)
179 {
180 UINT8 i;
181 UINT8 BitCount;
182
183
184 ACPI_FUNCTION_ENTRY ();
185
186
187 /* Decode the mask bits */
188
189 for (i = 0, BitCount = 0; Mask; i++)
190 {
191 if (Mask & 0x0001)
192 {
193 List[BitCount] = i;
194 BitCount++;
195 }
196
197 Mask >>= 1;
198 }
199
200 return (BitCount);
201 }
202
203
204 /*******************************************************************************
205 *
206 * FUNCTION: AcpiRsEncodeBitmask
207 *
208 * PARAMETERS: List - List of values to encode
209 * Count - Length of list
210 *
211 * RETURN: Encoded bitmask
212 *
213 * DESCRIPTION: Convert a list of values to an encoded bitmask
214 *
215 ******************************************************************************/
216
217 UINT16
AcpiRsEncodeBitmask(UINT8 * List,UINT8 Count)218 AcpiRsEncodeBitmask (
219 UINT8 *List,
220 UINT8 Count)
221 {
222 UINT32 i;
223 UINT16 Mask;
224
225
226 ACPI_FUNCTION_ENTRY ();
227
228
229 /* Encode the list into a single bitmask */
230
231 for (i = 0, Mask = 0; i < Count; i++)
232 {
233 Mask |= (0x1 << List[i]);
234 }
235
236 return (Mask);
237 }
238
239
240 /*******************************************************************************
241 *
242 * FUNCTION: AcpiRsMoveData
243 *
244 * PARAMETERS: Destination - Pointer to the destination descriptor
245 * Source - Pointer to the source descriptor
246 * ItemCount - How many items to move
247 * MoveType - Byte width
248 *
249 * RETURN: None
250 *
251 * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
252 * alignment issues and endian issues if necessary, as configured
253 * via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
254 *
255 ******************************************************************************/
256
257 void
AcpiRsMoveData(void * Destination,void * Source,UINT16 ItemCount,UINT8 MoveType)258 AcpiRsMoveData (
259 void *Destination,
260 void *Source,
261 UINT16 ItemCount,
262 UINT8 MoveType)
263 {
264 UINT32 i;
265
266
267 ACPI_FUNCTION_ENTRY ();
268
269
270 /* One move per item */
271
272 for (i = 0; i < ItemCount; i++)
273 {
274 switch (MoveType)
275 {
276 /*
277 * For the 8-bit case, we can perform the move all at once
278 * since there are no alignment or endian issues
279 */
280 case ACPI_RSC_MOVE8:
281 case ACPI_RSC_MOVE_GPIO_RES:
282 case ACPI_RSC_MOVE_SERIAL_VEN:
283 case ACPI_RSC_MOVE_SERIAL_RES:
284
285 memcpy (Destination, Source, ItemCount);
286 return;
287
288 /*
289 * 16-, 32-, and 64-bit cases must use the move macros that perform
290 * endian conversion and/or accommodate hardware that cannot perform
291 * misaligned memory transfers
292 */
293 case ACPI_RSC_MOVE16:
294 case ACPI_RSC_MOVE_GPIO_PIN:
295
296 ACPI_MOVE_16_TO_16 (
297 &ACPI_CAST_PTR (UINT16, Destination)[i],
298 &ACPI_CAST_PTR (UINT16, Source)[i]);
299 break;
300
301 case ACPI_RSC_MOVE32:
302
303 ACPI_MOVE_32_TO_32 (
304 &ACPI_CAST_PTR (UINT32, Destination)[i],
305 &ACPI_CAST_PTR (UINT32, Source)[i]);
306 break;
307
308 case ACPI_RSC_MOVE64:
309
310 ACPI_MOVE_64_TO_64 (
311 &ACPI_CAST_PTR (UINT64, Destination)[i],
312 &ACPI_CAST_PTR (UINT64, Source)[i]);
313 break;
314
315 default:
316
317 return;
318 }
319 }
320 }
321
322
323 /*******************************************************************************
324 *
325 * FUNCTION: AcpiRsSetResourceLength
326 *
327 * PARAMETERS: TotalLength - Length of the AML descriptor, including
328 * the header and length fields.
329 * Aml - Pointer to the raw AML descriptor
330 *
331 * RETURN: None
332 *
333 * DESCRIPTION: Set the ResourceLength field of an AML
334 * resource descriptor, both Large and Small descriptors are
335 * supported automatically. Note: Descriptor Type field must
336 * be valid.
337 *
338 ******************************************************************************/
339
340 void
AcpiRsSetResourceLength(ACPI_RSDESC_SIZE TotalLength,AML_RESOURCE * Aml)341 AcpiRsSetResourceLength (
342 ACPI_RSDESC_SIZE TotalLength,
343 AML_RESOURCE *Aml)
344 {
345 ACPI_RS_LENGTH ResourceLength;
346
347
348 ACPI_FUNCTION_ENTRY ();
349
350
351 /* Length is the total descriptor length minus the header length */
352
353 ResourceLength = (ACPI_RS_LENGTH)
354 (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
355
356 /* Length is stored differently for large and small descriptors */
357
358 if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
359 {
360 /* Large descriptor -- bytes 1-2 contain the 16-bit length */
361
362 ACPI_MOVE_16_TO_16 (
363 &Aml->LargeHeader.ResourceLength, &ResourceLength);
364 }
365 else
366 {
367 /*
368 * Small descriptor -- bits 2:0 of byte 0 contain the length
369 * Clear any existing length, preserving descriptor type bits
370 */
371 Aml->SmallHeader.DescriptorType = (UINT8)
372 ((Aml->SmallHeader.DescriptorType &
373 ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
374 | ResourceLength);
375 }
376 }
377
378
379 /*******************************************************************************
380 *
381 * FUNCTION: AcpiRsSetResourceHeader
382 *
383 * PARAMETERS: DescriptorType - Byte to be inserted as the type
384 * TotalLength - Length of the AML descriptor, including
385 * the header and length fields.
386 * Aml - Pointer to the raw AML descriptor
387 *
388 * RETURN: None
389 *
390 * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
391 * resource descriptor, both Large and Small descriptors are
392 * supported automatically
393 *
394 ******************************************************************************/
395
396 void
AcpiRsSetResourceHeader(UINT8 DescriptorType,ACPI_RSDESC_SIZE TotalLength,AML_RESOURCE * Aml)397 AcpiRsSetResourceHeader (
398 UINT8 DescriptorType,
399 ACPI_RSDESC_SIZE TotalLength,
400 AML_RESOURCE *Aml)
401 {
402 ACPI_FUNCTION_ENTRY ();
403
404
405 /* Set the Resource Type */
406
407 Aml->SmallHeader.DescriptorType = DescriptorType;
408
409 /* Set the Resource Length */
410
411 AcpiRsSetResourceLength (TotalLength, Aml);
412 }
413
414
415 /*******************************************************************************
416 *
417 * FUNCTION: AcpiRsStrcpy
418 *
419 * PARAMETERS: Destination - Pointer to the destination string
420 * Source - Pointer to the source string
421 *
422 * RETURN: String length, including NULL terminator
423 *
424 * DESCRIPTION: Local string copy that returns the string length, saving a
425 * strcpy followed by a strlen.
426 *
427 ******************************************************************************/
428
429 static UINT16
AcpiRsStrcpy(char * Destination,char * Source)430 AcpiRsStrcpy (
431 char *Destination,
432 char *Source)
433 {
434 UINT16 i;
435
436
437 ACPI_FUNCTION_ENTRY ();
438
439
440 for (i = 0; Source[i]; i++)
441 {
442 Destination[i] = Source[i];
443 }
444
445 Destination[i] = 0;
446
447 /* Return string length including the NULL terminator */
448
449 return ((UINT16) (i + 1));
450 }
451
452
453 /*******************************************************************************
454 *
455 * FUNCTION: AcpiRsGetResourceSource
456 *
457 * PARAMETERS: ResourceLength - Length field of the descriptor
458 * MinimumLength - Minimum length of the descriptor (minus
459 * any optional fields)
460 * ResourceSource - Where the ResourceSource is returned
461 * Aml - Pointer to the raw AML descriptor
462 * StringPtr - (optional) where to store the actual
463 * ResourceSource string
464 *
465 * RETURN: Length of the string plus NULL terminator, rounded up to native
466 * word boundary
467 *
468 * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
469 * to an internal resource descriptor
470 *
471 ******************************************************************************/
472
473 ACPI_RS_LENGTH
AcpiRsGetResourceSource(ACPI_RS_LENGTH ResourceLength,ACPI_RS_LENGTH MinimumLength,ACPI_RESOURCE_SOURCE * ResourceSource,AML_RESOURCE * Aml,char * StringPtr)474 AcpiRsGetResourceSource (
475 ACPI_RS_LENGTH ResourceLength,
476 ACPI_RS_LENGTH MinimumLength,
477 ACPI_RESOURCE_SOURCE *ResourceSource,
478 AML_RESOURCE *Aml,
479 char *StringPtr)
480 {
481 ACPI_RSDESC_SIZE TotalLength;
482 UINT8 *AmlResourceSource;
483
484
485 ACPI_FUNCTION_ENTRY ();
486
487
488 TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
489 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
490
491 /*
492 * ResourceSource is present if the length of the descriptor is longer
493 * than the minimum length.
494 *
495 * Note: Some resource descriptors will have an additional null, so
496 * we add 1 to the minimum length.
497 */
498 if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
499 {
500 /* Get the ResourceSourceIndex */
501
502 ResourceSource->Index = AmlResourceSource[0];
503
504 ResourceSource->StringPtr = StringPtr;
505 if (!StringPtr)
506 {
507 /*
508 * String destination pointer is not specified; Set the String
509 * pointer to the end of the current ResourceSource structure.
510 */
511 ResourceSource->StringPtr = ACPI_ADD_PTR (
512 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));
513 }
514
515 /*
516 * In order for the Resource length to be a multiple of the native
517 * word, calculate the length of the string (+1 for NULL terminator)
518 * and expand to the next word multiple.
519 *
520 * Zero the entire area of the buffer.
521 */
522 TotalLength = (UINT32) strlen (
523 ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
524
525 TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
526
527 memset (ResourceSource->StringPtr, 0, TotalLength);
528
529 /* Copy the ResourceSource string to the destination */
530
531 ResourceSource->StringLength = AcpiRsStrcpy (
532 ResourceSource->StringPtr,
533 ACPI_CAST_PTR (char, &AmlResourceSource[1]));
534
535 return ((ACPI_RS_LENGTH) TotalLength);
536 }
537
538 /* ResourceSource is not present */
539
540 ResourceSource->Index = 0;
541 ResourceSource->StringLength = 0;
542 ResourceSource->StringPtr = NULL;
543 return (0);
544 }
545
546
547 /*******************************************************************************
548 *
549 * FUNCTION: AcpiRsSetResourceSource
550 *
551 * PARAMETERS: Aml - Pointer to the raw AML descriptor
552 * MinimumLength - Minimum length of the descriptor (minus
553 * any optional fields)
554 * ResourceSource - Internal ResourceSource
555
556 *
557 * RETURN: Total length of the AML descriptor
558 *
559 * DESCRIPTION: Convert an optional ResourceSource from internal format to a
560 * raw AML resource descriptor
561 *
562 ******************************************************************************/
563
564 ACPI_RSDESC_SIZE
AcpiRsSetResourceSource(AML_RESOURCE * Aml,ACPI_RS_LENGTH MinimumLength,ACPI_RESOURCE_SOURCE * ResourceSource)565 AcpiRsSetResourceSource (
566 AML_RESOURCE *Aml,
567 ACPI_RS_LENGTH MinimumLength,
568 ACPI_RESOURCE_SOURCE *ResourceSource)
569 {
570 UINT8 *AmlResourceSource;
571 ACPI_RSDESC_SIZE DescriptorLength;
572
573
574 ACPI_FUNCTION_ENTRY ();
575
576
577 DescriptorLength = MinimumLength;
578
579 /* Non-zero string length indicates presence of a ResourceSource */
580
581 if (ResourceSource->StringLength)
582 {
583 /* Point to the end of the AML descriptor */
584
585 AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
586
587 /* Copy the ResourceSourceIndex */
588
589 AmlResourceSource[0] = (UINT8) ResourceSource->Index;
590
591 /* Copy the ResourceSource string */
592
593 strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
594 ResourceSource->StringPtr);
595
596 /*
597 * Add the length of the string (+ 1 for null terminator) to the
598 * final descriptor length
599 */
600 DescriptorLength += ((ACPI_RSDESC_SIZE)
601 ResourceSource->StringLength + 1);
602 }
603
604 /* Return the new total length of the AML descriptor */
605
606 return (DescriptorLength);
607 }
608
609
610 /*******************************************************************************
611 *
612 * FUNCTION: AcpiRsGetPrtMethodData
613 *
614 * PARAMETERS: Node - Device node
615 * RetBuffer - Pointer to a buffer structure for the
616 * results
617 *
618 * RETURN: Status
619 *
620 * DESCRIPTION: This function is called to get the _PRT value of an object
621 * contained in an object specified by the handle passed in
622 *
623 * If the function fails an appropriate status will be returned
624 * and the contents of the callers buffer is undefined.
625 *
626 ******************************************************************************/
627
628 ACPI_STATUS
AcpiRsGetPrtMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)629 AcpiRsGetPrtMethodData (
630 ACPI_NAMESPACE_NODE *Node,
631 ACPI_BUFFER *RetBuffer)
632 {
633 ACPI_OPERAND_OBJECT *ObjDesc;
634 ACPI_STATUS Status;
635
636
637 ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
638
639
640 /* Parameters guaranteed valid by caller */
641
642 /* Execute the method, no parameters */
643
644 Status = AcpiUtEvaluateObject (
645 Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc);
646 if (ACPI_FAILURE (Status))
647 {
648 return_ACPI_STATUS (Status);
649 }
650
651 /*
652 * Create a resource linked list from the byte stream buffer that comes
653 * back from the _CRS method execution.
654 */
655 Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
656
657 /* On exit, we must delete the object returned by EvaluateObject */
658
659 AcpiUtRemoveReference (ObjDesc);
660 return_ACPI_STATUS (Status);
661 }
662
663
664 /*******************************************************************************
665 *
666 * FUNCTION: AcpiRsGetCrsMethodData
667 *
668 * PARAMETERS: Node - Device node
669 * RetBuffer - Pointer to a buffer structure for the
670 * results
671 *
672 * RETURN: Status
673 *
674 * DESCRIPTION: This function is called to get the _CRS value of an object
675 * contained in an object specified by the handle passed in
676 *
677 * If the function fails an appropriate status will be returned
678 * and the contents of the callers buffer is undefined.
679 *
680 ******************************************************************************/
681
682 ACPI_STATUS
AcpiRsGetCrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)683 AcpiRsGetCrsMethodData (
684 ACPI_NAMESPACE_NODE *Node,
685 ACPI_BUFFER *RetBuffer)
686 {
687 ACPI_OPERAND_OBJECT *ObjDesc;
688 ACPI_STATUS Status;
689
690
691 ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
692
693
694 /* Parameters guaranteed valid by caller */
695
696 /* Execute the method, no parameters */
697
698 Status = AcpiUtEvaluateObject (
699 Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc);
700 if (ACPI_FAILURE (Status))
701 {
702 return_ACPI_STATUS (Status);
703 }
704
705 /*
706 * Make the call to create a resource linked list from the
707 * byte stream buffer that comes back from the _CRS method
708 * execution.
709 */
710 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
711
712 /* On exit, we must delete the object returned by evaluateObject */
713
714 AcpiUtRemoveReference (ObjDesc);
715 return_ACPI_STATUS (Status);
716 }
717
718
719 /*******************************************************************************
720 *
721 * FUNCTION: AcpiRsGetPrsMethodData
722 *
723 * PARAMETERS: Node - Device node
724 * RetBuffer - Pointer to a buffer structure for the
725 * results
726 *
727 * RETURN: Status
728 *
729 * DESCRIPTION: This function is called to get the _PRS value of an object
730 * contained in an object specified by the handle passed in
731 *
732 * If the function fails an appropriate status will be returned
733 * and the contents of the callers buffer is undefined.
734 *
735 ******************************************************************************/
736
737 ACPI_STATUS
AcpiRsGetPrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)738 AcpiRsGetPrsMethodData (
739 ACPI_NAMESPACE_NODE *Node,
740 ACPI_BUFFER *RetBuffer)
741 {
742 ACPI_OPERAND_OBJECT *ObjDesc;
743 ACPI_STATUS Status;
744
745
746 ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
747
748
749 /* Parameters guaranteed valid by caller */
750
751 /* Execute the method, no parameters */
752
753 Status = AcpiUtEvaluateObject (
754 Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc);
755 if (ACPI_FAILURE (Status))
756 {
757 return_ACPI_STATUS (Status);
758 }
759
760 /*
761 * Make the call to create a resource linked list from the
762 * byte stream buffer that comes back from the _CRS method
763 * execution.
764 */
765 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
766
767 /* On exit, we must delete the object returned by evaluateObject */
768
769 AcpiUtRemoveReference (ObjDesc);
770 return_ACPI_STATUS (Status);
771 }
772
773
774 /*******************************************************************************
775 *
776 * FUNCTION: AcpiRsGetAeiMethodData
777 *
778 * PARAMETERS: Node - Device node
779 * RetBuffer - Pointer to a buffer structure for the
780 * results
781 *
782 * RETURN: Status
783 *
784 * DESCRIPTION: This function is called to get the _AEI value of an object
785 * contained in an object specified by the handle passed in
786 *
787 * If the function fails an appropriate status will be returned
788 * and the contents of the callers buffer is undefined.
789 *
790 ******************************************************************************/
791
792 ACPI_STATUS
AcpiRsGetAeiMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * RetBuffer)793 AcpiRsGetAeiMethodData (
794 ACPI_NAMESPACE_NODE *Node,
795 ACPI_BUFFER *RetBuffer)
796 {
797 ACPI_OPERAND_OBJECT *ObjDesc;
798 ACPI_STATUS Status;
799
800
801 ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
802
803
804 /* Parameters guaranteed valid by caller */
805
806 /* Execute the method, no parameters */
807
808 Status = AcpiUtEvaluateObject (
809 Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc);
810 if (ACPI_FAILURE (Status))
811 {
812 return_ACPI_STATUS (Status);
813 }
814
815 /*
816 * Make the call to create a resource linked list from the
817 * byte stream buffer that comes back from the _CRS method
818 * execution.
819 */
820 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
821
822 /* On exit, we must delete the object returned by evaluateObject */
823
824 AcpiUtRemoveReference (ObjDesc);
825 return_ACPI_STATUS (Status);
826 }
827
828
829 /*******************************************************************************
830 *
831 * FUNCTION: AcpiRsGetMethodData
832 *
833 * PARAMETERS: Handle - Handle to the containing object
834 * Path - Path to method, relative to Handle
835 * RetBuffer - Pointer to a buffer structure for the
836 * results
837 *
838 * RETURN: Status
839 *
840 * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
841 * object contained in an object specified by the handle passed in
842 *
843 * If the function fails an appropriate status will be returned
844 * and the contents of the callers buffer is undefined.
845 *
846 ******************************************************************************/
847
848 ACPI_STATUS
AcpiRsGetMethodData(ACPI_HANDLE Handle,const char * Path,ACPI_BUFFER * RetBuffer)849 AcpiRsGetMethodData (
850 ACPI_HANDLE Handle,
851 const char *Path,
852 ACPI_BUFFER *RetBuffer)
853 {
854 ACPI_OPERAND_OBJECT *ObjDesc;
855 ACPI_STATUS Status;
856
857
858 ACPI_FUNCTION_TRACE (RsGetMethodData);
859
860
861 /* Parameters guaranteed valid by caller */
862
863 /* Execute the method, no parameters */
864
865 Status = AcpiUtEvaluateObject (
866 ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
867 Path, ACPI_BTYPE_BUFFER, &ObjDesc);
868 if (ACPI_FAILURE (Status))
869 {
870 return_ACPI_STATUS (Status);
871 }
872
873 /*
874 * Make the call to create a resource linked list from the
875 * byte stream buffer that comes back from the method
876 * execution.
877 */
878 Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
879
880 /* On exit, we must delete the object returned by EvaluateObject */
881
882 AcpiUtRemoveReference (ObjDesc);
883 return_ACPI_STATUS (Status);
884 }
885
886
887 /*******************************************************************************
888 *
889 * FUNCTION: AcpiRsSetSrsMethodData
890 *
891 * PARAMETERS: Node - Device node
892 * InBuffer - Pointer to a buffer structure of the
893 * parameter
894 *
895 * RETURN: Status
896 *
897 * DESCRIPTION: This function is called to set the _SRS of an object contained
898 * in an object specified by the handle passed in
899 *
900 * If the function fails an appropriate status will be returned
901 * and the contents of the callers buffer is undefined.
902 *
903 * Note: Parameters guaranteed valid by caller
904 *
905 ******************************************************************************/
906
907 ACPI_STATUS
AcpiRsSetSrsMethodData(ACPI_NAMESPACE_NODE * Node,ACPI_BUFFER * InBuffer)908 AcpiRsSetSrsMethodData (
909 ACPI_NAMESPACE_NODE *Node,
910 ACPI_BUFFER *InBuffer)
911 {
912 ACPI_EVALUATE_INFO *Info;
913 ACPI_OPERAND_OBJECT *Args[2];
914 ACPI_STATUS Status;
915 ACPI_BUFFER Buffer;
916
917
918 ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
919
920
921 /* Allocate and initialize the evaluation information block */
922
923 Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
924 if (!Info)
925 {
926 return_ACPI_STATUS (AE_NO_MEMORY);
927 }
928
929 Info->PrefixNode = Node;
930 Info->RelativePathname = METHOD_NAME__SRS;
931 Info->Parameters = Args;
932 Info->Flags = ACPI_IGNORE_RETURN_VALUE;
933
934 /*
935 * The InBuffer parameter will point to a linked list of
936 * resource parameters. It needs to be formatted into a
937 * byte stream to be sent in as an input parameter to _SRS
938 *
939 * Convert the linked list into a byte stream
940 */
941 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
942 Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
943 if (ACPI_FAILURE (Status))
944 {
945 goto Cleanup;
946 }
947
948 /* Create and initialize the method parameter object */
949
950 Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
951 if (!Args[0])
952 {
953 /*
954 * Must free the buffer allocated above (otherwise it is freed
955 * later)
956 */
957 ACPI_FREE (Buffer.Pointer);
958 Status = AE_NO_MEMORY;
959 goto Cleanup;
960 }
961
962 Args[0]->Buffer.Length = (UINT32) Buffer.Length;
963 Args[0]->Buffer.Pointer = Buffer.Pointer;
964 Args[0]->Common.Flags = AOPOBJ_DATA_VALID;
965 Args[1] = NULL;
966
967 /* Execute the method, no return value is expected */
968
969 Status = AcpiNsEvaluate (Info);
970
971 /* Clean up and return the status from AcpiNsEvaluate */
972
973 AcpiUtRemoveReference (Args[0]);
974
975 Cleanup:
976 ACPI_FREE (Info);
977 return_ACPI_STATUS (Status);
978 }
979