aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2016-05-05 01:00:36 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-05-05 09:22:28 -0400
commit6a0df32c22fdfc414e6613c1bc911f19f39df01b (patch)
tree731e0d82fbe3b446e09fbba4994980fa4c78bac8
parent66b1ed5aa8dd253a734bf6ca4e5390385724f99c (diff)
ACPICA: Move all ASCII utilities to a common file
ACPICA commit ba60e4500053010bf775d58f6f61febbdb94d817 New file is utascii.c Link: https://github.com/acpica/acpica/commit/ba60e450 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/acpica/Makefile1
-rw-r--r--drivers/acpi/acpica/actables.h2
-rw-r--r--drivers/acpi/acpica/acutils.h13
-rw-r--r--drivers/acpi/acpica/dbnames.c2
-rw-r--r--drivers/acpi/acpica/exnames.c2
-rw-r--r--drivers/acpi/acpica/tbdata.c6
-rw-r--r--drivers/acpi/acpica/tbfind.c2
-rw-r--r--drivers/acpi/acpica/tbinstal.c6
-rw-r--r--drivers/acpi/acpica/tbutils.c27
-rw-r--r--drivers/acpi/acpica/utascii.c140
-rw-r--r--drivers/acpi/acpica/utstring.c69
-rw-r--r--tools/power/acpi/tools/acpidump/Makefile1
-rw-r--r--tools/power/acpi/tools/acpidump/apdump.c8
13 files changed, 168 insertions, 111 deletions
diff --git a/drivers/acpi/acpica/Makefile b/drivers/acpi/acpica/Makefile
index 188597fface7..227bb7bb19d7 100644
--- a/drivers/acpi/acpica/Makefile
+++ b/drivers/acpi/acpica/Makefile
@@ -150,6 +150,7 @@ acpi-y += \
150acpi-y += \ 150acpi-y += \
151 utaddress.o \ 151 utaddress.o \
152 utalloc.o \ 152 utalloc.o \
153 utascii.o \
153 utbuffer.o \ 154 utbuffer.o \
154 utcopy.o \ 155 utcopy.o \
155 utexcep.o \ 156 utexcep.o \
diff --git a/drivers/acpi/acpica/actables.h b/drivers/acpi/acpica/actables.h
index 848ad3ac938f..cd5a135fcf29 100644
--- a/drivers/acpi/acpica/actables.h
+++ b/drivers/acpi/acpica/actables.h
@@ -161,8 +161,6 @@ acpi_tb_install_fixed_table(acpi_physical_address address,
161 161
162acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address); 162acpi_status acpi_tb_parse_root_table(acpi_physical_address rsdp_address);
163 163
164u8 acpi_is_valid_signature(char *signature);
165
166/* 164/*
167 * tbxfload 165 * tbxfload
168 */ 166 */
diff --git a/drivers/acpi/acpica/acutils.h b/drivers/acpi/acpica/acutils.h
index 107f9e0090f7..a7dbb2b882cf 100644
--- a/drivers/acpi/acpica/acutils.h
+++ b/drivers/acpi/acpica/acutils.h
@@ -167,6 +167,15 @@ struct acpi_pkg_info {
167#define DB_QWORD_DISPLAY 8 167#define DB_QWORD_DISPLAY 8
168 168
169/* 169/*
170 * utascii - ASCII utilities
171 */
172u8 acpi_ut_valid_nameseg(char *signature);
173
174u8 acpi_ut_valid_name_char(char character, u32 position);
175
176void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count);
177
178/*
170 * utnonansi - Non-ANSI C library functions 179 * utnonansi - Non-ANSI C library functions
171 */ 180 */
172void acpi_ut_strupr(char *src_string); 181void acpi_ut_strupr(char *src_string);
@@ -579,10 +588,6 @@ void acpi_ut_print_string(char *string, u16 max_length);
579void ut_convert_backslashes(char *pathname); 588void ut_convert_backslashes(char *pathname);
580#endif 589#endif
581 590
582u8 acpi_ut_valid_acpi_name(char *name);
583
584u8 acpi_ut_valid_acpi_char(char character, u32 position);
585
586void acpi_ut_repair_name(char *name); 591void acpi_ut_repair_name(char *name);
587 592
588#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) 593#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION)
diff --git a/drivers/acpi/acpica/dbnames.c b/drivers/acpi/acpica/dbnames.c
index 4c9e59a86db1..8667f14d535e 100644
--- a/drivers/acpi/acpica/dbnames.c
+++ b/drivers/acpi/acpica/dbnames.c
@@ -709,7 +709,7 @@ acpi_db_integrity_walk(acpi_handle obj_handle,
709 return (AE_OK); 709 return (AE_OK);
710 } 710 }
711 711
712 if (!acpi_ut_valid_acpi_name(node->name.ascii)) { 712 if (!acpi_ut_valid_nameseg(node->name.ascii)) {
713 acpi_os_printf("Invalid AcpiName for Node %p\n", node); 713 acpi_os_printf("Invalid AcpiName for Node %p\n", node);
714 return (AE_OK); 714 return (AE_OK);
715 } 715 }
diff --git a/drivers/acpi/acpica/exnames.c b/drivers/acpi/acpica/exnames.c
index 27c11ab5eb04..3d6af93fe561 100644
--- a/drivers/acpi/acpica/exnames.c
+++ b/drivers/acpi/acpica/exnames.c
@@ -178,7 +178,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
178 178
179 for (index = 0; 179 for (index = 0;
180 (index < ACPI_NAME_SIZE) 180 (index < ACPI_NAME_SIZE)
181 && (acpi_ut_valid_acpi_char(*aml_address, 0)); index++) { 181 && (acpi_ut_valid_name_char(*aml_address, 0)); index++) {
182 char_buf[index] = *aml_address++; 182 char_buf[index] = *aml_address++;
183 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index])); 183 ACPI_DEBUG_PRINT((ACPI_DB_LOAD, "%c\n", char_buf[index]));
184 } 184 }
diff --git a/drivers/acpi/acpica/tbdata.c b/drivers/acpi/acpica/tbdata.c
index d471df3988bb..1388a19e5db8 100644
--- a/drivers/acpi/acpica/tbdata.c
+++ b/drivers/acpi/acpica/tbdata.c
@@ -401,9 +401,9 @@ acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature)
401 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, 401 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
402 "%4.4s 0x%8.8X%8.8X" 402 "%4.4s 0x%8.8X%8.8X"
403 " Attempted table install failed", 403 " Attempted table install failed",
404 acpi_ut_valid_acpi_name(table_desc-> 404 acpi_ut_valid_nameseg(table_desc->
405 signature. 405 signature.
406 ascii) ? 406 ascii) ?
407 table_desc->signature.ascii : "????", 407 table_desc->signature.ascii : "????",
408 ACPI_FORMAT_UINT64(table_desc-> 408 ACPI_FORMAT_UINT64(table_desc->
409 address))); 409 address)));
diff --git a/drivers/acpi/acpica/tbfind.c b/drivers/acpi/acpica/tbfind.c
index f2d08034630e..e348d616e60f 100644
--- a/drivers/acpi/acpica/tbfind.c
+++ b/drivers/acpi/acpica/tbfind.c
@@ -76,7 +76,7 @@ acpi_tb_find_table(char *signature,
76 76
77 /* Validate the input table signature */ 77 /* Validate the input table signature */
78 78
79 if (!acpi_is_valid_signature(signature)) { 79 if (!acpi_ut_valid_nameseg(signature)) {
80 return_ACPI_STATUS(AE_BAD_SIGNATURE); 80 return_ACPI_STATUS(AE_BAD_SIGNATURE);
81 } 81 }
82 82
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 4dc6108de4ff..8b13052128fc 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -299,9 +299,9 @@ acpi_tb_install_standard_table(acpi_physical_address address,
299 ACPI_BIOS_ERROR((AE_INFO, 299 ACPI_BIOS_ERROR((AE_INFO,
300 "Table has invalid signature [%4.4s] (0x%8.8X), " 300 "Table has invalid signature [%4.4s] (0x%8.8X), "
301 "must be SSDT or OEMx", 301 "must be SSDT or OEMx",
302 acpi_ut_valid_acpi_name(new_table_desc. 302 acpi_ut_valid_nameseg(new_table_desc.
303 signature. 303 signature.
304 ascii) ? 304 ascii) ?
305 new_table_desc.signature. 305 new_table_desc.signature.
306 ascii : "????", 306 ascii : "????",
307 new_table_desc.signature.integer)); 307 new_table_desc.signature.integer));
diff --git a/drivers/acpi/acpica/tbutils.c b/drivers/acpi/acpica/tbutils.c
index a962a85b1d02..e28553914bf5 100644
--- a/drivers/acpi/acpica/tbutils.c
+++ b/drivers/acpi/acpica/tbutils.c
@@ -380,30 +380,3 @@ next_table:
380 acpi_os_unmap_memory(table, length); 380 acpi_os_unmap_memory(table, length);
381 return_ACPI_STATUS(AE_OK); 381 return_ACPI_STATUS(AE_OK);
382} 382}
383
384/*******************************************************************************
385 *
386 * FUNCTION: acpi_is_valid_signature
387 *
388 * PARAMETERS: signature - Sig string to be validated
389 *
390 * RETURN: TRUE if signature is has 4 valid ACPI characters
391 *
392 * DESCRIPTION: Validate an ACPI table signature.
393 *
394 ******************************************************************************/
395
396u8 acpi_is_valid_signature(char *signature)
397{
398 u32 i;
399
400 /* Validate each character in the signature */
401
402 for (i = 0; i < ACPI_NAME_SIZE; i++) {
403 if (!acpi_ut_valid_acpi_char(signature[i], i)) {
404 return (FALSE);
405 }
406 }
407
408 return (TRUE);
409}
diff --git a/drivers/acpi/acpica/utascii.c b/drivers/acpi/acpica/utascii.c
new file mode 100644
index 000000000000..706c1f346490
--- /dev/null
+++ b/drivers/acpi/acpica/utascii.c
@@ -0,0 +1,140 @@
1/******************************************************************************
2 *
3 * Module Name: utascii - Utility ascii functions
4 *
5 *****************************************************************************/
6
7/*
8 * Copyright (C) 2000 - 2016, 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/*******************************************************************************
48 *
49 * FUNCTION: acpi_ut_valid_nameseg
50 *
51 * PARAMETERS: name - The name or table signature to be examined.
52 * Four characters, does not have to be a
53 * NULL terminated string.
54 *
55 * RETURN: TRUE if signature is has 4 valid ACPI characters
56 *
57 * DESCRIPTION: Validate an ACPI table signature.
58 *
59 ******************************************************************************/
60
61u8 acpi_ut_valid_nameseg(char *name)
62{
63 u32 i;
64
65 /* Validate each character in the signature */
66
67 for (i = 0; i < ACPI_NAME_SIZE; i++) {
68 if (!acpi_ut_valid_name_char(name[i], i)) {
69 return (FALSE);
70 }
71 }
72
73 return (TRUE);
74}
75
76/*******************************************************************************
77 *
78 * FUNCTION: acpi_ut_valid_name_char
79 *
80 * PARAMETERS: char - The character to be examined
81 * position - Byte position (0-3)
82 *
83 * RETURN: TRUE if the character is valid, FALSE otherwise
84 *
85 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
86 * 1) Upper case alpha
87 * 2) numeric
88 * 3) underscore
89 *
90 * We allow a '!' as the last character because of the ASF! table
91 *
92 ******************************************************************************/
93
94u8 acpi_ut_valid_name_char(char character, u32 position)
95{
96
97 if (!((character >= 'A' && character <= 'Z') ||
98 (character >= '0' && character <= '9') || (character == '_'))) {
99
100 /* Allow a '!' in the last position */
101
102 if (character == '!' && position == 3) {
103 return (TRUE);
104 }
105
106 return (FALSE);
107 }
108
109 return (TRUE);
110}
111
112/*******************************************************************************
113 *
114 * FUNCTION: acpi_ut_check_and_repair_ascii
115 *
116 * PARAMETERS: name - Ascii string
117 * count - Number of characters to check
118 *
119 * RETURN: None
120 *
121 * DESCRIPTION: Ensure that the requested number of characters are printable
122 * Ascii characters. Sets non-printable and null chars to <space>.
123 *
124 ******************************************************************************/
125
126void acpi_ut_check_and_repair_ascii(u8 *name, char *repaired_name, u32 count)
127{
128 u32 i;
129
130 for (i = 0; i < count; i++) {
131 repaired_name[i] = (char)name[i];
132
133 if (!name[i]) {
134 return;
135 }
136 if (!isprint(name[i])) {
137 repaired_name[i] = ' ';
138 }
139 }
140}
diff --git a/drivers/acpi/acpica/utstring.c b/drivers/acpi/acpica/utstring.c
index 241259bfed64..288913a0e709 100644
--- a/drivers/acpi/acpica/utstring.c
+++ b/drivers/acpi/acpica/utstring.c
@@ -145,73 +145,6 @@ void acpi_ut_print_string(char *string, u16 max_length)
145 145
146/******************************************************************************* 146/*******************************************************************************
147 * 147 *
148 * FUNCTION: acpi_ut_valid_acpi_char
149 *
150 * PARAMETERS: char - The character to be examined
151 * position - Byte position (0-3)
152 *
153 * RETURN: TRUE if the character is valid, FALSE otherwise
154 *
155 * DESCRIPTION: Check for a valid ACPI character. Must be one of:
156 * 1) Upper case alpha
157 * 2) numeric
158 * 3) underscore
159 *
160 * We allow a '!' as the last character because of the ASF! table
161 *
162 ******************************************************************************/
163
164u8 acpi_ut_valid_acpi_char(char character, u32 position)
165{
166
167 if (!((character >= 'A' && character <= 'Z') ||
168 (character >= '0' && character <= '9') || (character == '_'))) {
169
170 /* Allow a '!' in the last position */
171
172 if (character == '!' && position == 3) {
173 return (TRUE);
174 }
175
176 return (FALSE);
177 }
178
179 return (TRUE);
180}
181
182/*******************************************************************************
183 *
184 * FUNCTION: acpi_ut_valid_acpi_name
185 *
186 * PARAMETERS: name - The name to be examined. Does not have to
187 * be NULL terminated string.
188 *
189 * RETURN: TRUE if the name is valid, FALSE otherwise
190 *
191 * DESCRIPTION: Check for a valid ACPI name. Each character must be one of:
192 * 1) Upper case alpha
193 * 2) numeric
194 * 3) underscore
195 *
196 ******************************************************************************/
197
198u8 acpi_ut_valid_acpi_name(char *name)
199{
200 u32 i;
201
202 ACPI_FUNCTION_ENTRY();
203
204 for (i = 0; i < ACPI_NAME_SIZE; i++) {
205 if (!acpi_ut_valid_acpi_char(name[i], i)) {
206 return (FALSE);
207 }
208 }
209
210 return (TRUE);
211}
212
213/*******************************************************************************
214 *
215 * FUNCTION: acpi_ut_repair_name 148 * FUNCTION: acpi_ut_repair_name
216 * 149 *
217 * PARAMETERS: name - The ACPI name to be repaired 150 * PARAMETERS: name - The ACPI name to be repaired
@@ -253,7 +186,7 @@ void acpi_ut_repair_name(char *name)
253 /* Check each character in the name */ 186 /* Check each character in the name */
254 187
255 for (i = 0; i < ACPI_NAME_SIZE; i++) { 188 for (i = 0; i < ACPI_NAME_SIZE; i++) {
256 if (acpi_ut_valid_acpi_char(name[i], i)) { 189 if (acpi_ut_valid_name_char(name[i], i)) {
257 continue; 190 continue;
258 } 191 }
259 192
diff --git a/tools/power/acpi/tools/acpidump/Makefile b/tools/power/acpi/tools/acpidump/Makefile
index 8d761576e91b..2942cdced2ad 100644
--- a/tools/power/acpi/tools/acpidump/Makefile
+++ b/tools/power/acpi/tools/acpidump/Makefile
@@ -31,6 +31,7 @@ TOOL_OBJS = \
31 osunixxf.o\ 31 osunixxf.o\
32 tbprint.o\ 32 tbprint.o\
33 tbxfroot.o\ 33 tbxfroot.o\
34 utascii.o\
34 utbuffer.o\ 35 utbuffer.o\
35 utdebug.o\ 36 utdebug.o\
36 utexcep.o\ 37 utexcep.o\
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c
index a39e44533369..fb8f1d9e3b1b 100644
--- a/tools/power/acpi/tools/acpidump/apdump.c
+++ b/tools/power/acpi/tools/acpidump/apdump.c
@@ -68,7 +68,7 @@ u8 ap_is_valid_header(struct acpi_table_header *table)
68 68
69 /* Make sure signature is all ASCII and a valid ACPI name */ 69 /* Make sure signature is all ASCII and a valid ACPI name */
70 70
71 if (!acpi_ut_valid_acpi_name(table->signature)) { 71 if (!acpi_ut_valid_nameseg(table->signature)) {
72 acpi_log_error("Table signature (0x%8.8X) is invalid\n", 72 acpi_log_error("Table signature (0x%8.8X) is invalid\n",
73 *(u32 *)table->signature); 73 *(u32 *)table->signature);
74 return (FALSE); 74 return (FALSE);
@@ -407,6 +407,12 @@ int ap_dump_table_from_file(char *pathname)
407 return (-1); 407 return (-1);
408 } 408 }
409 409
410 if (!acpi_ut_valid_nameseg(table->signature)) {
411 acpi_log_error
412 ("No valid ACPI signature was found in input file %s\n",
413 pathname);
414 }
415
410 /* File must be at least as long as the table length */ 416 /* File must be at least as long as the table length */
411 417
412 if (table->length > file_size) { 418 if (table->length > file_size) {