1 /*******************************************************************************
3 * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
50 #ifdef ACPI_DISASSEMBLER
52 #define _COMPONENT ACPI_CA_DEBUGGER
53 ACPI_MODULE_NAME ("dbresrcl2")
55 /* Local prototypes */
58 AcpiDmI2cSerialBusDescriptor (
59 AML_RESOURCE *Resource,
64 AcpiDmSpiSerialBusDescriptor (
65 AML_RESOURCE *Resource,
70 AcpiDmUartSerialBusDescriptor (
71 AML_RESOURCE *Resource,
77 AML_RESOURCE *Resource,
81 AcpiDmDumpRawDataBuffer (
87 /* Dispatch table for the serial bus descriptors */
89 static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] =
92 AcpiDmI2cSerialBusDescriptor,
93 AcpiDmSpiSerialBusDescriptor,
94 AcpiDmUartSerialBusDescriptor
98 /*******************************************************************************
100 * FUNCTION: AcpiDmDumpRawDataBuffer
102 * PARAMETERS: Buffer - Pointer to the data bytes
103 * Length - Length of the descriptor in bytes
104 * Level - Current source code indentation level
108 * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
111 ******************************************************************************/
114 AcpiDmDumpRawDataBuffer (
129 AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length);
132 AcpiDmIndent (Level + 1);
133 AcpiOsPrintf ("{\n");
134 AcpiDmIndent (Level + 2);
136 for (i = 0; i < Length;)
138 for (j = 0; j < 8; j++)
146 AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
147 if ((Index + 1) >= Length)
155 AcpiDmIndent (Level + 2);
162 AcpiDmIndent (Level + 1);
167 /*******************************************************************************
169 * FUNCTION: AcpiDmGpioCommon
171 * PARAMETERS: Resource - Pointer to the resource descriptor
172 * Level - Current source code indentation level
176 * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
178 ******************************************************************************/
182 AML_RESOURCE *Resource,
191 /* ResourceSource, ResourceSourceIndex, ResourceType */
193 AcpiDmIndent (Level + 1);
194 if (Resource->Gpio.ResSourceOffset)
197 ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset),
202 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex);
203 AcpiOsPrintf ("%s, ",
204 AcpiGbl_ConsumeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.Flags)]);
206 /* Insert a descriptor name */
208 AcpiDmDescriptorName ();
211 /* Dump the vendor data */
213 if (Resource->Gpio.VendorOffset)
216 AcpiDmIndent (Level + 1);
217 VendorData = ACPI_ADD_PTR (UINT8, Resource,
218 Resource->Gpio.VendorOffset);
220 AcpiDmDumpRawDataBuffer (VendorData,
221 Resource->Gpio.VendorLength, Level);
224 AcpiOsPrintf (")\n");
226 /* Dump the interrupt list */
228 AcpiDmIndent (Level + 1);
229 AcpiOsPrintf ("{ // Pin list\n");
231 PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset -
232 Resource->Gpio.PinTableOffset)) /
235 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource,
236 Resource->Gpio.PinTableOffset);
238 for (i = 0; i < PinCount; i++)
240 AcpiDmIndent (Level + 2);
241 AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : "");
244 AcpiDmIndent (Level + 1);
245 AcpiOsPrintf ("}\n");
249 /*******************************************************************************
251 * FUNCTION: AcpiDmGpioIntDescriptor
253 * PARAMETERS: Resource - Pointer to the resource descriptor
254 * Length - Length of the descriptor in bytes
255 * Level - Current source code indentation level
259 * DESCRIPTION: Decode a GPIO Interrupt descriptor
261 ******************************************************************************/
264 AcpiDmGpioIntDescriptor (
265 AML_RESOURCE *Resource,
270 /* Dump the GpioInt-specific portion of the descriptor */
272 /* EdgeLevel, ActiveLevel, Shared */
274 AcpiDmIndent (Level);
275 AcpiOsPrintf ("GpioInt (%s, %s, %s, ",
276 AcpiGbl_HeDecode [ACPI_GET_1BIT_FLAG (Resource->Gpio.IntFlags)],
277 AcpiGbl_LlDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->Gpio.IntFlags, 1)],
278 AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
280 /* PinConfig, DebounceTimeout */
282 if (Resource->Gpio.PinConfig <= 3)
284 AcpiOsPrintf ("%s, ",
285 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
289 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
291 AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout);
293 /* Dump the GpioInt/GpioIo common portion of the descriptor */
295 AcpiDmGpioCommon (Resource, Level);
299 /*******************************************************************************
301 * FUNCTION: AcpiDmGpioIoDescriptor
303 * PARAMETERS: Resource - Pointer to the resource descriptor
304 * Length - Length of the descriptor in bytes
305 * Level - Current source code indentation level
309 * DESCRIPTION: Decode a GPIO I/O descriptor
311 ******************************************************************************/
314 AcpiDmGpioIoDescriptor (
315 AML_RESOURCE *Resource,
320 /* Dump the GpioIo-specific portion of the descriptor */
322 /* Shared, PinConfig */
324 AcpiDmIndent (Level);
325 AcpiOsPrintf ("GpioIo (%s, ",
326 AcpiGbl_ShrDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->Gpio.IntFlags, 3)]);
328 if (Resource->Gpio.PinConfig <= 3)
330 AcpiOsPrintf ("%s, ",
331 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]);
335 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig);
338 /* DebounceTimeout, DriveStrength, IoRestriction */
340 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout);
341 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength);
342 AcpiOsPrintf ("%s,\n",
343 AcpiGbl_IorDecode [ACPI_GET_2BIT_FLAG (Resource->Gpio.IntFlags)]);
345 /* Dump the GpioInt/GpioIo common portion of the descriptor */
347 AcpiDmGpioCommon (Resource, Level);
351 /*******************************************************************************
353 * FUNCTION: AcpiDmGpioDescriptor
355 * PARAMETERS: Resource - Pointer to the resource descriptor
356 * Length - Length of the descriptor in bytes
357 * Level - Current source code indentation level
361 * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor
363 ******************************************************************************/
366 AcpiDmGpioDescriptor (
367 AML_RESOURCE *Resource,
371 UINT8 ConnectionType;
374 ConnectionType = Resource->Gpio.ConnectionType;
376 switch (ConnectionType)
378 case AML_RESOURCE_GPIO_TYPE_INT:
380 AcpiDmGpioIntDescriptor (Resource, Length, Level);
383 case AML_RESOURCE_GPIO_TYPE_IO:
385 AcpiDmGpioIoDescriptor (Resource, Length, Level);
390 AcpiOsPrintf ("Unknown GPIO type\n");
396 /*******************************************************************************
398 * FUNCTION: AcpiDmDumpSerialBusVendorData
400 * PARAMETERS: Resource - Pointer to the resource descriptor
404 * DESCRIPTION: Dump optional serial bus vendor data
406 ******************************************************************************/
409 AcpiDmDumpSerialBusVendorData (
410 AML_RESOURCE *Resource,
417 /* Get the (optional) vendor data and length */
419 switch (Resource->CommonSerialBus.Type)
421 case AML_RESOURCE_I2C_SERIALBUSTYPE:
423 VendorLength = Resource->CommonSerialBus.TypeDataLength -
424 AML_RESOURCE_I2C_MIN_DATA_LEN;
426 VendorData = ACPI_ADD_PTR (UINT8, Resource,
427 sizeof (AML_RESOURCE_I2C_SERIALBUS));
430 case AML_RESOURCE_SPI_SERIALBUSTYPE:
432 VendorLength = Resource->CommonSerialBus.TypeDataLength -
433 AML_RESOURCE_SPI_MIN_DATA_LEN;
435 VendorData = ACPI_ADD_PTR (UINT8, Resource,
436 sizeof (AML_RESOURCE_SPI_SERIALBUS));
439 case AML_RESOURCE_UART_SERIALBUSTYPE:
441 VendorLength = Resource->CommonSerialBus.TypeDataLength -
442 AML_RESOURCE_UART_MIN_DATA_LEN;
444 VendorData = ACPI_ADD_PTR (UINT8, Resource,
445 sizeof (AML_RESOURCE_UART_SERIALBUS));
453 /* Dump the vendor bytes as a RawDataBuffer object */
455 AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
459 /*******************************************************************************
461 * FUNCTION: AcpiDmI2cSerialBusDescriptor
463 * PARAMETERS: Resource - Pointer to the resource descriptor
464 * Length - Length of the descriptor in bytes
465 * Level - Current source code indentation level
469 * DESCRIPTION: Decode a I2C serial bus descriptor
471 ******************************************************************************/
474 AcpiDmI2cSerialBusDescriptor (
475 AML_RESOURCE *Resource,
479 UINT32 ResourceSourceOffset;
482 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
484 AcpiDmIndent (Level);
485 AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n",
486 Resource->I2cSerialBus.SlaveAddress,
487 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
488 Resource->I2cSerialBus.ConnectionSpeed);
490 AcpiDmIndent (Level + 1);
491 AcpiOsPrintf ("%s, ",
492 AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
494 /* ResourceSource is a required field */
496 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
497 Resource->CommonSerialBus.TypeDataLength;
500 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
503 /* ResourceSourceIndex, ResourceUsage */
505 AcpiOsPrintf (",\n");
506 AcpiDmIndent (Level + 1);
507 AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
509 AcpiOsPrintf ("%s, ",
510 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 1)]);
512 /* Insert a descriptor name */
514 AcpiDmDescriptorName ();
515 AcpiOsPrintf (",\n");
517 /* Dump the vendor data */
519 AcpiDmIndent (Level + 1);
520 AcpiDmDumpSerialBusVendorData (Resource, Level);
521 AcpiOsPrintf (")\n");
525 /*******************************************************************************
527 * FUNCTION: AcpiDmSpiSerialBusDescriptor
529 * PARAMETERS: Resource - Pointer to the resource descriptor
530 * Length - Length of the descriptor in bytes
531 * Level - Current source code indentation level
535 * DESCRIPTION: Decode a SPI serial bus descriptor
537 ******************************************************************************/
540 AcpiDmSpiSerialBusDescriptor (
541 AML_RESOURCE *Resource,
545 UINT32 ResourceSourceOffset;
548 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
550 AcpiDmIndent (Level);
551 AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n",
552 Resource->SpiSerialBus.DeviceSelection,
553 AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
554 AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
555 Resource->SpiSerialBus.DataBitLength);
557 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
559 AcpiDmIndent (Level + 1);
560 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
561 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
562 Resource->SpiSerialBus.ConnectionSpeed,
563 AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
565 AcpiDmIndent (Level + 1);
566 AcpiOsPrintf ("%s, ",
567 AcpiGbl_CphDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPhase)]);
569 /* ResourceSource is a required field */
571 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
572 Resource->CommonSerialBus.TypeDataLength;
575 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
578 /* ResourceSourceIndex, ResourceUsage */
580 AcpiOsPrintf (",\n");
581 AcpiDmIndent (Level + 1);
582 AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
584 AcpiOsPrintf ("%s, ",
585 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 1)]);
587 /* Insert a descriptor name */
589 AcpiDmDescriptorName ();
590 AcpiOsPrintf (",\n");
592 /* Dump the vendor data */
594 AcpiDmIndent (Level + 1);
595 AcpiDmDumpSerialBusVendorData (Resource, Level);
596 AcpiOsPrintf (")\n");
600 /*******************************************************************************
602 * FUNCTION: AcpiDmUartSerialBusDescriptor
604 * PARAMETERS: Resource - Pointer to the resource descriptor
605 * Length - Length of the descriptor in bytes
606 * Level - Current source code indentation level
610 * DESCRIPTION: Decode a UART serial bus descriptor
612 ******************************************************************************/
615 AcpiDmUartSerialBusDescriptor (
616 AML_RESOURCE *Resource,
620 UINT32 ResourceSourceOffset;
623 /* ConnectionSpeed, BitsPerByte, StopBits */
625 AcpiDmIndent (Level);
626 AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n",
627 Resource->UartSerialBus.DefaultBaudRate,
628 AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
629 AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
631 /* LinesInUse, IsBigEndian, Parity, FlowControl */
633 AcpiDmIndent (Level + 1);
634 AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
635 Resource->UartSerialBus.LinesEnabled,
636 AcpiGbl_EdDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 7)],
637 AcpiGbl_PtDecode [ACPI_GET_3BIT_FLAG (Resource->UartSerialBus.Parity)],
638 AcpiGbl_FcDecode [ACPI_GET_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags)]);
640 /* ReceiveBufferSize, TransmitBufferSize */
642 AcpiDmIndent (Level + 1);
643 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
644 Resource->UartSerialBus.RxFifoSize,
645 Resource->UartSerialBus.TxFifoSize);
647 /* ResourceSource is a required field */
649 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
650 Resource->CommonSerialBus.TypeDataLength;
653 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
656 /* ResourceSourceIndex, ResourceUsage */
658 AcpiOsPrintf (",\n");
659 AcpiDmIndent (Level + 1);
660 AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
662 AcpiOsPrintf ("%s, ",
663 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 1)]);
665 /* Insert a descriptor name */
667 AcpiDmDescriptorName ();
668 AcpiOsPrintf (",\n");
670 /* Dump the vendor data */
672 AcpiDmIndent (Level + 1);
673 AcpiDmDumpSerialBusVendorData (Resource, Level);
674 AcpiOsPrintf (")\n");
678 /*******************************************************************************
680 * FUNCTION: AcpiDmSerialBusDescriptor
682 * PARAMETERS: Resource - Pointer to the resource descriptor
683 * Length - Length of the descriptor in bytes
684 * Level - Current source code indentation level
688 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
690 ******************************************************************************/
693 AcpiDmSerialBusDescriptor (
694 AML_RESOURCE *Resource,
699 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
700 Resource, Length, Level);