4 * Tsunami CChip (processor, memory, or IO)
11 #include "base/trace.hh"
12 #include "cpu/exec_context.hh"
13 #include "dev/console.hh"
14 #include "dev/tsunami_cchip.hh"
15 #include "dev/tsunamireg.h"
16 #include "dev/tsunami.hh"
17 #include "cpu/intr_control.hh"
18 #include "mem/functional_mem/memory_control.hh"
19 #include "sim/builder.hh"
20 #include "sim/system.hh"
24 TsunamiCChip::TsunamiCChip(const string
&name
, Tsunami
*t
,
25 Addr addr
, Addr mask
, MemoryController
*mmu
)
26 : MmapDevice(name
, addr
, mask
, mmu
), tsunami(t
)
28 for(int i
=0; i
< Tsunami::Max_CPUs
; i
++) {
31 dirInterrupting
[i
] = false;
36 RTCInterrupting
= false;
38 //Put back pointer in tsunami
39 tsunami
->cchip
= this;
43 TsunamiCChip::read(MemReqPtr
&req
, uint8_t *data
)
45 DPRINTF(Tsunami
, "read va=%#x size=%d\n",
46 req
->vaddr
, req
->size
);
48 Addr daddr
= (req
->paddr
& addr_mask
) >> 6;
49 ExecContext
*xc
= req
->xc
;
53 case sizeof(uint64_t):
56 *(uint64_t*)data
= 0x0;
59 panic("TSDEV_CC_MTR not implemeted\n");
62 *(uint64_t*)data
= misc
| (xc
->cpu_id
& 0x3);
68 panic("TSDEV_CC_AARx not implemeted\n");
71 *(uint64_t*)data
= dim
[0];
74 *(uint64_t*)data
= dim
[1];
77 *(uint64_t*)data
= dim
[2];
80 *(uint64_t*)data
= dim
[3];
83 *(uint64_t*)data
= dir
[0];
86 *(uint64_t*)data
= dir
[1];
89 *(uint64_t*)data
= dir
[2];
92 *(uint64_t*)data
= dir
[3];
95 *(uint64_t*)data
= drir
;
98 panic("TSDEV_CC_PRBEN not implemented\n");
104 panic("TSDEV_CC_IICx not implemented\n");
110 panic("TSDEV_CC_MPRx not implemented\n");
113 panic("default in cchip read reached, accessing 0x%x\n");
117 case sizeof(uint32_t):
118 case sizeof(uint16_t):
119 case sizeof(uint8_t):
121 panic("invalid access size(?) for tsunami register!\n");
123 DPRINTFN("Tsunami CChip ERROR: read daddr=%#x size=%d\n", daddr
, req
->size
);
129 TsunamiCChip::write(MemReqPtr
&req
, const uint8_t *data
)
131 DPRINTF(Tsunami
, "write - va=%#x size=%d \n",
132 req
->vaddr
, req
->size
);
134 Addr daddr
= (req
->paddr
& addr_mask
) >> 6;
138 case sizeof(uint64_t):
141 panic("TSDEV_CC_CSR write\n");
144 panic("TSDEV_CC_MTR write not implemented\n");
147 //If it is the seventh bit, clear the RTC interrupt
148 if ((*(uint64_t*) data
) & (1<<4)) {
149 RTCInterrupting
= false;
150 tsunami
->intrctrl
->clear(0, TheISA::INTLEVEL_IRQ2
, 0);
151 DPRINTF(Tsunami
, "clearing rtc interrupt\n");
153 } else panic("TSDEV_CC_MISC write not implemented\n");
159 panic("TSDEV_CC_AARx write not implemeted\n");
162 dim
[0] = *(uint64_t*)data
;
164 dir
[0] = dim
[0] & drir
;
165 if (!dirInterrupting
[0]) {
166 dirInterrupting
[0] = true;
167 tsunami
->intrctrl
->post(0, TheISA::INTLEVEL_IRQ1
, 0);
168 DPRINTF(Tsunami
, "posting dir interrupt to cpu 0\n");
173 dim
[1] = *(uint64_t*)data
;
175 dir
[1] = dim
[1] & drir
;
176 if (!dirInterrupting
[1]) {
177 dirInterrupting
[1] = true;
178 tsunami
->intrctrl
->post(1, TheISA::INTLEVEL_IRQ1
, 0);
179 DPRINTF(Tsunami
, "posting dir interrupt to cpu 1\n");
184 dim
[2] = *(uint64_t*)data
;
186 dir
[2] = dim
[2] & drir
;
187 if (!dirInterrupting
[2]) {
188 dirInterrupting
[2] = true;
189 tsunami
->intrctrl
->post(2, TheISA::INTLEVEL_IRQ1
, 0);
190 DPRINTF(Tsunami
, "posting dir interrupt to cpu 2\n");
195 dim
[3] = *(uint64_t*)data
;
196 if ((dim
[3] & drir
) /*And Not Already Int*/) {
197 dir
[3] = dim
[3] & drir
;
198 if (!dirInterrupting
[3]) {
199 dirInterrupting
[3] = true;
200 tsunami
->intrctrl
->post(3, TheISA::INTLEVEL_IRQ1
, 0);
201 DPRINTF(Tsunami
, "posting dir interrupt to cpu 3\n");
209 panic("TSDEV_CC_DIR write not implemented\n");
212 panic("TSDEV_CC_DRIR write not implemented\n");
215 panic("TSDEV_CC_PRBEN write not implemented\n");
221 panic("TSDEV_CC_IICx write not implemented\n");
227 panic("TSDEV_CC_MPRx write not implemented\n");
230 panic("default in cchip read reached, accessing 0x%x\n");
234 case sizeof(uint32_t):
235 case sizeof(uint16_t):
236 case sizeof(uint8_t):
238 panic("invalid access size(?) for tsunami register!\n");
241 DPRINTFN("Tsunami ERROR: write daddr=%#x size=%d\n", daddr
, req
->size
);
247 TsunamiCChip::postDRIR(uint64_t bitvector
)
250 for(int i
=0; i
< Tsunami::Max_CPUs
; i
++) {
251 if (bitvector
& dim
[i
]) {
253 if (!dirInterrupting
[i
]) {
254 dirInterrupting
[i
] = true;
255 tsunami
->intrctrl
->post(i
, TheISA::INTLEVEL_IRQ1
, 0);
256 DPRINTF(Tsunami
, "posting dir interrupt to cpu %d\n",i
);
263 TsunamiCChip::clearDRIR(uint64_t bitvector
)
266 for(int i
=0; i
< Tsunami::Max_CPUs
; i
++) {
267 dir
[i
] &= ~bitvector
;
269 dirInterrupting
[i
] = false;
270 tsunami
->intrctrl
->clear(i
, TheISA::INTLEVEL_IRQ1
, 0);
271 DPRINTF(Tsunami
, "clearing dir interrupt to cpu %d\n", i
);
278 TsunamiCChip::serialize(std::ostream
&os
)
280 // code should be written
284 TsunamiCChip::unserialize(Checkpoint
*cp
, const std::string
§ion
)
286 //code should be written
289 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip
)
291 SimObjectParam
<Tsunami
*> tsunami
;
292 SimObjectParam
<MemoryController
*> mmu
;
296 END_DECLARE_SIM_OBJECT_PARAMS(TsunamiCChip
)
298 BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiCChip
)
300 INIT_PARAM(tsunami
, "Tsunami"),
301 INIT_PARAM(mmu
, "Memory Controller"),
302 INIT_PARAM(addr
, "Device Address"),
303 INIT_PARAM(mask
, "Address Mask")
305 END_INIT_SIM_OBJECT_PARAMS(TsunamiCChip
)
307 CREATE_SIM_OBJECT(TsunamiCChip
)
309 return new TsunamiCChip(getInstanceName(), tsunami
, addr
, mask
, mmu
);
312 REGISTER_SIM_OBJECT("TsunamiCChip", TsunamiCChip
)