1 /******************************************************************************
3 * Module Name: utbuffer - Buffer dump routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2014, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
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.
44 #define __UTBUFFER_C__
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utbuffer")
53 /*******************************************************************************
55 * FUNCTION: AcpiUtDumpBuffer
57 * PARAMETERS: Buffer - Buffer to dump
58 * Count - Amount to dump, in bytes
59 * Display - BYTE, WORD, DWORD, or QWORD display:
64 * BaseOffset - Beginning buffer offset (display only)
68 * DESCRIPTION: Generic dump buffer in both hex and ascii.
70 ******************************************************************************/
87 AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
91 if ((Count < 4) || (Count & 0x01))
93 Display = DB_BYTE_DISPLAY;
96 /* Nasty little dump buffer routine! */
100 /* Print current offset */
102 AcpiOsPrintf ("%6.4X: ", (BaseOffset + i));
104 /* Print 16 hex chars */
110 /* Dump fill spaces */
112 AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
119 case DB_BYTE_DISPLAY:
120 default: /* Default is BYTE display */
122 AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
125 case DB_WORD_DISPLAY:
127 ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
128 AcpiOsPrintf ("%04X ", Temp32);
131 case DB_DWORD_DISPLAY:
133 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
134 AcpiOsPrintf ("%08X ", Temp32);
137 case DB_QWORD_DISPLAY:
139 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
140 AcpiOsPrintf ("%08X", Temp32);
142 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
143 AcpiOsPrintf ("%08X ", Temp32);
151 * Print the ASCII equivalent characters but watch out for the bad
152 * unprintable ones (printable chars are 0x20 through 0x7E)
155 for (j = 0; j < 16; j++)
163 BufChar = Buffer[(ACPI_SIZE) i + j];
164 if (ACPI_IS_PRINT (BufChar))
166 AcpiOsPrintf ("%c", BufChar);
174 /* Done with that line. */
184 /*******************************************************************************
186 * FUNCTION: AcpiUtDebugDumpBuffer
188 * PARAMETERS: Buffer - Buffer to dump
189 * Count - Amount to dump, in bytes
190 * Display - BYTE, WORD, DWORD, or QWORD display:
195 * ComponentID - Caller's component ID
199 * DESCRIPTION: Generic dump buffer in both hex and ascii.
201 ******************************************************************************/
204 AcpiUtDebugDumpBuffer (
211 /* Only dump the buffer if tracing is enabled */
213 if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
214 (ComponentId & AcpiDbgLayer)))
219 AcpiUtDumpBuffer (Buffer, Count, Display, 0);