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.
32 * Isa Fake Device implementation
35 #include "base/trace.hh"
36 #include "dev/isa_fake.hh"
37 #include "mem/packet.hh"
38 #include "mem/packet_access.hh"
39 #include "sim/system.hh"
43 IsaFake::IsaFake(Params
*p
)
47 pioSize
= p
->pio_size
;
49 retData8
= p
->ret_data8
;
50 retData16
= p
->ret_data16
;
51 retData32
= p
->ret_data32
;
52 retData64
= p
->ret_data64
;
56 IsaFake::read(PacketPtr pkt
)
59 if (params()->warn_access
!= "")
60 warn("Device %s accessed by read to address %#x size=%d\n",
61 name(), pkt
->getAddr(), pkt
->getSize());
62 if (params()->ret_bad_addr
) {
63 DPRINTF(Tsunami
, "read to bad address va=%#x size=%d\n",
64 pkt
->getAddr(), pkt
->getSize());
67 assert(pkt
->getAddr() >= pioAddr
&& pkt
->getAddr() < pioAddr
+ pioSize
);
68 DPRINTF(Tsunami
, "read va=%#x size=%d\n",
69 pkt
->getAddr(), pkt
->getSize());
70 switch (pkt
->getSize()) {
71 case sizeof(uint64_t):
74 case sizeof(uint32_t):
77 case sizeof(uint16_t):
84 panic("invalid access size!\n");
86 pkt
->makeAtomicResponse();
92 IsaFake::write(PacketPtr pkt
)
94 if (params()->warn_access
!= "") {
96 switch (pkt
->getSize()) {
97 case sizeof(uint64_t):
98 data
= pkt
->get
<uint64_t>();
100 case sizeof(uint32_t):
101 data
= pkt
->get
<uint32_t>();
103 case sizeof(uint16_t):
104 data
= pkt
->get
<uint16_t>();
106 case sizeof(uint8_t):
107 data
= pkt
->get
<uint8_t>();
110 panic("invalid access size!\n");
112 warn("Device %s accessed by write to address %#x size=%d data=%#x\n",
113 name(), pkt
->getAddr(), pkt
->getSize(), data
);
115 if (params()->ret_bad_addr
) {
116 DPRINTF(Tsunami
, "write to bad address va=%#x size=%d \n",
117 pkt
->getAddr(), pkt
->getSize());
118 pkt
->setBadAddress();
120 DPRINTF(Tsunami
, "write - va=%#x size=%d \n",
121 pkt
->getAddr(), pkt
->getSize());
123 if (params()->update_data
) {
124 switch (pkt
->getSize()) {
125 case sizeof(uint64_t):
126 retData64
= pkt
->get
<uint64_t>();
128 case sizeof(uint32_t):
129 retData32
= pkt
->get
<uint32_t>();
131 case sizeof(uint16_t):
132 retData16
= pkt
->get
<uint16_t>();
134 case sizeof(uint8_t):
135 retData8
= pkt
->get
<uint8_t>();
138 panic("invalid access size!\n");
141 pkt
->makeAtomicResponse();
147 IsaFakeParams::create()
149 return new IsaFake(this);