source: rtems/bsps/shared/grlib/amba/ambapp_show.c

Last change on this file was 5d5b9ee, checked in by Daniel Cederman <cederman@…>, on 11/14/22 at 09:59:08

bsps/shared/grlib: Change license to BSD-2 for files with Gaisler copyright

This patch changes the license to BSD-2 for all source files where the
copyright is held by Aeroflex Gaisler, Cobham Gaisler, or Gaisler Research.
Some files also includes copyright right statements from OAR and/or
embedded Brains in addition to Gaisler.

Updates #3053.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/*
4 *  AMBA Plug & Play routines: device information printing.
5 *
6 *  COPYRIGHT (c) 2009.
7 *  Aeroflex Gaisler.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 *    notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 *    notice, this list of conditions and the following disclaimer in the
16 *    documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <stdio.h>
32#include <grlib/ambapp.h>
33
34struct ambapp_dev_print_arg {
35  int show_depth;
36};
37
38static char *unknown = "unknown";
39
40static int ambapp_dev_print(struct ambapp_dev *dev, int index, void *arg)
41{
42  char *dev_str, *ven_str, *type_str;
43  struct ambapp_dev_print_arg *p = arg;
44  char dp[32];
45  int i=0;
46  unsigned int basereg;
47
48  if (p->show_depth) {
49    for (i=0; i<ambapp_depth(dev)*2; i+=2) {
50      dp[i] = ' ';
51      dp[i+1] = ' ';
52    }
53  }
54  dp[i] = '\0';
55
56  ven_str = ambapp_vendor_id2str(dev->vendor);
57  if (!ven_str) {
58    ven_str = unknown;
59    dev_str = unknown;
60  } else {
61    dev_str = ambapp_device_id2str(dev->vendor, dev->device);
62    if (!dev_str)
63      dev_str = unknown;
64  }
65  if (dev->dev_type == DEV_APB_SLV) {
66    /* APB */
67    basereg = DEV_TO_APB(dev)->start;
68    type_str = "apb";
69  } else {
70    /* AHB */
71    basereg = DEV_TO_AHB(dev)->start[0];
72    type_str = "ahb";
73  }
74  printf("%s |-> 0x%x:0x%x:0x%x: %s_%s, %s: 0x%x, 0x%x (OWNER: 0x%x)\n",
75         dp, index, dev->vendor, dev->device, ven_str, dev_str, type_str,
76         basereg, (unsigned int)dev, (unsigned int)dev->owner);
77
78  return 0;
79}
80
81void ambapp_print(struct ambapp_bus *abus, int show_depth)
82{
83  struct ambapp_dev_print_arg arg;
84  arg.show_depth = show_depth;
85  ambapp_for_each(abus, (OPTIONS_ALL_DEVS|OPTIONS_ALL|OPTIONS_DEPTH_FIRST), -1,
86                  -1, ambapp_dev_print, &arg);
87}
Note: See TracBrowser for help on using the repository browser.