source: rtems/bsps/shared/grlib/amba/ambapp_old.c @ 7eb606d3

5
Last change on this file since 7eb606d3 was 7eb606d3, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/18 at 17:31:04

grlib: Move source files

Update #3678.

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  Old AMBA scanning Interface provided for backwards compability
3 *
4 *  COPYRIGHT (c) 2011
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 <grlib/ambapp.h>
13
14struct ambapp_dev_find_match_arg {
15  int      index;
16  int      count;
17  int      type;
18  void      *dev;
19};
20
21/* AMBA PP find routines */
22static int ambapp_dev_find_match(struct ambapp_dev *dev, int index, void *arg)
23{
24  struct ambapp_dev_find_match_arg *p = arg;
25
26  if (p->index == 0) {
27    /* Found controller, stop */
28    if (p->type == DEV_APB_SLV) {
29      *(struct ambapp_apb_info *)p->dev = *DEV_TO_APB(dev);
30      p->dev = ((struct ambapp_apb_info *)p->dev)+1;
31    } else {
32      *(struct ambapp_ahb_info *)p->dev = *DEV_TO_AHB(dev);
33      p->dev = ((struct ambapp_ahb_info *)p->dev)+1;
34    }
35    p->count--;
36    if (p->count < 1)
37      return 1;
38  } else {
39    p->index--;
40  }
41  return 0;
42}
43
44int ambapp_find_apbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index, int maxno)
45{
46  struct ambapp_dev_find_match_arg arg;
47
48  arg.index = index;
49  arg.count = maxno;
50  arg.type = DEV_APB_SLV; /* APB */
51  arg.dev = dev;
52
53  ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device,
54                  ambapp_dev_find_match, &arg);
55
56  return maxno - arg.count;
57}
58
59int ambapp_find_apbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev)
60{
61  return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, 1);
62}
63
64int ambapp_find_apbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int index)
65{
66  return ambapp_find_apbslvs_next(abus, vendor, device, dev, index, 1);
67}
68
69int ambapp_find_apbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_apb_info *dev, int maxno)
70{
71  return ambapp_find_apbslvs_next(abus, vendor, device, dev, 0, maxno);
72}
73
74int ambapp_get_number_apbslv_devices(struct ambapp_bus *abus, int vendor, int device)
75{
76  return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_APB_SLVS), vendor, device);
77}
78
79int ambapp_find_ahbslvs_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index, int maxno)
80{
81  struct ambapp_dev_find_match_arg arg;
82
83  arg.index = index;
84  arg.count = maxno;
85  arg.type = DEV_AHB_SLV; /* AHB SLV */
86  arg.dev = dev;
87
88  ambapp_for_each(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device,
89                  ambapp_dev_find_match, &arg);
90
91  return maxno - arg.count;
92}
93
94int ambapp_find_ahbslv_next(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int index)
95{
96  return ambapp_find_ahbslvs_next(abus, vendor, device, dev, index, 1);
97}
98
99int ambapp_find_ahbslv(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev)
100{
101  return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, 1);
102}
103
104int ambapp_find_ahbslvs(struct ambapp_bus *abus, int vendor, int device, struct ambapp_ahb_info *dev, int maxno)
105{
106  return ambapp_find_ahbslvs_next(abus, vendor, device, dev, 0, maxno);
107}
108
109int ambapp_get_number_ahbslv_devices(struct ambapp_bus *abus, int vendor, int device)
110{
111  return ambapp_dev_count(abus, (OPTIONS_ALL|OPTIONS_AHB_SLVS), vendor, device);
112}
Note: See TracBrowser for help on using the repository browser.