summaryrefslogtreecommitdiff
path: root/dev/baddev.cc
blob: 8a5d68533a7287c83854fe5dbff5146ab855819f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* $Id$ */

/* @file
 * BadDevice implemenation
 */

#include <deque>
#include <string>
#include <vector>

#include "base/trace.hh"
#include "cpu/exec_context.hh"
#include "dev/scsi_ctrl.hh"
#include "dev/baddev.hh"
#include "dev/tsunamireg.h"
#include "dev/tsunami.hh"
#include "mem/functional_mem/memory_control.hh"
#include "sim/builder.hh"
#include "sim/system.hh"

using namespace std;

BadDevice::BadDevice(const string &name, Addr a, MemoryController *mmu,
                     const string &devicename)
    : FunctionalMemory(name), addr(a), devname(devicename)
{
    mmu->add_child(this, Range<Addr>(addr, addr + size));
}

Fault
BadDevice::read(MemReqPtr &req, uint8_t *data)
{

    panic("Device %s not imlpmented\n", devname);
    return No_Fault;
}

Fault
BadDevice::write(MemReqPtr &req, const uint8_t *data)
{
    panic("Device %s not imlpmented\n", devname);
    return No_Fault;
}


BEGIN_DECLARE_SIM_OBJECT_PARAMS(BadDevice)

    SimObjectParam<MemoryController *> mmu;
    Param<Addr> addr;
    Param<string> devicename;

END_DECLARE_SIM_OBJECT_PARAMS(BadDevice)

BEGIN_INIT_SIM_OBJECT_PARAMS(BadDevice)

    INIT_PARAM(mmu, "Memory Controller"),
    INIT_PARAM(addr, "Device Address"),
    INIT_PARAM(devicename, "Name of device to error on")

END_INIT_SIM_OBJECT_PARAMS(BadDevice)

CREATE_SIM_OBJECT(BadDevice)
{
    return new BadDevice(getInstanceName(), addr, mmu, devicename);
}

REGISTER_SIM_OBJECT("BadDevice", BadDevice)