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