1 #include "cpu.h"
2 #include "mapper.h"
3 #include "vmips.h"
4 #include <stdint.h>
5 #include "testdev.h"
6 
TestDev()7 TestDev::TestDev() : DeviceMap()
8 {
9 	extent = 0x100;
10 	words = new uint32_t[extent/4];
11 	init();
12 }
13 
14 void
init()15 TestDev::init()
16 {
17 	for (int i = 0; i < extent/4; ++i) {
18 	    words[i] = 0;
19 	}
20 }
21 
22 uint32
fetch_word(uint32 offset,int mode,DeviceExc * client)23 TestDev::fetch_word(uint32 offset, int mode, DeviceExc *client)
24 {
25 	uint32 rv = words[offset/4];
26 	uint32 srv = machine->physmem->mips_to_host_word(rv);
27 	fprintf(stderr,"TestDev Fetch(0x%08x) found 0x%08x, returning 0x%08x\n",
28 		offset,rv,srv);
29 	return srv;
30 }
31 
32 void
store_word(uint32 offset,uint32 odata,DeviceExc * client)33 TestDev::store_word(uint32 offset, uint32 odata, DeviceExc *client)
34 {
35 	uint32 data = machine->physmem->host_to_mips_word(odata);
36 	fprintf(stderr,"TestDev Store(0x%08x) got 0x%08x, storing 0x%08x\n",
37 		offset,odata,data);
38 	words[offset/4] = data;
39 }
40