1 /*******************************************************************************
2  *
3  * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
4  *
5  ******************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2017, 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 "acdisasm.h"
155 
156 
157 #ifdef ACPI_DISASSEMBLER
158 
159 #define _COMPONENT          ACPI_CA_DEBUGGER
160         ACPI_MODULE_NAME    ("dbresrcl2")
161 
162 /* Local prototypes */
163 
164 static void
165 AcpiDmI2cSerialBusDescriptor (
166     ACPI_OP_WALK_INFO       *Info,
167     AML_RESOURCE            *Resource,
168     UINT32                  Length,
169     UINT32                  Level);
170 
171 static void
172 AcpiDmSpiSerialBusDescriptor (
173     ACPI_OP_WALK_INFO       *Info,
174     AML_RESOURCE            *Resource,
175     UINT32                  Length,
176     UINT32                  Level);
177 
178 static void
179 AcpiDmUartSerialBusDescriptor (
180     ACPI_OP_WALK_INFO       *Info,
181     AML_RESOURCE            *Resource,
182     UINT32                  Length,
183     UINT32                  Level);
184 
185 static void
186 AcpiDmGpioCommon (
187     ACPI_OP_WALK_INFO       *Info,
188     AML_RESOURCE            *Resource,
189     UINT32                  Level);
190 
191 static void
192 AcpiDmDumpRawDataBuffer (
193     UINT8                   *Buffer,
194     UINT32                  Length,
195     UINT32                  Level);
196 
197 
198 /* Dispatch table for the serial bus descriptors */
199 
200 static ACPI_RESOURCE_HANDLER        SerialBusResourceDispatch [] =
201 {
202     NULL,
203     AcpiDmI2cSerialBusDescriptor,
204     AcpiDmSpiSerialBusDescriptor,
205     AcpiDmUartSerialBusDescriptor
206 };
207 
208 
209 /*******************************************************************************
210  *
211  * FUNCTION:    AcpiDmDumpRawDataBuffer
212  *
213  * PARAMETERS:  Buffer              - Pointer to the data bytes
214  *              Length              - Length of the descriptor in bytes
215  *              Level               - Current source code indentation level
216  *
217  * RETURN:      None
218  *
219  * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
220  *              vendor data bytes.
221  *
222  ******************************************************************************/
223 
224 static void
225 AcpiDmDumpRawDataBuffer (
226     UINT8                   *Buffer,
227     UINT32                  Length,
228     UINT32                  Level)
229 {
230     UINT32                  Index;
231     UINT32                  i;
232     UINT32                  j;
233 
234 
235     if (!Length)
236     {
237         return;
238     }
239 
240     AcpiOsPrintf ("RawDataBuffer (0x%.2X)  // Vendor Data", Length);
241 
242     AcpiOsPrintf ("\n");
243     AcpiDmIndent (Level + 1);
244     AcpiOsPrintf ("{\n");
245     AcpiDmIndent (Level + 2);
246 
247     for (i = 0; i < Length;)
248     {
249         for (j = 0; j < 8; j++)
250         {
251             Index = i + j;
252             if (Index >= Length)
253             {
254                 goto Finish;
255             }
256 
257             AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
258             if ((Index + 1) >= Length)
259             {
260                 goto Finish;
261             }
262 
263             AcpiOsPrintf (", ");
264         }
265 
266         AcpiOsPrintf ("\n");
267         AcpiDmIndent (Level + 2);
268 
269         i += 8;
270     }
271 
272 Finish:
273     AcpiOsPrintf ("\n");
274     AcpiDmIndent (Level + 1);
275     AcpiOsPrintf ("}");
276 }
277 
278 
279 /*******************************************************************************
280  *
281  * FUNCTION:    AcpiDmGpioCommon
282  *
283  * PARAMETERS:  Info                - Extra resource info
284  *              Resource            - Pointer to the resource descriptor
285  *              Level               - Current source code indentation level
286  *
287  * RETURN:      None
288  *
289  * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
290  *
291  ******************************************************************************/
292 
293 static void
294 AcpiDmGpioCommon (
295     ACPI_OP_WALK_INFO       *Info,
296     AML_RESOURCE            *Resource,
297     UINT32                  Level)
298 {
299     UINT16                  *PinList;
300     UINT8                   *VendorData;
301     char                    *DeviceName = NULL;
302     UINT32                  PinCount;
303     UINT32                  i;
304 
305 
306     /* ResourceSource, ResourceSourceIndex, ResourceType */
307 
308     AcpiDmIndent (Level + 1);
309     if (Resource->Gpio.ResSourceOffset)
310     {
311         DeviceName = ACPI_ADD_PTR (char,
312             Resource, Resource->Gpio.ResSourceOffset),
313         AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
314     }
315 
316     AcpiOsPrintf (", ");
317     AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
318     AcpiOsPrintf ("%s, ",
319         AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
320 
321     /* Insert a descriptor name */
322 
323     AcpiDmDescriptorName ();
324     AcpiOsPrintf (",");
325 
326     /* Dump the vendor data */
327 
328     if (Resource->Gpio.VendorOffset)
329     {
330         AcpiOsPrintf ("\n");
331         AcpiDmIndent (Level + 1);
332         VendorData = ACPI_ADD_PTR (UINT8, Resource,
333             Resource->Gpio.VendorOffset);
334 
335         AcpiDmDumpRawDataBuffer (VendorData,
336             Resource->Gpio.VendorLength, Level);
337     }
338 
339     AcpiOsPrintf (")\n");
340 
341     /* Dump the interrupt list */
342 
343     AcpiDmIndent (Level + 1);
344     AcpiOsPrintf ("{   // Pin list\n");
345 
346     PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
347         Resource->Gpio.PinTableOffset)) /
348         sizeof (UINT16);
349 
350     PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
351         Resource->Gpio.PinTableOffset);
352 
353     for (i = 0; i < PinCount; i++)
354     {
355         AcpiDmIndent (Level + 2);
356         AcpiOsPrintf ("0x%4.4X%s\n", PinList[i],
357             ((i + 1) < PinCount) ? "," : "");
358     }
359 
360     AcpiDmIndent (Level + 1);
361     AcpiOsPrintf ("}\n");
362 
363 #ifndef _KERNEL
364     MpSaveGpioInfo (Info->MappingOp, Resource,
365         PinCount, PinList, DeviceName);
366 #endif
367 }
368 
369 
370 /*******************************************************************************
371  *
372  * FUNCTION:    AcpiDmGpioIntDescriptor
373  *
374  * PARAMETERS:  Info                - Extra resource info
375  *              Resource            - Pointer to the resource descriptor
376  *              Length              - Length of the descriptor in bytes
377  *              Level               - Current source code indentation level
378  *
379  * RETURN:      None
380  *
381  * DESCRIPTION: Decode a GPIO Interrupt descriptor
382  *
383  ******************************************************************************/
384 
385 static void
386 AcpiDmGpioIntDescriptor (
387     ACPI_OP_WALK_INFO       *Info,
388     AML_RESOURCE            *Resource,
389     UINT32                  Length,
390     UINT32                  Level)
391 {
392 
393     /* Dump the GpioInt-specific portion of the descriptor */
394 
395     /* EdgeLevel, ActiveLevel, Shared */
396 
397     AcpiDmIndent (Level);
398     AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
399         AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
400         AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
401         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
402 
403     /* PinConfig, DebounceTimeout */
404 
405     if (Resource->Gpio.PinConfig <= 3)
406     {
407         AcpiOsPrintf ("%s, ",
408             AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
409     }
410     else
411     {
412         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
413     }
414     AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
415 
416     /* Dump the GpioInt/GpioIo common portion of the descriptor */
417 
418     AcpiDmGpioCommon (Info, Resource, Level);
419 }
420 
421 
422 /*******************************************************************************
423  *
424  * FUNCTION:    AcpiDmGpioIoDescriptor
425  *
426  * PARAMETERS:  Info                - Extra resource info
427  *              Resource            - Pointer to the resource descriptor
428  *              Length              - Length of the descriptor in bytes
429  *              Level               - Current source code indentation level
430  *
431  * RETURN:      None
432  *
433  * DESCRIPTION: Decode a GPIO I/O descriptor
434  *
435  ******************************************************************************/
436 
437 static void
438 AcpiDmGpioIoDescriptor (
439     ACPI_OP_WALK_INFO       *Info,
440     AML_RESOURCE            *Resource,
441     UINT32                  Length,
442     UINT32                  Level)
443 {
444 
445     /* Dump the GpioIo-specific portion of the descriptor */
446 
447     /* Shared, PinConfig */
448 
449     AcpiDmIndent (Level);
450     AcpiOsPrintf ("GpioIo (%s, ",
451         AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
452 
453     if (Resource->Gpio.PinConfig <= 3)
454     {
455         AcpiOsPrintf ("%s, ",
456             AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
457     }
458     else
459     {
460         AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
461     }
462 
463     /* DebounceTimeout, DriveStrength, IoRestriction */
464 
465     AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
466     AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
467     AcpiOsPrintf ("%s,\n",
468         AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
469 
470     /* Dump the GpioInt/GpioIo common portion of the descriptor */
471 
472     AcpiDmGpioCommon (Info, Resource, Level);
473 }
474 
475 
476 /*******************************************************************************
477  *
478  * FUNCTION:    AcpiDmGpioDescriptor
479  *
480  * PARAMETERS:  Info                - Extra resource info
481  *              Resource            - Pointer to the resource descriptor
482  *              Length              - Length of the descriptor in bytes
483  *              Level               - Current source code indentation level
484  *
485  * RETURN:      None
486  *
487  * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor
488  *
489  ******************************************************************************/
490 
491 void
492 AcpiDmGpioDescriptor (
493     ACPI_OP_WALK_INFO       *Info,
494     AML_RESOURCE            *Resource,
495     UINT32                  Length,
496     UINT32                  Level)
497 {
498     UINT8                   ConnectionType;
499 
500 
501     ConnectionType = Resource->Gpio.ConnectionType;
502 
503     switch (ConnectionType)
504     {
505     case AML_RESOURCE_GPIO_TYPE_INT:
506 
507         AcpiDmGpioIntDescriptor (Info, Resource, Length, Level);
508         break;
509 
510     case AML_RESOURCE_GPIO_TYPE_IO:
511 
512         AcpiDmGpioIoDescriptor (Info, Resource, Length, Level);
513         break;
514 
515     default:
516 
517         AcpiOsPrintf ("Unknown GPIO type\n");
518         break;
519     }
520 }
521 
522 
523 /*******************************************************************************
524  *
525  * FUNCTION:    AcpiDmDumpSerialBusVendorData
526  *
527  * PARAMETERS:  Resource            - Pointer to the resource descriptor
528  *
529  * RETURN:      None
530  *
531  * DESCRIPTION: Dump optional serial bus vendor data
532  *
533  ******************************************************************************/
534 
535 static void
536 AcpiDmDumpSerialBusVendorData (
537     AML_RESOURCE            *Resource,
538     UINT32                  Level)
539 {
540     UINT8                   *VendorData;
541     UINT32                  VendorLength;
542 
543 
544     /* Get the (optional) vendor data and length */
545 
546     switch (Resource->CommonSerialBus.Type)
547     {
548     case AML_RESOURCE_I2C_SERIALBUSTYPE:
549 
550         VendorLength = Resource->CommonSerialBus.TypeDataLength -
551             AML_RESOURCE_I2C_MIN_DATA_LEN;
552 
553         VendorData = ACPI_ADD_PTR (UINT8, Resource,
554             sizeof (AML_RESOURCE_I2C_SERIALBUS));
555         break;
556 
557     case AML_RESOURCE_SPI_SERIALBUSTYPE:
558 
559         VendorLength = Resource->CommonSerialBus.TypeDataLength -
560             AML_RESOURCE_SPI_MIN_DATA_LEN;
561 
562         VendorData = ACPI_ADD_PTR (UINT8, Resource,
563             sizeof (AML_RESOURCE_SPI_SERIALBUS));
564         break;
565 
566     case AML_RESOURCE_UART_SERIALBUSTYPE:
567 
568         VendorLength = Resource->CommonSerialBus.TypeDataLength -
569             AML_RESOURCE_UART_MIN_DATA_LEN;
570 
571         VendorData = ACPI_ADD_PTR (UINT8, Resource,
572             sizeof (AML_RESOURCE_UART_SERIALBUS));
573         break;
574 
575     default:
576 
577         return;
578     }
579 
580     /* Dump the vendor bytes as a RawDataBuffer object */
581 
582     AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
583 }
584 
585 
586 /*******************************************************************************
587  *
588  * FUNCTION:    AcpiDmI2cSerialBusDescriptor
589  *
590  * PARAMETERS:  Info                - Extra resource info
591  *              Resource            - Pointer to the resource descriptor
592  *              Length              - Length of the descriptor in bytes
593  *              Level               - Current source code indentation level
594  *
595  * RETURN:      None
596  *
597  * DESCRIPTION: Decode a I2C serial bus descriptor
598  *
599  ******************************************************************************/
600 
601 static void
602 AcpiDmI2cSerialBusDescriptor (
603     ACPI_OP_WALK_INFO       *Info,
604     AML_RESOURCE            *Resource,
605     UINT32                  Length,
606     UINT32                  Level)
607 {
608     UINT32                  ResourceSourceOffset;
609     char                    *DeviceName;
610 
611 
612     /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
613 
614     AcpiDmIndent (Level);
615     AcpiOsPrintf ("I2cSerialBusV2 (0x%4.4X, %s, 0x%8.8X,\n",
616         Resource->I2cSerialBus.SlaveAddress,
617         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
618         Resource->I2cSerialBus.ConnectionSpeed);
619 
620     AcpiDmIndent (Level + 1);
621     AcpiOsPrintf ("%s, ",
622         AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
623 
624     /* ResourceSource is a required field */
625 
626     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
627         Resource->CommonSerialBus.TypeDataLength;
628 
629     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
630     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
631 
632     /* ResourceSourceIndex, ResourceUsage */
633 
634     AcpiOsPrintf (",\n");
635     AcpiDmIndent (Level + 1);
636     AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
637 
638     AcpiOsPrintf ("%s, ",
639         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 1)]);
640 
641     /* Insert a descriptor name */
642 
643     AcpiDmDescriptorName ();
644 
645     /* Share */
646 
647     AcpiOsPrintf (", %s,\n",
648         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 2)]);
649 
650     /* Dump the vendor data */
651 
652     AcpiDmIndent (Level + 1);
653     AcpiDmDumpSerialBusVendorData (Resource, Level);
654     AcpiOsPrintf (")\n");
655 
656 #ifndef _KERNEL
657     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
658 #endif
659 }
660 
661 
662 /*******************************************************************************
663  *
664  * FUNCTION:    AcpiDmSpiSerialBusDescriptor
665  *
666  * PARAMETERS:  Info                - Extra resource info
667  *              Resource            - Pointer to the resource descriptor
668  *              Length              - Length of the descriptor in bytes
669  *              Level               - Current source code indentation level
670  *
671  * RETURN:      None
672  *
673  * DESCRIPTION: Decode a SPI serial bus descriptor
674  *
675  ******************************************************************************/
676 
677 static void
678 AcpiDmSpiSerialBusDescriptor (
679     ACPI_OP_WALK_INFO       *Info,
680     AML_RESOURCE            *Resource,
681     UINT32                  Length,
682     UINT32                  Level)
683 {
684     UINT32                  ResourceSourceOffset;
685     char                    *DeviceName;
686 
687 
688     /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
689 
690     AcpiDmIndent (Level);
691     AcpiOsPrintf ("SpiSerialBusV2 (0x%4.4X, %s, %s, 0x%2.2X,\n",
692         Resource->SpiSerialBus.DeviceSelection,
693         AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
694         AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
695         Resource->SpiSerialBus.DataBitLength);
696 
697     /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
698 
699     AcpiDmIndent (Level + 1);
700     AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
701         AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
702         Resource->SpiSerialBus.ConnectionSpeed,
703         AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
704 
705     AcpiDmIndent (Level + 1);
706     AcpiOsPrintf ("%s, ",
707         AcpiGbl_CphDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPhase)]);
708 
709     /* ResourceSource is a required field */
710 
711     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
712         Resource->CommonSerialBus.TypeDataLength;
713 
714     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
715     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
716 
717     /* ResourceSourceIndex, ResourceUsage */
718 
719     AcpiOsPrintf (",\n");
720     AcpiDmIndent (Level + 1);
721     AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
722 
723     AcpiOsPrintf ("%s, ",
724         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 1)]);
725 
726     /* Insert a descriptor name */
727 
728     AcpiDmDescriptorName ();
729 
730     /* Share */
731 
732     AcpiOsPrintf (", %s,\n",
733         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 2)]);
734 
735     /* Dump the vendor data */
736 
737     AcpiDmIndent (Level + 1);
738     AcpiDmDumpSerialBusVendorData (Resource, Level);
739     AcpiOsPrintf (")\n");
740 
741 #ifndef _KERNEL
742     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
743 #endif
744 }
745 
746 
747 /*******************************************************************************
748  *
749  * FUNCTION:    AcpiDmUartSerialBusDescriptor
750  *
751  * PARAMETERS:  Info                - Extra resource info
752  *              Resource            - Pointer to the resource descriptor
753  *              Length              - Length of the descriptor in bytes
754  *              Level               - Current source code indentation level
755  *
756  * RETURN:      None
757  *
758  * DESCRIPTION: Decode a UART serial bus descriptor
759  *
760  ******************************************************************************/
761 
762 static void
763 AcpiDmUartSerialBusDescriptor (
764     ACPI_OP_WALK_INFO       *Info,
765     AML_RESOURCE            *Resource,
766     UINT32                  Length,
767     UINT32                  Level)
768 {
769     UINT32                  ResourceSourceOffset;
770     char                    *DeviceName;
771 
772 
773     /* ConnectionSpeed, BitsPerByte, StopBits */
774 
775     AcpiDmIndent (Level);
776     AcpiOsPrintf ("UartSerialBusV2 (0x%8.8X, %s, %s,\n",
777         Resource->UartSerialBus.DefaultBaudRate,
778         AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
779         AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
780 
781     /* LinesInUse, IsBigEndian, Parity, FlowControl */
782 
783     AcpiDmIndent (Level + 1);
784     AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
785         Resource->UartSerialBus.LinesEnabled,
786         AcpiGbl_EdDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 7)],
787         AcpiGbl_PtDecode [ACPI_GET_3BIT_FLAG (Resource->UartSerialBus.Parity)],
788         AcpiGbl_FcDecode [ACPI_GET_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags)]);
789 
790     /* ReceiveBufferSize, TransmitBufferSize */
791 
792     AcpiDmIndent (Level + 1);
793     AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
794         Resource->UartSerialBus.RxFifoSize,
795         Resource->UartSerialBus.TxFifoSize);
796 
797     /* ResourceSource is a required field */
798 
799     ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
800         Resource->CommonSerialBus.TypeDataLength;
801 
802     DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset);
803     AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
804 
805     /* ResourceSourceIndex, ResourceUsage */
806 
807     AcpiOsPrintf (",\n");
808     AcpiDmIndent (Level + 1);
809     AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
810 
811     AcpiOsPrintf ("%s, ",
812         AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 1)]);
813 
814     /* Insert a descriptor name */
815 
816     AcpiDmDescriptorName ();
817 
818     /* Share */
819 
820     AcpiOsPrintf (", %s,\n",
821         AcpiGbl_ShrDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 2)]);
822 
823     /* Dump the vendor data */
824 
825     AcpiDmIndent (Level + 1);
826     AcpiDmDumpSerialBusVendorData (Resource, Level);
827     AcpiOsPrintf (")\n");
828 
829 #ifndef _KERNEL
830     MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
831 #endif
832 }
833 
834 
835 /*******************************************************************************
836  *
837  * FUNCTION:    AcpiDmSerialBusDescriptor
838  *
839  * PARAMETERS:  Info                - Extra resource info
840  *              Resource            - Pointer to the resource descriptor
841  *              Length              - Length of the descriptor in bytes
842  *              Level               - Current source code indentation level
843  *
844  * RETURN:      None
845  *
846  * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
847  *
848  ******************************************************************************/
849 
850 void
851 AcpiDmSerialBusDescriptor (
852     ACPI_OP_WALK_INFO       *Info,
853     AML_RESOURCE            *Resource,
854     UINT32                  Length,
855     UINT32                  Level)
856 {
857 
858     SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
859         Info, Resource, Length, Level);
860 }
861 
862 #endif
863