ReactOS  0.4.14-dev-317-g96040ec
utbuffer.c
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Module Name: utbuffer - Buffer dump routines
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2019, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
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.
25  *
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.
29  *
30  * NO WARRANTY
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.
42  */
43 
44 #include "acpi.h"
45 #include "accommon.h"
46 
47 #define _COMPONENT ACPI_UTILITIES
48  ACPI_MODULE_NAME ("utbuffer")
49 
50 
51 /*******************************************************************************
52  *
53  * FUNCTION: AcpiUtDumpBuffer
54  *
55  * PARAMETERS: Buffer - Buffer to dump
56  * Count - Amount to dump, in bytes
57  * Display - BYTE, WORD, DWORD, or QWORD display:
58  * DB_BYTE_DISPLAY
59  * DB_WORD_DISPLAY
60  * DB_DWORD_DISPLAY
61  * DB_QWORD_DISPLAY
62  * BaseOffset - Beginning buffer offset (display only)
63  *
64  * RETURN: None
65  *
66  * DESCRIPTION: Generic dump buffer in both hex and ascii.
67  *
68  ******************************************************************************/
69 
70 void
72  UINT8 *Buffer,
73  UINT32 Count,
75  UINT32 BaseOffset)
76 {
77  UINT32 i = 0;
78  UINT32 j;
79  UINT32 Temp32;
80  UINT8 BufChar;
81 
82 
83  if (!Buffer)
84  {
85  AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
86  return;
87  }
88 
89  if ((Count < 4) || (Count & 0x01))
90  {
92  }
93 
94  /* Nasty little dump buffer routine! */
95 
96  while (i < Count)
97  {
98  /* Print current offset */
99 
100  AcpiOsPrintf ("%8.4X: ", (BaseOffset + i));
101 
102  /* Print 16 hex chars */
103 
104  for (j = 0; j < 16;)
105  {
106  if (i + j >= Count)
107  {
108  /* Dump fill spaces */
109 
110  AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
111  j += Display;
112  continue;
113  }
114 
115  switch (Display)
116  {
117  case DB_BYTE_DISPLAY:
118  default: /* Default is BYTE display */
119 
120  AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
121  break;
122 
123  case DB_WORD_DISPLAY:
124 
125  ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
126  AcpiOsPrintf ("%04X ", Temp32);
127  break;
128 
129  case DB_DWORD_DISPLAY:
130 
131  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
132  AcpiOsPrintf ("%08X ", Temp32);
133  break;
134 
135  case DB_QWORD_DISPLAY:
136 
137  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
138  AcpiOsPrintf ("%08X", Temp32);
139 
140  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
141  AcpiOsPrintf ("%08X ", Temp32);
142  break;
143  }
144 
145  j += Display;
146  }
147 
148  /*
149  * Print the ASCII equivalent characters but watch out for the bad
150  * unprintable ones (printable chars are 0x20 through 0x7E)
151  */
152  AcpiOsPrintf (" ");
153  for (j = 0; j < 16; j++)
154  {
155  if (i + j >= Count)
156  {
157  AcpiOsPrintf ("\n");
158  return;
159  }
160 
161  /*
162  * Add comment characters so rest of line is ignored when
163  * compiled
164  */
165  if (j == 0)
166  {
167  AcpiOsPrintf ("// ");
168  }
169 
170  BufChar = Buffer[(ACPI_SIZE) i + j];
171  if (isprint (BufChar))
172  {
173  AcpiOsPrintf ("%c", BufChar);
174  }
175  else
176  {
177  AcpiOsPrintf (".");
178  }
179  }
180 
181  /* Done with that line. */
182 
183  AcpiOsPrintf ("\n");
184  i += 16;
185  }
186 
187  return;
188 }
189 
190 
191 /*******************************************************************************
192  *
193  * FUNCTION: AcpiUtDebugDumpBuffer
194  *
195  * PARAMETERS: Buffer - Buffer to dump
196  * Count - Amount to dump, in bytes
197  * Display - BYTE, WORD, DWORD, or QWORD display:
198  * DB_BYTE_DISPLAY
199  * DB_WORD_DISPLAY
200  * DB_DWORD_DISPLAY
201  * DB_QWORD_DISPLAY
202  * ComponentID - Caller's component ID
203  *
204  * RETURN: None
205  *
206  * DESCRIPTION: Generic dump buffer in both hex and ascii.
207  *
208  ******************************************************************************/
209 
210 void
212  UINT8 *Buffer,
213  UINT32 Count,
214  UINT32 Display,
216 {
217 
218  /* Only dump the buffer if tracing is enabled */
219 
220  if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
221  (ComponentId & AcpiDbgLayer)))
222  {
223  return;
224  }
225 
227 }
228 
229 
230 #ifdef ACPI_APPLICATION
231 /*******************************************************************************
232  *
233  * FUNCTION: AcpiUtDumpBufferToFile
234  *
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:
239  * DB_BYTE_DISPLAY
240  * DB_WORD_DISPLAY
241  * DB_DWORD_DISPLAY
242  * DB_QWORD_DISPLAY
243  * BaseOffset - Beginning buffer offset (display only)
244  *
245  * RETURN: None
246  *
247  * DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
248  *
249  ******************************************************************************/
250 
251 void
252 AcpiUtDumpBufferToFile (
253  ACPI_FILE File,
254  UINT8 *Buffer,
255  UINT32 Count,
256  UINT32 Display,
257  UINT32 BaseOffset)
258 {
259  UINT32 i = 0;
260  UINT32 j;
261  UINT32 Temp32;
262  UINT8 BufChar;
263 
264 
265  if (!Buffer)
266  {
267  fprintf (File, "Null Buffer Pointer in DumpBuffer!\n");
268  return;
269  }
270 
271  if ((Count < 4) || (Count & 0x01))
272  {
274  }
275 
276  /* Nasty little dump buffer routine! */
277 
278  while (i < Count)
279  {
280  /* Print current offset */
281 
282  fprintf (File, "%8.4X: ", (BaseOffset + i));
283 
284  /* Print 16 hex chars */
285 
286  for (j = 0; j < 16;)
287  {
288  if (i + j >= Count)
289  {
290  /* Dump fill spaces */
291 
292  fprintf (File, "%*s", ((Display * 2) + 1), " ");
293  j += Display;
294  continue;
295  }
296 
297  switch (Display)
298  {
299  case DB_BYTE_DISPLAY:
300  default: /* Default is BYTE display */
301 
302  fprintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]);
303  break;
304 
305  case DB_WORD_DISPLAY:
306 
307  ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
308  fprintf (File, "%04X ", Temp32);
309  break;
310 
311  case DB_DWORD_DISPLAY:
312 
313  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
314  fprintf (File, "%08X ", Temp32);
315  break;
316 
317  case DB_QWORD_DISPLAY:
318 
319  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
320  fprintf (File, "%08X", Temp32);
321 
322  ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
323  fprintf (File, "%08X ", Temp32);
324  break;
325  }
326 
327  j += Display;
328  }
329 
330  /*
331  * Print the ASCII equivalent characters but watch out for the bad
332  * unprintable ones (printable chars are 0x20 through 0x7E)
333  */
334  fprintf (File, " ");
335  for (j = 0; j < 16; j++)
336  {
337  if (i + j >= Count)
338  {
339  fprintf (File, "\n");
340  return;
341  }
342 
343  BufChar = Buffer[(ACPI_SIZE) i + j];
344  if (isprint (BufChar))
345  {
346  fprintf (File, "%c", BufChar);
347  }
348  else
349  {
350  fprintf (File, ".");
351  }
352  }
353 
354  /* Done with that line. */
355 
356  fprintf (File, "\n");
357  i += 16;
358  }
359 
360  return;
361 }
362 #endif
#define ACPI_LV_TABLES
Definition: acoutput.h:105
#define DB_QWORD_DISPLAY
Definition: acutils.h:188
#define DB_WORD_DISPLAY
Definition: acutils.h:186
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
void AcpiUtDumpBuffer(UINT8 *Buffer, UINT32 Count, UINT32 Display, UINT32 BaseOffset)
Definition: utbuffer.c:71
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char UINT32 ComponentId
Definition: acpixf.h:1264
#define DB_DWORD_DISPLAY
Definition: acutils.h:187
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define DB_BYTE_DISPLAY
Definition: acutils.h:185
unsigned int UINT32
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define ACPI_MODULE_NAME(Name)
Definition: acoutput.h:216
Definition: bufpool.h:45
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
void AcpiUtDebugDumpBuffer(UINT8 *Buffer, UINT32 Count, UINT32 Display, UINT32 ComponentId)
Definition: utbuffer.c:211
void ACPI_INTERNAL_VAR_XFACE AcpiOsPrintf(const char *Format,...)
Definition: osl.c:851
#define ACPI_MOVE_32_TO_32(d, s)
Definition: acmacros.h:148
#define ACPI_FILE
Definition: acenv.h:389
#define isprint(c)
Definition: acclib.h:73
int Display
Definition: x11stubs.h:25
Definition: File.h:15
unsigned char UINT8
#define ACPI_MOVE_16_TO_32(d, s)
Definition: acmacros.h:142