1 /*******************************************************************************
3 * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
44 #include <contrib/dev/acpica/include/acpi.h>
45 #include <contrib/dev/acpica/include/accommon.h>
46 #include <contrib/dev/acpica/include/acdisasm.h>
49 #ifdef ACPI_DISASSEMBLER
51 #define _COMPONENT ACPI_CA_DEBUGGER
52 ACPI_MODULE_NAME ("dbresrcl2")
54 /* Local prototypes */
57 AcpiDmI2cSerialBusDescriptor (
58 ACPI_OP_WALK_INFO *Info,
59 AML_RESOURCE *Resource,
64 AcpiDmSpiSerialBusDescriptor (
65 ACPI_OP_WALK_INFO *Info,
66 AML_RESOURCE *Resource,
71 AcpiDmUartSerialBusDescriptor (
72 ACPI_OP_WALK_INFO *Info,
73 AML_RESOURCE *Resource,
79 ACPI_OP_WALK_INFO *Info,
80 AML_RESOURCE *Resource,
84 AcpiDmDumpRawDataBuffer (
90 /* Dispatch table for the serial bus descriptors */
92 static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] =
95 AcpiDmI2cSerialBusDescriptor,
96 AcpiDmSpiSerialBusDescriptor,
97 AcpiDmUartSerialBusDescriptor
101 /*******************************************************************************
103 * FUNCTION: AcpiDmDumpRawDataBuffer
105 * PARAMETERS: Buffer - Pointer to the data bytes
106 * Length - Length of the descriptor in bytes
107 * Level - Current source code indentation level
111 * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
114 ******************************************************************************/
117 AcpiDmDumpRawDataBuffer (
132 AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length);
135 AcpiDmIndent (Level + 1);
136 AcpiOsPrintf ("{\n");
137 AcpiDmIndent (Level + 2);
139 for (i = 0; i < Length;)
141 for (j = 0; j < 8; j++)
149 AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
150 if ((Index + 1) >= Length)
158 AcpiDmIndent (Level + 2);
165 AcpiDmIndent (Level + 1);
170 /*******************************************************************************
172 * FUNCTION: AcpiDmGpioCommon
174 * PARAMETERS: Info - Extra resource info
175 * Resource - Pointer to the resource descriptor
176 * Level - Current source code indentation level
180 * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
182 ******************************************************************************/
186 ACPI_OP_WALK_INFO *Info,
187 AML_RESOURCE *Resource,
192 char *DeviceName = NULL;
197 /* ResourceSource, ResourceSourceIndex, ResourceType */
199 AcpiDmIndent (Level + 1);
200 if (Resource->Gpio.ResSourceOffset)
202 DeviceName = ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset),
203 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
207 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
208 AcpiOsPrintf ("%s, ",
209 AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
211 /* Insert a descriptor name */
213 AcpiDmDescriptorName ();
216 /* Dump the vendor data */
218 if (Resource->Gpio.VendorOffset)
221 AcpiDmIndent (Level + 1);
222 VendorData = ACPI_ADD_PTR (UINT8, Resource,
223 Resource->Gpio.VendorOffset);
225 AcpiDmDumpRawDataBuffer (VendorData,
226 Resource->Gpio.VendorLength, Level);
229 AcpiOsPrintf (")\n");
231 /* Dump the interrupt list */
233 AcpiDmIndent (Level + 1);
234 AcpiOsPrintf ("{ // Pin list\n");
236 PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
237 Resource->Gpio.PinTableOffset)) /
240 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
241 Resource->Gpio.PinTableOffset);
243 for (i = 0; i < PinCount; i++)
245 AcpiDmIndent (Level + 2);
246 AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : "");
249 AcpiDmIndent (Level + 1);
250 AcpiOsPrintf ("}\n");
253 MpSaveGpioInfo (Info->MappingOp, Resource, PinCount, PinList, DeviceName);
258 /*******************************************************************************
260 * FUNCTION: AcpiDmGpioIntDescriptor
262 * PARAMETERS: Info - Extra resource info
263 * Resource - Pointer to the resource descriptor
264 * Length - Length of the descriptor in bytes
265 * Level - Current source code indentation level
269 * DESCRIPTION: Decode a GPIO Interrupt descriptor
271 ******************************************************************************/
274 AcpiDmGpioIntDescriptor (
275 ACPI_OP_WALK_INFO *Info,
276 AML_RESOURCE *Resource,
281 /* Dump the GpioInt-specific portion of the descriptor */
283 /* EdgeLevel, ActiveLevel, Shared */
285 AcpiDmIndent (Level);
286 AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
287 AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
288 AcpiGbl_LlDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 1)],
289 AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
291 /* PinConfig, DebounceTimeout */
293 if (Resource->Gpio.PinConfig <= 3)
295 AcpiOsPrintf ("%s, ",
296 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
300 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
302 AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
304 /* Dump the GpioInt/GpioIo common portion of the descriptor */
306 AcpiDmGpioCommon (Info, Resource, Level);
310 /*******************************************************************************
312 * FUNCTION: AcpiDmGpioIoDescriptor
314 * PARAMETERS: Info - Extra resource info
315 * Resource - Pointer to the resource descriptor
316 * Length - Length of the descriptor in bytes
317 * Level - Current source code indentation level
321 * DESCRIPTION: Decode a GPIO I/O descriptor
323 ******************************************************************************/
326 AcpiDmGpioIoDescriptor (
327 ACPI_OP_WALK_INFO *Info,
328 AML_RESOURCE *Resource,
333 /* Dump the GpioIo-specific portion of the descriptor */
335 /* Shared, PinConfig */
337 AcpiDmIndent (Level);
338 AcpiOsPrintf ("GpioIo (%s, ",
339 AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
341 if (Resource->Gpio.PinConfig <= 3)
343 AcpiOsPrintf ("%s, ",
344 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
348 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
351 /* DebounceTimeout, DriveStrength, IoRestriction */
353 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
354 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
355 AcpiOsPrintf ("%s,\n",
356 AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
358 /* Dump the GpioInt/GpioIo common portion of the descriptor */
360 AcpiDmGpioCommon (Info, Resource, Level);
364 /*******************************************************************************
366 * FUNCTION: AcpiDmGpioDescriptor
368 * PARAMETERS: Info - Extra resource info
369 * Resource - Pointer to the resource descriptor
370 * Length - Length of the descriptor in bytes
371 * Level - Current source code indentation level
375 * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor
377 ******************************************************************************/
380 AcpiDmGpioDescriptor (
381 ACPI_OP_WALK_INFO *Info,
382 AML_RESOURCE *Resource,
386 UINT8 ConnectionType;
389 ConnectionType = Resource->Gpio.ConnectionType;
391 switch (ConnectionType)
393 case AML_RESOURCE_GPIO_TYPE_INT:
395 AcpiDmGpioIntDescriptor (Info, Resource, Length, Level);
398 case AML_RESOURCE_GPIO_TYPE_IO:
400 AcpiDmGpioIoDescriptor (Info, Resource, Length, Level);
405 AcpiOsPrintf ("Unknown GPIO type\n");
411 /*******************************************************************************
413 * FUNCTION: AcpiDmDumpSerialBusVendorData
415 * PARAMETERS: Resource - Pointer to the resource descriptor
419 * DESCRIPTION: Dump optional serial bus vendor data
421 ******************************************************************************/
424 AcpiDmDumpSerialBusVendorData (
425 AML_RESOURCE *Resource,
432 /* Get the (optional) vendor data and length */
434 switch (Resource->CommonSerialBus.Type)
436 case AML_RESOURCE_I2C_SERIALBUSTYPE:
438 VendorLength = Resource->CommonSerialBus.TypeDataLength -
439 AML_RESOURCE_I2C_MIN_DATA_LEN;
441 VendorData = ACPI_ADD_PTR (UINT8, Resource,
442 sizeof (AML_RESOURCE_I2C_SERIALBUS));
445 case AML_RESOURCE_SPI_SERIALBUSTYPE:
447 VendorLength = Resource->CommonSerialBus.TypeDataLength -
448 AML_RESOURCE_SPI_MIN_DATA_LEN;
450 VendorData = ACPI_ADD_PTR (UINT8, Resource,
451 sizeof (AML_RESOURCE_SPI_SERIALBUS));
454 case AML_RESOURCE_UART_SERIALBUSTYPE:
456 VendorLength = Resource->CommonSerialBus.TypeDataLength -
457 AML_RESOURCE_UART_MIN_DATA_LEN;
459 VendorData = ACPI_ADD_PTR (UINT8, Resource,
460 sizeof (AML_RESOURCE_UART_SERIALBUS));
468 /* Dump the vendor bytes as a RawDataBuffer object */
470 AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
474 /*******************************************************************************
476 * FUNCTION: AcpiDmI2cSerialBusDescriptor
478 * PARAMETERS: Info - Extra resource info
479 * Resource - Pointer to the resource descriptor
480 * Length - Length of the descriptor in bytes
481 * Level - Current source code indentation level
485 * DESCRIPTION: Decode a I2C serial bus descriptor
487 ******************************************************************************/
490 AcpiDmI2cSerialBusDescriptor (
491 ACPI_OP_WALK_INFO *Info,
492 AML_RESOURCE *Resource,
496 UINT32 ResourceSourceOffset;
500 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
502 AcpiDmIndent (Level);
503 AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n",
504 Resource->I2cSerialBus.SlaveAddress,
505 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
506 Resource->I2cSerialBus.ConnectionSpeed);
508 AcpiDmIndent (Level + 1);
509 AcpiOsPrintf ("%s, ",
510 AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
512 /* ResourceSource is a required field */
514 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
515 Resource->CommonSerialBus.TypeDataLength;
517 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
518 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
520 /* ResourceSourceIndex, ResourceUsage */
522 AcpiOsPrintf (",\n");
523 AcpiDmIndent (Level + 1);
524 AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
526 AcpiOsPrintf ("%s, ",
527 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 1)]);
529 /* Insert a descriptor name */
531 AcpiDmDescriptorName ();
532 AcpiOsPrintf (",\n");
534 /* Dump the vendor data */
536 AcpiDmIndent (Level + 1);
537 AcpiDmDumpSerialBusVendorData (Resource, Level);
538 AcpiOsPrintf (")\n");
541 MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
546 /*******************************************************************************
548 * FUNCTION: AcpiDmSpiSerialBusDescriptor
550 * PARAMETERS: Info - Extra resource info
551 * Resource - Pointer to the resource descriptor
552 * Length - Length of the descriptor in bytes
553 * Level - Current source code indentation level
557 * DESCRIPTION: Decode a SPI serial bus descriptor
559 ******************************************************************************/
562 AcpiDmSpiSerialBusDescriptor (
563 ACPI_OP_WALK_INFO *Info,
564 AML_RESOURCE *Resource,
568 UINT32 ResourceSourceOffset;
572 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
574 AcpiDmIndent (Level);
575 AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n",
576 Resource->SpiSerialBus.DeviceSelection,
577 AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
578 AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
579 Resource->SpiSerialBus.DataBitLength);
581 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
583 AcpiDmIndent (Level + 1);
584 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
585 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
586 Resource->SpiSerialBus.ConnectionSpeed,
587 AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
589 AcpiDmIndent (Level + 1);
590 AcpiOsPrintf ("%s, ",
591 AcpiGbl_CphDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPhase)]);
593 /* ResourceSource is a required field */
595 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
596 Resource->CommonSerialBus.TypeDataLength;
598 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
599 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
601 /* ResourceSourceIndex, ResourceUsage */
603 AcpiOsPrintf (",\n");
604 AcpiDmIndent (Level + 1);
605 AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
607 AcpiOsPrintf ("%s, ",
608 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 1)]);
610 /* Insert a descriptor name */
612 AcpiDmDescriptorName ();
613 AcpiOsPrintf (",\n");
615 /* Dump the vendor data */
617 AcpiDmIndent (Level + 1);
618 AcpiDmDumpSerialBusVendorData (Resource, Level);
619 AcpiOsPrintf (")\n");
622 MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
627 /*******************************************************************************
629 * FUNCTION: AcpiDmUartSerialBusDescriptor
631 * PARAMETERS: Info - Extra resource info
632 * Resource - Pointer to the resource descriptor
633 * Length - Length of the descriptor in bytes
634 * Level - Current source code indentation level
638 * DESCRIPTION: Decode a UART serial bus descriptor
640 ******************************************************************************/
643 AcpiDmUartSerialBusDescriptor (
644 ACPI_OP_WALK_INFO *Info,
645 AML_RESOURCE *Resource,
649 UINT32 ResourceSourceOffset;
653 /* ConnectionSpeed, BitsPerByte, StopBits */
655 AcpiDmIndent (Level);
656 AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n",
657 Resource->UartSerialBus.DefaultBaudRate,
658 AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
659 AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
661 /* LinesInUse, IsBigEndian, Parity, FlowControl */
663 AcpiDmIndent (Level + 1);
664 AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
665 Resource->UartSerialBus.LinesEnabled,
666 AcpiGbl_EdDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 7)],
667 AcpiGbl_PtDecode [ACPI_GET_3BIT_FLAG (Resource->UartSerialBus.Parity)],
668 AcpiGbl_FcDecode [ACPI_GET_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags)]);
670 /* ReceiveBufferSize, TransmitBufferSize */
672 AcpiDmIndent (Level + 1);
673 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
674 Resource->UartSerialBus.RxFifoSize,
675 Resource->UartSerialBus.TxFifoSize);
677 /* ResourceSource is a required field */
679 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
680 Resource->CommonSerialBus.TypeDataLength;
682 DeviceName = ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
683 AcpiUtPrintString (DeviceName, ACPI_UINT16_MAX);
685 /* ResourceSourceIndex, ResourceUsage */
687 AcpiOsPrintf (",\n");
688 AcpiDmIndent (Level + 1);
689 AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
691 AcpiOsPrintf ("%s, ",
692 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 1)]);
694 /* Insert a descriptor name */
696 AcpiDmDescriptorName ();
697 AcpiOsPrintf (",\n");
699 /* Dump the vendor data */
701 AcpiDmIndent (Level + 1);
702 AcpiDmDumpSerialBusVendorData (Resource, Level);
703 AcpiOsPrintf (")\n");
706 MpSaveSerialInfo (Info->MappingOp, Resource, DeviceName);
711 /*******************************************************************************
713 * FUNCTION: AcpiDmSerialBusDescriptor
715 * PARAMETERS: Info - Extra resource info
716 * Resource - Pointer to the resource descriptor
717 * Length - Length of the descriptor in bytes
718 * Level - Current source code indentation level
722 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
724 ******************************************************************************/
727 AcpiDmSerialBusDescriptor (
728 ACPI_OP_WALK_INFO *Info,
729 AML_RESOURCE *Resource,
734 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
735 Info, Resource, Length, Level);