source: trunk/libs/newlib/src/libgloss/sparc_leon/amba_dbg.c @ 581

Last change on this file since 581 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 4.0 KB
Line 
1/*
2 * Copyright (c) 2011 Aeroflex Gaisler
3 *
4 * BSD license:
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24
25
26#include <asm-leon/leon.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <string.h>
30
31/*#define DEBUG_CONFIG*/
32
33/* Structure containing address to devices found on the Amba Plug&Play bus */
34extern amba_confarea_type amba_conf;
35
36#ifdef DEBUG_CONFIG
37#define printk(fmt,arg...) \
38{ char c[1024]; \
39  sprintf(c,fmt,##arg); \
40  DEBUG_puts(c); \
41}
42#else
43#define printk(fmt,arg...)
44#endif
45
46static void
47vendor_dev_string (unsigned long conf, char *vendorbuf, char *devbuf)
48{
49  int vendor = amba_vendor (conf);
50  int dev = amba_device (conf);
51  char *devstr;
52  char *vendorstr;
53#ifdef DEBUG_CONFIG
54  sprintf (vendorbuf, "Unknown vendor %2x", vendor);
55  sprintf (devbuf, "Unknown device %2x", dev);
56  vendorstr = vendor_id2str (vendor);
57  if (vendorstr)
58    {
59      sprintf (vendorbuf, "%s", vendorstr);
60    }
61  devstr = device_id2str (vendor, dev);
62  if (devstr)
63    {
64      sprintf (devbuf, "%s", devstr);
65    }
66#else
67  vendorbuf[0] = 0;
68  devbuf[0] = 0;
69#endif
70}
71
72void
73amba_prinf_config (void)
74{
75  char devbuf[128];
76  char vendorbuf[128];
77  unsigned int conf;
78  int i = 0;
79  int j = 0;
80  unsigned int addr;
81  unsigned int m;
82  printk ("             Vendors         Slaves\n");
83  printk ("Ahb masters:\n");
84  i = 0;
85  while (i < amba_conf.ahbmst.devnr)
86    {
87      conf = amba_get_confword (amba_conf.ahbmst, i, 0);
88      vendor_dev_string (conf, vendorbuf, devbuf);
89      printk ("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor (conf),
90              amba_device (conf), amba_irq (conf), vendorbuf, devbuf);
91      for (j = 0; j < 4; j++)
92        {
93          m = amba_ahb_get_membar (amba_conf.ahbmst, i, j);
94          if (m)
95            {
96              addr = amba_membar_start (m);
97              printk (" +%i: 0x%x \n", j, addr);
98            }
99        }
100      i++;
101    }
102  printk ("Ahb slaves:\n");
103  i = 0;
104  while (i < amba_conf.ahbslv.devnr)
105    {
106      conf = amba_get_confword (amba_conf.ahbslv, i, 0);
107      vendor_dev_string (conf, vendorbuf, devbuf);
108      printk ("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor (conf),
109              amba_device (conf), amba_irq (conf), vendorbuf, devbuf);
110      for (j = 0; j < 4; j++)
111        {
112          m = amba_ahb_get_membar (amba_conf.ahbslv, i, j);
113          if (m)
114            {
115              addr = amba_membar_start (m);
116              if (amba_membar_type (m) == AMBA_TYPE_AHBIO)
117                {
118                  addr = AMBA_TYPE_AHBIO_ADDR (addr);
119                }
120              else if (amba_membar_type (m) == AMBA_TYPE_APBIO)
121                {
122                  printk ("Warning: apbio membar\n");
123                }
124              printk (" +%i: 0x%x (raw:0x%x)\n", j, addr, m);
125            }
126        }
127      i++;
128    }
129  printk ("Apb slaves:\n");
130  i = 0;
131  while (i < amba_conf.apbslv.devnr)
132    {
133
134      conf = amba_get_confword (amba_conf.apbslv, i, 0);
135      vendor_dev_string (conf, vendorbuf, devbuf);
136      printk ("%2i(%2x:%3x|%2i): %16s %16s \n", i, amba_vendor (conf),
137              amba_device (conf), amba_irq (conf), vendorbuf, devbuf);
138
139      m = amba_apb_get_membar (amba_conf.apbslv, i);
140      addr = amba_iobar_start (amba_conf.apbslv.apbmst[i], m);
141      printk (" +%2i: 0x%x (raw:0x%x) \n", 0, addr, m);
142
143      i++;
144
145    }
146
147}
Note: See TracBrowser for help on using the repository browser.