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