1c70258b7SJérôme Duval /******************************************************************************
2c70258b7SJérôme Duval *
3c70258b7SJérôme Duval * Module Name: utbuffer - Buffer dump routines
4c70258b7SJérôme Duval *
5c70258b7SJérôme Duval *****************************************************************************/
6c70258b7SJérôme Duval
7c70258b7SJérôme Duval /******************************************************************************
8c70258b7SJérôme Duval *
9c70258b7SJérôme Duval * 1. Copyright Notice
10c70258b7SJérôme Duval *
11*6dde014fSPulkoMandy * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
12c70258b7SJérôme Duval * All rights reserved.
13c70258b7SJérôme Duval *
14c70258b7SJérôme Duval * 2. License
15c70258b7SJérôme Duval *
16c70258b7SJérôme Duval * 2.1. This is your license from Intel Corp. under its intellectual property
17c70258b7SJérôme Duval * rights. You may have additional license terms from the party that provided
18c70258b7SJérôme Duval * you this software, covering your right to use that party's intellectual
19c70258b7SJérôme Duval * property rights.
20c70258b7SJérôme Duval *
21c70258b7SJérôme Duval * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22c70258b7SJérôme Duval * copy of the source code appearing in this file ("Covered Code") an
23c70258b7SJérôme Duval * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24c70258b7SJérôme Duval * base code distributed originally by Intel ("Original Intel Code") to copy,
25c70258b7SJérôme Duval * make derivatives, distribute, use and display any portion of the Covered
26c70258b7SJérôme Duval * Code in any form, with the right to sublicense such rights; and
27c70258b7SJérôme Duval *
28c70258b7SJérôme Duval * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29c70258b7SJérôme Duval * license (with the right to sublicense), under only those claims of Intel
30c70258b7SJérôme Duval * patents that are infringed by the Original Intel Code, to make, use, sell,
31c70258b7SJérôme Duval * offer to sell, and import the Covered Code and derivative works thereof
32c70258b7SJérôme Duval * solely to the minimum extent necessary to exercise the above copyright
33c70258b7SJérôme Duval * license, and in no event shall the patent license extend to any additions
34c70258b7SJérôme Duval * to or modifications of the Original Intel Code. No other license or right
35c70258b7SJérôme Duval * is granted directly or by implication, estoppel or otherwise;
36c70258b7SJérôme Duval *
37c70258b7SJérôme Duval * The above copyright and patent license is granted only if the following
38c70258b7SJérôme Duval * conditions are met:
39c70258b7SJérôme Duval *
40c70258b7SJérôme Duval * 3. Conditions
41c70258b7SJérôme Duval *
42c70258b7SJérôme Duval * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43c70258b7SJérôme Duval * Redistribution of source code of any substantial portion of the Covered
44c70258b7SJérôme Duval * Code or modification with rights to further distribute source must include
45c70258b7SJérôme Duval * the above Copyright Notice, the above License, this list of Conditions,
46c70258b7SJérôme Duval * and the following Disclaimer and Export Compliance provision. In addition,
47c70258b7SJérôme Duval * Licensee must cause all Covered Code to which Licensee contributes to
48c70258b7SJérôme Duval * contain a file documenting the changes Licensee made to create that Covered
49c70258b7SJérôme Duval * Code and the date of any change. Licensee must include in that file the
50c70258b7SJérôme Duval * documentation of any changes made by any predecessor Licensee. Licensee
51c70258b7SJérôme Duval * must include a prominent statement that the modification is derived,
52c70258b7SJérôme Duval * directly or indirectly, from Original Intel Code.
53c70258b7SJérôme Duval *
54c70258b7SJérôme Duval * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55c70258b7SJérôme Duval * Redistribution of source code of any substantial portion of the Covered
56c70258b7SJérôme Duval * Code or modification without rights to further distribute source must
57c70258b7SJérôme Duval * include the following Disclaimer and Export Compliance provision in the
58c70258b7SJérôme Duval * documentation and/or other materials provided with distribution. In
59c70258b7SJérôme Duval * addition, Licensee may not authorize further sublicense of source of any
60c70258b7SJérôme Duval * portion of the Covered Code, and must include terms to the effect that the
61c70258b7SJérôme Duval * license from Licensee to its licensee is limited to the intellectual
62c70258b7SJérôme Duval * property embodied in the software Licensee provides to its licensee, and
63c70258b7SJérôme Duval * not to intellectual property embodied in modifications its licensee may
64c70258b7SJérôme Duval * make.
65c70258b7SJérôme Duval *
66c70258b7SJérôme Duval * 3.3. Redistribution of Executable. Redistribution in executable form of any
67c70258b7SJérôme Duval * substantial portion of the Covered Code or modification must reproduce the
68c70258b7SJérôme Duval * above Copyright Notice, and the following Disclaimer and Export Compliance
69c70258b7SJérôme Duval * provision in the documentation and/or other materials provided with the
70c70258b7SJérôme Duval * distribution.
71c70258b7SJérôme Duval *
72c70258b7SJérôme Duval * 3.4. Intel retains all right, title, and interest in and to the Original
73c70258b7SJérôme Duval * Intel Code.
74c70258b7SJérôme Duval *
75c70258b7SJérôme Duval * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76c70258b7SJérôme Duval * Intel shall be used in advertising or otherwise to promote the sale, use or
77c70258b7SJérôme Duval * other dealings in products derived from or relating to the Covered Code
78c70258b7SJérôme Duval * without prior written authorization from Intel.
79c70258b7SJérôme Duval *
80c70258b7SJérôme Duval * 4. Disclaimer and Export Compliance
81c70258b7SJérôme Duval *
82c70258b7SJérôme Duval * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83c70258b7SJérôme Duval * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84c70258b7SJérôme Duval * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85c70258b7SJérôme Duval * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86c70258b7SJérôme Duval * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87c70258b7SJérôme Duval * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88c70258b7SJérôme Duval * PARTICULAR PURPOSE.
89c70258b7SJérôme Duval *
90c70258b7SJérôme Duval * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91c70258b7SJérôme Duval * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92c70258b7SJérôme Duval * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93c70258b7SJérôme Duval * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94c70258b7SJérôme Duval * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95c70258b7SJérôme Duval * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96c70258b7SJérôme Duval * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97c70258b7SJérôme Duval * LIMITED REMEDY.
98c70258b7SJérôme Duval *
99c70258b7SJérôme Duval * 4.3. Licensee shall not export, either directly or indirectly, any of this
100c70258b7SJérôme Duval * software or system incorporating such software without first obtaining any
101c70258b7SJérôme Duval * required license or other approval from the U. S. Department of Commerce or
102c70258b7SJérôme Duval * any other agency or department of the United States Government. In the
103c70258b7SJérôme Duval * event Licensee exports any such software from the United States or
104c70258b7SJérôme Duval * re-exports any such software from a foreign destination, Licensee shall
105c70258b7SJérôme Duval * ensure that the distribution and export/re-export of the software is in
106c70258b7SJérôme Duval * compliance with all laws, regulations, orders, or other restrictions of the
107c70258b7SJérôme Duval * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108c70258b7SJérôme Duval * any of its subsidiaries will export/re-export any technical data, process,
109c70258b7SJérôme Duval * software, or service, directly or indirectly, to any country for which the
110c70258b7SJérôme Duval * United States government or any agency thereof requires an export license,
111c70258b7SJérôme Duval * other governmental approval, or letter of assurance, without first obtaining
112c70258b7SJérôme Duval * such license, approval or letter.
113c70258b7SJérôme Duval *
114ff2e2f81SFredrik Holmqvist *****************************************************************************
115ff2e2f81SFredrik Holmqvist *
116ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
117ff2e2f81SFredrik Holmqvist * following license:
118ff2e2f81SFredrik Holmqvist *
119ff2e2f81SFredrik Holmqvist * Redistribution and use in source and binary forms, with or without
120ff2e2f81SFredrik Holmqvist * modification, are permitted provided that the following conditions
121ff2e2f81SFredrik Holmqvist * are met:
122ff2e2f81SFredrik Holmqvist * 1. Redistributions of source code must retain the above copyright
123ff2e2f81SFredrik Holmqvist * notice, this list of conditions, and the following disclaimer,
124ff2e2f81SFredrik Holmqvist * without modification.
125ff2e2f81SFredrik Holmqvist * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126ff2e2f81SFredrik Holmqvist * substantially similar to the "NO WARRANTY" disclaimer below
127ff2e2f81SFredrik Holmqvist * ("Disclaimer") and any redistribution must be conditioned upon
128ff2e2f81SFredrik Holmqvist * including a substantially similar Disclaimer requirement for further
129ff2e2f81SFredrik Holmqvist * binary redistribution.
130ff2e2f81SFredrik Holmqvist * 3. Neither the names of the above-listed copyright holders nor the names
131ff2e2f81SFredrik Holmqvist * of any contributors may be used to endorse or promote products derived
132ff2e2f81SFredrik Holmqvist * from this software without specific prior written permission.
133ff2e2f81SFredrik Holmqvist *
134ff2e2f81SFredrik Holmqvist * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135ff2e2f81SFredrik Holmqvist * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136ff2e2f81SFredrik Holmqvist * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137ff2e2f81SFredrik Holmqvist * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138ff2e2f81SFredrik Holmqvist * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139ff2e2f81SFredrik Holmqvist * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140ff2e2f81SFredrik Holmqvist * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141ff2e2f81SFredrik Holmqvist * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142ff2e2f81SFredrik Holmqvist * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143ff2e2f81SFredrik Holmqvist * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144ff2e2f81SFredrik Holmqvist * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145ff2e2f81SFredrik Holmqvist *
146ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
147ff2e2f81SFredrik Holmqvist * GNU General Public License ("GPL") version 2 as published by the Free
148ff2e2f81SFredrik Holmqvist * Software Foundation.
149ff2e2f81SFredrik Holmqvist *
150c70258b7SJérôme Duval *****************************************************************************/
151c70258b7SJérôme Duval
152c70258b7SJérôme Duval #include "acpi.h"
153c70258b7SJérôme Duval #include "accommon.h"
154c70258b7SJérôme Duval
155c70258b7SJérôme Duval #define _COMPONENT ACPI_UTILITIES
156c70258b7SJérôme Duval ACPI_MODULE_NAME ("utbuffer")
157c70258b7SJérôme Duval
158c70258b7SJérôme Duval
159c70258b7SJérôme Duval /*******************************************************************************
160c70258b7SJérôme Duval *
161c70258b7SJérôme Duval * FUNCTION: AcpiUtDumpBuffer
162c70258b7SJérôme Duval *
163c70258b7SJérôme Duval * PARAMETERS: Buffer - Buffer to dump
164c70258b7SJérôme Duval * Count - Amount to dump, in bytes
165c70258b7SJérôme Duval * Display - BYTE, WORD, DWORD, or QWORD display:
166c70258b7SJérôme Duval * DB_BYTE_DISPLAY
167c70258b7SJérôme Duval * DB_WORD_DISPLAY
168c70258b7SJérôme Duval * DB_DWORD_DISPLAY
169c70258b7SJérôme Duval * DB_QWORD_DISPLAY
170c70258b7SJérôme Duval * BaseOffset - Beginning buffer offset (display only)
171c70258b7SJérôme Duval *
172c70258b7SJérôme Duval * RETURN: None
173c70258b7SJérôme Duval *
174c70258b7SJérôme Duval * DESCRIPTION: Generic dump buffer in both hex and ascii.
175c70258b7SJérôme Duval *
176c70258b7SJérôme Duval ******************************************************************************/
177c70258b7SJérôme Duval
178c70258b7SJérôme Duval void
AcpiUtDumpBuffer(UINT8 * Buffer,UINT32 Count,UINT32 Display,UINT32 BaseOffset)179c70258b7SJérôme Duval AcpiUtDumpBuffer (
180c70258b7SJérôme Duval UINT8 *Buffer,
181c70258b7SJérôme Duval UINT32 Count,
182c70258b7SJérôme Duval UINT32 Display,
183c70258b7SJérôme Duval UINT32 BaseOffset)
184c70258b7SJérôme Duval {
185c70258b7SJérôme Duval UINT32 i = 0;
186c70258b7SJérôme Duval UINT32 j;
187c70258b7SJérôme Duval UINT32 Temp32;
188c70258b7SJérôme Duval UINT8 BufChar;
1890ffed378SFredrik Holmqvist UINT32 DisplayDataOnly = Display & DB_DISPLAY_DATA_ONLY;
190c70258b7SJérôme Duval
191c70258b7SJérôme Duval
1920ffed378SFredrik Holmqvist Display &= ~DB_DISPLAY_DATA_ONLY;
193c70258b7SJérôme Duval if (!Buffer)
194c70258b7SJérôme Duval {
195c70258b7SJérôme Duval AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
196c70258b7SJérôme Duval return;
197c70258b7SJérôme Duval }
198c70258b7SJérôme Duval
199c70258b7SJérôme Duval if ((Count < 4) || (Count & 0x01))
200c70258b7SJérôme Duval {
201c70258b7SJérôme Duval Display = DB_BYTE_DISPLAY;
202c70258b7SJérôme Duval }
203c70258b7SJérôme Duval
204c70258b7SJérôme Duval /* Nasty little dump buffer routine! */
205c70258b7SJérôme Duval
206c70258b7SJérôme Duval while (i < Count)
207c70258b7SJérôme Duval {
208c70258b7SJérôme Duval /* Print current offset */
209c70258b7SJérôme Duval
2100ffed378SFredrik Holmqvist if (!DisplayDataOnly)
2110ffed378SFredrik Holmqvist {
21208c9948cSFredrik Holmqvist AcpiOsPrintf ("%8.4X: ", (BaseOffset + i));
2130ffed378SFredrik Holmqvist }
214c70258b7SJérôme Duval
215c70258b7SJérôme Duval /* Print 16 hex chars */
216c70258b7SJérôme Duval
217c70258b7SJérôme Duval for (j = 0; j < 16;)
218c70258b7SJérôme Duval {
219c70258b7SJérôme Duval if (i + j >= Count)
220c70258b7SJérôme Duval {
221c70258b7SJérôme Duval /* Dump fill spaces */
222c70258b7SJérôme Duval
223c70258b7SJérôme Duval AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
224c70258b7SJérôme Duval j += Display;
225c70258b7SJérôme Duval continue;
226c70258b7SJérôme Duval }
227c70258b7SJérôme Duval
228c70258b7SJérôme Duval switch (Display)
229c70258b7SJérôme Duval {
230c70258b7SJérôme Duval case DB_BYTE_DISPLAY:
231c70258b7SJérôme Duval default: /* Default is BYTE display */
232c70258b7SJérôme Duval
233c70258b7SJérôme Duval AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
234c70258b7SJérôme Duval break;
235c70258b7SJérôme Duval
236c70258b7SJérôme Duval case DB_WORD_DISPLAY:
237c70258b7SJérôme Duval
238c70258b7SJérôme Duval ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
239c70258b7SJérôme Duval AcpiOsPrintf ("%04X ", Temp32);
240c70258b7SJérôme Duval break;
241c70258b7SJérôme Duval
242c70258b7SJérôme Duval case DB_DWORD_DISPLAY:
243c70258b7SJérôme Duval
244c70258b7SJérôme Duval ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
245c70258b7SJérôme Duval AcpiOsPrintf ("%08X ", Temp32);
246c70258b7SJérôme Duval break;
247c70258b7SJérôme Duval
248c70258b7SJérôme Duval case DB_QWORD_DISPLAY:
249c70258b7SJérôme Duval
250c70258b7SJérôme Duval ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
251c70258b7SJérôme Duval AcpiOsPrintf ("%08X", Temp32);
252c70258b7SJérôme Duval
253c70258b7SJérôme Duval ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
254c70258b7SJérôme Duval AcpiOsPrintf ("%08X ", Temp32);
255c70258b7SJérôme Duval break;
256c70258b7SJérôme Duval }
257c70258b7SJérôme Duval
258c70258b7SJérôme Duval j += Display;
259c70258b7SJérôme Duval }
260c70258b7SJérôme Duval
261c70258b7SJérôme Duval /*
262c70258b7SJérôme Duval * Print the ASCII equivalent characters but watch out for the bad
263c70258b7SJérôme Duval * unprintable ones (printable chars are 0x20 through 0x7E)
264c70258b7SJérôme Duval */
2650ffed378SFredrik Holmqvist if (!DisplayDataOnly)
2660ffed378SFredrik Holmqvist {
267c70258b7SJérôme Duval AcpiOsPrintf (" ");
268c70258b7SJérôme Duval for (j = 0; j < 16; j++)
269c70258b7SJérôme Duval {
270c70258b7SJérôme Duval if (i + j >= Count)
271c70258b7SJérôme Duval {
272c70258b7SJérôme Duval AcpiOsPrintf ("\n");
273c70258b7SJérôme Duval return;
274c70258b7SJérôme Duval }
275c70258b7SJérôme Duval
276e226d1d0SFredrik Holmqvist /*
277e226d1d0SFredrik Holmqvist * Add comment characters so rest of line is ignored when
278e226d1d0SFredrik Holmqvist * compiled
279e226d1d0SFredrik Holmqvist */
280e226d1d0SFredrik Holmqvist if (j == 0)
281e226d1d0SFredrik Holmqvist {
282e226d1d0SFredrik Holmqvist AcpiOsPrintf ("// ");
283e226d1d0SFredrik Holmqvist }
284e226d1d0SFredrik Holmqvist
285c70258b7SJérôme Duval BufChar = Buffer[(ACPI_SIZE) i + j];
286e226d1d0SFredrik Holmqvist if (isprint (BufChar))
287c70258b7SJérôme Duval {
288c70258b7SJérôme Duval AcpiOsPrintf ("%c", BufChar);
289c70258b7SJérôme Duval }
290c70258b7SJérôme Duval else
291c70258b7SJérôme Duval {
292c70258b7SJérôme Duval AcpiOsPrintf (".");
293c70258b7SJérôme Duval }
294c70258b7SJérôme Duval }
295c70258b7SJérôme Duval
296c70258b7SJérôme Duval /* Done with that line. */
297c70258b7SJérôme Duval
298c70258b7SJérôme Duval AcpiOsPrintf ("\n");
2990ffed378SFredrik Holmqvist }
300c70258b7SJérôme Duval i += 16;
301c70258b7SJérôme Duval }
302c70258b7SJérôme Duval
303c70258b7SJérôme Duval return;
304c70258b7SJérôme Duval }
305c70258b7SJérôme Duval
306c70258b7SJérôme Duval
307c70258b7SJérôme Duval /*******************************************************************************
308c70258b7SJérôme Duval *
309c70258b7SJérôme Duval * FUNCTION: AcpiUtDebugDumpBuffer
310c70258b7SJérôme Duval *
311c70258b7SJérôme Duval * PARAMETERS: Buffer - Buffer to dump
312c70258b7SJérôme Duval * Count - Amount to dump, in bytes
313c70258b7SJérôme Duval * Display - BYTE, WORD, DWORD, or QWORD display:
314c70258b7SJérôme Duval * DB_BYTE_DISPLAY
315c70258b7SJérôme Duval * DB_WORD_DISPLAY
316c70258b7SJérôme Duval * DB_DWORD_DISPLAY
317c70258b7SJérôme Duval * DB_QWORD_DISPLAY
318c70258b7SJérôme Duval * ComponentID - Caller's component ID
319c70258b7SJérôme Duval *
320c70258b7SJérôme Duval * RETURN: None
321c70258b7SJérôme Duval *
322c70258b7SJérôme Duval * DESCRIPTION: Generic dump buffer in both hex and ascii.
323c70258b7SJérôme Duval *
324c70258b7SJérôme Duval ******************************************************************************/
325c70258b7SJérôme Duval
326c70258b7SJérôme Duval void
AcpiUtDebugDumpBuffer(UINT8 * Buffer,UINT32 Count,UINT32 Display,UINT32 ComponentId)327c70258b7SJérôme Duval AcpiUtDebugDumpBuffer (
328c70258b7SJérôme Duval UINT8 *Buffer,
329c70258b7SJérôme Duval UINT32 Count,
330c70258b7SJérôme Duval UINT32 Display,
331c70258b7SJérôme Duval UINT32 ComponentId)
332c70258b7SJérôme Duval {
333c70258b7SJérôme Duval
334c70258b7SJérôme Duval /* Only dump the buffer if tracing is enabled */
335c70258b7SJérôme Duval
336c70258b7SJérôme Duval if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
337c70258b7SJérôme Duval (ComponentId & AcpiDbgLayer)))
338c70258b7SJérôme Duval {
339c70258b7SJérôme Duval return;
340c70258b7SJérôme Duval }
341c70258b7SJérôme Duval
342c70258b7SJérôme Duval AcpiUtDumpBuffer (Buffer, Count, Display, 0);
343c70258b7SJérôme Duval }
344ad5bbfb8SFredrik Holmqvist
345ad5bbfb8SFredrik Holmqvist
346ad5bbfb8SFredrik Holmqvist #ifdef ACPI_APPLICATION
347ad5bbfb8SFredrik Holmqvist /*******************************************************************************
348ad5bbfb8SFredrik Holmqvist *
349ad5bbfb8SFredrik Holmqvist * FUNCTION: AcpiUtDumpBufferToFile
350ad5bbfb8SFredrik Holmqvist *
351ad5bbfb8SFredrik Holmqvist * PARAMETERS: File - File descriptor
352ad5bbfb8SFredrik Holmqvist * Buffer - Buffer to dump
353ad5bbfb8SFredrik Holmqvist * Count - Amount to dump, in bytes
354ad5bbfb8SFredrik Holmqvist * Display - BYTE, WORD, DWORD, or QWORD display:
355ad5bbfb8SFredrik Holmqvist * DB_BYTE_DISPLAY
356ad5bbfb8SFredrik Holmqvist * DB_WORD_DISPLAY
357ad5bbfb8SFredrik Holmqvist * DB_DWORD_DISPLAY
358ad5bbfb8SFredrik Holmqvist * DB_QWORD_DISPLAY
359ad5bbfb8SFredrik Holmqvist * BaseOffset - Beginning buffer offset (display only)
360ad5bbfb8SFredrik Holmqvist *
361ad5bbfb8SFredrik Holmqvist * RETURN: None
362ad5bbfb8SFredrik Holmqvist *
363ad5bbfb8SFredrik Holmqvist * DESCRIPTION: Generic dump buffer in both hex and ascii to a file.
364ad5bbfb8SFredrik Holmqvist *
365ad5bbfb8SFredrik Holmqvist ******************************************************************************/
366ad5bbfb8SFredrik Holmqvist
367ad5bbfb8SFredrik Holmqvist void
AcpiUtDumpBufferToFile(ACPI_FILE File,UINT8 * Buffer,UINT32 Count,UINT32 Display,UINT32 BaseOffset)368ad5bbfb8SFredrik Holmqvist AcpiUtDumpBufferToFile (
369ad5bbfb8SFredrik Holmqvist ACPI_FILE File,
370ad5bbfb8SFredrik Holmqvist UINT8 *Buffer,
371ad5bbfb8SFredrik Holmqvist UINT32 Count,
372ad5bbfb8SFredrik Holmqvist UINT32 Display,
373ad5bbfb8SFredrik Holmqvist UINT32 BaseOffset)
374ad5bbfb8SFredrik Holmqvist {
375ad5bbfb8SFredrik Holmqvist UINT32 i = 0;
376ad5bbfb8SFredrik Holmqvist UINT32 j;
377ad5bbfb8SFredrik Holmqvist UINT32 Temp32;
378ad5bbfb8SFredrik Holmqvist UINT8 BufChar;
379ad5bbfb8SFredrik Holmqvist
380ad5bbfb8SFredrik Holmqvist
381ad5bbfb8SFredrik Holmqvist if (!Buffer)
382ad5bbfb8SFredrik Holmqvist {
38374ffd18dSFredrik Holmqvist fprintf (File, "Null Buffer Pointer in DumpBuffer!\n");
384ad5bbfb8SFredrik Holmqvist return;
385ad5bbfb8SFredrik Holmqvist }
386ad5bbfb8SFredrik Holmqvist
387ad5bbfb8SFredrik Holmqvist if ((Count < 4) || (Count & 0x01))
388ad5bbfb8SFredrik Holmqvist {
389ad5bbfb8SFredrik Holmqvist Display = DB_BYTE_DISPLAY;
390ad5bbfb8SFredrik Holmqvist }
391ad5bbfb8SFredrik Holmqvist
392ad5bbfb8SFredrik Holmqvist /* Nasty little dump buffer routine! */
393ad5bbfb8SFredrik Holmqvist
394ad5bbfb8SFredrik Holmqvist while (i < Count)
395ad5bbfb8SFredrik Holmqvist {
396ad5bbfb8SFredrik Holmqvist /* Print current offset */
397ad5bbfb8SFredrik Holmqvist
39808c9948cSFredrik Holmqvist fprintf (File, "%8.4X: ", (BaseOffset + i));
399ad5bbfb8SFredrik Holmqvist
400ad5bbfb8SFredrik Holmqvist /* Print 16 hex chars */
401ad5bbfb8SFredrik Holmqvist
402ad5bbfb8SFredrik Holmqvist for (j = 0; j < 16;)
403ad5bbfb8SFredrik Holmqvist {
404ad5bbfb8SFredrik Holmqvist if (i + j >= Count)
405ad5bbfb8SFredrik Holmqvist {
406ad5bbfb8SFredrik Holmqvist /* Dump fill spaces */
407ad5bbfb8SFredrik Holmqvist
40874ffd18dSFredrik Holmqvist fprintf (File, "%*s", ((Display * 2) + 1), " ");
409ad5bbfb8SFredrik Holmqvist j += Display;
410ad5bbfb8SFredrik Holmqvist continue;
411ad5bbfb8SFredrik Holmqvist }
412ad5bbfb8SFredrik Holmqvist
413ad5bbfb8SFredrik Holmqvist switch (Display)
414ad5bbfb8SFredrik Holmqvist {
415ad5bbfb8SFredrik Holmqvist case DB_BYTE_DISPLAY:
416ad5bbfb8SFredrik Holmqvist default: /* Default is BYTE display */
417ad5bbfb8SFredrik Holmqvist
41874ffd18dSFredrik Holmqvist fprintf (File, "%02X ", Buffer[(ACPI_SIZE) i + j]);
419ad5bbfb8SFredrik Holmqvist break;
420ad5bbfb8SFredrik Holmqvist
421ad5bbfb8SFredrik Holmqvist case DB_WORD_DISPLAY:
422ad5bbfb8SFredrik Holmqvist
423ad5bbfb8SFredrik Holmqvist ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
42474ffd18dSFredrik Holmqvist fprintf (File, "%04X ", Temp32);
425ad5bbfb8SFredrik Holmqvist break;
426ad5bbfb8SFredrik Holmqvist
427ad5bbfb8SFredrik Holmqvist case DB_DWORD_DISPLAY:
428ad5bbfb8SFredrik Holmqvist
429ad5bbfb8SFredrik Holmqvist ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
43074ffd18dSFredrik Holmqvist fprintf (File, "%08X ", Temp32);
431ad5bbfb8SFredrik Holmqvist break;
432ad5bbfb8SFredrik Holmqvist
433ad5bbfb8SFredrik Holmqvist case DB_QWORD_DISPLAY:
434ad5bbfb8SFredrik Holmqvist
435ad5bbfb8SFredrik Holmqvist ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
43674ffd18dSFredrik Holmqvist fprintf (File, "%08X", Temp32);
437ad5bbfb8SFredrik Holmqvist
438ad5bbfb8SFredrik Holmqvist ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
43974ffd18dSFredrik Holmqvist fprintf (File, "%08X ", Temp32);
440ad5bbfb8SFredrik Holmqvist break;
441ad5bbfb8SFredrik Holmqvist }
442ad5bbfb8SFredrik Holmqvist
443ad5bbfb8SFredrik Holmqvist j += Display;
444ad5bbfb8SFredrik Holmqvist }
445ad5bbfb8SFredrik Holmqvist
446ad5bbfb8SFredrik Holmqvist /*
447ad5bbfb8SFredrik Holmqvist * Print the ASCII equivalent characters but watch out for the bad
448ad5bbfb8SFredrik Holmqvist * unprintable ones (printable chars are 0x20 through 0x7E)
449ad5bbfb8SFredrik Holmqvist */
45074ffd18dSFredrik Holmqvist fprintf (File, " ");
451ad5bbfb8SFredrik Holmqvist for (j = 0; j < 16; j++)
452ad5bbfb8SFredrik Holmqvist {
453ad5bbfb8SFredrik Holmqvist if (i + j >= Count)
454ad5bbfb8SFredrik Holmqvist {
45574ffd18dSFredrik Holmqvist fprintf (File, "\n");
456ad5bbfb8SFredrik Holmqvist return;
457ad5bbfb8SFredrik Holmqvist }
458ad5bbfb8SFredrik Holmqvist
459ad5bbfb8SFredrik Holmqvist BufChar = Buffer[(ACPI_SIZE) i + j];
460e226d1d0SFredrik Holmqvist if (isprint (BufChar))
461ad5bbfb8SFredrik Holmqvist {
46274ffd18dSFredrik Holmqvist fprintf (File, "%c", BufChar);
463ad5bbfb8SFredrik Holmqvist }
464ad5bbfb8SFredrik Holmqvist else
465ad5bbfb8SFredrik Holmqvist {
46674ffd18dSFredrik Holmqvist fprintf (File, ".");
467ad5bbfb8SFredrik Holmqvist }
468ad5bbfb8SFredrik Holmqvist }
469ad5bbfb8SFredrik Holmqvist
470ad5bbfb8SFredrik Holmqvist /* Done with that line. */
471ad5bbfb8SFredrik Holmqvist
47274ffd18dSFredrik Holmqvist fprintf (File, "\n");
473ad5bbfb8SFredrik Holmqvist i += 16;
474ad5bbfb8SFredrik Holmqvist }
475ad5bbfb8SFredrik Holmqvist
476ad5bbfb8SFredrik Holmqvist return;
477ad5bbfb8SFredrik Holmqvist }
478ad5bbfb8SFredrik Holmqvist #endif
479