This source file includes following definitions.
- acpi_ut_get_next_predefined_method
- acpi_ut_match_predefined_method
- acpi_ut_get_expected_return_types
- acpi_ut_match_resource_name
- acpi_ut_display_predefined_method
- acpi_ut_get_argument_types
- acpi_ut_get_resource_bit_width
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acpredef.h"
13
14 #define _COMPONENT ACPI_UTILITIES
15 ACPI_MODULE_NAME("utpredef")
16
17
18
19
20
21 static const char *ut_rtype_names[] = {
22 "/Integer",
23 "/String",
24 "/Buffer",
25 "/Package",
26 "/Reference",
27 };
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 const union acpi_predefined_info *acpi_ut_get_next_predefined_method(const union
44 acpi_predefined_info
45 *this_name)
46 {
47
48
49
50
51
52 if ((this_name->info.expected_btypes & ACPI_RTYPE_PACKAGE) &&
53 (this_name->info.expected_btypes != ACPI_RTYPE_ALL)) {
54 this_name++;
55 }
56
57 this_name++;
58 return (this_name);
59 }
60
61
62
63
64
65
66
67
68
69
70
71
72
73 const union acpi_predefined_info *acpi_ut_match_predefined_method(char *name)
74 {
75 const union acpi_predefined_info *this_name;
76
77
78
79 if (name[0] != '_') {
80 return (NULL);
81 }
82
83
84
85 this_name = acpi_gbl_predefined_methods;
86 while (this_name->info.name[0]) {
87 if (ACPI_COMPARE_NAMESEG(name, this_name->info.name)) {
88 return (this_name);
89 }
90
91 this_name = acpi_ut_get_next_predefined_method(this_name);
92 }
93
94 return (NULL);
95 }
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 void acpi_ut_get_expected_return_types(char *buffer, u32 expected_btypes)
111 {
112 u32 this_rtype;
113 u32 i;
114 u32 j;
115
116 if (!expected_btypes) {
117 strcpy(buffer, "NONE");
118 return;
119 }
120
121 j = 1;
122 buffer[0] = 0;
123 this_rtype = ACPI_RTYPE_INTEGER;
124
125 for (i = 0; i < ACPI_NUM_RTYPES; i++) {
126
127
128
129 if (expected_btypes & this_rtype) {
130 strcat(buffer, &ut_rtype_names[i][j]);
131 j = 0;
132 }
133
134 this_rtype <<= 1;
135 }
136 }
137
138
139
140
141
142
143
144 #if (defined ACPI_ASL_COMPILER || defined ACPI_HELP_APP)
145
146
147
148 static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types);
149
150
151
152 static const char *ut_external_type_names[] =
153 {
154 ", UNSUPPORTED-TYPE",
155 ", Integer",
156 ", String",
157 ", Buffer",
158 ", Package"
159 };
160
161
162
163 static const char *ut_resource_type_names[] = {
164 "/1",
165 "/2",
166 "/3",
167 "/8",
168 "/16",
169 "/32",
170 "/64",
171 "/variable",
172 };
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188 const union acpi_predefined_info *acpi_ut_match_resource_name(char *name)
189 {
190 const union acpi_predefined_info *this_name;
191
192
193
194
195
196 if (name[0] != '_') {
197 return (NULL);
198 }
199
200
201
202 this_name = acpi_gbl_resource_names;
203 while (this_name->info.name[0]) {
204 if (ACPI_COMPARE_NAMESEG(name, this_name->info.name)) {
205 return (this_name);
206 }
207
208 this_name++;
209 }
210
211 return (NULL);
212 }
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230 void
231 acpi_ut_display_predefined_method(char *buffer,
232 const union acpi_predefined_info *this_name,
233 u8 multi_line)
234 {
235 u32 arg_count;
236
237
238
239
240
241 arg_count = acpi_ut_get_argument_types(buffer,
242 this_name->info.argument_list);
243
244 if (multi_line) {
245 printf(" ");
246 }
247
248 printf("%4.4s Requires %s%u argument%s",
249 this_name->info.name,
250 (this_name->info.argument_list & ARG_COUNT_IS_MINIMUM) ?
251 "(at least) " : "", arg_count, arg_count != 1 ? "s" : "");
252
253
254
255 if (arg_count > 0) {
256 printf(" (%s)", buffer);
257 }
258
259 if (multi_line) {
260 printf("\n ");
261 }
262
263
264
265 if (this_name->info.expected_btypes) {
266 acpi_ut_get_expected_return_types(buffer,
267 this_name->info.
268 expected_btypes);
269 printf(" Return value types: %s\n", buffer);
270 } else {
271 printf(" No return value\n");
272 }
273 }
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290 static u32 acpi_ut_get_argument_types(char *buffer, u16 argument_types)
291 {
292 u16 this_argument_type;
293 u16 sub_index;
294 u16 arg_count;
295 u32 i;
296
297 *buffer = 0;
298 sub_index = 2;
299
300
301
302 arg_count = METHOD_GET_ARG_COUNT(argument_types);
303 if (arg_count > METHOD_PREDEF_ARGS_MAX) {
304 printf("**** Invalid argument count (%u) "
305 "in predefined info structure\n", arg_count);
306 return (arg_count);
307 }
308
309
310
311 for (i = 0; i < arg_count; i++) {
312 this_argument_type = METHOD_GET_NEXT_TYPE(argument_types);
313
314 if (!this_argument_type
315 || (this_argument_type > METHOD_MAX_ARG_TYPE)) {
316 printf("**** Invalid argument type (%u) "
317 "in predefined info structure\n",
318 this_argument_type);
319 return (arg_count);
320 }
321
322 strcat(buffer,
323 ut_external_type_names[this_argument_type] + sub_index);
324 sub_index = 0;
325 }
326
327 return (arg_count);
328 }
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343 u32 acpi_ut_get_resource_bit_width(char *buffer, u16 types)
344 {
345 u32 i;
346 u16 sub_index;
347 u32 found;
348
349 *buffer = 0;
350 sub_index = 1;
351 found = 0;
352
353 for (i = 0; i < NUM_RESOURCE_WIDTHS; i++) {
354 if (types & 1) {
355 strcat(buffer, &(ut_resource_type_names[i][sub_index]));
356 sub_index = 0;
357 found++;
358 }
359
360 types >>= 1;
361 }
362
363 return (found);
364 }
365 #endif