11 #include "base/trace.hh"
12 #include "cpu/exec_context.hh"
13 #include "dev/console.hh"
14 #include "dev/etherdev.hh"
15 #include "dev/scsi_ctrl.hh"
16 #include "dev/tlaser_clock.hh"
17 #include "dev/tsunami_pchip.hh"
18 #include "dev/tsunamireg.h"
19 #include "dev/tsunami.hh"
20 #include "mem/functional_mem/memory_control.hh"
21 #include "sim/builder.hh"
22 #include "sim/system.hh"
26 TsunamiPChip::TsunamiPChip(const string
&name
, Tsunami
*t
, Addr a
,
27 MemoryController
*mmu
)
28 : FunctionalMemory(name
), addr(a
), tsunami(t
)
30 mmu
->add_child(this, Range
<Addr
>(addr
, addr
+ size
));
32 for (int i
= 0; i
< 4; i
++) {
38 //Set back pointer in tsunami
39 tsunami
->pchip
= this;
43 TsunamiPChip::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
& PA_IMPL_MASK
)) >> 6;
49 // ExecContext *xc = req->xc;
50 // int cpuid = xc->cpu_id;
54 case sizeof(uint64_t):
57 *(uint64_t*)data
= wsba
[0];
60 *(uint64_t*)data
= wsba
[1];
63 *(uint64_t*)data
= wsba
[2];
66 *(uint64_t*)data
= wsba
[3];
69 *(uint64_t*)data
= wsm
[0];
72 *(uint64_t*)data
= wsm
[1];
75 *(uint64_t*)data
= wsm
[2];
78 *(uint64_t*)data
= wsm
[3];
81 *(uint64_t*)data
= tba
[0];
84 *(uint64_t*)data
= tba
[1];
87 *(uint64_t*)data
= tba
[2];
90 *(uint64_t*)data
= tba
[3];
93 // might want to change the clock??
94 *(uint64_t*)data
= 0x00; // try this
97 panic("PC_PLAT not implemented\n");
99 panic("PC_RES not implemented\n");
100 case TSDEV_PC_PERROR
:
101 panic("PC_PERROR not implemented\n");
102 case TSDEV_PC_PERRMASK
:
103 panic("PC_PERRMASK not implemented\n");
104 case TSDEV_PC_PERRSET
:
105 panic("PC_PERRSET not implemented\n");
107 panic("PC_TLBIV not implemented\n");
109 *(uint64_t*)data
= 0x00; // shouldn't be readable, but linux
111 case TSDEV_PC_PMONCTL
:
112 panic("PC_PMONCTL not implemented\n");
113 case TSDEV_PC_PMONCNT
:
114 panic("PC_PMONCTN not implemented\n");
116 panic("Default in PChip Read reached reading 0x%x\n", daddr
);
121 case sizeof(uint32_t):
122 case sizeof(uint16_t):
123 case sizeof(uint8_t):
125 panic("invalid access size(?) for tsunami register!\n\n");
127 DPRINTFN("Tsunami PChip ERROR: read daddr=%#x size=%d\n", daddr
, req
->size
);
133 TsunamiPChip::write(MemReqPtr
&req
, const uint8_t *data
)
135 DPRINTF(Tsunami
, "write - va=%#x size=%d \n",
136 req
->vaddr
, req
->size
);
138 Addr daddr
= (req
->paddr
- (addr
& PA_IMPL_MASK
)) >> 6;
142 case sizeof(uint64_t):
145 wsba
[0] = *(uint64_t*)data
;
148 wsba
[1] = *(uint64_t*)data
;
151 wsba
[2] = *(uint64_t*)data
;
154 wsba
[3] = *(uint64_t*)data
;
157 wsm
[0] = *(uint64_t*)data
;
160 wsm
[1] = *(uint64_t*)data
;
163 wsm
[2] = *(uint64_t*)data
;
166 wsm
[3] = *(uint64_t*)data
;
169 tba
[0] = *(uint64_t*)data
;
172 tba
[1] = *(uint64_t*)data
;
175 tba
[2] = *(uint64_t*)data
;
178 tba
[3] = *(uint64_t*)data
;
181 // might want to change the clock??
182 //*(uint64_t*)data; // try this
185 panic("PC_PLAT not implemented\n");
187 panic("PC_RES not implemented\n");
188 case TSDEV_PC_PERROR
:
189 panic("PC_PERROR not implemented\n");
190 case TSDEV_PC_PERRMASK
:
191 panic("PC_PERRMASK not implemented\n");
192 case TSDEV_PC_PERRSET
:
193 panic("PC_PERRSET not implemented\n");
195 panic("PC_TLBIV not implemented\n");
197 return No_Fault
; // value ignored, supposted to invalidate SG TLB
198 case TSDEV_PC_PMONCTL
:
199 panic("PC_PMONCTL not implemented\n");
200 case TSDEV_PC_PMONCNT
:
201 panic("PC_PMONCTN not implemented\n");
203 panic("Default in PChip Read reached reading 0x%x\n", daddr
);
208 case sizeof(uint32_t):
209 case sizeof(uint16_t):
210 case sizeof(uint8_t):
212 panic("invalid access size(?) for tsunami register!\n\n");
215 DPRINTFN("Tsunami ERROR: write daddr=%#x size=%d\n", daddr
, req
->size
);
221 TsunamiPChip::translatePciToDma(Addr busAddr
)
223 // compare the address to the window base registers
224 uint64_t windowMask
= 0;
225 uint64_t windowBase
= 0;
228 for (int i
= 0; i
< 4; i
++) {
229 windowBase
= wsba
[i
];
230 windowMask
= ~wsm
[i
] & (0x7ff << 20);
232 if ((busAddr
& windowMask
) == (windowBase
& windowMask
)) {
233 windowMask
= (wsm
[i
] & (0x7ff << 20)) | 0xfffff;
235 if (wsba
[i
] & 0x1) { // see if enabled
236 if (wsba
[i
] & 0x2) // see if SG bit is set
237 panic("PCI to system SG mapping not currently implemented!\n");
239 dmaAddr
= (tba
[i
] & ~windowMask
) | (busAddr
& windowMask
);
250 TsunamiPChip::serialize(std::ostream
&os
)
252 SERIALIZE_ARRAY(wsba
, 4);
253 SERIALIZE_ARRAY(wsm
, 4);
254 SERIALIZE_ARRAY(tba
, 4);
258 TsunamiPChip::unserialize(Checkpoint
*cp
, const std::string
§ion
)
260 UNSERIALIZE_ARRAY(wsba
, 4);
261 UNSERIALIZE_ARRAY(wsm
, 4);
262 UNSERIALIZE_ARRAY(tba
, 4);
265 BEGIN_DECLARE_SIM_OBJECT_PARAMS(TsunamiPChip
)
267 SimObjectParam
<Tsunami
*> tsunami
;
268 SimObjectParam
<MemoryController
*> mmu
;
271 END_DECLARE_SIM_OBJECT_PARAMS(TsunamiPChip
)
273 BEGIN_INIT_SIM_OBJECT_PARAMS(TsunamiPChip
)
275 INIT_PARAM(tsunami
, "Tsunami"),
276 INIT_PARAM(mmu
, "Memory Controller"),
277 INIT_PARAM(addr
, "Device Address")
279 END_INIT_SIM_OBJECT_PARAMS(TsunamiPChip
)
281 CREATE_SIM_OBJECT(TsunamiPChip
)
283 return new TsunamiPChip(getInstanceName(), tsunami
, addr
, mmu
);
286 REGISTER_SIM_OBJECT("TsunamiPChip", TsunamiPChip
)