diff options
author | Bob Moore <robert.moore@intel.com> | 2013-06-07 20:57:47 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-06-15 18:52:22 -0400 |
commit | 88ec28603c09ccba0346c15eef64ff0b4327c9ee (patch) | |
tree | b314287b73d46e876642486a1947f87fd83f2317 /drivers/acpi/acpica | |
parent | 67a9277496d8e674f27bb2a62c995eb79801d555 (diff) |
ACPICA: Split buffer dump routines into separate file
To enhance configurability of ACPICA. The new file is
utilities/utbuffer.c
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Acked-by: Len Brown <len.brown@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/Makefile | 1 | ||||
-rw-r--r-- | drivers/acpi/acpica/utbuffer.c | 201 | ||||
-rw-r--r-- | drivers/acpi/acpica/utdebug.c | 148 |
3 files changed, 203 insertions, 147 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile index 29b3dab401ec..474901ec01c2 100644 --- a/drivers/acpi/acpica/Makefile +++ b/drivers/acpi/acpica/Makefile | |||
@@ -146,6 +146,7 @@ acpi-y += \ | |||
146 | acpi-y += \ | 146 | acpi-y += \ |
147 | utaddress.o \ | 147 | utaddress.o \ |
148 | utalloc.o \ | 148 | utalloc.o \ |
149 | utbuffer.o \ | ||
149 | utcopy.o \ | 150 | utcopy.o \ |
150 | utexcep.o \ | 151 | utexcep.o \ |
151 | utdebug.o \ | 152 | utdebug.o \ |
diff --git a/drivers/acpi/acpica/utbuffer.c b/drivers/acpi/acpica/utbuffer.c new file mode 100644 index 000000000000..11fde93be120 --- /dev/null +++ b/drivers/acpi/acpica/utbuffer.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /****************************************************************************** | ||
2 | * | ||
3 | * Module Name: utbuffer - Buffer dump routines | ||
4 | * | ||
5 | *****************************************************************************/ | ||
6 | |||
7 | /* | ||
8 | * Copyright (C) 2000 - 2013, 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/acpi.h> | ||
45 | #include "accommon.h" | ||
46 | |||
47 | #define _COMPONENT ACPI_UTILITIES | ||
48 | ACPI_MODULE_NAME("utbuffer") | ||
49 | |||
50 | /******************************************************************************* | ||
51 | * | ||
52 | * FUNCTION: acpi_ut_dump_buffer | ||
53 | * | ||
54 | * PARAMETERS: buffer - Buffer to dump | ||
55 | * count - Amount to dump, in bytes | ||
56 | * display - BYTE, WORD, DWORD, or QWORD display: | ||
57 | * DB_BYTE_DISPLAY | ||
58 | * DB_WORD_DISPLAY | ||
59 | * DB_DWORD_DISPLAY | ||
60 | * DB_QWORD_DISPLAY | ||
61 | * base_offset - Beginning buffer offset (display only) | ||
62 | * | ||
63 | * RETURN: None | ||
64 | * | ||
65 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
66 | * | ||
67 | ******************************************************************************/ | ||
68 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) | ||
69 | { | ||
70 | u32 i = 0; | ||
71 | u32 j; | ||
72 | u32 temp32; | ||
73 | u8 buf_char; | ||
74 | |||
75 | if (!buffer) { | ||
76 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | if ((count < 4) || (count & 0x01)) { | ||
81 | display = DB_BYTE_DISPLAY; | ||
82 | } | ||
83 | |||
84 | /* Nasty little dump buffer routine! */ | ||
85 | |||
86 | while (i < count) { | ||
87 | |||
88 | /* Print current offset */ | ||
89 | |||
90 | acpi_os_printf("%6.4X: ", (base_offset + i)); | ||
91 | |||
92 | /* Print 16 hex chars */ | ||
93 | |||
94 | for (j = 0; j < 16;) { | ||
95 | if (i + j >= count) { | ||
96 | |||
97 | /* Dump fill spaces */ | ||
98 | |||
99 | acpi_os_printf("%*s", ((display * 2) + 1), " "); | ||
100 | j += display; | ||
101 | continue; | ||
102 | } | ||
103 | |||
104 | switch (display) { | ||
105 | case DB_BYTE_DISPLAY: | ||
106 | default: /* Default is BYTE display */ | ||
107 | |||
108 | acpi_os_printf("%02X ", | ||
109 | buffer[(acpi_size) i + j]); | ||
110 | break; | ||
111 | |||
112 | case DB_WORD_DISPLAY: | ||
113 | |||
114 | ACPI_MOVE_16_TO_32(&temp32, | ||
115 | &buffer[(acpi_size) i + j]); | ||
116 | acpi_os_printf("%04X ", temp32); | ||
117 | break; | ||
118 | |||
119 | case DB_DWORD_DISPLAY: | ||
120 | |||
121 | ACPI_MOVE_32_TO_32(&temp32, | ||
122 | &buffer[(acpi_size) i + j]); | ||
123 | acpi_os_printf("%08X ", temp32); | ||
124 | break; | ||
125 | |||
126 | case DB_QWORD_DISPLAY: | ||
127 | |||
128 | ACPI_MOVE_32_TO_32(&temp32, | ||
129 | &buffer[(acpi_size) i + j]); | ||
130 | acpi_os_printf("%08X", temp32); | ||
131 | |||
132 | ACPI_MOVE_32_TO_32(&temp32, | ||
133 | &buffer[(acpi_size) i + j + | ||
134 | 4]); | ||
135 | acpi_os_printf("%08X ", temp32); | ||
136 | break; | ||
137 | } | ||
138 | |||
139 | j += display; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * Print the ASCII equivalent characters but watch out for the bad | ||
144 | * unprintable ones (printable chars are 0x20 through 0x7E) | ||
145 | */ | ||
146 | acpi_os_printf(" "); | ||
147 | for (j = 0; j < 16; j++) { | ||
148 | if (i + j >= count) { | ||
149 | acpi_os_printf("\n"); | ||
150 | return; | ||
151 | } | ||
152 | |||
153 | buf_char = buffer[(acpi_size) i + j]; | ||
154 | if (ACPI_IS_PRINT(buf_char)) { | ||
155 | acpi_os_printf("%c", buf_char); | ||
156 | } else { | ||
157 | acpi_os_printf("."); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | /* Done with that line. */ | ||
162 | |||
163 | acpi_os_printf("\n"); | ||
164 | i += 16; | ||
165 | } | ||
166 | |||
167 | return; | ||
168 | } | ||
169 | |||
170 | /******************************************************************************* | ||
171 | * | ||
172 | * FUNCTION: acpi_ut_debug_dump_buffer | ||
173 | * | ||
174 | * PARAMETERS: buffer - Buffer to dump | ||
175 | * count - Amount to dump, in bytes | ||
176 | * display - BYTE, WORD, DWORD, or QWORD display: | ||
177 | * DB_BYTE_DISPLAY | ||
178 | * DB_WORD_DISPLAY | ||
179 | * DB_DWORD_DISPLAY | ||
180 | * DB_QWORD_DISPLAY | ||
181 | * component_ID - Caller's component ID | ||
182 | * | ||
183 | * RETURN: None | ||
184 | * | ||
185 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
186 | * | ||
187 | ******************************************************************************/ | ||
188 | |||
189 | void | ||
190 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | ||
191 | { | ||
192 | |||
193 | /* Only dump the buffer if tracing is enabled */ | ||
194 | |||
195 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | ||
196 | (component_id & acpi_dbg_layer))) { | ||
197 | return; | ||
198 | } | ||
199 | |||
200 | acpi_ut_dump_buffer(buffer, count, display, 0); | ||
201 | } | ||
diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index c57d9cc07ba9..5796e11a0671 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c | |||
@@ -1,6 +1,6 @@ | |||
1 | /****************************************************************************** | 1 | /****************************************************************************** |
2 | * | 2 | * |
3 | * Module Name: utdebug - Debug print routines | 3 | * Module Name: utdebug - Debug print/trace routines |
4 | * | 4 | * |
5 | *****************************************************************************/ | 5 | *****************************************************************************/ |
6 | 6 | ||
@@ -543,149 +543,3 @@ acpi_ut_ptr_exit(u32 line_number, | |||
543 | } | 543 | } |
544 | 544 | ||
545 | #endif | 545 | #endif |
546 | |||
547 | /******************************************************************************* | ||
548 | * | ||
549 | * FUNCTION: acpi_ut_dump_buffer | ||
550 | * | ||
551 | * PARAMETERS: buffer - Buffer to dump | ||
552 | * count - Amount to dump, in bytes | ||
553 | * display - BYTE, WORD, DWORD, or QWORD display | ||
554 | * offset - Beginning buffer offset (display only) | ||
555 | * | ||
556 | * RETURN: None | ||
557 | * | ||
558 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
559 | * | ||
560 | ******************************************************************************/ | ||
561 | |||
562 | void acpi_ut_dump_buffer(u8 *buffer, u32 count, u32 display, u32 base_offset) | ||
563 | { | ||
564 | u32 i = 0; | ||
565 | u32 j; | ||
566 | u32 temp32; | ||
567 | u8 buf_char; | ||
568 | |||
569 | if (!buffer) { | ||
570 | acpi_os_printf("Null Buffer Pointer in DumpBuffer!\n"); | ||
571 | return; | ||
572 | } | ||
573 | |||
574 | if ((count < 4) || (count & 0x01)) { | ||
575 | display = DB_BYTE_DISPLAY; | ||
576 | } | ||
577 | |||
578 | /* Nasty little dump buffer routine! */ | ||
579 | |||
580 | while (i < count) { | ||
581 | |||
582 | /* Print current offset */ | ||
583 | |||
584 | acpi_os_printf("%6.4X: ", (base_offset + i)); | ||
585 | |||
586 | /* Print 16 hex chars */ | ||
587 | |||
588 | for (j = 0; j < 16;) { | ||
589 | if (i + j >= count) { | ||
590 | |||
591 | /* Dump fill spaces */ | ||
592 | |||
593 | acpi_os_printf("%*s", ((display * 2) + 1), " "); | ||
594 | j += display; | ||
595 | continue; | ||
596 | } | ||
597 | |||
598 | switch (display) { | ||
599 | case DB_BYTE_DISPLAY: | ||
600 | default: /* Default is BYTE display */ | ||
601 | |||
602 | acpi_os_printf("%02X ", | ||
603 | buffer[(acpi_size) i + j]); | ||
604 | break; | ||
605 | |||
606 | case DB_WORD_DISPLAY: | ||
607 | |||
608 | ACPI_MOVE_16_TO_32(&temp32, | ||
609 | &buffer[(acpi_size) i + j]); | ||
610 | acpi_os_printf("%04X ", temp32); | ||
611 | break; | ||
612 | |||
613 | case DB_DWORD_DISPLAY: | ||
614 | |||
615 | ACPI_MOVE_32_TO_32(&temp32, | ||
616 | &buffer[(acpi_size) i + j]); | ||
617 | acpi_os_printf("%08X ", temp32); | ||
618 | break; | ||
619 | |||
620 | case DB_QWORD_DISPLAY: | ||
621 | |||
622 | ACPI_MOVE_32_TO_32(&temp32, | ||
623 | &buffer[(acpi_size) i + j]); | ||
624 | acpi_os_printf("%08X", temp32); | ||
625 | |||
626 | ACPI_MOVE_32_TO_32(&temp32, | ||
627 | &buffer[(acpi_size) i + j + | ||
628 | 4]); | ||
629 | acpi_os_printf("%08X ", temp32); | ||
630 | break; | ||
631 | } | ||
632 | |||
633 | j += display; | ||
634 | } | ||
635 | |||
636 | /* | ||
637 | * Print the ASCII equivalent characters but watch out for the bad | ||
638 | * unprintable ones (printable chars are 0x20 through 0x7E) | ||
639 | */ | ||
640 | acpi_os_printf(" "); | ||
641 | for (j = 0; j < 16; j++) { | ||
642 | if (i + j >= count) { | ||
643 | acpi_os_printf("\n"); | ||
644 | return; | ||
645 | } | ||
646 | |||
647 | buf_char = buffer[(acpi_size) i + j]; | ||
648 | if (ACPI_IS_PRINT(buf_char)) { | ||
649 | acpi_os_printf("%c", buf_char); | ||
650 | } else { | ||
651 | acpi_os_printf("."); | ||
652 | } | ||
653 | } | ||
654 | |||
655 | /* Done with that line. */ | ||
656 | |||
657 | acpi_os_printf("\n"); | ||
658 | i += 16; | ||
659 | } | ||
660 | |||
661 | return; | ||
662 | } | ||
663 | |||
664 | /******************************************************************************* | ||
665 | * | ||
666 | * FUNCTION: acpi_ut_debug_dump_buffer | ||
667 | * | ||
668 | * PARAMETERS: buffer - Buffer to dump | ||
669 | * count - Amount to dump, in bytes | ||
670 | * display - BYTE, WORD, DWORD, or QWORD display | ||
671 | * component_ID - Caller's component ID | ||
672 | * | ||
673 | * RETURN: None | ||
674 | * | ||
675 | * DESCRIPTION: Generic dump buffer in both hex and ascii. | ||
676 | * | ||
677 | ******************************************************************************/ | ||
678 | |||
679 | void | ||
680 | acpi_ut_debug_dump_buffer(u8 *buffer, u32 count, u32 display, u32 component_id) | ||
681 | { | ||
682 | |||
683 | /* Only dump the buffer if tracing is enabled */ | ||
684 | |||
685 | if (!((ACPI_LV_TABLES & acpi_dbg_level) && | ||
686 | (component_id & acpi_dbg_layer))) { | ||
687 | return; | ||
688 | } | ||
689 | |||
690 | acpi_ut_dump_buffer(buffer, count, display, 0); | ||
691 | } | ||