1 /******************************************************************************
3 * Module Name: utbuffer - Buffer dump routines
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, 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.
47 #define _COMPONENT ACPI_UTILITIES
48 ACPI_MODULE_NAME ("utbuffer")
51 /*******************************************************************************
53 * FUNCTION: AcpiUtDumpBuffer
55 * PARAMETERS: Buffer - Buffer to dump
56 * Count - Amount to dump, in bytes
57 * Display - BYTE, WORD, DWORD, or QWORD display:
62 * BaseOffset - Beginning buffer offset (display only)
66 * DESCRIPTION: Generic dump buffer in both hex and ascii.
68 ******************************************************************************/
85 AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
89 if ((Count
< 4) || (Count
& 0x01))
91 Display
= DB_BYTE_DISPLAY
;
94 /* Nasty little dump buffer routine! */
98 /* Print current offset */
100 AcpiOsPrintf ("%7.4X: ", (BaseOffset
+ i
));
102 /* Print 16 hex chars */
108 /* Dump fill spaces */
110 AcpiOsPrintf ("%*s", ((Display
* 2) + 1), " ");
117 case DB_BYTE_DISPLAY
:
118 default: /* Default is BYTE display */
120 AcpiOsPrintf ("%02X ", Buffer
[(ACPI_SIZE
) i
+ j
]);
123 case DB_WORD_DISPLAY
:
125 ACPI_MOVE_16_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
126 AcpiOsPrintf ("%04X ", Temp32
);
129 case DB_DWORD_DISPLAY
:
131 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
132 AcpiOsPrintf ("%08X ", Temp32
);
135 case DB_QWORD_DISPLAY
:
137 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
138 AcpiOsPrintf ("%08X", Temp32
);
140 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
+ 4]);
141 AcpiOsPrintf ("%08X ", Temp32
);
149 * Print the ASCII equivalent characters but watch out for the bad
150 * unprintable ones (printable chars are 0x20 through 0x7E)
153 for (j
= 0; j
< 16; j
++)
162 * Add comment characters so rest of line is ignored when
167 AcpiOsPrintf ("// ");
170 BufChar
= Buffer
[(ACPI_SIZE
) i
+ j
];
171 if (isprint (BufChar
))
173 AcpiOsPrintf ("%c", BufChar
);
181 /* Done with that line. */
191 /*******************************************************************************
193 * FUNCTION: AcpiUtDebugDumpBuffer
195 * PARAMETERS: Buffer - Buffer to dump
196 * Count - Amount to dump, in bytes
197 * Display - BYTE, WORD, DWORD, or QWORD display:
202 * ComponentID - Caller's component ID
206 * DESCRIPTION: Generic dump buffer in both hex and ascii.
208 ******************************************************************************/
211 AcpiUtDebugDumpBuffer (
218 /* Only dump the buffer if tracing is enabled */
220 if (!((ACPI_LV_TABLES
& AcpiDbgLevel
) &&
221 (ComponentId
& AcpiDbgLayer
)))
226 AcpiUtDumpBuffer (Buffer
, Count
, Display
, 0);
230 #ifdef ACPI_APPLICATION
231 /*******************************************************************************
233 * FUNCTION: AcpiUtDumpBufferToFile
235 * PARAMETERS: File - File descriptor
236 * Buffer - Buffer to dump
237 * Count - Amount to dump, in bytes
238 * Display - BYTE, WORD, DWORD, or QWORD display:
243 * BaseOffset - Beginning buffer offset (display only)
247 * DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
249 ******************************************************************************/
252 AcpiUtDumpBufferToFile (
267 AcpiUtFilePrintf (File
, "Null Buffer Pointer in DumpBuffer!\n");
271 if ((Count
< 4) || (Count
& 0x01))
273 Display
= DB_BYTE_DISPLAY
;
276 /* Nasty little dump buffer routine! */
280 /* Print current offset */
282 AcpiUtFilePrintf (File
, "%7.4X: ", (BaseOffset
+ i
));
284 /* Print 16 hex chars */
290 /* Dump fill spaces */
292 AcpiUtFilePrintf (File
, "%*s", ((Display
* 2) + 1), " ");
299 case DB_BYTE_DISPLAY
:
300 default: /* Default is BYTE display */
302 AcpiUtFilePrintf (File
, "%02X ", Buffer
[(ACPI_SIZE
) i
+ j
]);
305 case DB_WORD_DISPLAY
:
307 ACPI_MOVE_16_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
308 AcpiUtFilePrintf (File
, "%04X ", Temp32
);
311 case DB_DWORD_DISPLAY
:
313 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
314 AcpiUtFilePrintf (File
, "%08X ", Temp32
);
317 case DB_QWORD_DISPLAY
:
319 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
]);
320 AcpiUtFilePrintf (File
, "%08X", Temp32
);
322 ACPI_MOVE_32_TO_32 (&Temp32
, &Buffer
[(ACPI_SIZE
) i
+ j
+ 4]);
323 AcpiUtFilePrintf (File
, "%08X ", Temp32
);
331 * Print the ASCII equivalent characters but watch out for the bad
332 * unprintable ones (printable chars are 0x20 through 0x7E)
334 AcpiUtFilePrintf (File
, " ");
335 for (j
= 0; j
< 16; j
++)
339 AcpiUtFilePrintf (File
, "\n");
343 BufChar
= Buffer
[(ACPI_SIZE
) i
+ j
];
344 if (isprint (BufChar
))
346 AcpiUtFilePrintf (File
, "%c", BufChar
);
350 AcpiUtFilePrintf (File
, ".");
354 /* Done with that line. */
356 AcpiUtFilePrintf (File
, "\n");