T-EMU  2
The Terma Emulator
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Amba.h
Go to the documentation of this file.
1 #ifndef TEMU_BUS_AMBA_H
2 #define TEMU_BUS_AMBA_H
3 
11 #include "temu-c/Support/Objsys.h"
12 #include <stdint.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 
19 // Vendor constants
20 static const uint32_t teAMBA_VendorGaisler = 0x01;
21 static const uint32_t teAMBA_VendorPender = 0x02;
22 static const uint32_t teAMBA_VendorEsa = 0x04;
23 static const uint32_t teAMBA_VendorAstrium = 0x06;
24 static const uint32_t teAMBA_VendorOpenChip = 0x07;
25 static const uint32_t teAMBA_VendorOpenCores = 0x08;
26 static const uint32_t teAMBA_VendorVarious = 0x09;
27 static const uint32_t teAMBA_VendorDlr = 0x0a;
28 static const uint32_t teAMBA_VendorEonic = 0x0b;
29 static const uint32_t teAMBA_VendorParisTech = 0x0c;
30 static const uint32_t teAMBA_VendorRadionor = 0x0f;
31 static const uint32_t teAMBA_VendorGleichmann = 0x10;
32 static const uint32_t teAMBA_VendorMenta = 0x11;
33 static const uint32_t teAMBA_VendorSun = 0x13; // Oracle ?
34 static const uint32_t teAMBA_VendorMovidia = 0x14;
35 static const uint32_t teAMBA_VendorOrbita = 0x17;
36 static const uint32_t teAMBA_VendorSiemens = 0x1a;
37 static const uint32_t teAMBA_VendorActel = 0xac;
38 static const uint32_t teAMBA_VendorCaltech = 0xca;
39 static const uint32_t teAMBA_VendorEmbeddit = 0xea;
40 
41 
43 typedef struct {
44  uint32_t IdentReg;
45  uint32_t UserDef[3];
46  uint32_t Bar[4];
48 
56 typedef struct temu_AhbIface {
57  temu_AhbPnpInfo* (*getAhbPnp)(void *Obj);
59 
60 OBJSYS_OBJ_TYPE(temu_Ahb);
61 
62 
64 typedef struct {
65  uint32_t ConfigWord;
66  uint32_t Bar;
68 
69 
77 typedef struct temu_ApbIface {
78  temu_ApbPnpInfo* (*getApbPnp)(void *Obj);
80 
81 OBJSYS_OBJ_TYPE(temu_Apb);
82 
83 
84 
85 static inline void
86 temu_ahbSetVendor(temu_AhbPnpInfo *Ahb, uint32_t Vendor)
87 {
88  Ahb->IdentReg = (Ahb->IdentReg & 0x00ffffff) | (Vendor << 24);
89 }
90 
91 
92 static inline void
93 temu_ahbSetDeviceId(temu_AhbPnpInfo *Ahb, uint32_t Device)
94 {
95  Ahb->IdentReg = (Ahb->IdentReg & 0xff000fff) | (Device << 12);
96 }
97 
98 static inline void
99 temu_ahbSetVersion(temu_AhbPnpInfo *Ahb, uint32_t Version)
100 {
101  Ahb->IdentReg = (Ahb->IdentReg & 0xfffffc1f) | (Version << 5);
102 }
103 
104 static inline void
105 temu_ahbSetIrq(temu_AhbPnpInfo *Ahb, uint32_t Irq)
106 {
107  Ahb->IdentReg = (Ahb->IdentReg & 0xffffffe0) | Irq;
108 }
109 
110 static inline uint32_t
111 temu_ahbGetIrq(temu_AhbPnpInfo *Ahb)
112 {
113  return Ahb->IdentReg & 0x1f;
114 }
115 
116 static inline void
117 temu_ahbSetUserDef(temu_AhbPnpInfo *Ahb, int Id, uint32_t User)
118 {
119  Ahb->UserDef[Id] = User;
120 }
121 
122 static inline void
123 temu_ahbSetAddr(temu_AhbPnpInfo *Ahb, int Id, uint32_t Addr)
124 {
125  Ahb->Bar[Id] = (Ahb->Bar[Id] & 0x000fffff) | (Addr & 0xfff00000);
126 }
127 
128 static inline void
129 temu_ahbSetCP(temu_AhbPnpInfo *Ahb, int Id, uint32_t CP)
130 {
131  Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xfff0ffff) | (CP << 16);
132 }
133 
134 static inline void
135 temu_ahbSetMask(temu_AhbPnpInfo *Ahb, int Id, uint32_t Mask)
136 {
137  Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xffff000f) | (Mask << 4);
138 }
139 
140 static inline void
141 temu_ahbSetType(temu_AhbPnpInfo *Ahb, int Id, uint32_t Type)
142 {
143  Ahb->Bar[Id] = (Ahb->Bar[Id] & 0xfffffff0) | Type;
144 }
145 
146 
147 
148 static inline void
149 temu_apbSetVendorId(temu_ApbPnpInfo *Apb, uint32_t Vendor)
150 {
151  Apb->ConfigWord = (Apb->ConfigWord & 0x00ffffff) | (Vendor << 24);
152 }
153 
154 
155 static inline void
156 temu_apbSetDeviceId(temu_ApbPnpInfo *Apb, uint32_t Device)
157 {
158  Apb->ConfigWord = (Apb->ConfigWord & 0xff000fff) | (Device << 12);
159 }
160 
161 static inline void
162 temu_apbSetVersion(temu_ApbPnpInfo *Apb, uint32_t Version)
163 {
164  Apb->ConfigWord = (Apb->ConfigWord & 0xfffffc1f) | (Version << 5);
165 }
166 
167 static inline void
168 temu_apbSetIrq(temu_ApbPnpInfo *Apb, uint32_t Irq)
169 {
170  Apb->ConfigWord = (Apb->ConfigWord & 0xffffffe0) | Irq;
171 }
172 
173 static inline uint32_t
174 temu_apbGetIrq(temu_ApbPnpInfo *Apb)
175 {
176  return Apb->ConfigWord & 0x1f;
177 }
178 
179 static inline void
180 temu_apbSetAddr(temu_ApbPnpInfo *Apb, uint32_t Addr)
181 {
182  Apb->Bar = (Apb->Bar & 0x000fffff) | ((Addr & 0x000fff00) << 12);
183 }
184 
185 static inline void
186 temu_apbSetCP(temu_ApbPnpInfo *Apb, uint32_t CP)
187 {
188  Apb->Bar = (Apb->Bar & 0xfff0ffff) | (CP << 16);
189 }
190 
191 static inline void
192 temu_apbSetMask(temu_ApbPnpInfo *Apb, uint32_t Mask)
193 {
194  Apb->Bar = (Apb->Bar & 0xffff000f) | (Mask << 4);
195 }
196 
197 static inline void
198 temu_apbSetType(temu_ApbPnpInfo *Apb, uint32_t Type)
199 {
200  Apb->Bar = (Apb->Bar & 0xfffffff0) | Type;
201 }
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 
207 #endif /* ! TEMU_BUS_SERIAL_H */
struct temu_ApbIface temu_ApbIface
#define OBJSYS_OBJ_TYPE(N)
Definition: Objsys.h:74
AHB bus plug and play record.
Definition: Amba.h:43
uint32_t UserDef[3]
Definition: Amba.h:45
uint32_t ConfigWord
Definition: Amba.h:65
uint32_t Bar
Definition: Amba.h:66
struct temu_AhbIface temu_AhbIface
APB bus plug and play record.
Definition: Amba.h:64
uint32_t IdentReg
Definition: Amba.h:44
uint32_t Bar[4]
Definition: Amba.h:46