utbuffer.c revision 1.1.1.1.10.2 1 1.1.1.1.10.2 tls /******************************************************************************
2 1.1.1.1.10.2 tls *
3 1.1.1.1.10.2 tls * Module Name: utbuffer - Buffer dump routines
4 1.1.1.1.10.2 tls *
5 1.1.1.1.10.2 tls *****************************************************************************/
6 1.1.1.1.10.2 tls
7 1.1.1.1.10.2 tls /*
8 1.1.1.1.10.2 tls * Copyright (C) 2000 - 2013, Intel Corp.
9 1.1.1.1.10.2 tls * All rights reserved.
10 1.1.1.1.10.2 tls *
11 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
12 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
13 1.1.1.1.10.2 tls * are met:
14 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions, and the following disclaimer,
16 1.1.1.1.10.2 tls * without modification.
17 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.1.1.1.10.2 tls * substantially similar to the "NO WARRANTY" disclaimer below
19 1.1.1.1.10.2 tls * ("Disclaimer") and any redistribution must be conditioned upon
20 1.1.1.1.10.2 tls * including a substantially similar Disclaimer requirement for further
21 1.1.1.1.10.2 tls * binary redistribution.
22 1.1.1.1.10.2 tls * 3. Neither the names of the above-listed copyright holders nor the names
23 1.1.1.1.10.2 tls * of any contributors may be used to endorse or promote products derived
24 1.1.1.1.10.2 tls * from this software without specific prior written permission.
25 1.1.1.1.10.2 tls *
26 1.1.1.1.10.2 tls * Alternatively, this software may be distributed under the terms of the
27 1.1.1.1.10.2 tls * GNU General Public License ("GPL") version 2 as published by the Free
28 1.1.1.1.10.2 tls * Software Foundation.
29 1.1.1.1.10.2 tls *
30 1.1.1.1.10.2 tls * NO WARRANTY
31 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.1.1.1.10.2 tls * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.1.1.1.10.2 tls * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.1.1.1.10.2 tls * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.1.1.1.10.2 tls * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.1.1.1.10.2 tls * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.1.1.1.10.2 tls * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.1.1.1.10.2 tls * POSSIBILITY OF SUCH DAMAGES.
42 1.1.1.1.10.2 tls */
43 1.1.1.1.10.2 tls
44 1.1.1.1.10.2 tls #define __UTBUFFER_C__
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls #include "acpi.h"
47 1.1.1.1.10.2 tls #include "accommon.h"
48 1.1.1.1.10.2 tls
49 1.1.1.1.10.2 tls #define _COMPONENT ACPI_UTILITIES
50 1.1.1.1.10.2 tls ACPI_MODULE_NAME ("utbuffer")
51 1.1.1.1.10.2 tls
52 1.1.1.1.10.2 tls
53 1.1.1.1.10.2 tls /*******************************************************************************
54 1.1.1.1.10.2 tls *
55 1.1.1.1.10.2 tls * FUNCTION: AcpiUtDumpBuffer
56 1.1.1.1.10.2 tls *
57 1.1.1.1.10.2 tls * PARAMETERS: Buffer - Buffer to dump
58 1.1.1.1.10.2 tls * Count - Amount to dump, in bytes
59 1.1.1.1.10.2 tls * Display - BYTE, WORD, DWORD, or QWORD display:
60 1.1.1.1.10.2 tls * DB_BYTE_DISPLAY
61 1.1.1.1.10.2 tls * DB_WORD_DISPLAY
62 1.1.1.1.10.2 tls * DB_DWORD_DISPLAY
63 1.1.1.1.10.2 tls * DB_QWORD_DISPLAY
64 1.1.1.1.10.2 tls * BaseOffset - Beginning buffer offset (display only)
65 1.1.1.1.10.2 tls *
66 1.1.1.1.10.2 tls * RETURN: None
67 1.1.1.1.10.2 tls *
68 1.1.1.1.10.2 tls * DESCRIPTION: Generic dump buffer in both hex and ascii.
69 1.1.1.1.10.2 tls *
70 1.1.1.1.10.2 tls ******************************************************************************/
71 1.1.1.1.10.2 tls
72 1.1.1.1.10.2 tls void
73 1.1.1.1.10.2 tls AcpiUtDumpBuffer (
74 1.1.1.1.10.2 tls UINT8 *Buffer,
75 1.1.1.1.10.2 tls UINT32 Count,
76 1.1.1.1.10.2 tls UINT32 Display,
77 1.1.1.1.10.2 tls UINT32 BaseOffset)
78 1.1.1.1.10.2 tls {
79 1.1.1.1.10.2 tls UINT32 i = 0;
80 1.1.1.1.10.2 tls UINT32 j;
81 1.1.1.1.10.2 tls UINT32 Temp32;
82 1.1.1.1.10.2 tls UINT8 BufChar;
83 1.1.1.1.10.2 tls
84 1.1.1.1.10.2 tls
85 1.1.1.1.10.2 tls if (!Buffer)
86 1.1.1.1.10.2 tls {
87 1.1.1.1.10.2 tls AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
88 1.1.1.1.10.2 tls return;
89 1.1.1.1.10.2 tls }
90 1.1.1.1.10.2 tls
91 1.1.1.1.10.2 tls if ((Count < 4) || (Count & 0x01))
92 1.1.1.1.10.2 tls {
93 1.1.1.1.10.2 tls Display = DB_BYTE_DISPLAY;
94 1.1.1.1.10.2 tls }
95 1.1.1.1.10.2 tls
96 1.1.1.1.10.2 tls /* Nasty little dump buffer routine! */
97 1.1.1.1.10.2 tls
98 1.1.1.1.10.2 tls while (i < Count)
99 1.1.1.1.10.2 tls {
100 1.1.1.1.10.2 tls /* Print current offset */
101 1.1.1.1.10.2 tls
102 1.1.1.1.10.2 tls AcpiOsPrintf ("%6.4X: ", (BaseOffset + i));
103 1.1.1.1.10.2 tls
104 1.1.1.1.10.2 tls /* Print 16 hex chars */
105 1.1.1.1.10.2 tls
106 1.1.1.1.10.2 tls for (j = 0; j < 16;)
107 1.1.1.1.10.2 tls {
108 1.1.1.1.10.2 tls if (i + j >= Count)
109 1.1.1.1.10.2 tls {
110 1.1.1.1.10.2 tls /* Dump fill spaces */
111 1.1.1.1.10.2 tls
112 1.1.1.1.10.2 tls AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
113 1.1.1.1.10.2 tls j += Display;
114 1.1.1.1.10.2 tls continue;
115 1.1.1.1.10.2 tls }
116 1.1.1.1.10.2 tls
117 1.1.1.1.10.2 tls switch (Display)
118 1.1.1.1.10.2 tls {
119 1.1.1.1.10.2 tls case DB_BYTE_DISPLAY:
120 1.1.1.1.10.2 tls default: /* Default is BYTE display */
121 1.1.1.1.10.2 tls
122 1.1.1.1.10.2 tls AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
123 1.1.1.1.10.2 tls break;
124 1.1.1.1.10.2 tls
125 1.1.1.1.10.2 tls case DB_WORD_DISPLAY:
126 1.1.1.1.10.2 tls
127 1.1.1.1.10.2 tls ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
128 1.1.1.1.10.2 tls AcpiOsPrintf ("%04X ", Temp32);
129 1.1.1.1.10.2 tls break;
130 1.1.1.1.10.2 tls
131 1.1.1.1.10.2 tls case DB_DWORD_DISPLAY:
132 1.1.1.1.10.2 tls
133 1.1.1.1.10.2 tls ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
134 1.1.1.1.10.2 tls AcpiOsPrintf ("%08X ", Temp32);
135 1.1.1.1.10.2 tls break;
136 1.1.1.1.10.2 tls
137 1.1.1.1.10.2 tls case DB_QWORD_DISPLAY:
138 1.1.1.1.10.2 tls
139 1.1.1.1.10.2 tls ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
140 1.1.1.1.10.2 tls AcpiOsPrintf ("%08X", Temp32);
141 1.1.1.1.10.2 tls
142 1.1.1.1.10.2 tls ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
143 1.1.1.1.10.2 tls AcpiOsPrintf ("%08X ", Temp32);
144 1.1.1.1.10.2 tls break;
145 1.1.1.1.10.2 tls }
146 1.1.1.1.10.2 tls
147 1.1.1.1.10.2 tls j += Display;
148 1.1.1.1.10.2 tls }
149 1.1.1.1.10.2 tls
150 1.1.1.1.10.2 tls /*
151 1.1.1.1.10.2 tls * Print the ASCII equivalent characters but watch out for the bad
152 1.1.1.1.10.2 tls * unprintable ones (printable chars are 0x20 through 0x7E)
153 1.1.1.1.10.2 tls */
154 1.1.1.1.10.2 tls AcpiOsPrintf (" ");
155 1.1.1.1.10.2 tls for (j = 0; j < 16; j++)
156 1.1.1.1.10.2 tls {
157 1.1.1.1.10.2 tls if (i + j >= Count)
158 1.1.1.1.10.2 tls {
159 1.1.1.1.10.2 tls AcpiOsPrintf ("\n");
160 1.1.1.1.10.2 tls return;
161 1.1.1.1.10.2 tls }
162 1.1.1.1.10.2 tls
163 1.1.1.1.10.2 tls BufChar = Buffer[(ACPI_SIZE) i + j];
164 1.1.1.1.10.2 tls if (ACPI_IS_PRINT (BufChar))
165 1.1.1.1.10.2 tls {
166 1.1.1.1.10.2 tls AcpiOsPrintf ("%c", BufChar);
167 1.1.1.1.10.2 tls }
168 1.1.1.1.10.2 tls else
169 1.1.1.1.10.2 tls {
170 1.1.1.1.10.2 tls AcpiOsPrintf (".");
171 1.1.1.1.10.2 tls }
172 1.1.1.1.10.2 tls }
173 1.1.1.1.10.2 tls
174 1.1.1.1.10.2 tls /* Done with that line. */
175 1.1.1.1.10.2 tls
176 1.1.1.1.10.2 tls AcpiOsPrintf ("\n");
177 1.1.1.1.10.2 tls i += 16;
178 1.1.1.1.10.2 tls }
179 1.1.1.1.10.2 tls
180 1.1.1.1.10.2 tls return;
181 1.1.1.1.10.2 tls }
182 1.1.1.1.10.2 tls
183 1.1.1.1.10.2 tls
184 1.1.1.1.10.2 tls /*******************************************************************************
185 1.1.1.1.10.2 tls *
186 1.1.1.1.10.2 tls * FUNCTION: AcpiUtDebugDumpBuffer
187 1.1.1.1.10.2 tls *
188 1.1.1.1.10.2 tls * PARAMETERS: Buffer - Buffer to dump
189 1.1.1.1.10.2 tls * Count - Amount to dump, in bytes
190 1.1.1.1.10.2 tls * Display - BYTE, WORD, DWORD, or QWORD display:
191 1.1.1.1.10.2 tls * DB_BYTE_DISPLAY
192 1.1.1.1.10.2 tls * DB_WORD_DISPLAY
193 1.1.1.1.10.2 tls * DB_DWORD_DISPLAY
194 1.1.1.1.10.2 tls * DB_QWORD_DISPLAY
195 1.1.1.1.10.2 tls * ComponentID - Caller's component ID
196 1.1.1.1.10.2 tls *
197 1.1.1.1.10.2 tls * RETURN: None
198 1.1.1.1.10.2 tls *
199 1.1.1.1.10.2 tls * DESCRIPTION: Generic dump buffer in both hex and ascii.
200 1.1.1.1.10.2 tls *
201 1.1.1.1.10.2 tls ******************************************************************************/
202 1.1.1.1.10.2 tls
203 1.1.1.1.10.2 tls void
204 1.1.1.1.10.2 tls AcpiUtDebugDumpBuffer (
205 1.1.1.1.10.2 tls UINT8 *Buffer,
206 1.1.1.1.10.2 tls UINT32 Count,
207 1.1.1.1.10.2 tls UINT32 Display,
208 1.1.1.1.10.2 tls UINT32 ComponentId)
209 1.1.1.1.10.2 tls {
210 1.1.1.1.10.2 tls
211 1.1.1.1.10.2 tls /* Only dump the buffer if tracing is enabled */
212 1.1.1.1.10.2 tls
213 1.1.1.1.10.2 tls if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
214 1.1.1.1.10.2 tls (ComponentId & AcpiDbgLayer)))
215 1.1.1.1.10.2 tls {
216 1.1.1.1.10.2 tls return;
217 1.1.1.1.10.2 tls }
218 1.1.1.1.10.2 tls
219 1.1.1.1.10.2 tls AcpiUtDumpBuffer (Buffer, Count, Display, 0);
220 1.1.1.1.10.2 tls }
221