1 /*******************************************************************************
3 * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2013, 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.
45 #include <contrib/dev/acpica/include/acpi.h>
46 #include <contrib/dev/acpica/include/accommon.h>
47 #include <contrib/dev/acpica/include/acdisasm.h>
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:
379 AcpiDmGpioIntDescriptor (Resource, Length, Level);
382 case AML_RESOURCE_GPIO_TYPE_IO:
383 AcpiDmGpioIoDescriptor (Resource, Length, Level);
387 AcpiOsPrintf ("Unknown GPIO type\n");
393 /*******************************************************************************
395 * FUNCTION: AcpiDmDumpSerialBusVendorData
397 * PARAMETERS: Resource - Pointer to the resource descriptor
401 * DESCRIPTION: Dump optional serial bus vendor data
403 ******************************************************************************/
406 AcpiDmDumpSerialBusVendorData (
407 AML_RESOURCE *Resource,
414 /* Get the (optional) vendor data and length */
416 switch (Resource->CommonSerialBus.Type)
418 case AML_RESOURCE_I2C_SERIALBUSTYPE:
420 VendorLength = Resource->CommonSerialBus.TypeDataLength -
421 AML_RESOURCE_I2C_MIN_DATA_LEN;
423 VendorData = ACPI_ADD_PTR (UINT8, Resource,
424 sizeof (AML_RESOURCE_I2C_SERIALBUS));
427 case AML_RESOURCE_SPI_SERIALBUSTYPE:
429 VendorLength = Resource->CommonSerialBus.TypeDataLength -
430 AML_RESOURCE_SPI_MIN_DATA_LEN;
432 VendorData = ACPI_ADD_PTR (UINT8, Resource,
433 sizeof (AML_RESOURCE_SPI_SERIALBUS));
436 case AML_RESOURCE_UART_SERIALBUSTYPE:
438 VendorLength = Resource->CommonSerialBus.TypeDataLength -
439 AML_RESOURCE_UART_MIN_DATA_LEN;
441 VendorData = ACPI_ADD_PTR (UINT8, Resource,
442 sizeof (AML_RESOURCE_UART_SERIALBUS));
449 /* Dump the vendor bytes as a RawDataBuffer object */
451 AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level);
455 /*******************************************************************************
457 * FUNCTION: AcpiDmI2cSerialBusDescriptor
459 * PARAMETERS: Resource - Pointer to the resource descriptor
460 * Length - Length of the descriptor in bytes
461 * Level - Current source code indentation level
465 * DESCRIPTION: Decode a I2C serial bus descriptor
467 ******************************************************************************/
470 AcpiDmI2cSerialBusDescriptor (
471 AML_RESOURCE *Resource,
475 UINT32 ResourceSourceOffset;
478 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */
480 AcpiDmIndent (Level);
481 AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n",
482 Resource->I2cSerialBus.SlaveAddress,
483 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.Flags)],
484 Resource->I2cSerialBus.ConnectionSpeed);
486 AcpiDmIndent (Level + 1);
487 AcpiOsPrintf ("%s, ",
488 AcpiGbl_AmDecode [ACPI_GET_1BIT_FLAG (Resource->I2cSerialBus.TypeSpecificFlags)]);
490 /* ResourceSource is a required field */
492 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
493 Resource->CommonSerialBus.TypeDataLength;
496 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
499 /* ResourceSourceIndex, ResourceUsage */
501 AcpiOsPrintf (",\n");
502 AcpiDmIndent (Level + 1);
503 AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex);
505 AcpiOsPrintf ("%s, ",
506 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->I2cSerialBus.Flags, 1)]);
508 /* Insert a descriptor name */
510 AcpiDmDescriptorName ();
511 AcpiOsPrintf (",\n");
513 /* Dump the vendor data */
515 AcpiDmIndent (Level + 1);
516 AcpiDmDumpSerialBusVendorData (Resource, Level);
517 AcpiOsPrintf (")\n");
521 /*******************************************************************************
523 * FUNCTION: AcpiDmSpiSerialBusDescriptor
525 * PARAMETERS: Resource - Pointer to the resource descriptor
526 * Length - Length of the descriptor in bytes
527 * Level - Current source code indentation level
531 * DESCRIPTION: Decode a SPI serial bus descriptor
533 ******************************************************************************/
536 AcpiDmSpiSerialBusDescriptor (
537 AML_RESOURCE *Resource,
541 UINT32 ResourceSourceOffset;
544 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */
546 AcpiDmIndent (Level);
547 AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n",
548 Resource->SpiSerialBus.DeviceSelection,
549 AcpiGbl_DpDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags, 1)],
550 AcpiGbl_WmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.TypeSpecificFlags)],
551 Resource->SpiSerialBus.DataBitLength);
553 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */
555 AcpiDmIndent (Level + 1);
556 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n",
557 AcpiGbl_SmDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.Flags)],
558 Resource->SpiSerialBus.ConnectionSpeed,
559 AcpiGbl_CpoDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPolarity)]);
561 AcpiDmIndent (Level + 1);
562 AcpiOsPrintf ("%s, ",
563 AcpiGbl_CphDecode [ACPI_GET_1BIT_FLAG (Resource->SpiSerialBus.ClockPhase)]);
565 /* ResourceSource is a required field */
567 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
568 Resource->CommonSerialBus.TypeDataLength;
571 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
574 /* ResourceSourceIndex, ResourceUsage */
576 AcpiOsPrintf (",\n");
577 AcpiDmIndent (Level + 1);
578 AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex);
580 AcpiOsPrintf ("%s, ",
581 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->SpiSerialBus.Flags, 1)]);
583 /* Insert a descriptor name */
585 AcpiDmDescriptorName ();
586 AcpiOsPrintf (",\n");
588 /* Dump the vendor data */
590 AcpiDmIndent (Level + 1);
591 AcpiDmDumpSerialBusVendorData (Resource, Level);
592 AcpiOsPrintf (")\n");
596 /*******************************************************************************
598 * FUNCTION: AcpiDmUartSerialBusDescriptor
600 * PARAMETERS: Resource - Pointer to the resource descriptor
601 * Length - Length of the descriptor in bytes
602 * Level - Current source code indentation level
606 * DESCRIPTION: Decode a UART serial bus descriptor
608 ******************************************************************************/
611 AcpiDmUartSerialBusDescriptor (
612 AML_RESOURCE *Resource,
616 UINT32 ResourceSourceOffset;
619 /* ConnectionSpeed, BitsPerByte, StopBits */
621 AcpiDmIndent (Level);
622 AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n",
623 Resource->UartSerialBus.DefaultBaudRate,
624 AcpiGbl_BpbDecode [ACPI_EXTRACT_3BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 4)],
625 AcpiGbl_SbDecode [ACPI_EXTRACT_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 2)]);
627 /* LinesInUse, IsBigEndian, Parity, FlowControl */
629 AcpiDmIndent (Level + 1);
630 AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n",
631 Resource->UartSerialBus.LinesEnabled,
632 AcpiGbl_EdDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags, 7)],
633 AcpiGbl_PtDecode [ACPI_GET_3BIT_FLAG (Resource->UartSerialBus.Parity)],
634 AcpiGbl_FcDecode [ACPI_GET_2BIT_FLAG (Resource->UartSerialBus.TypeSpecificFlags)]);
636 /* ReceiveBufferSize, TransmitBufferSize */
638 AcpiDmIndent (Level + 1);
639 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ",
640 Resource->UartSerialBus.RxFifoSize,
641 Resource->UartSerialBus.TxFifoSize);
643 /* ResourceSource is a required field */
645 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) +
646 Resource->CommonSerialBus.TypeDataLength;
649 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
652 /* ResourceSourceIndex, ResourceUsage */
654 AcpiOsPrintf (",\n");
655 AcpiDmIndent (Level + 1);
656 AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex);
658 AcpiOsPrintf ("%s, ",
659 AcpiGbl_ConsumeDecode [ACPI_EXTRACT_1BIT_FLAG (Resource->UartSerialBus.Flags, 1)]);
661 /* Insert a descriptor name */
663 AcpiDmDescriptorName ();
664 AcpiOsPrintf (",\n");
666 /* Dump the vendor data */
668 AcpiDmIndent (Level + 1);
669 AcpiDmDumpSerialBusVendorData (Resource, Level);
670 AcpiOsPrintf (")\n");
674 /*******************************************************************************
676 * FUNCTION: AcpiDmSerialBusDescriptor
678 * PARAMETERS: Resource - Pointer to the resource descriptor
679 * Length - Length of the descriptor in bytes
680 * Level - Current source code indentation level
684 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
686 ******************************************************************************/
689 AcpiDmSerialBusDescriptor (
690 AML_RESOURCE *Resource,
695 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
696 Resource, Length, Level);