source: trunk/libs/newlib/src/libgloss/sparc_leon/asm-leon/lambapp.h @ 444

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

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

File size: 5.2 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#ifndef _LAMBAPP_H
27#define _LAMBAPP_H
28
29
30/* Include VENDOR and DEVICE definitions */
31#include "lambapp_devs.h"
32
33#ifdef __cplusplus
34extern "C"
35{
36#endif
37
38  struct ambapp_dev_hdr;
39  struct ambapp_apb_info;
40  struct ambapp_ahb_info;
41
42  struct ambapp_dev_hdr
43  {
44    struct ambapp_dev_hdr *next;        /* Next */
45    struct ambapp_dev_hdr *prev;        /* Previous Device. If (this == prev->child) prev is bus bridge */
46    struct ambapp_dev_hdr *children;    /* Points to first device on sub-bus */
47    void *owner;                /* Owner of this AMBA device */
48    unsigned char dev_type;     /* AHB MST, AHB SLV or APB SLV */
49    unsigned char vendor;       /* Vendor ID */
50    unsigned short device;      /* Device ID */
51    void *devinfo;              /* Device info (APB or AHB depending on type) */
52  };
53
54#define AMBAPP_FLAG_FFACT_DIR   0x100   /* Frequency factor direction, 0=down, 1=up */
55#define AMBAPP_FLAG_FFACT       0x0f0   /* Frequency factor against top bus */
56#define AMBAPP_FLAG_MBUS        0x00c
57#define AMBAPP_FLAG_SBUS        0x003
58
59  struct ambapp_apb_info
60  {
61    /* COMMON */
62    unsigned char irq;
63    unsigned char ver;
64
65    /* APB SPECIFIC */
66    unsigned int start;
67    unsigned int mask;
68  };
69
70  struct ambapp_ahb_info
71  {
72    /* COMMON */
73    unsigned char irq;
74    unsigned char ver;
75
76    /* AHB SPECIFIC */
77    unsigned int start[4];
78    unsigned int mask[4];
79    char type[4];               /* type[N] Determine type of start[N]-mask[N], 2=AHB Memory Space, 3=AHB I/O Space */
80    unsigned int custom[3];
81  };
82
83/* Describes a complete AMBA Core. Each device may consist of 3 interfaces */
84  struct ambapp_dev_info
85  {
86    char irq;                   /* irq=-1 indicate no IRQ */
87    unsigned char vendor;
88    unsigned short device;
89    int index;                  /* Core index if multiple "subcores" in one */
90    struct ambapp_ahb_info *ahb_mst;
91    struct ambapp_ahb_info *ahb_slv;
92    struct ambapp_apb_info *apb_slv;
93  };
94
95  struct ambapp_mmap
96  {
97    unsigned int size;
98    unsigned int local_adr;
99    unsigned int remote_adr;
100  };
101
102/* Complete AMBA PnP information */
103  struct ambapp_bus
104  {
105    struct ambapp_mmap *mmaps;
106    struct ambapp_dev_hdr *root;
107  };
108
109/*
110 * Return values
111 *  0 - continue
112 *  1 - stop scanning
113 */
114  typedef int (*ambapp_func_t) (struct ambapp_dev_hdr * dev, int index,
115                                int maxdepth, void *arg);
116
117#define DEV_IS_FREE(dev) (dev->owner == NULL)
118#define DEV_IS_ALLOCATED(dev) (dev->owner != NULL)
119
120/* Options to ambapp_for_each */
121#define OPTIONS_AHB_MSTS        0x00000001
122#define OPTIONS_AHB_SLVS        0x00000002
123#define OPTIONS_APB_SLVS        0x00000004
124#define OPTIONS_ALL_DEVS        (OPTIONS_AHB_MSTS|OPTIONS_AHB_SLVS|OPTIONS_APB_SLVS)
125
126#define OPTIONS_FREE            0x00000010
127#define OPTIONS_ALLOCATED       0x00000020
128#define OPTIONS_ALL             (OPTIONS_FREE|OPTIONS_ALLOCATED)
129
130/* Depth first search, Defualt is breth first search. */
131#define OPTIONS_DEPTH_FIRST     0x00000100
132
133#define DEV_AHB_NONE 0
134#define DEV_AHB_MST  1
135#define DEV_AHB_SLV  2
136#define DEV_APB_SLV 3
137
138/* Structures used to access Plug&Play information directly */
139  struct ambapp_pnp_ahb
140  {
141    const unsigned int id;      /* VENDOR, DEVICE, VER, IRQ, */
142    const unsigned int custom[3];
143    const unsigned int mbar[4]; /* MASK, ADDRESS, TYPE, CACHABLE/PREFETCHABLE */
144  };
145
146  struct ambapp_pnp_apb
147  {
148    const unsigned int id;      /* VENDOR, DEVICE, VER, IRQ, */
149    const unsigned int iobar;   /* MASK, ADDRESS, TYPE, CACHABLE/PREFETCHABLE */
150  };
151
152#define ambapp_pnp_vendor(id) (((id) >> 24) & 0xff)
153#define ambapp_pnp_device(id) (((id) >> 12) & 0xfff)
154#define ambapp_pnp_ver(id) (((id)>>5) & 0x1f)
155#define ambapp_pnp_irq(id) ((id) & 0x1f)
156
157#define ambapp_pnp_start(mbar)  (((mbar) & 0xfff00000) & (((mbar) & 0xfff0) << 16))
158#define ambapp_pnp_mbar_mask(mbar) (((mbar)>>4) & 0xfff)
159#define ambapp_pnp_mbar_type(mbar) ((mbar) & 0xf)
160
161#define ambapp_pnp_apb_start(iobar, base) ((base) | ((((iobar) & 0xfff00000)>>12) & (((iobar) & 0xfff0)<<4)) )
162#define ambapp_pnp_apb_mask(iobar) ((~(ambapp_pnp_mbar_mask(iobar)<<8) & 0x000fffff) + 1)
163
164#define AMBA_TYPE_AHBIO_ADDR(addr,base_ioarea) ((unsigned int)(base_ioarea) | ((addr) >> 12))
165
166#define AMBA_TYPE_APBIO 0x1
167#define AMBA_TYPE_MEM   0x2
168#define AMBA_TYPE_AHBIO 0x3
169
170  extern int find_apbslv (int vendor, int device,
171                          struct ambapp_apb_info *dev);
172
173#ifdef __cplusplus
174}
175#endif
176
177#endif
Note: See TracBrowser for help on using the repository browser.