1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acresrc.h"
47
48#define _COMPONENT ACPI_RESOURCES
49ACPI_MODULE_NAME("rsdump")
50
51#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DISASSEMBLER) || defined(ACPI_DEBUGGER)
52
53static void acpi_rs_out_string(char *title, char *value);
54
55static void acpi_rs_out_integer8(char *title, u8 value);
56
57static void acpi_rs_out_integer16(char *title, u16 value);
58
59static void acpi_rs_out_integer32(char *title, u32 value);
60
61static void acpi_rs_out_integer64(char *title, u64 value);
62
63static void acpi_rs_out_title(char *title);
64
65static void acpi_rs_dump_byte_list(u16 length, u8 *data);
66
67static void acpi_rs_dump_word_list(u16 length, u16 *data);
68
69static void acpi_rs_dump_dword_list(u8 length, u32 *data);
70
71static void acpi_rs_dump_short_byte_list(u8 length, u8 *data);
72
73static void
74acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source);
75
76static void acpi_rs_dump_address_common(union acpi_resource_data *resource);
77
78static void
79acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table);
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94static void
95acpi_rs_dump_descriptor(void *resource, struct acpi_rsdump_info *table)
96{
97 u8 *target = NULL;
98 u8 *previous_target;
99 char *name;
100 u8 count;
101
102
103
104 count = table->offset;
105
106 while (count) {
107 previous_target = target;
108 target = ACPI_ADD_PTR(u8, resource, table->offset);
109 name = table->name;
110
111 switch (table->opcode) {
112 case ACPI_RSD_TITLE:
113
114
115
116 if (table->name) {
117 acpi_os_printf("%s Resource\n", name);
118 }
119 break;
120
121
122
123 case ACPI_RSD_LITERAL:
124
125 acpi_rs_out_string(name,
126 ACPI_CAST_PTR(char, table->pointer));
127 break;
128
129 case ACPI_RSD_STRING:
130
131 acpi_rs_out_string(name, ACPI_CAST_PTR(char, target));
132 break;
133
134
135
136 case ACPI_RSD_UINT8:
137
138 if (table->pointer) {
139 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
140 table->
141 pointer
142 [*target]));
143 } else {
144 acpi_rs_out_integer8(name, ACPI_GET8(target));
145 }
146 break;
147
148 case ACPI_RSD_UINT16:
149
150 acpi_rs_out_integer16(name, ACPI_GET16(target));
151 break;
152
153 case ACPI_RSD_UINT32:
154
155 acpi_rs_out_integer32(name, ACPI_GET32(target));
156 break;
157
158 case ACPI_RSD_UINT64:
159
160 acpi_rs_out_integer64(name, ACPI_GET64(target));
161 break;
162
163
164
165 case ACPI_RSD_1BITFLAG:
166
167 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
168 table->
169 pointer[*target &
170 0x01]));
171 break;
172
173 case ACPI_RSD_2BITFLAG:
174
175 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
176 table->
177 pointer[*target &
178 0x03]));
179 break;
180
181 case ACPI_RSD_3BITFLAG:
182
183 acpi_rs_out_string(name, ACPI_CAST_PTR(char,
184 table->
185 pointer[*target &
186 0x07]));
187 break;
188
189 case ACPI_RSD_SHORTLIST:
190
191
192
193
194 if (previous_target) {
195 acpi_rs_out_title(name);
196 acpi_rs_dump_short_byte_list(*previous_target,
197 target);
198 }
199 break;
200
201 case ACPI_RSD_SHORTLISTX:
202
203
204
205
206 if (previous_target) {
207 acpi_rs_out_title(name);
208 acpi_rs_dump_short_byte_list(*previous_target,
209 *
210 (ACPI_CAST_INDIRECT_PTR
211 (u8, target)));
212 }
213 break;
214
215 case ACPI_RSD_LONGLIST:
216
217
218
219
220 if (previous_target) {
221 acpi_rs_dump_byte_list(ACPI_GET16
222 (previous_target),
223 target);
224 }
225 break;
226
227 case ACPI_RSD_DWORDLIST:
228
229
230
231
232 if (previous_target) {
233 acpi_rs_dump_dword_list(*previous_target,
234 ACPI_CAST_PTR(u32,
235 target));
236 }
237 break;
238
239 case ACPI_RSD_WORDLIST:
240
241
242
243
244 if (previous_target) {
245 acpi_rs_dump_word_list(*previous_target,
246 *(ACPI_CAST_INDIRECT_PTR
247 (u16, target)));
248 }
249 break;
250
251 case ACPI_RSD_ADDRESS:
252
253
254
255 acpi_rs_dump_address_common(ACPI_CAST_PTR
256 (union acpi_resource_data,
257 target));
258 break;
259
260 case ACPI_RSD_SOURCE:
261
262
263
264 acpi_rs_dump_resource_source(ACPI_CAST_PTR
265 (struct
266 acpi_resource_source,
267 target));
268 break;
269
270 default:
271
272 acpi_os_printf("**** Invalid table opcode [%X] ****\n",
273 table->opcode);
274 return;
275 }
276
277 table++;
278 count--;
279 }
280}
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295static void
296acpi_rs_dump_resource_source(struct acpi_resource_source *resource_source)
297{
298 ACPI_FUNCTION_ENTRY();
299
300 if (resource_source->index == 0xFF) {
301 return;
302 }
303
304 acpi_rs_out_integer8("Resource Source Index", resource_source->index);
305
306 acpi_rs_out_string("Resource Source",
307 resource_source->string_ptr ?
308 resource_source->string_ptr : "[Not Specified]");
309}
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324static void acpi_rs_dump_address_common(union acpi_resource_data *resource)
325{
326 ACPI_FUNCTION_ENTRY();
327
328
329
330 switch (resource->address.resource_type) {
331 case ACPI_MEMORY_RANGE:
332
333 acpi_rs_dump_descriptor(resource, acpi_rs_dump_memory_flags);
334 break;
335
336 case ACPI_IO_RANGE:
337
338 acpi_rs_dump_descriptor(resource, acpi_rs_dump_io_flags);
339 break;
340
341 case ACPI_BUS_NUMBER_RANGE:
342
343 acpi_rs_out_string("Resource Type", "Bus Number Range");
344 break;
345
346 default:
347
348 acpi_rs_out_integer8("Resource Type",
349 (u8) resource->address.resource_type);
350 break;
351 }
352
353
354
355 acpi_rs_dump_descriptor(resource, acpi_rs_dump_general_flags);
356}
357
358
359
360
361
362
363
364
365
366
367
368
369
370void acpi_rs_dump_resource_list(struct acpi_resource *resource_list)
371{
372 u32 count = 0;
373 u32 type;
374
375 ACPI_FUNCTION_ENTRY();
376
377
378
379 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
380 return;
381 }
382
383
384
385 do {
386 acpi_os_printf("\n[%02X] ", count);
387 count++;
388
389
390
391 type = resource_list->type;
392 if (type > ACPI_RESOURCE_TYPE_MAX) {
393 acpi_os_printf
394 ("Invalid descriptor type (%X) in resource list\n",
395 resource_list->type);
396 return;
397 }
398
399
400
401 if (!resource_list->length) {
402 acpi_os_printf
403 ("Invalid zero length descriptor in resource list\n");
404 return;
405 }
406
407
408
409 if (type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
410 acpi_rs_dump_descriptor(&resource_list->data,
411 acpi_gbl_dump_serial_bus_dispatch
412 [resource_list->data.
413 common_serial_bus.type]);
414 } else {
415 acpi_rs_dump_descriptor(&resource_list->data,
416 acpi_gbl_dump_resource_dispatch
417 [type]);
418 }
419
420
421
422 resource_list = ACPI_NEXT_RESOURCE(resource_list);
423
424
425
426 } while (type != ACPI_RESOURCE_TYPE_END_TAG);
427}
428
429
430
431
432
433
434
435
436
437
438
439
440
441void acpi_rs_dump_irq_list(u8 * route_table)
442{
443 struct acpi_pci_routing_table *prt_element;
444 u8 count;
445
446 ACPI_FUNCTION_ENTRY();
447
448
449
450 if (!ACPI_IS_DEBUG_ENABLED(ACPI_LV_RESOURCES, _COMPONENT)) {
451 return;
452 }
453
454 prt_element = ACPI_CAST_PTR(struct acpi_pci_routing_table, route_table);
455
456
457
458 for (count = 0; prt_element->length; count++) {
459 acpi_os_printf("\n[%02X] PCI IRQ Routing Table Package\n",
460 count);
461 acpi_rs_dump_descriptor(prt_element, acpi_rs_dump_prt);
462
463 prt_element = ACPI_ADD_PTR(struct acpi_pci_routing_table,
464 prt_element, prt_element->length);
465 }
466}
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482static void acpi_rs_out_string(char *title, char *value)
483{
484 acpi_os_printf("%27s : %s", title, value);
485 if (!*value) {
486 acpi_os_printf("[NULL NAMESTRING]");
487 }
488 acpi_os_printf("\n");
489}
490
491static void acpi_rs_out_integer8(char *title, u8 value)
492{
493 acpi_os_printf("%27s : %2.2X\n", title, value);
494}
495
496static void acpi_rs_out_integer16(char *title, u16 value)
497{
498 acpi_os_printf("%27s : %4.4X\n", title, value);
499}
500
501static void acpi_rs_out_integer32(char *title, u32 value)
502{
503 acpi_os_printf("%27s : %8.8X\n", title, value);
504}
505
506static void acpi_rs_out_integer64(char *title, u64 value)
507{
508 acpi_os_printf("%27s : %8.8X%8.8X\n", title, ACPI_FORMAT_UINT64(value));
509}
510
511static void acpi_rs_out_title(char *title)
512{
513 acpi_os_printf("%27s : ", title);
514}
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529static void acpi_rs_dump_byte_list(u16 length, u8 * data)
530{
531 u8 i;
532
533 for (i = 0; i < length; i++) {
534 acpi_os_printf("%25s%2.2X : %2.2X\n", "Byte", i, data[i]);
535 }
536}
537
538static void acpi_rs_dump_short_byte_list(u8 length, u8 * data)
539{
540 u8 i;
541
542 for (i = 0; i < length; i++) {
543 acpi_os_printf("%X ", data[i]);
544 }
545 acpi_os_printf("\n");
546}
547
548static void acpi_rs_dump_dword_list(u8 length, u32 * data)
549{
550 u8 i;
551
552 for (i = 0; i < length; i++) {
553 acpi_os_printf("%25s%2.2X : %8.8X\n", "Dword", i, data[i]);
554 }
555}
556
557static void acpi_rs_dump_word_list(u16 length, u16 *data)
558{
559 u16 i;
560
561 for (i = 0; i < length; i++) {
562 acpi_os_printf("%25s%2.2X : %4.4X\n", "Word", i, data[i]);
563 }
564}
565
566#endif
567