9 * All rights reserved. 10 * 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. 25 * 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. 29 * 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. 42 */ 43 44 45#include <contrib/dev/acpica/include/acpi.h> 46#include <contrib/dev/acpica/include/accommon.h> 47#include <contrib/dev/acpica/include/acdisasm.h> 48 49 50#ifdef ACPI_DISASSEMBLER 51 52#define _COMPONENT ACPI_CA_DEBUGGER 53 ACPI_MODULE_NAME ("dbresrcl2") 54 55/* Local prototypes */ 56 57static void 58AcpiDmI2cSerialBusDescriptor ( 59 AML_RESOURCE *Resource, 60 UINT32 Length, 61 UINT32 Level); 62 63static void 64AcpiDmSpiSerialBusDescriptor ( 65 AML_RESOURCE *Resource, 66 UINT32 Length, 67 UINT32 Level); 68 69static void 70AcpiDmUartSerialBusDescriptor ( 71 AML_RESOURCE *Resource, 72 UINT32 Length, 73 UINT32 Level); 74 75static void 76AcpiDmGpioCommon ( 77 AML_RESOURCE *Resource, 78 UINT32 Level); 79 80static void 81AcpiDmDumpRawDataBuffer ( 82 UINT8 *Buffer, 83 UINT32 Length, 84 UINT32 Level); 85 86 87/* Dispatch table for the serial bus descriptors */ 88 89static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] = 90{ 91 NULL, 92 AcpiDmI2cSerialBusDescriptor, 93 AcpiDmSpiSerialBusDescriptor, 94 AcpiDmUartSerialBusDescriptor 95}; 96 97 98/******************************************************************************* 99 * 100 * FUNCTION: AcpiDmDumpRawDataBuffer 101 * 102 * PARAMETERS: Buffer - Pointer to the data bytes 103 * Length - Length of the descriptor in bytes 104 * Level - Current source code indentation level 105 * 106 * RETURN: None 107 * 108 * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for 109 * vendor data bytes. 110 * 111 ******************************************************************************/ 112 113static void 114AcpiDmDumpRawDataBuffer ( 115 UINT8 *Buffer, 116 UINT32 Length, 117 UINT32 Level) 118{ 119 UINT32 Index; 120 UINT32 i; 121 UINT32 j; 122 123 124 if (!Length) 125 { 126 return; 127 } 128 129 AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length); 130 131 AcpiOsPrintf ("\n"); 132 AcpiDmIndent (Level + 1); 133 AcpiOsPrintf ("{\n"); 134 AcpiDmIndent (Level + 2); 135 136 for (i = 0; i < Length;) 137 { 138 for (j = 0; j < 8; j++) 139 { 140 Index = i + j; 141 if (Index >= Length) 142 { 143 goto Finish; 144 } 145 146 AcpiOsPrintf ("0x%2.2X", Buffer[Index]); 147 if ((Index + 1) >= Length) 148 { 149 goto Finish; 150 } 151 152 AcpiOsPrintf (", "); 153 } 154 AcpiOsPrintf ("\n"); 155 AcpiDmIndent (Level + 2); 156 157 i += 8; 158 } 159 160Finish: 161 AcpiOsPrintf ("\n"); 162 AcpiDmIndent (Level + 1); 163 AcpiOsPrintf ("}"); 164} 165 166 167/******************************************************************************* 168 * 169 * FUNCTION: AcpiDmGpioCommon 170 * 171 * PARAMETERS: Resource - Pointer to the resource descriptor 172 * Level - Current source code indentation level 173 * 174 * RETURN: None 175 * 176 * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor 177 * 178 ******************************************************************************/ 179 180static void 181AcpiDmGpioCommon ( 182 AML_RESOURCE *Resource, 183 UINT32 Level) 184{ 185 UINT32 PinCount; 186 UINT16 *PinList; 187 UINT8 *VendorData; 188 UINT32 i; 189 190 191 /* ResourceSource, ResourceSourceIndex, ResourceType */ 192 193 AcpiDmIndent (Level + 1); 194 if (Resource->Gpio.ResSourceOffset) 195 { 196 AcpiUtPrintString ( 197 ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), 198 ACPI_UINT8_MAX); 199 } 200 201 AcpiOsPrintf (", "); 202 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex); 203 AcpiOsPrintf ("%s, ", 204 AcpiGbl_ConsumeDecode [(Resource->Gpio.Flags & 1)]); 205 206 /* Insert a descriptor name */ 207 208 AcpiDmDescriptorName (); 209 AcpiOsPrintf (","); 210 211 /* Dump the vendor data */ 212 213 if (Resource->Gpio.VendorOffset) 214 { 215 AcpiOsPrintf ("\n"); 216 AcpiDmIndent (Level + 1); 217 VendorData = ACPI_ADD_PTR (UINT8, Resource, 218 Resource->Gpio.VendorOffset); 219 220 AcpiDmDumpRawDataBuffer (VendorData, 221 Resource->Gpio.VendorLength, Level); 222 } 223 224 AcpiOsPrintf (")\n"); 225 226 /* Dump the interrupt list */ 227 228 AcpiDmIndent (Level + 1); 229 AcpiOsPrintf ("{ // Pin list\n"); 230 231 PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset - 232 Resource->Gpio.PinTableOffset)) / 233 sizeof (UINT16); 234 235 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource, 236 Resource->Gpio.PinTableOffset); 237 238 for (i = 0; i < PinCount; i++) 239 { 240 AcpiDmIndent (Level + 2); 241 AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : ""); 242 } 243 244 AcpiDmIndent (Level + 1); 245 AcpiOsPrintf ("}\n"); 246} 247 248 249/******************************************************************************* 250 * 251 * FUNCTION: AcpiDmGpioIntDescriptor 252 * 253 * PARAMETERS: Resource - Pointer to the resource descriptor 254 * Length - Length of the descriptor in bytes 255 * Level - Current source code indentation level 256 * 257 * RETURN: None 258 * 259 * DESCRIPTION: Decode a GPIO Interrupt descriptor 260 * 261 ******************************************************************************/ 262 263static void 264AcpiDmGpioIntDescriptor ( 265 AML_RESOURCE *Resource, 266 UINT32 Length, 267 UINT32 Level) 268{ 269 270 /* Dump the GpioInt-specific portion of the descriptor */ 271 272 /* EdgeLevel, ActiveLevel, Shared */ 273 274 AcpiDmIndent (Level); 275 AcpiOsPrintf ("GpioInt (%s, %s, %s, ", 276 AcpiGbl_HeDecode [(Resource->Gpio.IntFlags & 1)], 277 AcpiGbl_LlDecode [(Resource->Gpio.IntFlags >> 1) & 1], 278 AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); 279 280 /* PinConfig, DebounceTimeout */ 281 282 if (Resource->Gpio.PinConfig <= 3) 283 { 284 AcpiOsPrintf ("%s, ", 285 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); 286 } 287 else 288 { 289 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); 290 } 291 AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout); 292 293 /* Dump the GpioInt/GpioIo common portion of the descriptor */ 294 295 AcpiDmGpioCommon (Resource, Level); 296} 297 298 299/******************************************************************************* 300 * 301 * FUNCTION: AcpiDmGpioIoDescriptor 302 * 303 * PARAMETERS: Resource - Pointer to the resource descriptor 304 * Length - Length of the descriptor in bytes 305 * Level - Current source code indentation level 306 * 307 * RETURN: None 308 * 309 * DESCRIPTION: Decode a GPIO Interrupt descriptor 310 * 311 ******************************************************************************/ 312 313static void 314AcpiDmGpioIoDescriptor ( 315 AML_RESOURCE *Resource, 316 UINT32 Length, 317 UINT32 Level) 318{ 319 320 /* Dump the GpioIo-specific portion of the descriptor */ 321 322 /* Shared, PinConfig */ 323 324 AcpiDmIndent (Level); 325 AcpiOsPrintf ("GpioIo (%s, ", 326 AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); 327 328 if (Resource->Gpio.PinConfig <= 3) 329 { 330 AcpiOsPrintf ("%s, ", 331 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); 332 } 333 else 334 { 335 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); 336 } 337 338 /* DebounceTimeout, DriveStrength, IoRestriction */ 339 340 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout); 341 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength); 342 AcpiOsPrintf ("%s,\n", 343 AcpiGbl_IorDecode [Resource->Gpio.IntFlags & 3]); 344 345 /* Dump the GpioInt/GpioIo common portion of the descriptor */ 346 347 AcpiDmGpioCommon (Resource, Level); 348} 349 350 351/******************************************************************************* 352 * 353 * FUNCTION: AcpiDmGpioDescriptor 354 * 355 * PARAMETERS: Resource - Pointer to the resource descriptor 356 * Length - Length of the descriptor in bytes 357 * Level - Current source code indentation level 358 * 359 * RETURN: None 360 * 361 * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor 362 * 363 ******************************************************************************/ 364 365void 366AcpiDmGpioDescriptor ( 367 AML_RESOURCE *Resource, 368 UINT32 Length, 369 UINT32 Level) 370{ 371 UINT8 ConnectionType; 372 373 374 ConnectionType = Resource->Gpio.ConnectionType; 375 376 switch (ConnectionType) 377 { 378 case AML_RESOURCE_GPIO_TYPE_INT: 379 AcpiDmGpioIntDescriptor (Resource, Length, Level); 380 break; 381 382 case AML_RESOURCE_GPIO_TYPE_IO: 383 AcpiDmGpioIoDescriptor (Resource, Length, Level); 384 break; 385 386 default: 387 AcpiOsPrintf ("Unknown GPIO type\n"); 388 break; 389 } 390} 391 392 393/******************************************************************************* 394 * 395 * FUNCTION: AcpiDmDumpSerialBusVendorData 396 * 397 * PARAMETERS: Resource - Pointer to the resource descriptor 398 * 399 * RETURN: None 400 * 401 * DESCRIPTION: Dump optional serial bus vendor data 402 * 403 ******************************************************************************/ 404 405static void 406AcpiDmDumpSerialBusVendorData ( 407 AML_RESOURCE *Resource, 408 UINT32 Level) 409{ 410 UINT8 *VendorData; 411 UINT32 VendorLength; 412 413 414 /* Get the (optional) vendor data and length */ 415 416 switch (Resource->CommonSerialBus.Type) 417 { 418 case AML_RESOURCE_I2C_SERIALBUSTYPE: 419 420 VendorLength = Resource->CommonSerialBus.TypeDataLength - 421 AML_RESOURCE_I2C_MIN_DATA_LEN; 422 423 VendorData = ACPI_ADD_PTR (UINT8, Resource, 424 sizeof (AML_RESOURCE_I2C_SERIALBUS)); 425 break; 426 427 case AML_RESOURCE_SPI_SERIALBUSTYPE: 428 429 VendorLength = Resource->CommonSerialBus.TypeDataLength - 430 AML_RESOURCE_SPI_MIN_DATA_LEN; 431 432 VendorData = ACPI_ADD_PTR (UINT8, Resource, 433 sizeof (AML_RESOURCE_SPI_SERIALBUS)); 434 break; 435 436 case AML_RESOURCE_UART_SERIALBUSTYPE: 437 438 VendorLength = Resource->CommonSerialBus.TypeDataLength - 439 AML_RESOURCE_UART_MIN_DATA_LEN; 440 441 VendorData = ACPI_ADD_PTR (UINT8, Resource, 442 sizeof (AML_RESOURCE_UART_SERIALBUS)); 443 break; 444 445 default: 446 return; 447 } 448 449 /* Dump the vendor bytes as a RawDataBuffer object */ 450 451 AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level); 452} 453 454 455/******************************************************************************* 456 * 457 * FUNCTION: AcpiDmI2cSerialBusDescriptor 458 * 459 * PARAMETERS: Resource - Pointer to the resource descriptor 460 * Length - Length of the descriptor in bytes 461 * Level - Current source code indentation level 462 * 463 * RETURN: None 464 * 465 * DESCRIPTION: Decode a I2C serial bus descriptor 466 * 467 ******************************************************************************/ 468 469static void 470AcpiDmI2cSerialBusDescriptor ( 471 AML_RESOURCE *Resource, 472 UINT32 Length, 473 UINT32 Level) 474{ 475 UINT32 ResourceSourceOffset; 476 477 478 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ 479 480 AcpiDmIndent (Level); 481 AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n", 482 Resource->I2cSerialBus.SlaveAddress, 483 AcpiGbl_SmDecode [(Resource->I2cSerialBus.Flags & 1)], 484 Resource->I2cSerialBus.ConnectionSpeed); 485 486 AcpiDmIndent (Level + 1); 487 AcpiOsPrintf ("%s, ", 488 AcpiGbl_AmDecode [(Resource->I2cSerialBus.TypeSpecificFlags & 1)]); 489 490 /* ResourceSource is a required field */ 491 492 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 493 Resource->CommonSerialBus.TypeDataLength; 494 495 AcpiUtPrintString ( 496 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 497 ACPI_UINT8_MAX); 498 499 /* ResourceSourceIndex, ResourceUsage */ 500 501 AcpiOsPrintf (",\n"); 502 AcpiDmIndent (Level + 1); 503 AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex); 504 505 AcpiOsPrintf ("%s, ", 506 AcpiGbl_ConsumeDecode [(Resource->I2cSerialBus.Flags & 1)]); 507 508 /* Insert a descriptor name */ 509 510 AcpiDmDescriptorName (); 511 AcpiOsPrintf (",\n"); 512 513 /* Dump the vendor data */ 514 515 AcpiDmIndent (Level + 1); 516 AcpiDmDumpSerialBusVendorData (Resource, Level); 517 AcpiOsPrintf (")\n"); 518} 519 520 521/******************************************************************************* 522 * 523 * FUNCTION: AcpiDmSpiSerialBusDescriptor 524 * 525 * PARAMETERS: Resource - Pointer to the resource descriptor 526 * Length - Length of the descriptor in bytes 527 * Level - Current source code indentation level 528 * 529 * RETURN: None 530 * 531 * DESCRIPTION: Decode a SPI serial bus descriptor 532 * 533 ******************************************************************************/ 534 535static void 536AcpiDmSpiSerialBusDescriptor ( 537 AML_RESOURCE *Resource, 538 UINT32 Length, 539 UINT32 Level) 540{ 541 UINT32 ResourceSourceOffset; 542 543 544 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ 545 546 AcpiDmIndent (Level); 547 AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n", 548 Resource->SpiSerialBus.DeviceSelection, 549 AcpiGbl_DpDecode [(Resource->SpiSerialBus.TypeSpecificFlags >> 1) & 1], 550 AcpiGbl_WmDecode [(Resource->SpiSerialBus.TypeSpecificFlags & 1)], 551 Resource->SpiSerialBus.DataBitLength); 552 553 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */ 554 555 AcpiDmIndent (Level + 1); 556 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n", 557 AcpiGbl_SmDecode [(Resource->SpiSerialBus.Flags & 1)], 558 Resource->SpiSerialBus.ConnectionSpeed, 559 AcpiGbl_CpoDecode [(Resource->SpiSerialBus.ClockPolarity & 1)]); 560 561 AcpiDmIndent (Level + 1); 562 AcpiOsPrintf ("%s, ", 563 AcpiGbl_CphDecode [(Resource->SpiSerialBus.ClockPhase & 1)]); 564 565 /* ResourceSource is a required field */ 566 567 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 568 Resource->CommonSerialBus.TypeDataLength; 569 570 AcpiUtPrintString ( 571 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 572 ACPI_UINT8_MAX); 573 574 /* ResourceSourceIndex, ResourceUsage */ 575 576 AcpiOsPrintf (",\n"); 577 AcpiDmIndent (Level + 1); 578 AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex); 579 580 AcpiOsPrintf ("%s, ", 581 AcpiGbl_ConsumeDecode [(Resource->SpiSerialBus.Flags & 1)]); 582 583 /* Insert a descriptor name */ 584 585 AcpiDmDescriptorName (); 586 AcpiOsPrintf (",\n"); 587 588 /* Dump the vendor data */ 589 590 AcpiDmIndent (Level + 1); 591 AcpiDmDumpSerialBusVendorData (Resource, Level); 592 AcpiOsPrintf (")\n"); 593} 594 595 596/******************************************************************************* 597 * 598 * FUNCTION: AcpiDmUartSerialBusDescriptor 599 * 600 * PARAMETERS: Resource - Pointer to the resource descriptor 601 * Length - Length of the descriptor in bytes 602 * Level - Current source code indentation level 603 * 604 * RETURN: None 605 * 606 * DESCRIPTION: Decode a UART serial bus descriptor 607 * 608 ******************************************************************************/ 609 610static void 611AcpiDmUartSerialBusDescriptor ( 612 AML_RESOURCE *Resource, 613 UINT32 Length, 614 UINT32 Level) 615{ 616 UINT32 ResourceSourceOffset; 617 618 619 /* ConnectionSpeed, BitsPerByte, StopBits */ 620 621 AcpiDmIndent (Level); 622 AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n", 623 Resource->UartSerialBus.DefaultBaudRate, 624 AcpiGbl_BpbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 4) & 3], 625 AcpiGbl_SbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 2) & 3]); 626 627 /* LinesInUse, IsBigEndian, Parity, FlowControl */ 628 629 AcpiDmIndent (Level + 1); 630 AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n", 631 Resource->UartSerialBus.LinesEnabled, 632 AcpiGbl_EdDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 7) & 1], 633 AcpiGbl_PtDecode [Resource->UartSerialBus.Parity & 7], 634 AcpiGbl_FcDecode [Resource->UartSerialBus.TypeSpecificFlags & 3]); 635 636 /* ReceiveBufferSize, TransmitBufferSize */ 637 638 AcpiDmIndent (Level + 1); 639 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ", 640 Resource->UartSerialBus.RxFifoSize, 641 Resource->UartSerialBus.TxFifoSize); 642 643 /* ResourceSource is a required field */ 644 645 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 646 Resource->CommonSerialBus.TypeDataLength; 647 648 AcpiUtPrintString ( 649 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 650 ACPI_UINT8_MAX); 651 652 /* ResourceSourceIndex, ResourceUsage */ 653 654 AcpiOsPrintf (",\n"); 655 AcpiDmIndent (Level + 1); 656 AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex); 657 658 AcpiOsPrintf ("%s, ", 659 AcpiGbl_ConsumeDecode [(Resource->UartSerialBus.Flags & 1)]); 660 661 /* Insert a descriptor name */ 662 663 AcpiDmDescriptorName (); 664 AcpiOsPrintf (",\n"); 665 666 /* Dump the vendor data */ 667 668 AcpiDmIndent (Level + 1); 669 AcpiDmDumpSerialBusVendorData (Resource, Level); 670 AcpiOsPrintf (")\n"); 671} 672 673 674/******************************************************************************* 675 * 676 * FUNCTION: AcpiDmSerialBusDescriptor 677 * 678 * PARAMETERS: Resource - Pointer to the resource descriptor 679 * Length - Length of the descriptor in bytes 680 * Level - Current source code indentation level 681 * 682 * RETURN: None 683 * 684 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor 685 * 686 ******************************************************************************/ 687 688void 689AcpiDmSerialBusDescriptor ( 690 AML_RESOURCE *Resource, 691 UINT32 Length, 692 UINT32 Level) 693{ 694 695 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( 696 Resource, Length, Level); 697} 698 699#endif 700
| 9 * All rights reserved. 10 * 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. 25 * 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. 29 * 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. 42 */ 43 44 45#include <contrib/dev/acpica/include/acpi.h> 46#include <contrib/dev/acpica/include/accommon.h> 47#include <contrib/dev/acpica/include/acdisasm.h> 48 49 50#ifdef ACPI_DISASSEMBLER 51 52#define _COMPONENT ACPI_CA_DEBUGGER 53 ACPI_MODULE_NAME ("dbresrcl2") 54 55/* Local prototypes */ 56 57static void 58AcpiDmI2cSerialBusDescriptor ( 59 AML_RESOURCE *Resource, 60 UINT32 Length, 61 UINT32 Level); 62 63static void 64AcpiDmSpiSerialBusDescriptor ( 65 AML_RESOURCE *Resource, 66 UINT32 Length, 67 UINT32 Level); 68 69static void 70AcpiDmUartSerialBusDescriptor ( 71 AML_RESOURCE *Resource, 72 UINT32 Length, 73 UINT32 Level); 74 75static void 76AcpiDmGpioCommon ( 77 AML_RESOURCE *Resource, 78 UINT32 Level); 79 80static void 81AcpiDmDumpRawDataBuffer ( 82 UINT8 *Buffer, 83 UINT32 Length, 84 UINT32 Level); 85 86 87/* Dispatch table for the serial bus descriptors */ 88 89static ACPI_RESOURCE_HANDLER SerialBusResourceDispatch [] = 90{ 91 NULL, 92 AcpiDmI2cSerialBusDescriptor, 93 AcpiDmSpiSerialBusDescriptor, 94 AcpiDmUartSerialBusDescriptor 95}; 96 97 98/******************************************************************************* 99 * 100 * FUNCTION: AcpiDmDumpRawDataBuffer 101 * 102 * PARAMETERS: Buffer - Pointer to the data bytes 103 * Length - Length of the descriptor in bytes 104 * Level - Current source code indentation level 105 * 106 * RETURN: None 107 * 108 * DESCRIPTION: Dump a data buffer as a RawDataBuffer() object. Used for 109 * vendor data bytes. 110 * 111 ******************************************************************************/ 112 113static void 114AcpiDmDumpRawDataBuffer ( 115 UINT8 *Buffer, 116 UINT32 Length, 117 UINT32 Level) 118{ 119 UINT32 Index; 120 UINT32 i; 121 UINT32 j; 122 123 124 if (!Length) 125 { 126 return; 127 } 128 129 AcpiOsPrintf ("RawDataBuffer (0x%.2X) // Vendor Data", Length); 130 131 AcpiOsPrintf ("\n"); 132 AcpiDmIndent (Level + 1); 133 AcpiOsPrintf ("{\n"); 134 AcpiDmIndent (Level + 2); 135 136 for (i = 0; i < Length;) 137 { 138 for (j = 0; j < 8; j++) 139 { 140 Index = i + j; 141 if (Index >= Length) 142 { 143 goto Finish; 144 } 145 146 AcpiOsPrintf ("0x%2.2X", Buffer[Index]); 147 if ((Index + 1) >= Length) 148 { 149 goto Finish; 150 } 151 152 AcpiOsPrintf (", "); 153 } 154 AcpiOsPrintf ("\n"); 155 AcpiDmIndent (Level + 2); 156 157 i += 8; 158 } 159 160Finish: 161 AcpiOsPrintf ("\n"); 162 AcpiDmIndent (Level + 1); 163 AcpiOsPrintf ("}"); 164} 165 166 167/******************************************************************************* 168 * 169 * FUNCTION: AcpiDmGpioCommon 170 * 171 * PARAMETERS: Resource - Pointer to the resource descriptor 172 * Level - Current source code indentation level 173 * 174 * RETURN: None 175 * 176 * DESCRIPTION: Decode common parts of a GPIO Interrupt descriptor 177 * 178 ******************************************************************************/ 179 180static void 181AcpiDmGpioCommon ( 182 AML_RESOURCE *Resource, 183 UINT32 Level) 184{ 185 UINT32 PinCount; 186 UINT16 *PinList; 187 UINT8 *VendorData; 188 UINT32 i; 189 190 191 /* ResourceSource, ResourceSourceIndex, ResourceType */ 192 193 AcpiDmIndent (Level + 1); 194 if (Resource->Gpio.ResSourceOffset) 195 { 196 AcpiUtPrintString ( 197 ACPI_ADD_PTR (char, Resource, Resource->Gpio.ResSourceOffset), 198 ACPI_UINT8_MAX); 199 } 200 201 AcpiOsPrintf (", "); 202 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.ResSourceIndex); 203 AcpiOsPrintf ("%s, ", 204 AcpiGbl_ConsumeDecode [(Resource->Gpio.Flags & 1)]); 205 206 /* Insert a descriptor name */ 207 208 AcpiDmDescriptorName (); 209 AcpiOsPrintf (","); 210 211 /* Dump the vendor data */ 212 213 if (Resource->Gpio.VendorOffset) 214 { 215 AcpiOsPrintf ("\n"); 216 AcpiDmIndent (Level + 1); 217 VendorData = ACPI_ADD_PTR (UINT8, Resource, 218 Resource->Gpio.VendorOffset); 219 220 AcpiDmDumpRawDataBuffer (VendorData, 221 Resource->Gpio.VendorLength, Level); 222 } 223 224 AcpiOsPrintf (")\n"); 225 226 /* Dump the interrupt list */ 227 228 AcpiDmIndent (Level + 1); 229 AcpiOsPrintf ("{ // Pin list\n"); 230 231 PinCount = ((UINT32) (Resource->Gpio.ResSourceOffset - 232 Resource->Gpio.PinTableOffset)) / 233 sizeof (UINT16); 234 235 PinList = (UINT16 *) ACPI_ADD_PTR (char, Resource, 236 Resource->Gpio.PinTableOffset); 237 238 for (i = 0; i < PinCount; i++) 239 { 240 AcpiDmIndent (Level + 2); 241 AcpiOsPrintf ("0x%4.4X%s\n", PinList[i], ((i + 1) < PinCount) ? "," : ""); 242 } 243 244 AcpiDmIndent (Level + 1); 245 AcpiOsPrintf ("}\n"); 246} 247 248 249/******************************************************************************* 250 * 251 * FUNCTION: AcpiDmGpioIntDescriptor 252 * 253 * PARAMETERS: Resource - Pointer to the resource descriptor 254 * Length - Length of the descriptor in bytes 255 * Level - Current source code indentation level 256 * 257 * RETURN: None 258 * 259 * DESCRIPTION: Decode a GPIO Interrupt descriptor 260 * 261 ******************************************************************************/ 262 263static void 264AcpiDmGpioIntDescriptor ( 265 AML_RESOURCE *Resource, 266 UINT32 Length, 267 UINT32 Level) 268{ 269 270 /* Dump the GpioInt-specific portion of the descriptor */ 271 272 /* EdgeLevel, ActiveLevel, Shared */ 273 274 AcpiDmIndent (Level); 275 AcpiOsPrintf ("GpioInt (%s, %s, %s, ", 276 AcpiGbl_HeDecode [(Resource->Gpio.IntFlags & 1)], 277 AcpiGbl_LlDecode [(Resource->Gpio.IntFlags >> 1) & 1], 278 AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); 279 280 /* PinConfig, DebounceTimeout */ 281 282 if (Resource->Gpio.PinConfig <= 3) 283 { 284 AcpiOsPrintf ("%s, ", 285 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); 286 } 287 else 288 { 289 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); 290 } 291 AcpiOsPrintf ("0x%4.4X,\n", Resource->Gpio.DebounceTimeout); 292 293 /* Dump the GpioInt/GpioIo common portion of the descriptor */ 294 295 AcpiDmGpioCommon (Resource, Level); 296} 297 298 299/******************************************************************************* 300 * 301 * FUNCTION: AcpiDmGpioIoDescriptor 302 * 303 * PARAMETERS: Resource - Pointer to the resource descriptor 304 * Length - Length of the descriptor in bytes 305 * Level - Current source code indentation level 306 * 307 * RETURN: None 308 * 309 * DESCRIPTION: Decode a GPIO Interrupt descriptor 310 * 311 ******************************************************************************/ 312 313static void 314AcpiDmGpioIoDescriptor ( 315 AML_RESOURCE *Resource, 316 UINT32 Length, 317 UINT32 Level) 318{ 319 320 /* Dump the GpioIo-specific portion of the descriptor */ 321 322 /* Shared, PinConfig */ 323 324 AcpiDmIndent (Level); 325 AcpiOsPrintf ("GpioIo (%s, ", 326 AcpiGbl_ShrDecode [(Resource->Gpio.IntFlags >> 3) & 1]); 327 328 if (Resource->Gpio.PinConfig <= 3) 329 { 330 AcpiOsPrintf ("%s, ", 331 AcpiGbl_PpcDecode[Resource->Gpio.PinConfig]); 332 } 333 else 334 { 335 AcpiOsPrintf ("0x%2.2X, ", Resource->Gpio.PinConfig); 336 } 337 338 /* DebounceTimeout, DriveStrength, IoRestriction */ 339 340 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DebounceTimeout); 341 AcpiOsPrintf ("0x%4.4X, ", Resource->Gpio.DriveStrength); 342 AcpiOsPrintf ("%s,\n", 343 AcpiGbl_IorDecode [Resource->Gpio.IntFlags & 3]); 344 345 /* Dump the GpioInt/GpioIo common portion of the descriptor */ 346 347 AcpiDmGpioCommon (Resource, Level); 348} 349 350 351/******************************************************************************* 352 * 353 * FUNCTION: AcpiDmGpioDescriptor 354 * 355 * PARAMETERS: Resource - Pointer to the resource descriptor 356 * Length - Length of the descriptor in bytes 357 * Level - Current source code indentation level 358 * 359 * RETURN: None 360 * 361 * DESCRIPTION: Decode a GpioInt/GpioIo GPIO Interrupt/IO descriptor 362 * 363 ******************************************************************************/ 364 365void 366AcpiDmGpioDescriptor ( 367 AML_RESOURCE *Resource, 368 UINT32 Length, 369 UINT32 Level) 370{ 371 UINT8 ConnectionType; 372 373 374 ConnectionType = Resource->Gpio.ConnectionType; 375 376 switch (ConnectionType) 377 { 378 case AML_RESOURCE_GPIO_TYPE_INT: 379 AcpiDmGpioIntDescriptor (Resource, Length, Level); 380 break; 381 382 case AML_RESOURCE_GPIO_TYPE_IO: 383 AcpiDmGpioIoDescriptor (Resource, Length, Level); 384 break; 385 386 default: 387 AcpiOsPrintf ("Unknown GPIO type\n"); 388 break; 389 } 390} 391 392 393/******************************************************************************* 394 * 395 * FUNCTION: AcpiDmDumpSerialBusVendorData 396 * 397 * PARAMETERS: Resource - Pointer to the resource descriptor 398 * 399 * RETURN: None 400 * 401 * DESCRIPTION: Dump optional serial bus vendor data 402 * 403 ******************************************************************************/ 404 405static void 406AcpiDmDumpSerialBusVendorData ( 407 AML_RESOURCE *Resource, 408 UINT32 Level) 409{ 410 UINT8 *VendorData; 411 UINT32 VendorLength; 412 413 414 /* Get the (optional) vendor data and length */ 415 416 switch (Resource->CommonSerialBus.Type) 417 { 418 case AML_RESOURCE_I2C_SERIALBUSTYPE: 419 420 VendorLength = Resource->CommonSerialBus.TypeDataLength - 421 AML_RESOURCE_I2C_MIN_DATA_LEN; 422 423 VendorData = ACPI_ADD_PTR (UINT8, Resource, 424 sizeof (AML_RESOURCE_I2C_SERIALBUS)); 425 break; 426 427 case AML_RESOURCE_SPI_SERIALBUSTYPE: 428 429 VendorLength = Resource->CommonSerialBus.TypeDataLength - 430 AML_RESOURCE_SPI_MIN_DATA_LEN; 431 432 VendorData = ACPI_ADD_PTR (UINT8, Resource, 433 sizeof (AML_RESOURCE_SPI_SERIALBUS)); 434 break; 435 436 case AML_RESOURCE_UART_SERIALBUSTYPE: 437 438 VendorLength = Resource->CommonSerialBus.TypeDataLength - 439 AML_RESOURCE_UART_MIN_DATA_LEN; 440 441 VendorData = ACPI_ADD_PTR (UINT8, Resource, 442 sizeof (AML_RESOURCE_UART_SERIALBUS)); 443 break; 444 445 default: 446 return; 447 } 448 449 /* Dump the vendor bytes as a RawDataBuffer object */ 450 451 AcpiDmDumpRawDataBuffer (VendorData, VendorLength, Level); 452} 453 454 455/******************************************************************************* 456 * 457 * FUNCTION: AcpiDmI2cSerialBusDescriptor 458 * 459 * PARAMETERS: Resource - Pointer to the resource descriptor 460 * Length - Length of the descriptor in bytes 461 * Level - Current source code indentation level 462 * 463 * RETURN: None 464 * 465 * DESCRIPTION: Decode a I2C serial bus descriptor 466 * 467 ******************************************************************************/ 468 469static void 470AcpiDmI2cSerialBusDescriptor ( 471 AML_RESOURCE *Resource, 472 UINT32 Length, 473 UINT32 Level) 474{ 475 UINT32 ResourceSourceOffset; 476 477 478 /* SlaveAddress, SlaveMode, ConnectionSpeed, AddressingMode */ 479 480 AcpiDmIndent (Level); 481 AcpiOsPrintf ("I2cSerialBus (0x%4.4X, %s, 0x%8.8X,\n", 482 Resource->I2cSerialBus.SlaveAddress, 483 AcpiGbl_SmDecode [(Resource->I2cSerialBus.Flags & 1)], 484 Resource->I2cSerialBus.ConnectionSpeed); 485 486 AcpiDmIndent (Level + 1); 487 AcpiOsPrintf ("%s, ", 488 AcpiGbl_AmDecode [(Resource->I2cSerialBus.TypeSpecificFlags & 1)]); 489 490 /* ResourceSource is a required field */ 491 492 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 493 Resource->CommonSerialBus.TypeDataLength; 494 495 AcpiUtPrintString ( 496 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 497 ACPI_UINT8_MAX); 498 499 /* ResourceSourceIndex, ResourceUsage */ 500 501 AcpiOsPrintf (",\n"); 502 AcpiDmIndent (Level + 1); 503 AcpiOsPrintf ("0x%2.2X, ", Resource->I2cSerialBus.ResSourceIndex); 504 505 AcpiOsPrintf ("%s, ", 506 AcpiGbl_ConsumeDecode [(Resource->I2cSerialBus.Flags & 1)]); 507 508 /* Insert a descriptor name */ 509 510 AcpiDmDescriptorName (); 511 AcpiOsPrintf (",\n"); 512 513 /* Dump the vendor data */ 514 515 AcpiDmIndent (Level + 1); 516 AcpiDmDumpSerialBusVendorData (Resource, Level); 517 AcpiOsPrintf (")\n"); 518} 519 520 521/******************************************************************************* 522 * 523 * FUNCTION: AcpiDmSpiSerialBusDescriptor 524 * 525 * PARAMETERS: Resource - Pointer to the resource descriptor 526 * Length - Length of the descriptor in bytes 527 * Level - Current source code indentation level 528 * 529 * RETURN: None 530 * 531 * DESCRIPTION: Decode a SPI serial bus descriptor 532 * 533 ******************************************************************************/ 534 535static void 536AcpiDmSpiSerialBusDescriptor ( 537 AML_RESOURCE *Resource, 538 UINT32 Length, 539 UINT32 Level) 540{ 541 UINT32 ResourceSourceOffset; 542 543 544 /* DeviceSelection, DeviceSelectionPolarity, WireMode, DataBitLength */ 545 546 AcpiDmIndent (Level); 547 AcpiOsPrintf ("SpiSerialBus (0x%4.4X, %s, %s, 0x%2.2X,\n", 548 Resource->SpiSerialBus.DeviceSelection, 549 AcpiGbl_DpDecode [(Resource->SpiSerialBus.TypeSpecificFlags >> 1) & 1], 550 AcpiGbl_WmDecode [(Resource->SpiSerialBus.TypeSpecificFlags & 1)], 551 Resource->SpiSerialBus.DataBitLength); 552 553 /* SlaveMode, ConnectionSpeed, ClockPolarity, ClockPhase */ 554 555 AcpiDmIndent (Level + 1); 556 AcpiOsPrintf ("%s, 0x%8.8X, %s,\n", 557 AcpiGbl_SmDecode [(Resource->SpiSerialBus.Flags & 1)], 558 Resource->SpiSerialBus.ConnectionSpeed, 559 AcpiGbl_CpoDecode [(Resource->SpiSerialBus.ClockPolarity & 1)]); 560 561 AcpiDmIndent (Level + 1); 562 AcpiOsPrintf ("%s, ", 563 AcpiGbl_CphDecode [(Resource->SpiSerialBus.ClockPhase & 1)]); 564 565 /* ResourceSource is a required field */ 566 567 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 568 Resource->CommonSerialBus.TypeDataLength; 569 570 AcpiUtPrintString ( 571 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 572 ACPI_UINT8_MAX); 573 574 /* ResourceSourceIndex, ResourceUsage */ 575 576 AcpiOsPrintf (",\n"); 577 AcpiDmIndent (Level + 1); 578 AcpiOsPrintf ("0x%2.2X, ", Resource->SpiSerialBus.ResSourceIndex); 579 580 AcpiOsPrintf ("%s, ", 581 AcpiGbl_ConsumeDecode [(Resource->SpiSerialBus.Flags & 1)]); 582 583 /* Insert a descriptor name */ 584 585 AcpiDmDescriptorName (); 586 AcpiOsPrintf (",\n"); 587 588 /* Dump the vendor data */ 589 590 AcpiDmIndent (Level + 1); 591 AcpiDmDumpSerialBusVendorData (Resource, Level); 592 AcpiOsPrintf (")\n"); 593} 594 595 596/******************************************************************************* 597 * 598 * FUNCTION: AcpiDmUartSerialBusDescriptor 599 * 600 * PARAMETERS: Resource - Pointer to the resource descriptor 601 * Length - Length of the descriptor in bytes 602 * Level - Current source code indentation level 603 * 604 * RETURN: None 605 * 606 * DESCRIPTION: Decode a UART serial bus descriptor 607 * 608 ******************************************************************************/ 609 610static void 611AcpiDmUartSerialBusDescriptor ( 612 AML_RESOURCE *Resource, 613 UINT32 Length, 614 UINT32 Level) 615{ 616 UINT32 ResourceSourceOffset; 617 618 619 /* ConnectionSpeed, BitsPerByte, StopBits */ 620 621 AcpiDmIndent (Level); 622 AcpiOsPrintf ("UartSerialBus (0x%8.8X, %s, %s,\n", 623 Resource->UartSerialBus.DefaultBaudRate, 624 AcpiGbl_BpbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 4) & 3], 625 AcpiGbl_SbDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 2) & 3]); 626 627 /* LinesInUse, IsBigEndian, Parity, FlowControl */ 628 629 AcpiDmIndent (Level + 1); 630 AcpiOsPrintf ("0x%2.2X, %s, %s, %s,\n", 631 Resource->UartSerialBus.LinesEnabled, 632 AcpiGbl_EdDecode [(Resource->UartSerialBus.TypeSpecificFlags >> 7) & 1], 633 AcpiGbl_PtDecode [Resource->UartSerialBus.Parity & 7], 634 AcpiGbl_FcDecode [Resource->UartSerialBus.TypeSpecificFlags & 3]); 635 636 /* ReceiveBufferSize, TransmitBufferSize */ 637 638 AcpiDmIndent (Level + 1); 639 AcpiOsPrintf ("0x%4.4X, 0x%4.4X, ", 640 Resource->UartSerialBus.RxFifoSize, 641 Resource->UartSerialBus.TxFifoSize); 642 643 /* ResourceSource is a required field */ 644 645 ResourceSourceOffset = sizeof (AML_RESOURCE_COMMON_SERIALBUS) + 646 Resource->CommonSerialBus.TypeDataLength; 647 648 AcpiUtPrintString ( 649 ACPI_ADD_PTR (char, Resource, ResourceSourceOffset), 650 ACPI_UINT8_MAX); 651 652 /* ResourceSourceIndex, ResourceUsage */ 653 654 AcpiOsPrintf (",\n"); 655 AcpiDmIndent (Level + 1); 656 AcpiOsPrintf ("0x%2.2X, ", Resource->UartSerialBus.ResSourceIndex); 657 658 AcpiOsPrintf ("%s, ", 659 AcpiGbl_ConsumeDecode [(Resource->UartSerialBus.Flags & 1)]); 660 661 /* Insert a descriptor name */ 662 663 AcpiDmDescriptorName (); 664 AcpiOsPrintf (",\n"); 665 666 /* Dump the vendor data */ 667 668 AcpiDmIndent (Level + 1); 669 AcpiDmDumpSerialBusVendorData (Resource, Level); 670 AcpiOsPrintf (")\n"); 671} 672 673 674/******************************************************************************* 675 * 676 * FUNCTION: AcpiDmSerialBusDescriptor 677 * 678 * PARAMETERS: Resource - Pointer to the resource descriptor 679 * Length - Length of the descriptor in bytes 680 * Level - Current source code indentation level 681 * 682 * RETURN: None 683 * 684 * DESCRIPTION: Decode a I2C/SPI/UART serial bus descriptor 685 * 686 ******************************************************************************/ 687 688void 689AcpiDmSerialBusDescriptor ( 690 AML_RESOURCE *Resource, 691 UINT32 Length, 692 UINT32 Level) 693{ 694 695 SerialBusResourceDispatch [Resource->CommonSerialBus.Type] ( 696 Resource, Length, Level); 697} 698 699#endif 700
|