380N/A/******************************************************************************* 380N/A * Module Name: dmbuffer - AML disassembler, buffer and string support 380N/A ******************************************************************************/ 380N/A * Copyright (C) 2000 - 2016, Intel Corp. 380N/A * Redistribution and use in source and binary forms, with or without 380N/A * modification, are permitted provided that the following conditions 380N/A * 1. Redistributions of source code must retain the above copyright 380N/A * notice, this list of conditions, and the following disclaimer, 380N/A * without modification. 380N/A * 2. Redistributions in binary form must reproduce at minimum a disclaimer 380N/A * substantially similar to the "NO WARRANTY" disclaimer below 380N/A * ("Disclaimer") and any redistribution must be conditioned upon 380N/A * including a substantially similar Disclaimer requirement for further 380N/A * binary redistribution. 380N/A * 3. Neither the names of the above-listed copyright holders nor the names 380N/A * of any contributors may be used to endorse or promote products derived 380N/A * from this software without specific prior written permission. 380N/A * Alternatively, this software may be distributed under the terms of the 380N/A * GNU General Public License ("GPL") version 2 as published by the Free 380N/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 380N/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 380N/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 380N/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 380N/A * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 380N/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 380N/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 380N/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 380N/A * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 380N/A * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 380N/A * POSSIBILITY OF SUCH DAMAGES. /******************************************************************************* * FUNCTION: AcpiDmDisasmByteList * PARAMETERS: Level - Current source code indentation level * ByteData - Pointer to the byte list * ByteCount - Length of the byte list * DESCRIPTION: Dump an AML "ByteList" in Hex format. 8 bytes per line, prefixed * with the hex buffer offset. ******************************************************************************/ /* Line indent and offset prefix for each new line */ /* Dump the actual hex values */ /* Add comma if there are more bytes to display */ /* Dump the ASCII equivalents within a comment */ /* Finished with this line */ /******************************************************************************* * FUNCTION: AcpiDmByteList * PARAMETERS: Info - Parse tree walk info * DESCRIPTION: Dump a buffer byte list, handling the various types of buffers. * Buffer type must be already set in the Op DisasmOpcode. ******************************************************************************/ * The byte list belongs to a buffer, and can be produced by either * a ResourceTemplate, Unicode, quoted string, or a plain byte list. * Not a resource, string, or unicode string. /******************************************************************************* * FUNCTION: AcpiDmIsUuidBuffer * PARAMETERS: Op - Buffer Object to be examined * RETURN: TRUE if buffer contains a UUID * DESCRIPTION: Determine if a buffer Op contains a UUID * To help determine whether the buffer is a UUID versus a raw data buffer, * there a are a couple bytes we can look at: * xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx * The variant covered by the UUID specification is indicated by the two most * significant bits of N being 1 0 (i.e., the hexadecimal N will always be * The variant covered by the UUID specification has five versions. For this * variant, the four bits of M indicates the UUID version (i.e., the * hexadecimal M will be either 1, 2, 3, 4, or 5). ******************************************************************************/ /* Buffer size is the buffer argument */ /* Next, the initializer byte list to examine */ /* Extract the byte list info */ /* Byte count must be exactly 16 */ /* Check for valid "M" and "N" values (see function header above) */ if (((
ByteData[
7] &
0xF0) ==
0x00) ||
/* M={1,2,3,4,5} */ ((
ByteData[
8] &
0xF0) <
0x80) ||
/* N={8,9,A,B} */ /* Ignore the Size argument in the disassembly of this buffer op */ /******************************************************************************* * PARAMETERS: Op - Byte List op containing a UUID * DESCRIPTION: Dump a buffer containing a UUID as a standard ASCII string. * In its canonical form, the UUID is represented by a string containing 32 * lowercase hexadecimal digits, displayed in 5 groups separated by hyphens. * The complete form is 8-4-4-4-12 for a total of 36 characters (32 * alphanumeric characters representing hex digits and 4 hyphens). In bytes, * ToUUID ("107ededd-d381-4fd7-8da9-08e9a6c79644") ******************************************************************************/ /* Emit the 36-byte UUID string in the proper format/order */ "\"%2.2x%2.2x%2.2x%2.2x-" "%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\")",
/* Dump the UUID description string if available */ /******************************************************************************* * FUNCTION: AcpiDmIsUnicodeBuffer * PARAMETERS: Op - Buffer Object to be examined * RETURN: TRUE if buffer contains a UNICODE string * DESCRIPTION: Determine if a buffer Op contains a Unicode string ******************************************************************************/ /* Buffer size is the buffer argument */ /* Next, the initializer byte list to examine */ /* Extract the byte list info */ * Unicode string must have an even number of bytes and last /* For each word, 1st byte must be ascii (1-0x7F), 2nd byte must be zero */ /* Ignore the Size argument in the disassembly of this buffer op */ /******************************************************************************* * FUNCTION: AcpiDmIsStringBuffer * PARAMETERS: Op - Buffer Object to be examined * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise * DESCRIPTION: Determine if a buffer Op contains a ASCII string ******************************************************************************/ /* Buffer size is the buffer argument */ /* Next, the initializer byte list to examine */ /* Extract the byte list info */ /* Last byte must be the null terminator */ /* TBD: allow some escapes (non-ascii chars). * they will be handled in the string output routine /******************************************************************************* * FUNCTION: AcpiDmIsPldBuffer * PARAMETERS: Op - Buffer Object to be examined * RETURN: TRUE if buffer contains a ASCII string, FALSE otherwise * DESCRIPTION: Determine if a buffer Op contains a _PLD structure ******************************************************************************/ /* Buffer size is the buffer argument */ /* Check for form: Name(_PLD, Buffer() {}). Not legal, however */ /* Ignore the Size argument in the disassembly of this buffer op */ /* Check for proper form: Name(_PLD, Package() {Buffer() {}}) */ /* Ignore the Size argument in the disassembly of this buffer op */ /******************************************************************************* * FUNCTION: AcpiDmFindNameByIndex * PARAMETERS: Index - Index of array to check * List - Array to reference * RETURN: String from List or empty string * DESCRIPTION: Finds and returns the char string located at the given index ******************************************************************************/ /******************************************************************************* * FUNCTION: AcpiDmPldBuffer * PARAMETERS: Level - Current source code indentation level * ByteData - Pointer to the byte list * ByteCount - Length of the byte list * DESCRIPTION: Dump and format the contents of a _PLD buffer object ******************************************************************************/ /* Check for valid byte count */ /* Convert _PLD buffer to local _PLD struct */ /* Second 32-bit dword */ /* Fourth 32-bit dword */ /******************************************************************************* * FUNCTION: AcpiDmUnicode * PARAMETERS: Op - Byte List op containing Unicode string * DESCRIPTION: Dump Unicode string as a standard ASCII string. (Remove ******************************************************************************/ /* Extract the buffer info as a WORD buffer */ /* Write every other byte as an ASCII character */ /* Handle values that must be escaped */ /******************************************************************************* * FUNCTION: AcpiDmGetHardwareIdType * PARAMETERS: Op - Op to be examined * DESCRIPTION: Determine the type of the argument to a _HID or _CID * 2) If Integer, determine if it is a valid EISAID ******************************************************************************/ /* Mark this string as an _HID/_CID string */ /* Determine if a Word/Dword is a valid encoded EISAID */ /* Swap from little-endian to big-endian to simplify conversion */ /* Create the 3 leading ASCII letters */ /* Verify that all 3 are ascii and alpha */ /* Mark this node as convertable to an EISA ID string */ /******************************************************************************* * FUNCTION: AcpiDmCheckForHardwareId * PARAMETERS: Op - Op to be examined * DESCRIPTION: Determine if a Name() Op is a _HID/_CID. ******************************************************************************/ /* Get the NameSegment */ /* Check for _HID - has one argument */ /* _CID can contain a single argument or a package */ /* _CID with Package: get the package length, check all elements */ /* Don't need to use the length, just walk the peer list */ /******************************************************************************* * FUNCTION: AcpiDmDecompressEisaId * PARAMETERS: EncodedId - Raw encoded EISA ID. * DESCRIPTION: Convert an encoded EISAID back to the original ASCII String * and emit the correct ASL statement. If the ID is known, emit * a description of the ID as a comment. ******************************************************************************/ /* Convert EISAID to a string an emit the statement */ /* If we know about the ID, emit the description */