This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_db_set_output_destination
- acpi_db_dump_external_object
- acpi_db_prep_namestring
- acpi_db_local_ns_lookup
- acpi_db_uint32_to_hex_string
- acpi_db_second_pass_parse
- acpi_db_dump_buffer
1
2
3
4
5
6
7
8 #include <acpi/acpi.h>
9 #include "accommon.h"
10 #include "acnamesp.h"
11 #include "acdebug.h"
12
13 #define _COMPONENT ACPI_CA_DEBUGGER
14 ACPI_MODULE_NAME("dbutils")
15
16
17 #ifdef ACPI_OBSOLETE_FUNCTIONS
18 acpi_status acpi_db_second_pass_parse(union acpi_parse_object *root);
19
20 void acpi_db_dump_buffer(u32 address);
21 #endif
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 acpi_object_type
37 acpi_db_match_argument(char *user_argument,
38 struct acpi_db_argument_info *arguments)
39 {
40 u32 i;
41
42 if (!user_argument || user_argument[0] == 0) {
43 return (ACPI_TYPE_NOT_FOUND);
44 }
45
46 for (i = 0; arguments[i].name; i++) {
47 if (strstr(ACPI_CAST_PTR(char, arguments[i].name),
48 ACPI_CAST_PTR(char,
49 user_argument)) == arguments[i].name) {
50 return (i);
51 }
52 }
53
54
55
56 return (ACPI_TYPE_NOT_FOUND);
57 }
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 void acpi_db_set_output_destination(u32 output_flags)
73 {
74
75 acpi_gbl_db_output_flags = (u8)output_flags;
76
77 if ((output_flags & ACPI_DB_REDIRECTABLE_OUTPUT) &&
78 acpi_gbl_db_output_to_file) {
79 acpi_dbg_level = acpi_gbl_db_debug_level;
80 } else {
81 acpi_dbg_level = acpi_gbl_db_console_debug_level;
82 }
83 }
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 void acpi_db_dump_external_object(union acpi_object *obj_desc, u32 level)
99 {
100 u32 i;
101
102 if (!obj_desc) {
103 acpi_os_printf("[Null Object]\n");
104 return;
105 }
106
107 for (i = 0; i < level; i++) {
108 acpi_os_printf(" ");
109 }
110
111 switch (obj_desc->type) {
112 case ACPI_TYPE_ANY:
113
114 acpi_os_printf("[Null Object] (Type=0)\n");
115 break;
116
117 case ACPI_TYPE_INTEGER:
118
119 acpi_os_printf("[Integer] = %8.8X%8.8X\n",
120 ACPI_FORMAT_UINT64(obj_desc->integer.value));
121 break;
122
123 case ACPI_TYPE_STRING:
124
125 acpi_os_printf("[String] Length %.2X = ",
126 obj_desc->string.length);
127 acpi_ut_print_string(obj_desc->string.pointer, ACPI_UINT8_MAX);
128 acpi_os_printf("\n");
129 break;
130
131 case ACPI_TYPE_BUFFER:
132
133 acpi_os_printf("[Buffer] Length %.2X = ",
134 obj_desc->buffer.length);
135 if (obj_desc->buffer.length) {
136 if (obj_desc->buffer.length > 16) {
137 acpi_os_printf("\n");
138 }
139
140 acpi_ut_debug_dump_buffer(ACPI_CAST_PTR
141 (u8,
142 obj_desc->buffer.pointer),
143 obj_desc->buffer.length,
144 DB_BYTE_DISPLAY, _COMPONENT);
145 } else {
146 acpi_os_printf("\n");
147 }
148 break;
149
150 case ACPI_TYPE_PACKAGE:
151
152 acpi_os_printf("[Package] Contains %u Elements:\n",
153 obj_desc->package.count);
154
155 for (i = 0; i < obj_desc->package.count; i++) {
156 acpi_db_dump_external_object(&obj_desc->package.
157 elements[i], level + 1);
158 }
159 break;
160
161 case ACPI_TYPE_LOCAL_REFERENCE:
162
163 acpi_os_printf("[Object Reference] = ");
164 acpi_db_display_internal_object(obj_desc->reference.handle,
165 NULL);
166 break;
167
168 case ACPI_TYPE_PROCESSOR:
169
170 acpi_os_printf("[Processor]\n");
171 break;
172
173 case ACPI_TYPE_POWER:
174
175 acpi_os_printf("[Power Resource]\n");
176 break;
177
178 default:
179
180 acpi_os_printf("[Unknown Type] %X\n", obj_desc->type);
181 break;
182 }
183 }
184
185
186
187
188
189
190
191
192
193
194
195
196
197 void acpi_db_prep_namestring(char *name)
198 {
199
200 if (!name) {
201 return;
202 }
203
204 acpi_ut_strupr(name);
205
206
207
208 if (*name == '/') {
209 *name = '\\';
210 }
211
212
213
214 if (ACPI_IS_ROOT_PREFIX(*name)) {
215 name++;
216 }
217
218
219
220 while (*name) {
221 if ((*name == '/') || (*name == '\\')) {
222 *name = '.';
223 }
224
225 name++;
226 }
227 }
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244 struct acpi_namespace_node *acpi_db_local_ns_lookup(char *name)
245 {
246 char *internal_path;
247 acpi_status status;
248 struct acpi_namespace_node *node = NULL;
249
250 acpi_db_prep_namestring(name);
251
252
253
254 status = acpi_ns_internalize_name(name, &internal_path);
255 if (ACPI_FAILURE(status)) {
256 acpi_os_printf("Invalid namestring: %s\n", name);
257 return (NULL);
258 }
259
260
261
262
263
264 status = acpi_ns_lookup(NULL, internal_path, ACPI_TYPE_ANY,
265 ACPI_IMODE_EXECUTE,
266 ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE,
267 NULL, &node);
268 if (ACPI_FAILURE(status)) {
269 acpi_os_printf("Could not locate name: %s, %s\n",
270 name, acpi_format_exception(status));
271 }
272
273 ACPI_FREE(internal_path);
274 return (node);
275 }
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293 void acpi_db_uint32_to_hex_string(u32 value, char *buffer)
294 {
295 int i;
296
297 if (value == 0) {
298 strcpy(buffer, "0");
299 return;
300 }
301
302 buffer[8] = '\0';
303
304 for (i = 7; i >= 0; i--) {
305 buffer[i] = acpi_gbl_upper_hex_digits[value & 0x0F];
306 value = value >> 4;
307 }
308 }
309
310 #ifdef ACPI_OBSOLETE_FUNCTIONS
311
312
313
314
315
316
317
318
319
320
321
322
323
324 acpi_status acpi_db_second_pass_parse(union acpi_parse_object *root)
325 {
326 union acpi_parse_object *op = root;
327 union acpi_parse_object *method;
328 union acpi_parse_object *search_op;
329 union acpi_parse_object *start_op;
330 acpi_status status = AE_OK;
331 u32 base_aml_offset;
332 struct acpi_walk_state *walk_state;
333
334 ACPI_FUNCTION_ENTRY();
335
336 acpi_os_printf("Pass two parse ....\n");
337
338 while (op) {
339 if (op->common.aml_opcode == AML_METHOD_OP) {
340 method = op;
341
342
343
344 walk_state =
345 acpi_ds_create_walk_state(0, NULL, NULL, NULL);
346 if (!walk_state) {
347 return (AE_NO_MEMORY);
348 }
349
350
351
352 walk_state->parser_state.aml =
353 walk_state->parser_state.aml_start =
354 method->named.data;
355 walk_state->parser_state.aml_end =
356 walk_state->parser_state.pkg_end =
357 method->named.data + method->named.length;
358 walk_state->parser_state.start_scope = op;
359
360 walk_state->descending_callback =
361 acpi_ds_load1_begin_op;
362 walk_state->ascending_callback = acpi_ds_load1_end_op;
363
364
365
366 status = acpi_ps_parse_aml(walk_state);
367
368 base_aml_offset =
369 (method->common.value.arg)->common.aml_offset + 1;
370 start_op = (method->common.value.arg)->common.next;
371 search_op = start_op;
372
373 while (search_op) {
374 search_op->common.aml_offset += base_aml_offset;
375 search_op =
376 acpi_ps_get_depth_next(start_op, search_op);
377 }
378 }
379
380 if (op->common.aml_opcode == AML_REGION_OP) {
381
382
383
384
385
386
387
388 }
389
390 if (ACPI_FAILURE(status)) {
391 break;
392 }
393
394 op = acpi_ps_get_depth_next(root, op);
395 }
396
397 return (status);
398 }
399
400
401
402
403
404
405
406
407
408
409
410
411
412 void acpi_db_dump_buffer(u32 address)
413 {
414
415 acpi_os_printf("\nLocation %X:\n", address);
416
417 acpi_dbg_level |= ACPI_LV_TABLES;
418 acpi_ut_debug_dump_buffer(ACPI_TO_POINTER(address), 64, DB_BYTE_DISPLAY,
419 ACPI_UINT32_MAX);
420 }
421 #endif