1 | /* |
---|
2 | * AMBA Plug & Play routines: device information printing. |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 2009. |
---|
5 | * Aeroflex Gaisler. |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.org/license/LICENSE. |
---|
10 | */ |
---|
11 | |
---|
12 | #include <stdio.h> |
---|
13 | #include <grlib/ambapp.h> |
---|
14 | |
---|
15 | struct ambapp_dev_print_arg { |
---|
16 | int show_depth; |
---|
17 | }; |
---|
18 | |
---|
19 | static char *unknown = "unknown"; |
---|
20 | |
---|
21 | static int ambapp_dev_print(struct ambapp_dev *dev, int index, void *arg) |
---|
22 | { |
---|
23 | char *dev_str, *ven_str, *type_str; |
---|
24 | struct ambapp_dev_print_arg *p = arg; |
---|
25 | char dp[32]; |
---|
26 | int i=0; |
---|
27 | unsigned int basereg; |
---|
28 | |
---|
29 | if (p->show_depth) { |
---|
30 | for (i=0; i<ambapp_depth(dev)*2; i+=2) { |
---|
31 | dp[i] = ' '; |
---|
32 | dp[i+1] = ' '; |
---|
33 | } |
---|
34 | } |
---|
35 | dp[i] = '\0'; |
---|
36 | |
---|
37 | ven_str = ambapp_vendor_id2str(dev->vendor); |
---|
38 | if (!ven_str) { |
---|
39 | ven_str = unknown; |
---|
40 | dev_str = unknown; |
---|
41 | } else { |
---|
42 | dev_str = ambapp_device_id2str(dev->vendor, dev->device); |
---|
43 | if (!dev_str) |
---|
44 | dev_str = unknown; |
---|
45 | } |
---|
46 | if (dev->dev_type == DEV_APB_SLV) { |
---|
47 | /* APB */ |
---|
48 | basereg = DEV_TO_APB(dev)->start; |
---|
49 | type_str = "apb"; |
---|
50 | } else { |
---|
51 | /* AHB */ |
---|
52 | basereg = DEV_TO_AHB(dev)->start[0]; |
---|
53 | type_str = "ahb"; |
---|
54 | } |
---|
55 | printf("%s |-> 0x%x:0x%x:0x%x: %s_%s, %s: 0x%x, 0x%x (OWNER: 0x%x)\n", |
---|
56 | dp, index, dev->vendor, dev->device, ven_str, dev_str, type_str, |
---|
57 | basereg, (unsigned int)dev, (unsigned int)dev->owner); |
---|
58 | |
---|
59 | return 0; |
---|
60 | } |
---|
61 | |
---|
62 | void ambapp_print(struct ambapp_bus *abus, int show_depth) |
---|
63 | { |
---|
64 | struct ambapp_dev_print_arg arg; |
---|
65 | arg.show_depth = show_depth; |
---|
66 | ambapp_for_each(abus, (OPTIONS_ALL_DEVS|OPTIONS_ALL|OPTIONS_DEPTH_FIRST), -1, |
---|
67 | -1, ambapp_dev_print, &arg); |
---|
68 | } |
---|