2 * Copyright (c) 2004-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * Isa Fake Device implementation
37 #include "base/trace.hh"
38 #include "cpu/exec_context.hh"
39 #include "dev/isa_fake.hh"
40 #include "mem/bus/bus.hh"
41 #include "mem/bus/pio_interface.hh"
42 #include "mem/bus/pio_interface_impl.hh"
43 #include "mem/functional/memory_control.hh"
44 #include "sim/builder.hh"
45 #include "sim/system.hh"
48 using namespace TheISA
;
50 IsaFake::IsaFake(const string
&name
, Addr a
, MemoryController
*mmu
,
51 HierParams
*hier
, Bus
*pio_bus
, Addr size
)
52 : PioDevice(name
, NULL
), addr(a
)
54 mmu
->add_child(this, RangeSize(addr
, size
));
57 pioInterface
= newPioInterface(name
+ ".pio", hier
, pio_bus
, this,
58 &IsaFake::cacheAccess
);
59 pioInterface
->addAddrRange(RangeSize(addr
, size
));
64 IsaFake::read(MemReqPtr
&req
, uint8_t *data
)
66 DPRINTF(Tsunami
, "read va=%#x size=%d\n",
67 req
->vaddr
, req
->size
);
70 Addr daddr
= (req
->paddr
- (addr
& EV5::PAddrImplMask
)) >> 6;
75 case sizeof(uint64_t):
76 *(uint64_t*)data
= 0xFFFFFFFFFFFFFFFFULL
;
78 case sizeof(uint32_t):
79 *(uint32_t*)data
= 0xFFFFFFFF;
81 case sizeof(uint16_t):
82 *(uint16_t*)data
= 0xFFFF;
85 *(uint8_t*)data
= 0xFF;
89 panic("invalid access size(?) for PCI configspace!\n");
91 DPRINTFN("Isa FakeSMC ERROR: read daddr=%#x size=%d\n", daddr
, req
->size
);
97 IsaFake::write(MemReqPtr
&req
, const uint8_t *data
)
99 DPRINTF(Tsunami
, "write - va=%#x size=%d \n",
100 req
->vaddr
, req
->size
);
102 //:Addr daddr = (req->paddr & addr_mask) >> 6;
108 IsaFake::cacheAccess(MemReqPtr
&req
)
113 BEGIN_DECLARE_SIM_OBJECT_PARAMS(IsaFake
)
115 SimObjectParam
<MemoryController
*> mmu
;
117 SimObjectParam
<Bus
*> pio_bus
;
118 Param
<Tick
> pio_latency
;
119 SimObjectParam
<HierParams
*> hier
;
122 END_DECLARE_SIM_OBJECT_PARAMS(IsaFake
)
124 BEGIN_INIT_SIM_OBJECT_PARAMS(IsaFake
)
126 INIT_PARAM(mmu
, "Memory Controller"),
127 INIT_PARAM(addr
, "Device Address"),
128 INIT_PARAM_DFLT(pio_bus
, "The IO Bus to attach to", NULL
),
129 INIT_PARAM_DFLT(pio_latency
, "Programmed IO latency", 1000),
130 INIT_PARAM_DFLT(hier
, "Hierarchy global variables", &defaultHierParams
),
131 INIT_PARAM_DFLT(size
, "Size of address range", 0x8)
133 END_INIT_SIM_OBJECT_PARAMS(IsaFake
)
135 CREATE_SIM_OBJECT(IsaFake
)
137 return new IsaFake(getInstanceName(), addr
, mmu
, hier
, pio_bus
, size
);
140 REGISTER_SIM_OBJECT("IsaFake", IsaFake
)