Indentation fix, cleanup.
[AROS.git] / arch / all-pc / acpica / source / components / disassembler / dmresrcl2.c
bloba81f9f8c92d4c4ed8900fac21e20acc9bdb70a1d
1 /*******************************************************************************
3 * Module Name: dmresrcl2.c - "Large" Resource Descriptor disassembly (#2)
5 ******************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2013, Intel Corp.
9 * All rights reserved.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
30 * NO WARRANTY
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 "acpi.h"
46 #include "accommon.h"
47 #include "acdisasm.h"
50 #ifdef ACPI_DISASSEMBLER
52 #define _COMPONENT ACPI_CA_DEBUGGER
53 ACPI_MODULE_NAME ("dbresrcl2")
55 /* Local prototypes */
57 static void
58 AcpiDmI2cSerialBusDescriptor (
59 AML_RESOURCE *Resource,
60 UINT32 Length,
61 UINT32 Level);
63 static void
64 AcpiDmSpiSerialBusDescriptor (
65 AML_RESOURCE *Resource,
66 UINT32 Length,
67 UINT32 Level);
69 static void
70 AcpiDmUartSerialBusDescriptor (
71 AML_RESOURCE *Resource,
72 UINT32 Length,
73 UINT32 Level);
75 static void
76 AcpiDmGpioCommon (
77 AML_RESOURCE *Resource,
78 UINT32 Level);
80 static void
81 AcpiDmDumpRawDataBuffer (
82 UINT8 *Buffer,
83 UINT32 Length,
84 UINT32 Level);
87 /* Dispatch table for the serial bus descriptors */
89 static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] =
91 NULL,
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
106 * RETURN: None
108 * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for
109 * vendor data bytes.
111 ******************************************************************************/
113 static void
114 AcpiDmDumpRawDataBuffer (
115 UINT8 *Buffer,
116 UINT32 Length,
117 UINT32 Level)
119 UINT32 Index;
120 UINT32 i;
121 UINT32 j;
124 if (!Length)
126 return;
129 AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length);
131 AcpiOsPrintf ("\n");
132 AcpiDmIndent (Level + 1);
133 AcpiOsPrintf ("{\n");
134 AcpiDmIndent (Level + 2);
136 for (i = 0; i < Length;)
138 for (j = 0; j < 8; j++)
140 Index = i + j;
141 if (Index >= Length)
143 goto Finish;
146 AcpiOsPrintf ("0x%2.2X", Buffer[Index]);
147 if ((Index + 1) >= Length)
149 goto Finish;
152 AcpiOsPrintf (", ");
154 AcpiOsPrintf ("\n");
155 AcpiDmIndent (Level + 2);
157 i += 8;
160 Finish:
161 AcpiOsPrintf ("\n");
162 AcpiDmIndent (Level + 1);
163 AcpiOsPrintf ("}");
167 /*******************************************************************************
169 * FUNCTION: AcpiDmGpioCommon
171 * PARAMETERS: Resource - Pointer to the resource descriptor
172 * Level - Current source code indentation level
174 * RETURN: None
176 * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor
178 ******************************************************************************/
180 static void
181 AcpiDmGpioCommon (
182 AML_RESOURCE *Resource,
183 UINT32 Level)
185 UINT32 PinCount;
186 UINT16 *PinList;
187 UINT8 *VendorData;
188 UINT32 i;
191 /* ResourceSource, ResourceSourceIndex, ResourceType */
193 AcpiDmIndent (Level + 1);
194 if (Resource->Gpio.ResSourceOffset)
196 AcpiUtPrintString (
197 ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset),
198 ACPI_UINT16_MAX);
201 AcpiOsPrintf (", ");
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 ();
209 AcpiOsPrintf (",");
211 /* Dump the vendor data */
213 if (Resource->Gpio.VendorOffset)
215 AcpiOsPrintf ("\n");
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)) /
233 sizeof (UINT16);
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
257 * RETURN: None
259 * DESCRIPTION: Decode a GPIO Interrupt descriptor
261 ******************************************************************************/
263 static void
264 AcpiDmGpioIntDescriptor (
265 AML_RESOURCE *Resource,
266 UINT32 Length,
267 UINT32 Level)
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]);
287 else
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
307 * RETURN: None
309 * DESCRIPTION: Decode a GPIO I/O descriptor
311 ******************************************************************************/
313 static void
314 AcpiDmGpioIoDescriptor (
315 AML_RESOURCE *Resource,
316 UINT32 Length,
317 UINT32 Level)
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]);
333 else
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
359 * RETURN: None
361 * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor
363 ******************************************************************************/
365 void
366 AcpiDmGpioDescriptor (
367 AML_RESOURCE *Resource,
368 UINT32 Length,
369 UINT32 Level)
371 UINT8 ConnectionType;
374 ConnectionType = Resource->Gpio.ConnectionType;
376 switch (ConnectionType)
378 case AML_RESOURCE_GPIO_TYPE_INT:
380 AcpiDmGpioIntDescriptor (Resource, Length, Level);
381 break;
383 case AML_RESOURCE_GPIO_TYPE_IO:
385 AcpiDmGpioIoDescriptor (Resource, Length, Level);
386 break;
388 default:
390 AcpiOsPrintf ("Unknown GPIO type\n");
391 break;
396 /*******************************************************************************
398 * FUNCTION: AcpiDmDumpSerialBusVendorData
400 * PARAMETERS: Resource - Pointer to the resource descriptor
402 * RETURN: None
404 * DESCRIPTION: Dump optional serial bus vendor data
406 ******************************************************************************/
408 static void
409 AcpiDmDumpSerialBusVendorData (
410 AML_RESOURCE *Resource,
411 UINT32 Level)
413 UINT8 *VendorData;
414 UINT32 VendorLength;
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));
428 break;
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));
437 break;
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));
446 break;
448 default:
450 return;
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
467 * RETURN: None
469 * DESCRIPTION: Decode a I2C serial bus descriptor
471 ******************************************************************************/
473 static void
474 AcpiDmI2cSerialBusDescriptor (
475 AML_RESOURCE *Resource,
476 UINT32 Length,
477 UINT32 Level)
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;
499 AcpiUtPrintString (
500 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
501 ACPI_UINT16_MAX);
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
533 * RETURN: None
535 * DESCRIPTION: Decode a SPI serial bus descriptor
537 ******************************************************************************/
539 static void
540 AcpiDmSpiSerialBusDescriptor (
541 AML_RESOURCE *Resource,
542 UINT32 Length,
543 UINT32 Level)
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;
574 AcpiUtPrintString (
575 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
576 ACPI_UINT16_MAX);
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
608 * RETURN: None
610 * DESCRIPTION: Decode a UART serial bus descriptor
612 ******************************************************************************/
614 static void
615 AcpiDmUartSerialBusDescriptor (
616 AML_RESOURCE *Resource,
617 UINT32 Length,
618 UINT32 Level)
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;
652 AcpiUtPrintString (
653 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset),
654 ACPI_UINT16_MAX);
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
686 * RETURN: None
688 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor
690 ******************************************************************************/
692 void
693 AcpiDmSerialBusDescriptor (
694 AML_RESOURCE *Resource,
695 UINT32 Length,
696 UINT32 Level)
699 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] (
700 Resource, Length, Level);
703 #endif