gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
backdoor.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2005 The Regents of The University of Michigan
3  * All rights reserved.
4  *
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.
15  *
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.
27  *
28  * Authors: Nathan Binkert
29  * Ali Saidi
30  * Steve Reinhardt
31  * Erik Hallnor
32  */
33 
38 #include "dev/alpha/backdoor.hh"
39 
40 #include <cstddef>
41 #include <string>
42 
43 #include "arch/alpha/system.hh"
44 #include "base/inifile.hh"
45 #include "base/str.hh"
46 #include "base/trace.hh"
47 #include "cpu/base.hh"
48 #include "cpu/thread_context.hh"
49 #include "debug/AlphaBackdoor.hh"
50 #include "dev/alpha/tsunami.hh"
52 #include "dev/alpha/tsunami_io.hh"
53 #include "dev/platform.hh"
55 #include "dev/terminal.hh"
56 #include "mem/packet.hh"
57 #include "mem/packet_access.hh"
58 #include "mem/physical.hh"
59 #include "params/AlphaBackdoor.hh"
60 #include "sim/sim_object.hh"
61 
62 using namespace std;
63 using namespace AlphaISA;
64 
66  : BasicPioDevice(p, sizeof(struct AlphaAccess)),
67  disk(p->disk), terminal(p->terminal),
68  system(p->system), cpu(p->cpu)
69 {
70  alphaAccess = new Access();
72 
74  alphaAccess->diskUnit = 1;
75 
82  std::memset(alphaAccess->cpuStack, 0, sizeof(alphaAccess->cpuStack));
83 
84 }
85 
86 void
88 {
95  alphaAccess->cpuClock = cpu->frequency() / 1000000; // In MHz
96  Tsunami *tsunami = dynamic_cast<Tsunami *>(params()->platform);
97  if (!tsunami)
98  fatal("Platform is not Tsunami.\n");
100 }
101 
102 Tick
104 {
105 
111  assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
112 
113  Addr daddr = pkt->getAddr() - pioAddr;
114 
115  pkt->makeAtomicResponse();
116 
117  switch (pkt->getSize())
118  {
119  case sizeof(uint32_t):
120  switch (daddr)
121  {
122  case offsetof(AlphaAccess, last_offset):
123  pkt->set(alphaAccess->last_offset);
124  break;
125  case offsetof(AlphaAccess, version):
126  pkt->set(alphaAccess->version);
127  break;
128  case offsetof(AlphaAccess, numCPUs):
129  pkt->set(alphaAccess->numCPUs);
130  break;
131  case offsetof(AlphaAccess, intrClockFrequency):
133  break;
134  default:
135  /* Old console code read in everyting as a 32bit int
136  * we now break that for better error checking.
137  */
138  pkt->setBadAddress();
139  }
140  DPRINTF(AlphaBackdoor, "read: offset=%#x val=%#x\n", daddr,
141  pkt->get<uint32_t>());
142  break;
143  case sizeof(uint64_t):
144  switch (daddr)
145  {
146  case offsetof(AlphaAccess, inputChar):
147  pkt->set(terminal->console_in());
148  break;
149  case offsetof(AlphaAccess, cpuClock):
150  pkt->set(alphaAccess->cpuClock);
151  break;
152  case offsetof(AlphaAccess, mem_size):
153  pkt->set(alphaAccess->mem_size);
154  break;
155  case offsetof(AlphaAccess, kernStart):
156  pkt->set(alphaAccess->kernStart);
157  break;
158  case offsetof(AlphaAccess, kernEnd):
159  pkt->set(alphaAccess->kernEnd);
160  break;
161  case offsetof(AlphaAccess, entryPoint):
162  pkt->set(alphaAccess->entryPoint);
163  break;
164  case offsetof(AlphaAccess, diskUnit):
165  pkt->set(alphaAccess->diskUnit);
166  break;
167  case offsetof(AlphaAccess, diskCount):
168  pkt->set(alphaAccess->diskCount);
169  break;
170  case offsetof(AlphaAccess, diskPAddr):
171  pkt->set(alphaAccess->diskPAddr);
172  break;
173  case offsetof(AlphaAccess, diskBlock):
174  pkt->set(alphaAccess->diskBlock);
175  break;
176  case offsetof(AlphaAccess, diskOperation):
178  break;
179  case offsetof(AlphaAccess, outputChar):
180  pkt->set(alphaAccess->outputChar);
181  break;
182  default:
183  int cpunum = (daddr - offsetof(AlphaAccess, cpuStack)) /
184  sizeof(alphaAccess->cpuStack[0]);
185 
186  if (cpunum >= 0 && cpunum < 64)
187  pkt->set(alphaAccess->cpuStack[cpunum]);
188  else
189  panic("Unknown 64bit access, %#x\n", daddr);
190  }
191  DPRINTF(AlphaBackdoor, "read: offset=%#x val=%#x\n", daddr,
192  pkt->get<uint64_t>());
193  break;
194  default:
195  pkt->setBadAddress();
196  }
197  return pioDelay;
198 }
199 
200 Tick
202 {
203  assert(pkt->getAddr() >= pioAddr && pkt->getAddr() < pioAddr + pioSize);
204  Addr daddr = pkt->getAddr() - pioAddr;
205 
206  uint64_t val = pkt->get<uint64_t>();
207  assert(pkt->getSize() == sizeof(uint64_t));
208 
209  switch (daddr) {
210  case offsetof(AlphaAccess, diskUnit):
212  break;
213 
214  case offsetof(AlphaAccess, diskCount):
216  break;
217 
218  case offsetof(AlphaAccess, diskPAddr):
220  break;
221 
222  case offsetof(AlphaAccess, diskBlock):
224  break;
225 
226  case offsetof(AlphaAccess, diskOperation):
227  if (val == 0x13)
230  else
231  panic("Invalid disk operation!");
232 
233  break;
234 
235  case offsetof(AlphaAccess, outputChar):
236  terminal->out((char)(val & 0xff));
237  break;
238 
239  default:
240  int cpunum = (daddr - offsetof(AlphaAccess, cpuStack)) /
241  sizeof(alphaAccess->cpuStack[0]);
242  inform("Launching CPU %d @ %d", cpunum, curTick());
243  assert(val > 0 && "Must not access primary cpu");
244  if (cpunum >= 0 && cpunum < 64)
245  alphaAccess->cpuStack[cpunum] = val;
246  else
247  panic("Unknown 64bit access, %#x\n", daddr);
248  }
249 
250  pkt->makeAtomicResponse();
251 
252  return pioDelay;
253 }
254 
255 void
257 {
275 }
276 
277 void
279 {
280  UNSERIALIZE_SCALAR(last_offset);
281  UNSERIALIZE_SCALAR(version);
283  UNSERIALIZE_SCALAR(mem_size);
284  UNSERIALIZE_SCALAR(cpuClock);
285  UNSERIALIZE_SCALAR(intrClockFrequency);
286  UNSERIALIZE_SCALAR(kernStart);
287  UNSERIALIZE_SCALAR(kernEnd);
288  UNSERIALIZE_SCALAR(entryPoint);
289  UNSERIALIZE_SCALAR(diskUnit);
290  UNSERIALIZE_SCALAR(diskCount);
291  UNSERIALIZE_SCALAR(diskPAddr);
292  UNSERIALIZE_SCALAR(diskBlock);
293  UNSERIALIZE_SCALAR(diskOperation);
294  UNSERIALIZE_SCALAR(outputChar);
295  UNSERIALIZE_SCALAR(inputChar);
296  UNSERIALIZE_ARRAY(cpuStack, 64);
297 }
298 
299 void
301 {
302  alphaAccess->serialize(cp);
303 }
304 
305 void
307 {
309 }
310 
312 AlphaBackdoorParams::create()
313 {
314  return new AlphaBackdoor(this);
315 }
#define DPRINTF(x,...)
Definition: trace.hh:212
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: backdoor.cc:256
void set(T v, ByteOrder endian)
Set the value in the data pointer to v using the specified endianness.
Emulation of the Tsunami CChip CSRs.
const Params * params() const
Definition: backdoor.hh:105
uint32_t version
Definition: access.h:49
AlphaSystem * system
a pointer to the system we are running in
Definition: backdoor.hh:95
#define panic(...)
Definition: misc.hh:153
Addr getKernelStart() const
Returns the address the kernel starts at.
Definition: system.hh:511
void startup() override
startup() is the final initialization call before simulation.
Definition: backdoor.cc:87
uint64_t mem_size
Definition: access.h:53
Access * alphaAccess
Definition: backdoor.hh:84
Top level class for Tsunami Chipset emulation.
Definition: tsunami.hh:56
Tick read(PacketPtr pkt) override
memory mapped reads and writes
Definition: backdoor.cc:103
uint64_t outputChar
Definition: access.h:68
BaseCPU * cpu
a pointer to the CPU boot cpu
Definition: backdoor.hh:98
T get(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness.
Bitfield< 63 > val
Definition: misc.hh:770
uint32_t last_offset
Definition: access.h:48
uint64_t diskCount
Definition: access.h:62
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:145
uint64_t inputChar
Definition: access.h:69
void setAlphaAccess(Addr access)
Set the m5AlphaAccess pointer in the console.
Definition: system.cc:211
system
Definition: isa.cc:226
Tick curTick()
The current simulated tick.
Definition: core.hh:47
Addr pioSize
Size that the device's address range.
Definition: io_device.hh:142
AlphaBackdoorParams Params
Definition: backdoor.hh:101
System Console Backdoor Interface.
void makeAtomicResponse()
Definition: packet.hh:857
uint64_t Tick
Tick count type.
Definition: types.hh:63
Declaration of top level class for the Tsunami chipset.
void out(char c)
Definition: terminal.cc:317
uint64_t diskPAddr
Definition: access.h:63
uint64_t cpuClock
Definition: access.h:52
#define fatal(...)
Definition: misc.hh:163
#define SERIALIZE_ARRAY(member, size)
Definition: serialize.hh:158
uint64_t diskUnit
Definition: access.h:61
uint64_t kernStart
Definition: access.h:56
Tsunami I/O Space mapping including RTC/timer interrupts.
Tick frequency() const
Return the freqency of the RTC.
Definition: tsunami_io.cc:85
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
Declaration of IniFile object.
Bitfield< 25, 24 > numCPUs
Definition: miscregs.hh:1806
Addr getKernelEnd() const
Returns the address the kernel ends at.
Definition: system.hh:517
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:245
AlphaBackdoor(const Params *p)
Definition: backdoor.cc:65
int numContexts()
Definition: system.hh:208
void setBadAddress()
Definition: packet.hh:631
#define ALPHA_ACCESS_VERSION
Definition: access.h:38
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:143
#define UNSERIALIZE_ARRAY(member, size)
Definition: serialize.hh:161
Addr memSize() const
Amount of physical memory that exists.
Definition: system.cc:359
uint32_t intrClockFrequency
Definition: access.h:51
Addr getKernelEntry() const
Returns the address the entry point to the kernel code.
Definition: system.hh:523
Generic interface for platforms.
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:67
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: backdoor.cc:201
void read(Addr addr, baddr_t block, int count) const
Definition: simple_disk.cc:64
void serialize(CheckpointOut &cp) const override
standard serialization routines for checkpointing
Definition: backdoor.cc:300
uint32_t numCPUs
Definition: access.h:50
Memory mapped interface to the system console.
Definition: backdoor.hh:74
Tick pioDelay
Delay that the device experinces on an access.
Definition: io_device.hh:145
Terminal * terminal
the system console (the terminal) is accessable from the console
Definition: backdoor.hh:92
TsunamiIO * io
Pointer to the TsunamiIO device which has the RTC.
Definition: tsunami.hh:66
SimpleDisk * disk
the disk must be accessed from the console
Definition: backdoor.hh:89
unsigned getSize() const
Definition: packet.hh:649
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: backdoor.cc:306
uint64_t console_in()
Definition: terminal.cc:299
#define inform(...)
Definition: misc.hh:221
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: backdoor.cc:278
Bitfield< 0 > p
Addr pioAddr
Address that the device listens to.
Definition: io_device.hh:139
uint64_t diskOperation
Definition: access.h:65
uint64_t cpuStack[64]
Definition: access.h:72
uint64_t diskBlock
Definition: access.h:64
uint64_t entryPoint
Definition: access.h:58
Addr getAddr() const
Definition: packet.hh:639
uint64_t kernEnd
Definition: access.h:57

Generated on Fri Jun 9 2017 13:03:45 for gem5 by doxygen 1.8.6