1 /******************************************************************************* 2 * 3 * Module Name: dmbuffer - AML disassembler, buffer and string support 4 * 5 ******************************************************************************/ 6 7 /* 8 * Copyright (C) 2000 - 2016, Intel Corp. 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 #include <contrib/dev/acpica/include/acpi.h> 45 #include <contrib/dev/acpica/include/accommon.h> 46 #include <contrib/dev/acpica/include/acutils.h> 47 #include <contrib/dev/acpica/include/acdisasm.h> 48 #include <contrib/dev/acpica/include/acparser.h> 49 #include <contrib/dev/acpica/include/amlcode.h> 50 #include <contrib/dev/acpica/include/acinterp.h> 51 52 53 #define _COMPONENT ACPI_CA_DEBUGGER 54 ACPI_MODULE_NAME ("dmbuffer") 55 56 /* Local prototypes */ 57 58 static void 59 AcpiDmUuid ( 60 ACPI_PARSE_OBJECT *Op); 61 62 static void 63 AcpiDmUnicode ( 64 ACPI_PARSE_OBJECT *Op); 65 66 static void 67 AcpiDmGetHardwareIdType ( 68 ACPI_PARSE_OBJECT *Op); 69 70 static void 71 AcpiDmPldBuffer ( 72 UINT32 Level, 73 UINT8 *ByteData, 74 UINT32 ByteCount); 75 76 static const char * 77 AcpiDmFindNameByIndex ( 78 UINT64 Index, 79 const char **List); 80 81 82 #define ACPI_BUFFER_BYTES_PER_LINE 8 83 84 85 /******************************************************************************* 86 * 87 * FUNCTION: AcpiDmDisasmByteList 88 * 89 * PARAMETERS: Level - Current source code indentation level 90 * ByteData - Pointer to the byte list 91 * ByteCount - Length of the byte list 92 * 93 * RETURN: None 94 * 95 * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed 96 * with the hex buffer offset. 97 * 98 ******************************************************************************/ 99 100 void 101 AcpiDmDisasmByteList ( 102 UINT32 Level, 103 UINT8 *ByteData, 104 UINT32 ByteCount) 105 { 106 UINT32 i; 107 UINT32 j; 108 UINT32 CurrentIndex; 109 UINT8 BufChar; 110 111 112 if (!ByteCount) 113 { 114 return; 115 } 116 117 for (i = 0; i < ByteCount; i += ACPI_BUFFER_BYTES_PER_LINE) 118 { 119 /* Line indent and offset prefix for each new line */ 120 121 AcpiDmIndent (Level); 122 if (ByteCount > ACPI_BUFFER_BYTES_PER_LINE) 123 { 124 AcpiOsPrintf ("/* %04X */ ", i); 125 } 126 127 /* Dump the actual hex values */ 128 129 for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) 130 { 131 CurrentIndex = i + j; 132 if (CurrentIndex >= ByteCount) 133 { 134 /* Dump fill spaces */ 135 136 AcpiOsPrintf (" "); 137 continue; 138 } 139 140 AcpiOsPrintf (" 0x%2.2X", ByteData[CurrentIndex]); 141 142 /* Add comma if there are more bytes to display */ 143 144 if (CurrentIndex < (ByteCount - 1)) 145 { 146 AcpiOsPrintf (","); 147 } 148 else 149 { 150 AcpiOsPrintf (" "); 151 } 152 } 153 154 /* Dump the ASCII equivalents within a comment */ 155 156 AcpiOsPrintf (" /* "); 157 for (j = 0; j < ACPI_BUFFER_BYTES_PER_LINE; j++) 158 { 159 CurrentIndex = i + j; 160 if (CurrentIndex >= ByteCount) 161 { 162 break; 163 } 164 165 BufChar = ByteData[CurrentIndex]; 166 if (isprint (BufChar)) 167 { 168 AcpiOsPrintf ("%c", BufChar); 169 } 170 else 171 { 172 AcpiOsPrintf ("."); 173 } 174 } 175 176 /* Finished with this line */ 177 178 AcpiOsPrintf (" */\n"); 179 } 180 } 181 182 183 /******************************************************************************* 184 * 185 * FUNCTION: AcpiDmByteList 186 * 187 * PARAMETERS: Info - Parse tree walk info 188 * Op - Byte list op 189 * 190 * RETURN: None 191 * 192 * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers. 193 * Buffer type must be already set in the Op DisasmOpcode. 194 * 195 ******************************************************************************/ 196 197 void 198 AcpiDmByteList ( 199 ACPI_OP_WALK_INFO *Info, 200 ACPI_PARSE_OBJECT *Op) 201 { 202 UINT8 *ByteData; 203 UINT32 ByteCount; 204 205 206 ByteData = Op->Named.Data; 207 ByteCount = (UINT32) Op->Common.Value.Integer; 208 209 /* 210 * The byte list belongs to a buffer, and can be produced by either 211 * a ResourceTemplate, Unicode, quoted string, or a plain byte list. 212 */ 213 switch (Op->Common.Parent->Common.DisasmOpcode) 214 { 215 case ACPI_DASM_RESOURCE: 216 217 AcpiDmResourceTemplate ( 218 Info, Op->Common.Parent, ByteData, ByteCount); 219 break; 220 221 case ACPI_DASM_STRING: 222 223 AcpiDmIndent (Info->Level); 224 AcpiUtPrintString ((char *) ByteData, ACPI_UINT16_MAX); 225 AcpiOsPrintf ("\n"); 226 break; 227 228 case ACPI_DASM_UUID: 229 230 AcpiDmUuid (Op); 231 break; 232 233 case ACPI_DASM_UNICODE: 234 235 AcpiDmUnicode (Op); 236 break; 237 238 case ACPI_DASM_PLD_METHOD: 239 #if 0 240 AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount); 241 #endif 242 AcpiDmPldBuffer (Info->Level, ByteData, ByteCount); 243 break; 244 245 case ACPI_DASM_BUFFER: 246 default: 247 /* 248 * Not a resource, string, or unicode string. 249 * Just dump the buffer 250 */ 251 AcpiDmDisasmByteList (Info->Level, ByteData, ByteCount); 252 break; 253 } 254 } 255 256 257 /******************************************************************************* 258 * 259 * FUNCTION: AcpiDmIsUuidBuffer 260 * 261 * PARAMETERS: Op - Buffer Object to be examined 262 * 263 * RETURN: TRUE if buffer contains a UUID 264 * 265 * DESCRIPTION: Determine if a buffer Op contains a UUID 266 * 267 * To help determine whether the buffer is a UUID versus a raw data buffer, 268 * there a are a couple bytes we can look at: 269 * 270 * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 271 * 272 * The variant covered by the UUID specification is indicated by the two most 273 * significant bits of N being 1 0 (i.e., the hexadecimal N will always be 274 * 8, 9, A, or B). 275 * 276 * The variant covered by the UUID specification has five versions. For this 277 * variant, the four bits of M indicates the UUID version (i.e., the 278 * hexadecimal M will be either 1, 2, 3, 4, or 5). 279 * 280 ******************************************************************************/ 281 282 BOOLEAN 283 AcpiDmIsUuidBuffer ( 284 ACPI_PARSE_OBJECT *Op) 285 { 286 UINT8 *ByteData; 287 UINT32 ByteCount; 288 ACPI_PARSE_OBJECT *SizeOp; 289 ACPI_PARSE_OBJECT *NextOp; 290 291 292 /* Buffer size is the buffer argument */ 293 294 SizeOp = Op->Common.Value.Arg; 295 296 /* Next, the initializer byte list to examine */ 297 298 NextOp = SizeOp->Common.Next; 299 if (!NextOp) 300 { 301 return (FALSE); 302 } 303 304 /* Extract the byte list info */ 305 306 ByteData = NextOp->Named.Data; 307 ByteCount = (UINT32) NextOp->Common.Value.Integer; 308 309 /* Byte count must be exactly 16 */ 310 311 if (ByteCount != UUID_BUFFER_LENGTH) 312 { 313 return (FALSE); 314 } 315 316 /* Check for valid "M" and "N" values (see function header above) */ 317 318 if (((ByteData[7] & 0xF0) == 0x00) || /* M={1,2,3,4,5} */ 319 ((ByteData[7] & 0xF0) > 0x50) || 320 ((ByteData[8] & 0xF0) < 0x80) || /* N={8,9,A,B} */ 321 ((ByteData[8] & 0xF0) > 0xB0)) 322 { 323 return (FALSE); 324 } 325 326 /* Ignore the Size argument in the disassembly of this buffer op */ 327 328 SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 329 return (TRUE); 330 } 331 332 333 /******************************************************************************* 334 * 335 * FUNCTION: AcpiDmUuid 336 * 337 * PARAMETERS: Op - Byte List op containing a UUID 338 * 339 * RETURN: None 340 * 341 * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string. 342 * 343 * Output Format: 344 * In its canonical form, the UUID is represented by a string containing 32 345 * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens. 346 * The complete form is 8-4-4-4-12 for a total of 36 characters (32 347 * alphanumeric characters representing hex digits and 4 hyphens). In bytes, 348 * 4-2-2-2-6. Example: 349 * 350 * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644") 351 * 352 ******************************************************************************/ 353 354 static void 355 AcpiDmUuid ( 356 ACPI_PARSE_OBJECT *Op) 357 { 358 UINT8 *Data; 359 const char *Description; 360 361 362 Data = ACPI_CAST_PTR (UINT8, Op->Named.Data); 363 364 /* Emit the 36-byte UUID string in the proper format/order */ 365 366 AcpiOsPrintf ( 367 "\"%2.2x%2.2x%2.2x%2.2x-" 368 "%2.2x%2.2x-" 369 "%2.2x%2.2x-" 370 "%2.2x%2.2x-" 371 "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")", 372 Data[3], Data[2], Data[1], Data[0], 373 Data[5], Data[4], 374 Data[7], Data[6], 375 Data[8], Data[9], 376 Data[10], Data[11], Data[12], Data[13], Data[14], Data[15]); 377 378 /* Dump the UUID description string if available */ 379 380 Description = AcpiAhMatchUuid (Data); 381 if (Description) 382 { 383 AcpiOsPrintf (" /* %s */", Description); 384 } 385 } 386 387 388 /******************************************************************************* 389 * 390 * FUNCTION: AcpiDmIsUnicodeBuffer 391 * 392 * PARAMETERS: Op - Buffer Object to be examined 393 * 394 * RETURN: TRUE if buffer contains a UNICODE string 395 * 396 * DESCRIPTION: Determine if a buffer Op contains a Unicode string 397 * 398 ******************************************************************************/ 399 400 BOOLEAN 401 AcpiDmIsUnicodeBuffer ( 402 ACPI_PARSE_OBJECT *Op) 403 { 404 UINT8 *ByteData; 405 UINT32 ByteCount; 406 UINT32 WordCount; 407 ACPI_PARSE_OBJECT *SizeOp; 408 ACPI_PARSE_OBJECT *NextOp; 409 UINT32 i; 410 411 412 /* Buffer size is the buffer argument */ 413 414 SizeOp = Op->Common.Value.Arg; 415 416 /* Next, the initializer byte list to examine */ 417 418 NextOp = SizeOp->Common.Next; 419 if (!NextOp) 420 { 421 return (FALSE); 422 } 423 424 /* Extract the byte list info */ 425 426 ByteData = NextOp->Named.Data; 427 ByteCount = (UINT32) NextOp->Common.Value.Integer; 428 WordCount = ACPI_DIV_2 (ByteCount); 429 430 /* 431 * Unicode string must have an even number of bytes and last 432 * word must be zero 433 */ 434 if ((!ByteCount) || 435 (ByteCount < 4) || 436 (ByteCount & 1) || 437 ((UINT16 *) (void *) ByteData)[WordCount - 1] != 0) 438 { 439 return (FALSE); 440 } 441 442 /* For each word, 1st byte must be ascii (1-0x7F), 2nd byte must be zero */ 443 444 for (i = 0; i < (ByteCount - 2); i += 2) 445 { 446 if ((ByteData[i] == 0) || 447 (ByteData[i] > 0x7F) || 448 (ByteData[(ACPI_SIZE) i + 1] != 0)) 449 { 450 return (FALSE); 451 } 452 } 453 454 /* Ignore the Size argument in the disassembly of this buffer op */ 455 456 SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 457 return (TRUE); 458 } 459 460 461 /******************************************************************************* 462 * 463 * FUNCTION: AcpiDmIsStringBuffer 464 * 465 * PARAMETERS: Op - Buffer Object to be examined 466 * 467 * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise 468 * 469 * DESCRIPTION: Determine if a buffer Op contains a ASCII string 470 * 471 ******************************************************************************/ 472 473 BOOLEAN 474 AcpiDmIsStringBuffer ( 475 ACPI_PARSE_OBJECT *Op) 476 { 477 UINT8 *ByteData; 478 UINT32 ByteCount; 479 ACPI_PARSE_OBJECT *SizeOp; 480 ACPI_PARSE_OBJECT *NextOp; 481 UINT32 i; 482 483 484 /* Buffer size is the buffer argument */ 485 486 SizeOp = Op->Common.Value.Arg; 487 488 /* Next, the initializer byte list to examine */ 489 490 NextOp = SizeOp->Common.Next; 491 if (!NextOp) 492 { 493 return (FALSE); 494 } 495 496 /* Extract the byte list info */ 497 498 ByteData = NextOp->Named.Data; 499 ByteCount = (UINT32) NextOp->Common.Value.Integer; 500 501 /* Last byte must be the null terminator */ 502 503 if ((!ByteCount) || 504 (ByteCount < 2) || 505 (ByteData[ByteCount-1] != 0)) 506 { 507 return (FALSE); 508 } 509 510 for (i = 0; i < (ByteCount - 1); i++) 511 { 512 /* TBD: allow some escapes (non-ascii chars). 513 * they will be handled in the string output routine 514 */ 515 516 if (!isprint (ByteData[i])) 517 { 518 return (FALSE); 519 } 520 } 521 522 return (TRUE); 523 } 524 525 526 /******************************************************************************* 527 * 528 * FUNCTION: AcpiDmIsPldBuffer 529 * 530 * PARAMETERS: Op - Buffer Object to be examined 531 * 532 * RETURN: TRUE if buffer appears to contain data produced via the 533 * ToPLD macro, FALSE otherwise 534 * 535 * DESCRIPTION: Determine if a buffer Op contains a _PLD structure 536 * 537 ******************************************************************************/ 538 539 BOOLEAN 540 AcpiDmIsPldBuffer ( 541 ACPI_PARSE_OBJECT *Op) 542 { 543 ACPI_NAMESPACE_NODE *Node; 544 ACPI_PARSE_OBJECT *SizeOp; 545 ACPI_PARSE_OBJECT *ByteListOp; 546 ACPI_PARSE_OBJECT *ParentOp; 547 UINT64 BufferSize; 548 UINT64 InitializerSize; 549 550 551 /* 552 * Get the BufferSize argument - Buffer(BufferSize) 553 * If the buffer was generated by the ToPld macro, it must 554 * be a BYTE constant. 555 */ 556 SizeOp = Op->Common.Value.Arg; 557 if (SizeOp->Common.AmlOpcode != AML_BYTE_OP) 558 { 559 return (FALSE); 560 } 561 562 /* Check the declared BufferSize, two possibilities */ 563 564 BufferSize = SizeOp->Common.Value.Integer; 565 if ((BufferSize != ACPI_PLD_REV1_BUFFER_SIZE) && 566 (BufferSize != ACPI_PLD_REV2_BUFFER_SIZE)) 567 { 568 return (FALSE); 569 } 570 571 /* 572 * Check the initializer list length. This is the actual 573 * number of bytes in the buffer as counted by the AML parser. 574 * The declared BufferSize can be larger than the actual length. 575 * However, for the ToPLD macro, the BufferSize will be the same 576 * as the initializer list length. 577 */ 578 ByteListOp = SizeOp->Common.Next; 579 if (!ByteListOp) 580 { 581 return (FALSE); /* Zero-length buffer case */ 582 } 583 584 InitializerSize = ByteListOp->Common.Value.Integer; 585 if ((InitializerSize != ACPI_PLD_REV1_BUFFER_SIZE) && 586 (InitializerSize != ACPI_PLD_REV2_BUFFER_SIZE)) 587 { 588 return (FALSE); 589 } 590 591 /* Final size check */ 592 593 if (BufferSize != InitializerSize) 594 { 595 return (FALSE); 596 } 597 598 /* Now examine the buffer parent */ 599 600 ParentOp = Op->Common.Parent; 601 if (!ParentOp) 602 { 603 return (FALSE); 604 } 605 606 /* Check for form: Name(_PLD, Buffer() {}). Not legal, however */ 607 608 if (ParentOp->Common.AmlOpcode == AML_NAME_OP) 609 { 610 Node = ParentOp->Common.Node; 611 612 if (ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__PLD)) 613 { 614 /* Ignore the Size argument in the disassembly of this buffer op */ 615 616 SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 617 return (TRUE); 618 } 619 620 return (FALSE); 621 } 622 623 /* 624 * Check for proper form: Name(_PLD, Package() {ToPLD()}) 625 * 626 * Note: All other forms such as 627 * Return (Package() {ToPLD()}) 628 * Local0 = ToPLD() 629 * etc. are not converted back to the ToPLD macro, because 630 * there is really no deterministic way to disassemble the buffer 631 * back to the ToPLD macro, other than trying to find the "_PLD" 632 * name 633 */ 634 if (ParentOp->Common.AmlOpcode == AML_PACKAGE_OP) 635 { 636 ParentOp = ParentOp->Common.Parent; 637 if (!ParentOp) 638 { 639 return (FALSE); 640 } 641 642 if (ParentOp->Common.AmlOpcode == AML_NAME_OP) 643 { 644 Node = ParentOp->Common.Node; 645 646 if (ACPI_COMPARE_NAME (Node->Name.Ascii, METHOD_NAME__PLD)) 647 { 648 /* Ignore the Size argument in the disassembly of this buffer op */ 649 650 SizeOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE; 651 return (TRUE); 652 } 653 } 654 } 655 656 return (FALSE); 657 } 658 659 660 /******************************************************************************* 661 * 662 * FUNCTION: AcpiDmFindNameByIndex 663 * 664 * PARAMETERS: Index - Index of array to check 665 * List - Array to reference 666 * 667 * RETURN: String from List or empty string 668 * 669 * DESCRIPTION: Finds and returns the char string located at the given index 670 * position in List. 671 * 672 ******************************************************************************/ 673 674 static const char * 675 AcpiDmFindNameByIndex ( 676 UINT64 Index, 677 const char **List) 678 { 679 const char *NameString; 680 UINT32 i; 681 682 683 /* Bounds check */ 684 685 NameString = List[0]; 686 i = 0; 687 688 while (NameString) 689 { 690 i++; 691 NameString = List[i]; 692 } 693 694 if (Index >= i) 695 { 696 /* TBD: Add error msg */ 697 698 return (""); 699 } 700 701 return (List[Index]); 702 } 703 704 705 /******************************************************************************* 706 * 707 * FUNCTION: AcpiDmPldBuffer 708 * 709 * PARAMETERS: Level - Current source code indentation level 710 * ByteData - Pointer to the byte list 711 * ByteCount - Length of the byte list 712 * 713 * RETURN: None 714 * 715 * DESCRIPTION: Dump and format the contents of a _PLD buffer object 716 * 717 ******************************************************************************/ 718 719 #define ACPI_PLD_OUTPUT08 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " 720 #define ACPI_PLD_OUTPUT08P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " 721 #define ACPI_PLD_OUTPUT16 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " 722 #define ACPI_PLD_OUTPUT16P "%*.s%-22s = 0x%X)\n", ACPI_MUL_4 (Level), " " 723 #define ACPI_PLD_OUTPUT24 "%*.s%-22s = 0x%X,\n", ACPI_MUL_4 (Level), " " 724 #define ACPI_PLD_OUTPUTSTR "%*.s%-22s = \"%s\",\n", ACPI_MUL_4 (Level), " " 725 726 static void 727 AcpiDmPldBuffer ( 728 UINT32 Level, 729 UINT8 *ByteData, 730 UINT32 ByteCount) 731 { 732 ACPI_PLD_INFO *PldInfo; 733 ACPI_STATUS Status; 734 735 736 /* Check for valid byte count */ 737 738 if (ByteCount < ACPI_PLD_REV1_BUFFER_SIZE) 739 { 740 return; 741 } 742 743 /* Convert _PLD buffer to local _PLD struct */ 744 745 Status = AcpiDecodePldBuffer (ByteData, ByteCount, &PldInfo); 746 if (ACPI_FAILURE (Status)) 747 { 748 return; 749 } 750 751 AcpiOsPrintf ("\n"); 752 753 /* First 32-bit dword */ 754 755 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Revision", PldInfo->Revision); 756 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_IgnoreColor", PldInfo->IgnoreColor); 757 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Red", PldInfo->Red); 758 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Green", PldInfo->Green); 759 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Blue", PldInfo->Blue); 760 761 /* Second 32-bit dword */ 762 763 AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_Width", PldInfo->Width); 764 AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_Height", PldInfo->Height); 765 766 /* Third 32-bit dword */ 767 768 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_UserVisible", PldInfo->UserVisible); 769 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Dock", PldInfo->Dock); 770 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Lid", PldInfo->Lid); 771 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Panel", 772 AcpiDmFindNameByIndex(PldInfo->Panel, AcpiGbl_PldPanelList)); 773 774 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_VerticalPosition", 775 AcpiDmFindNameByIndex(PldInfo->VerticalPosition, AcpiGbl_PldVerticalPositionList)); 776 777 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_HorizontalPosition", 778 AcpiDmFindNameByIndex(PldInfo->HorizontalPosition, AcpiGbl_PldHorizontalPositionList)); 779 780 AcpiOsPrintf (ACPI_PLD_OUTPUTSTR, "PLD_Shape", 781 AcpiDmFindNameByIndex(PldInfo->Shape, AcpiGbl_PldShapeList)); 782 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupOrientation", PldInfo->GroupOrientation); 783 784 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupToken", PldInfo->GroupToken); 785 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_GroupPosition", PldInfo->GroupPosition); 786 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Bay", PldInfo->Bay); 787 788 /* Fourth 32-bit dword */ 789 790 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Ejectable", PldInfo->Ejectable); 791 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_EjectRequired", PldInfo->OspmEjectRequired); 792 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_CabinetNumber", PldInfo->CabinetNumber); 793 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_CardCageNumber", PldInfo->CardCageNumber); 794 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Reference", PldInfo->Reference); 795 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Rotation", PldInfo->Rotation); 796 797 if (ByteCount >= ACPI_PLD_REV2_BUFFER_SIZE) 798 { 799 AcpiOsPrintf (ACPI_PLD_OUTPUT08, "PLD_Order", PldInfo->Order); 800 801 /* Fifth 32-bit dword */ 802 803 AcpiOsPrintf (ACPI_PLD_OUTPUT16, "PLD_VerticalOffset", PldInfo->VerticalOffset); 804 AcpiOsPrintf (ACPI_PLD_OUTPUT16P, "PLD_HorizontalOffset", PldInfo->HorizontalOffset); 805 } 806 else /* Rev 1 buffer */ 807 { 808 AcpiOsPrintf (ACPI_PLD_OUTPUT08P, "PLD_Order", PldInfo->Order); 809 } 810 811 ACPI_FREE (PldInfo); 812 } 813 814 815 /******************************************************************************* 816 * 817 * FUNCTION: AcpiDmUnicode 818 * 819 * PARAMETERS: Op - Byte List op containing Unicode string 820 * 821 * RETURN: None 822 * 823 * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove 824 * the extra zero bytes). 825 * 826 ******************************************************************************/ 827 828 static void 829 AcpiDmUnicode ( 830 ACPI_PARSE_OBJECT *Op) 831 { 832 UINT16 *WordData; 833 UINT32 WordCount; 834 UINT32 i; 835 int OutputValue; 836 837 838 /* Extract the buffer info as a WORD buffer */ 839 840 WordData = ACPI_CAST_PTR (UINT16, Op->Named.Data); 841 WordCount = ACPI_DIV_2 (((UINT32) Op->Common.Value.Integer)); 842 843 /* Write every other byte as an ASCII character */ 844 845 AcpiOsPrintf ("\""); 846 for (i = 0; i < (WordCount - 1); i++) 847 { 848 OutputValue = (int) WordData[i]; 849 850 /* Handle values that must be escaped */ 851 852 if ((OutputValue == '\"') || 853 (OutputValue == '\\')) 854 { 855 AcpiOsPrintf ("\\%c", OutputValue); 856 } 857 else if (!isprint (OutputValue)) 858 { 859 AcpiOsPrintf ("\\x%2.2X", OutputValue); 860 } 861 else 862 { 863 AcpiOsPrintf ("%c", OutputValue); 864 } 865 } 866 867 AcpiOsPrintf ("\")"); 868 } 869 870 871 /******************************************************************************* 872 * 873 * FUNCTION: AcpiDmGetHardwareIdType 874 * 875 * PARAMETERS: Op - Op to be examined 876 * 877 * RETURN: None 878 * 879 * DESCRIPTION: Determine the type of the argument to a _HID or _CID 880 * 1) Strings are allowed 881 * 2) If Integer, determine if it is a valid EISAID 882 * 883 ******************************************************************************/ 884 885 static void 886 AcpiDmGetHardwareIdType ( 887 ACPI_PARSE_OBJECT *Op) 888 { 889 UINT32 BigEndianId; 890 UINT32 Prefix[3]; 891 UINT32 i; 892 893 894 switch (Op->Common.AmlOpcode) 895 { 896 case AML_STRING_OP: 897 898 /* Mark this string as an _HID/_CID string */ 899 900 Op->Common.DisasmOpcode = ACPI_DASM_HID_STRING; 901 break; 902 903 case AML_WORD_OP: 904 case AML_DWORD_OP: 905 906 /* Determine if a Word/Dword is a valid encoded EISAID */ 907 908 /* Swap from little-endian to big-endian to simplify conversion */ 909 910 BigEndianId = AcpiUtDwordByteSwap ((UINT32) Op->Common.Value.Integer); 911 912 /* Create the 3 leading ASCII letters */ 913 914 Prefix[0] = ((BigEndianId >> 26) & 0x1F) + 0x40; 915 Prefix[1] = ((BigEndianId >> 21) & 0x1F) + 0x40; 916 Prefix[2] = ((BigEndianId >> 16) & 0x1F) + 0x40; 917 918 /* Verify that all 3 are ascii and alpha */ 919 920 for (i = 0; i < 3; i++) 921 { 922 if (!ACPI_IS_ASCII (Prefix[i]) || 923 !isalpha (Prefix[i])) 924 { 925 return; 926 } 927 } 928 929 /* Mark this node as convertable to an EISA ID string */ 930 931 Op->Common.DisasmOpcode = ACPI_DASM_EISAID; 932 break; 933 934 default: 935 break; 936 } 937 } 938 939 940 /******************************************************************************* 941 * 942 * FUNCTION: AcpiDmCheckForHardwareId 943 * 944 * PARAMETERS: Op - Op to be examined 945 * 946 * RETURN: None 947 * 948 * DESCRIPTION: Determine if a Name() Op is a _HID/_CID. 949 * 950 ******************************************************************************/ 951 952 void 953 AcpiDmCheckForHardwareId ( 954 ACPI_PARSE_OBJECT *Op) 955 { 956 UINT32 Name; 957 ACPI_PARSE_OBJECT *NextOp; 958 959 960 /* Get the NameSegment */ 961 962 Name = AcpiPsGetName (Op); 963 if (!Name) 964 { 965 return; 966 } 967 968 NextOp = AcpiPsGetDepthNext (NULL, Op); 969 if (!NextOp) 970 { 971 return; 972 } 973 974 /* Check for _HID - has one argument */ 975 976 if (ACPI_COMPARE_NAME (&Name, METHOD_NAME__HID)) 977 { 978 AcpiDmGetHardwareIdType (NextOp); 979 return; 980 } 981 982 /* Exit if not _CID */ 983 984 if (!ACPI_COMPARE_NAME (&Name, METHOD_NAME__CID)) 985 { 986 return; 987 } 988 989 /* _CID can contain a single argument or a package */ 990 991 if (NextOp->Common.AmlOpcode != AML_PACKAGE_OP) 992 { 993 AcpiDmGetHardwareIdType (NextOp); 994 return; 995 } 996 997 /* _CID with Package: get the package length, check all elements */ 998 999 NextOp = AcpiPsGetDepthNext (NULL, NextOp); 1000 if (!NextOp) 1001 { 1002 return; 1003 } 1004 1005 /* Don't need to use the length, just walk the peer list */ 1006 1007 NextOp = NextOp->Common.Next; 1008 while (NextOp) 1009 { 1010 AcpiDmGetHardwareIdType (NextOp); 1011 NextOp = NextOp->Common.Next; 1012 } 1013 } 1014 1015 1016 /******************************************************************************* 1017 * 1018 * FUNCTION: AcpiDmDecompressEisaId 1019 * 1020 * PARAMETERS: EncodedId - Raw encoded EISA ID. 1021 * 1022 * RETURN: None 1023 * 1024 * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String 1025 * and emit the correct ASL statement. If the ID is known, emit 1026 * a description of the ID as a comment. 1027 * 1028 ******************************************************************************/ 1029 1030 void 1031 AcpiDmDecompressEisaId ( 1032 UINT32 EncodedId) 1033 { 1034 char IdBuffer[ACPI_EISAID_STRING_SIZE]; 1035 const AH_DEVICE_ID *Info; 1036 1037 1038 /* Convert EISAID to a string an emit the statement */ 1039 1040 AcpiExEisaIdToString (IdBuffer, EncodedId); 1041 AcpiOsPrintf ("EisaId (\"%s\")", IdBuffer); 1042 1043 /* If we know about the ID, emit the description */ 1044 1045 Info = AcpiAhMatchHardwareId (IdBuffer); 1046 if (Info) 1047 { 1048 AcpiOsPrintf (" /* %s */", Info->Description); 1049 } 1050 } 1051