1244971Sjkim/******************************************************************************* 2244971Sjkim * 3244971Sjkim * Module Name: dbconvert - debugger miscellaneous conversion routines 4244971Sjkim * 5244971Sjkim ******************************************************************************/ 6244971Sjkim 7316303Sjkim/****************************************************************************** 8316303Sjkim * 9316303Sjkim * 1. Copyright Notice 10316303Sjkim * 11316303Sjkim * Some or all of this work - Copyright (c) 1999 - 2017, Intel Corp. 12244971Sjkim * All rights reserved. 13244971Sjkim * 14316303Sjkim * 2. License 15316303Sjkim * 16316303Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17316303Sjkim * rights. You may have additional license terms from the party that provided 18316303Sjkim * you this software, covering your right to use that party's intellectual 19316303Sjkim * property rights. 20316303Sjkim * 21316303Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22316303Sjkim * copy of the source code appearing in this file ("Covered Code") an 23316303Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24316303Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25316303Sjkim * make derivatives, distribute, use and display any portion of the Covered 26316303Sjkim * Code in any form, with the right to sublicense such rights; and 27316303Sjkim * 28316303Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29316303Sjkim * license (with the right to sublicense), under only those claims of Intel 30316303Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31316303Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32316303Sjkim * solely to the minimum extent necessary to exercise the above copyright 33316303Sjkim * license, and in no event shall the patent license extend to any additions 34316303Sjkim * to or modifications of the Original Intel Code. No other license or right 35316303Sjkim * is granted directly or by implication, estoppel or otherwise; 36316303Sjkim * 37316303Sjkim * The above copyright and patent license is granted only if the following 38316303Sjkim * conditions are met: 39316303Sjkim * 40316303Sjkim * 3. Conditions 41316303Sjkim * 42316303Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43316303Sjkim * Redistribution of source code of any substantial portion of the Covered 44316303Sjkim * Code or modification with rights to further distribute source must include 45316303Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46316303Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47316303Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48316303Sjkim * contain a file documenting the changes Licensee made to create that Covered 49316303Sjkim * Code and the date of any change. Licensee must include in that file the 50316303Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51316303Sjkim * must include a prominent statement that the modification is derived, 52316303Sjkim * directly or indirectly, from Original Intel Code. 53316303Sjkim * 54316303Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55316303Sjkim * Redistribution of source code of any substantial portion of the Covered 56316303Sjkim * Code or modification without rights to further distribute source must 57316303Sjkim * include the following Disclaimer and Export Compliance provision in the 58316303Sjkim * documentation and/or other materials provided with distribution. In 59316303Sjkim * addition, Licensee may not authorize further sublicense of source of any 60316303Sjkim * portion of the Covered Code, and must include terms to the effect that the 61316303Sjkim * license from Licensee to its licensee is limited to the intellectual 62316303Sjkim * property embodied in the software Licensee provides to its licensee, and 63316303Sjkim * not to intellectual property embodied in modifications its licensee may 64316303Sjkim * make. 65316303Sjkim * 66316303Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67316303Sjkim * substantial portion of the Covered Code or modification must reproduce the 68316303Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69316303Sjkim * provision in the documentation and/or other materials provided with the 70316303Sjkim * distribution. 71316303Sjkim * 72316303Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73316303Sjkim * Intel Code. 74316303Sjkim * 75316303Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76316303Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77316303Sjkim * other dealings in products derived from or relating to the Covered Code 78316303Sjkim * without prior written authorization from Intel. 79316303Sjkim * 80316303Sjkim * 4. Disclaimer and Export Compliance 81316303Sjkim * 82316303Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83316303Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84316303Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85316303Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86316303Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87316303Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88316303Sjkim * PARTICULAR PURPOSE. 89316303Sjkim * 90316303Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91316303Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92316303Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93316303Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94316303Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95316303Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96316303Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97316303Sjkim * LIMITED REMEDY. 98316303Sjkim * 99316303Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100316303Sjkim * software or system incorporating such software without first obtaining any 101316303Sjkim * required license or other approval from the U. S. Department of Commerce or 102316303Sjkim * any other agency or department of the United States Government. In the 103316303Sjkim * event Licensee exports any such software from the United States or 104316303Sjkim * re-exports any such software from a foreign destination, Licensee shall 105316303Sjkim * ensure that the distribution and export/re-export of the software is in 106316303Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107316303Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108316303Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109316303Sjkim * software, or service, directly or indirectly, to any country for which the 110316303Sjkim * United States government or any agency thereof requires an export license, 111316303Sjkim * other governmental approval, or letter of assurance, without first obtaining 112316303Sjkim * such license, approval or letter. 113316303Sjkim * 114316303Sjkim ***************************************************************************** 115316303Sjkim * 116316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 117316303Sjkim * following license: 118316303Sjkim * 119244971Sjkim * Redistribution and use in source and binary forms, with or without 120244971Sjkim * modification, are permitted provided that the following conditions 121244971Sjkim * are met: 122244971Sjkim * 1. Redistributions of source code must retain the above copyright 123244971Sjkim * notice, this list of conditions, and the following disclaimer, 124244971Sjkim * without modification. 125244971Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 126244971Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 127244971Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 128244971Sjkim * including a substantially similar Disclaimer requirement for further 129244971Sjkim * binary redistribution. 130244971Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 131244971Sjkim * of any contributors may be used to endorse or promote products derived 132244971Sjkim * from this software without specific prior written permission. 133244971Sjkim * 134316303Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 135316303Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 136316303Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 137316303Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 138316303Sjkim * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 139316303Sjkim * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 140316303Sjkim * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 141316303Sjkim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 142316303Sjkim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 143316303Sjkim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 144316303Sjkim * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 145316303Sjkim * 146316303Sjkim * Alternatively, you may choose to be licensed under the terms of the 147244971Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 148244971Sjkim * Software Foundation. 149244971Sjkim * 150316303Sjkim *****************************************************************************/ 151244971Sjkim 152245582Sjkim#include <contrib/dev/acpica/include/acpi.h> 153245582Sjkim#include <contrib/dev/acpica/include/accommon.h> 154245582Sjkim#include <contrib/dev/acpica/include/acdebug.h> 155244971Sjkim 156244971Sjkim 157244971Sjkim#define _COMPONENT ACPI_CA_DEBUGGER 158244971Sjkim ACPI_MODULE_NAME ("dbconvert") 159244971Sjkim 160244971Sjkim 161244971Sjkim#define DB_DEFAULT_PKG_ELEMENTS 33 162244971Sjkim 163244971Sjkim 164244971Sjkim/******************************************************************************* 165244971Sjkim * 166244971Sjkim * FUNCTION: AcpiDbHexCharToValue 167244971Sjkim * 168244971Sjkim * PARAMETERS: HexChar - Ascii Hex digit, 0-9|a-f|A-F 169244971Sjkim * ReturnValue - Where the converted value is returned 170244971Sjkim * 171244971Sjkim * RETURN: Status 172244971Sjkim * 173244971Sjkim * DESCRIPTION: Convert a single hex character to a 4-bit number (0-16). 174244971Sjkim * 175244971Sjkim ******************************************************************************/ 176244971Sjkim 177244971SjkimACPI_STATUS 178244971SjkimAcpiDbHexCharToValue ( 179244971Sjkim int HexChar, 180244971Sjkim UINT8 *ReturnValue) 181244971Sjkim{ 182244971Sjkim UINT8 Value; 183244971Sjkim 184244971Sjkim 185244971Sjkim /* Digit must be ascii [0-9a-fA-F] */ 186244971Sjkim 187284583Sjkim if (!isxdigit (HexChar)) 188244971Sjkim { 189244971Sjkim return (AE_BAD_HEX_CONSTANT); 190244971Sjkim } 191244971Sjkim 192244971Sjkim if (HexChar <= 0x39) 193244971Sjkim { 194244971Sjkim Value = (UINT8) (HexChar - 0x30); 195244971Sjkim } 196244971Sjkim else 197244971Sjkim { 198284583Sjkim Value = (UINT8) (toupper (HexChar) - 0x37); 199244971Sjkim } 200244971Sjkim 201244971Sjkim *ReturnValue = Value; 202244971Sjkim return (AE_OK); 203244971Sjkim} 204244971Sjkim 205244971Sjkim 206244971Sjkim/******************************************************************************* 207244971Sjkim * 208244971Sjkim * FUNCTION: AcpiDbHexByteToBinary 209244971Sjkim * 210244971Sjkim * PARAMETERS: HexByte - Double hex digit (0x00 - 0xFF) in format: 211244971Sjkim * HiByte then LoByte. 212244971Sjkim * ReturnValue - Where the converted value is returned 213244971Sjkim * 214244971Sjkim * RETURN: Status 215244971Sjkim * 216244971Sjkim * DESCRIPTION: Convert two hex characters to an 8 bit number (0 - 255). 217244971Sjkim * 218244971Sjkim ******************************************************************************/ 219244971Sjkim 220244971Sjkimstatic ACPI_STATUS 221244971SjkimAcpiDbHexByteToBinary ( 222244971Sjkim char *HexByte, 223244971Sjkim UINT8 *ReturnValue) 224244971Sjkim{ 225244971Sjkim UINT8 Local0; 226244971Sjkim UINT8 Local1; 227244971Sjkim ACPI_STATUS Status; 228244971Sjkim 229244971Sjkim 230244971Sjkim /* High byte */ 231244971Sjkim 232244971Sjkim Status = AcpiDbHexCharToValue (HexByte[0], &Local0); 233244971Sjkim if (ACPI_FAILURE (Status)) 234244971Sjkim { 235244971Sjkim return (Status); 236244971Sjkim } 237244971Sjkim 238244971Sjkim /* Low byte */ 239244971Sjkim 240244971Sjkim Status = AcpiDbHexCharToValue (HexByte[1], &Local1); 241244971Sjkim if (ACPI_FAILURE (Status)) 242244971Sjkim { 243244971Sjkim return (Status); 244244971Sjkim } 245244971Sjkim 246244971Sjkim *ReturnValue = (UINT8) ((Local0 << 4) | Local1); 247244971Sjkim return (AE_OK); 248244971Sjkim} 249244971Sjkim 250244971Sjkim 251244971Sjkim/******************************************************************************* 252244971Sjkim * 253244971Sjkim * FUNCTION: AcpiDbConvertToBuffer 254244971Sjkim * 255244971Sjkim * PARAMETERS: String - Input string to be converted 256244971Sjkim * Object - Where the buffer object is returned 257244971Sjkim * 258244971Sjkim * RETURN: Status 259244971Sjkim * 260244971Sjkim * DESCRIPTION: Convert a string to a buffer object. String is treated a list 261244971Sjkim * of buffer elements, each separated by a space or comma. 262244971Sjkim * 263244971Sjkim ******************************************************************************/ 264244971Sjkim 265244971Sjkimstatic ACPI_STATUS 266244971SjkimAcpiDbConvertToBuffer ( 267244971Sjkim char *String, 268244971Sjkim ACPI_OBJECT *Object) 269244971Sjkim{ 270244971Sjkim UINT32 i; 271244971Sjkim UINT32 j; 272244971Sjkim UINT32 Length; 273244971Sjkim UINT8 *Buffer; 274244971Sjkim ACPI_STATUS Status; 275244971Sjkim 276244971Sjkim 277244971Sjkim /* Generate the final buffer length */ 278244971Sjkim 279244971Sjkim for (i = 0, Length = 0; String[i];) 280244971Sjkim { 281244971Sjkim i+=2; 282244971Sjkim Length++; 283244971Sjkim 284244971Sjkim while (String[i] && 285244971Sjkim ((String[i] == ',') || (String[i] == ' '))) 286244971Sjkim { 287244971Sjkim i++; 288244971Sjkim } 289244971Sjkim } 290244971Sjkim 291244971Sjkim Buffer = ACPI_ALLOCATE (Length); 292244971Sjkim if (!Buffer) 293244971Sjkim { 294244971Sjkim return (AE_NO_MEMORY); 295244971Sjkim } 296244971Sjkim 297244971Sjkim /* Convert the command line bytes to the buffer */ 298244971Sjkim 299244971Sjkim for (i = 0, j = 0; String[i];) 300244971Sjkim { 301244971Sjkim Status = AcpiDbHexByteToBinary (&String[i], &Buffer[j]); 302244971Sjkim if (ACPI_FAILURE (Status)) 303244971Sjkim { 304244971Sjkim ACPI_FREE (Buffer); 305244971Sjkim return (Status); 306244971Sjkim } 307244971Sjkim 308244971Sjkim j++; 309298714Sjkim i += 2; 310244971Sjkim while (String[i] && 311244971Sjkim ((String[i] == ',') || (String[i] == ' '))) 312244971Sjkim { 313244971Sjkim i++; 314244971Sjkim } 315244971Sjkim } 316244971Sjkim 317244971Sjkim Object->Type = ACPI_TYPE_BUFFER; 318244971Sjkim Object->Buffer.Pointer = Buffer; 319244971Sjkim Object->Buffer.Length = Length; 320244971Sjkim return (AE_OK); 321244971Sjkim} 322244971Sjkim 323244971Sjkim 324244971Sjkim/******************************************************************************* 325244971Sjkim * 326244971Sjkim * FUNCTION: AcpiDbConvertToPackage 327244971Sjkim * 328244971Sjkim * PARAMETERS: String - Input string to be converted 329244971Sjkim * Object - Where the package object is returned 330244971Sjkim * 331244971Sjkim * RETURN: Status 332244971Sjkim * 333244971Sjkim * DESCRIPTION: Convert a string to a package object. Handles nested packages 334244971Sjkim * via recursion with AcpiDbConvertToObject. 335244971Sjkim * 336244971Sjkim ******************************************************************************/ 337244971Sjkim 338244971SjkimACPI_STATUS 339244971SjkimAcpiDbConvertToPackage ( 340244971Sjkim char *String, 341244971Sjkim ACPI_OBJECT *Object) 342244971Sjkim{ 343244971Sjkim char *This; 344244971Sjkim char *Next; 345244971Sjkim UINT32 i; 346244971Sjkim ACPI_OBJECT_TYPE Type; 347244971Sjkim ACPI_OBJECT *Elements; 348244971Sjkim ACPI_STATUS Status; 349244971Sjkim 350244971Sjkim 351244971Sjkim Elements = ACPI_ALLOCATE_ZEROED ( 352244971Sjkim DB_DEFAULT_PKG_ELEMENTS * sizeof (ACPI_OBJECT)); 353244971Sjkim 354244971Sjkim This = String; 355244971Sjkim for (i = 0; i < (DB_DEFAULT_PKG_ELEMENTS - 1); i++) 356244971Sjkim { 357244971Sjkim This = AcpiDbGetNextToken (This, &Next, &Type); 358244971Sjkim if (!This) 359244971Sjkim { 360244971Sjkim break; 361244971Sjkim } 362244971Sjkim 363244971Sjkim /* Recursive call to convert each package element */ 364244971Sjkim 365244971Sjkim Status = AcpiDbConvertToObject (Type, This, &Elements[i]); 366244971Sjkim if (ACPI_FAILURE (Status)) 367244971Sjkim { 368244971Sjkim AcpiDbDeleteObjects (i + 1, Elements); 369244971Sjkim ACPI_FREE (Elements); 370244971Sjkim return (Status); 371244971Sjkim } 372244971Sjkim 373244971Sjkim This = Next; 374244971Sjkim } 375244971Sjkim 376244971Sjkim Object->Type = ACPI_TYPE_PACKAGE; 377244971Sjkim Object->Package.Count = i; 378244971Sjkim Object->Package.Elements = Elements; 379244971Sjkim return (AE_OK); 380244971Sjkim} 381244971Sjkim 382244971Sjkim 383244971Sjkim/******************************************************************************* 384244971Sjkim * 385244971Sjkim * FUNCTION: AcpiDbConvertToObject 386244971Sjkim * 387244971Sjkim * PARAMETERS: Type - Object type as determined by parser 388244971Sjkim * String - Input string to be converted 389244971Sjkim * Object - Where the new object is returned 390244971Sjkim * 391244971Sjkim * RETURN: Status 392244971Sjkim * 393244971Sjkim * DESCRIPTION: Convert a typed and tokenized string to an ACPI_OBJECT. Typing: 394244971Sjkim * 1) String objects were surrounded by quotes. 395244971Sjkim * 2) Buffer objects were surrounded by parentheses. 396244971Sjkim * 3) Package objects were surrounded by brackets "[]". 397244971Sjkim * 4) All standalone tokens are treated as integers. 398244971Sjkim * 399244971Sjkim ******************************************************************************/ 400244971Sjkim 401244971SjkimACPI_STATUS 402244971SjkimAcpiDbConvertToObject ( 403244971Sjkim ACPI_OBJECT_TYPE Type, 404244971Sjkim char *String, 405244971Sjkim ACPI_OBJECT *Object) 406244971Sjkim{ 407244971Sjkim ACPI_STATUS Status = AE_OK; 408244971Sjkim 409244971Sjkim 410244971Sjkim switch (Type) 411244971Sjkim { 412244971Sjkim case ACPI_TYPE_STRING: 413250838Sjkim 414244971Sjkim Object->Type = ACPI_TYPE_STRING; 415244971Sjkim Object->String.Pointer = String; 416284583Sjkim Object->String.Length = (UINT32) strlen (String); 417244971Sjkim break; 418244971Sjkim 419244971Sjkim case ACPI_TYPE_BUFFER: 420250838Sjkim 421244971Sjkim Status = AcpiDbConvertToBuffer (String, Object); 422244971Sjkim break; 423244971Sjkim 424244971Sjkim case ACPI_TYPE_PACKAGE: 425250838Sjkim 426244971Sjkim Status = AcpiDbConvertToPackage (String, Object); 427244971Sjkim break; 428244971Sjkim 429244971Sjkim default: 430250838Sjkim 431244971Sjkim Object->Type = ACPI_TYPE_INTEGER; 432327557Sjkim Status = AcpiUtStrtoul64 (String, &Object->Integer.Value); 433244971Sjkim break; 434244971Sjkim } 435244971Sjkim 436244971Sjkim return (Status); 437244971Sjkim} 438244971Sjkim 439244971Sjkim 440244971Sjkim/******************************************************************************* 441244971Sjkim * 442244971Sjkim * FUNCTION: AcpiDbEncodePldBuffer 443244971Sjkim * 444244971Sjkim * PARAMETERS: PldInfo - _PLD buffer struct (Using local struct) 445244971Sjkim * 446244971Sjkim * RETURN: Encode _PLD buffer suitable for return value from _PLD 447244971Sjkim * 448244971Sjkim * DESCRIPTION: Bit-packs a _PLD buffer struct. Used to test the _PLD macros 449244971Sjkim * 450244971Sjkim ******************************************************************************/ 451244971Sjkim 452244971SjkimUINT8 * 453244971SjkimAcpiDbEncodePldBuffer ( 454244971Sjkim ACPI_PLD_INFO *PldInfo) 455244971Sjkim{ 456244971Sjkim UINT32 *Buffer; 457244971Sjkim UINT32 Dword; 458244971Sjkim 459244971Sjkim 460244971Sjkim Buffer = ACPI_ALLOCATE_ZEROED (ACPI_PLD_BUFFER_SIZE); 461244971Sjkim if (!Buffer) 462244971Sjkim { 463244971Sjkim return (NULL); 464244971Sjkim } 465244971Sjkim 466244971Sjkim /* First 32 bits */ 467244971Sjkim 468244971Sjkim Dword = 0; 469244971Sjkim ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision); 470244971Sjkim ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor); 471278970Sjkim ACPI_PLD_SET_RED (&Dword, PldInfo->Red); 472278970Sjkim ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green); 473278970Sjkim ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue); 474244971Sjkim ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword); 475244971Sjkim 476244971Sjkim /* Second 32 bits */ 477244971Sjkim 478244971Sjkim Dword = 0; 479244971Sjkim ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width); 480244971Sjkim ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height); 481244971Sjkim ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword); 482244971Sjkim 483244971Sjkim /* Third 32 bits */ 484244971Sjkim 485244971Sjkim Dword = 0; 486244971Sjkim ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible); 487244971Sjkim ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock); 488244971Sjkim ACPI_PLD_SET_LID (&Dword, PldInfo->Lid); 489244971Sjkim ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel); 490244971Sjkim ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition); 491244971Sjkim ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition); 492244971Sjkim ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape); 493244971Sjkim ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation); 494244971Sjkim ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken); 495244971Sjkim ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition); 496244971Sjkim ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay); 497244971Sjkim ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword); 498244971Sjkim 499244971Sjkim /* Fourth 32 bits */ 500244971Sjkim 501244971Sjkim Dword = 0; 502244971Sjkim ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable); 503244971Sjkim ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired); 504244971Sjkim ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber); 505244971Sjkim ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber); 506244971Sjkim ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference); 507244971Sjkim ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation); 508244971Sjkim ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order); 509244971Sjkim ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword); 510244971Sjkim 511244971Sjkim if (PldInfo->Revision >= 2) 512244971Sjkim { 513244971Sjkim /* Fifth 32 bits */ 514244971Sjkim 515244971Sjkim Dword = 0; 516244971Sjkim ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset); 517244971Sjkim ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset); 518244971Sjkim ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword); 519244971Sjkim } 520244971Sjkim 521244971Sjkim return (ACPI_CAST_PTR (UINT8, Buffer)); 522244971Sjkim} 523244971Sjkim 524244971Sjkim 525244971Sjkim/******************************************************************************* 526244971Sjkim * 527244971Sjkim * FUNCTION: AcpiDbDumpPldBuffer 528244971Sjkim * 529244971Sjkim * PARAMETERS: ObjDesc - Object returned from _PLD method 530244971Sjkim * 531244971Sjkim * RETURN: None. 532244971Sjkim * 533244971Sjkim * DESCRIPTION: Dumps formatted contents of a _PLD return buffer. 534244971Sjkim * 535244971Sjkim ******************************************************************************/ 536244971Sjkim 537244971Sjkim#define ACPI_PLD_OUTPUT "%20s : %-6X\n" 538244971Sjkim 539244971Sjkimvoid 540244971SjkimAcpiDbDumpPldBuffer ( 541244971Sjkim ACPI_OBJECT *ObjDesc) 542244971Sjkim{ 543244971Sjkim ACPI_OBJECT *BufferDesc; 544244971Sjkim ACPI_PLD_INFO *PldInfo; 545244971Sjkim UINT8 *NewBuffer; 546244971Sjkim ACPI_STATUS Status; 547244971Sjkim 548244971Sjkim 549244971Sjkim /* Object must be of type Package with at least one Buffer element */ 550244971Sjkim 551244971Sjkim if (ObjDesc->Type != ACPI_TYPE_PACKAGE) 552244971Sjkim { 553244971Sjkim return; 554244971Sjkim } 555244971Sjkim 556244971Sjkim BufferDesc = &ObjDesc->Package.Elements[0]; 557244971Sjkim if (BufferDesc->Type != ACPI_TYPE_BUFFER) 558244971Sjkim { 559244971Sjkim return; 560244971Sjkim } 561244971Sjkim 562244971Sjkim /* Convert _PLD buffer to local _PLD struct */ 563244971Sjkim 564244971Sjkim Status = AcpiDecodePldBuffer (BufferDesc->Buffer.Pointer, 565244971Sjkim BufferDesc->Buffer.Length, &PldInfo); 566244971Sjkim if (ACPI_FAILURE (Status)) 567244971Sjkim { 568244971Sjkim return; 569244971Sjkim } 570244971Sjkim 571244971Sjkim /* Encode local _PLD struct back to a _PLD buffer */ 572244971Sjkim 573244971Sjkim NewBuffer = AcpiDbEncodePldBuffer (PldInfo); 574244971Sjkim if (!NewBuffer) 575244971Sjkim { 576298714Sjkim goto Exit; 577244971Sjkim } 578244971Sjkim 579244971Sjkim /* The two bit-packed buffers should match */ 580244971Sjkim 581284583Sjkim if (memcmp (NewBuffer, BufferDesc->Buffer.Pointer, 582244971Sjkim BufferDesc->Buffer.Length)) 583244971Sjkim { 584244971Sjkim AcpiOsPrintf ("Converted _PLD buffer does not compare. New:\n"); 585244971Sjkim 586244971Sjkim AcpiUtDumpBuffer (NewBuffer, 587244971Sjkim BufferDesc->Buffer.Length, DB_BYTE_DISPLAY, 0); 588244971Sjkim } 589244971Sjkim 590244971Sjkim /* First 32-bit dword */ 591244971Sjkim 592278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Revision", PldInfo->Revision); 593278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_IgnoreColor", PldInfo->IgnoreColor); 594278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Red", PldInfo->Red); 595278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Green", PldInfo->Green); 596278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Blue", PldInfo->Blue); 597244971Sjkim 598244971Sjkim /* Second 32-bit dword */ 599244971Sjkim 600278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Width", PldInfo->Width); 601278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Height", PldInfo->Height); 602244971Sjkim 603244971Sjkim /* Third 32-bit dword */ 604244971Sjkim 605278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_UserVisible", PldInfo->UserVisible); 606278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Dock", PldInfo->Dock); 607278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Lid", PldInfo->Lid); 608278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Panel", PldInfo->Panel); 609278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_VerticalPosition", PldInfo->VerticalPosition); 610278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalPosition", PldInfo->HorizontalPosition); 611278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Shape", PldInfo->Shape); 612278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupOrientation", PldInfo->GroupOrientation); 613278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupToken", PldInfo->GroupToken); 614278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_GroupPosition", PldInfo->GroupPosition); 615278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Bay", PldInfo->Bay); 616244971Sjkim 617244971Sjkim /* Fourth 32-bit dword */ 618244971Sjkim 619278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Ejectable", PldInfo->Ejectable); 620278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_EjectRequired", PldInfo->OspmEjectRequired); 621278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_CabinetNumber", PldInfo->CabinetNumber); 622278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_CardCageNumber", PldInfo->CardCageNumber); 623278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Reference", PldInfo->Reference); 624278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Rotation", PldInfo->Rotation); 625278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_Order", PldInfo->Order); 626244971Sjkim 627244971Sjkim /* Fifth 32-bit dword */ 628244971Sjkim 629244971Sjkim if (BufferDesc->Buffer.Length > 16) 630244971Sjkim { 631278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_VerticalOffset", PldInfo->VerticalOffset); 632278970Sjkim AcpiOsPrintf (ACPI_PLD_OUTPUT, "PLD_HorizontalOffset", PldInfo->HorizontalOffset); 633244971Sjkim } 634244971Sjkim 635298714Sjkim ACPI_FREE (NewBuffer); 636298714SjkimExit: 637244971Sjkim ACPI_FREE (PldInfo); 638244971Sjkim} 639