aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/utbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/acpica/utbuffer.c')
-rw-r--r--drivers/acpi/acpica/utbuffer.c128
1 files changed, 128 insertions, 0 deletions
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c
index 3c1699740653..038ea887f562 100644
--- a/drivers/acpi/acpica/utbuffer.c
+++ b/drivers/acpi/acpica/utbuffer.c
@@ -199,3 +199,131 @@ acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id)
199 199
200 acpi_ut_dump_buffer(buffer, count, display, 0); 200 acpi_ut_dump_buffer(buffer, count, display, 0);
201} 201}
202
203#ifdef ACPI_APPLICATION
204/*******************************************************************************
205 *
206 * FUNCTION: acpi_ut_dump_buffer_to_file
207 *
208 * PARAMETERS: file - File descriptor
209 * buffer - Buffer to dump
210 * count - Amount to dump, in bytes
211 * display - BYTE, WORD, DWORD, or QWORD display:
212 * DB_BYTE_DISPLAY
213 * DB_WORD_DISPLAY
214 * DB_DWORD_DISPLAY
215 * DB_QWORD_DISPLAY
216 * base_offset - Beginning buffer offset (display only)
217 *
218 * RETURN: None
219 *
220 * DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
221 *
222 ******************************************************************************/
223
224void
225acpi_ut_dump_buffer_to_file(ACPI_FILE file,
226 u8 *buffer, u32 count, u32 display, u32 base_offset)
227{
228 u32 i = 0;
229 u32 j;
230 u32 temp32;
231 u8 buf_char;
232
233 if (!buffer) {
234 acpi_ut_file_printf(file,
235 "Null Buffer Pointer in DumpBuffer!\n");
236 return;
237 }
238
239 if ((count < 4) || (count & 0x01)) {
240 display = DB_BYTE_DISPLAY;
241 }
242
243 /* Nasty little dump buffer routine! */
244
245 while (i < count) {
246
247 /* Print current offset */
248
249 acpi_ut_file_printf(file, "%6.4X: ", (base_offset + i));
250
251 /* Print 16 hex chars */
252
253 for (j = 0; j < 16;) {
254 if (i + j >= count) {
255
256 /* Dump fill spaces */
257
258 acpi_ut_file_printf(file, "%*s",
259 ((display * 2) + 1), " ");
260 j += display;
261 continue;
262 }
263
264 switch (display) {
265 case DB_BYTE_DISPLAY:
266 default: /* Default is BYTE display */
267
268 acpi_ut_file_printf(file, "%02X ",
269 buffer[(acpi_size) i + j]);
270 break;
271
272 case DB_WORD_DISPLAY:
273
274 ACPI_MOVE_16_TO_32(&temp32,
275 &buffer[(acpi_size) i + j]);
276 acpi_ut_file_printf(file, "%04X ", temp32);
277 break;
278
279 case DB_DWORD_DISPLAY:
280
281 ACPI_MOVE_32_TO_32(&temp32,
282 &buffer[(acpi_size) i + j]);
283 acpi_ut_file_printf(file, "%08X ", temp32);
284 break;
285
286 case DB_QWORD_DISPLAY:
287
288 ACPI_MOVE_32_TO_32(&temp32,
289 &buffer[(acpi_size) i + j]);
290 acpi_ut_file_printf(file, "%08X", temp32);
291
292 ACPI_MOVE_32_TO_32(&temp32,
293 &buffer[(acpi_size) i + j +
294 4]);
295 acpi_ut_file_printf(file, "%08X ", temp32);
296 break;
297 }
298
299 j += display;
300 }
301
302 /*
303 * Print the ASCII equivalent characters but watch out for the bad
304 * unprintable ones (printable chars are 0x20 through 0x7E)
305 */
306 acpi_ut_file_printf(file, " ");
307 for (j = 0; j < 16; j++) {
308 if (i + j >= count) {
309 acpi_ut_file_printf(file, "\n");
310 return;
311 }
312
313 buf_char = buffer[(acpi_size) i + j];
314 if (ACPI_IS_PRINT(buf_char)) {
315 acpi_ut_file_printf(file, "%c", buf_char);
316 } else {
317 acpi_ut_file_printf(file, ".");
318 }
319 }
320
321 /* Done with that line. */
322
323 acpi_ut_file_printf(file, "\n");
324 i += 16;
325 }
326
327 return;
328}
329#endif