gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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/serial/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):
124  break;
125  case offsetof(AlphaAccess, version):
126  pkt->setLE(alphaAccess->version);
127  break;
128  case offsetof(AlphaAccess, numCPUs):
129  pkt->setLE(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->getLE<uint32_t>());
142  break;
143  case sizeof(uint64_t):
144  switch (daddr)
145  {
146  case offsetof(AlphaAccess, inputChar):
147  pkt->setLE(terminal->console_in());
148  break;
149  case offsetof(AlphaAccess, cpuClock):
150  pkt->setLE(alphaAccess->cpuClock);
151  break;
152  case offsetof(AlphaAccess, mem_size):
153  pkt->setLE(alphaAccess->mem_size);
154  break;
155  case offsetof(AlphaAccess, kernStart):
156  pkt->setLE(alphaAccess->kernStart);
157  break;
158  case offsetof(AlphaAccess, kernEnd):
159  pkt->setLE(alphaAccess->kernEnd);
160  break;
161  case offsetof(AlphaAccess, entryPoint):
163  break;
164  case offsetof(AlphaAccess, diskUnit):
165  pkt->setLE(alphaAccess->diskUnit);
166  break;
167  case offsetof(AlphaAccess, diskCount):
168  pkt->setLE(alphaAccess->diskCount);
169  break;
170  case offsetof(AlphaAccess, diskPAddr):
171  pkt->setLE(alphaAccess->diskPAddr);
172  break;
173  case offsetof(AlphaAccess, diskBlock):
174  pkt->setLE(alphaAccess->diskBlock);
175  break;
176  case offsetof(AlphaAccess, diskOperation):
178  break;
179  case offsetof(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->setLE(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->getLE<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->getLE<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->writeData((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 {
258  SERIALIZE_SCALAR(last_offset);
259  SERIALIZE_SCALAR(version);
261  SERIALIZE_SCALAR(mem_size);
262  SERIALIZE_SCALAR(cpuClock);
263  SERIALIZE_SCALAR(intrClockFrequency);
264  SERIALIZE_SCALAR(kernStart);
265  SERIALIZE_SCALAR(kernEnd);
266  SERIALIZE_SCALAR(entryPoint);
267  SERIALIZE_SCALAR(diskUnit);
268  SERIALIZE_SCALAR(diskCount);
269  SERIALIZE_SCALAR(diskPAddr);
270  SERIALIZE_SCALAR(diskBlock);
271  SERIALIZE_SCALAR(diskOperation);
272  SERIALIZE_SCALAR(outputChar);
273  SERIALIZE_SCALAR(inputChar);
274  SERIALIZE_ARRAY(cpuStack,64);
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 panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
#define DPRINTF(x,...)
Definition: trace.hh:229
void serialize(CheckpointOut &cp) const override
Serialize an object.
Definition: backdoor.cc:256
Emulation of the Tsunami CChip CSRs.
Addr getKernelEntry() const
Returns the address the entry point to the kernel code.
Definition: system.hh:611
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:175
uint32_t version
Definition: access.h:49
AlphaSystem * system
a pointer to the system we are running in
Definition: backdoor.hh:95
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
void writeData(uint8_t c) override
Transmit a character from the host interface to the device.
Definition: terminal.cc:330
Overload hash function for BasicBlockRange type.
Definition: vec_reg.hh:586
Definition: cprintf.cc:42
Tick read(PacketPtr pkt) override
memory mapped reads and writes
Definition: backdoor.cc:103
void read(Addr addr, baddr_t block, int count) const
Definition: simple_disk.cc:64
uint64_t outputChar
Definition: access.h:68
BaseCPU * cpu
a pointer to the CPU boot cpu
Definition: backdoor.hh:98
Bitfield< 63 > val
Definition: misc.hh:771
uint32_t last_offset
Definition: access.h:48
void setLE(T v)
Set the value in the data pointer to v as little endian.
unsigned getSize() const
Definition: packet.hh:736
uint64_t diskCount
Definition: access.h:62
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:645
uint64_t inputChar
Definition: access.h:69
void setAlphaAccess(Addr access)
Set the m5AlphaAccess pointer in the console.
Definition: system.cc:227
#define inform(...)
Definition: logging.hh:213
Tick curTick()
The current simulated tick.
Definition: core.hh:47
Addr memSize() const
Amount of physical memory that exists.
Definition: system.cc:447
Addr pioSize
Size that the device&#39;s address range.
Definition: io_device.hh:160
System Console Backdoor Interface.
AlphaBackdoorParams Params
Definition: backdoor.hh:101
uint64_t frequency() const
void makeAtomicResponse()
Definition: packet.hh:949
uint64_t Tick
Tick count type.
Definition: types.hh:63
Declaration of top level class for the Tsunami chipset.
uint64_t diskPAddr
Definition: access.h:63
const Params * params() const
Definition: backdoor.hh:105
uint64_t cpuClock
Definition: access.h:52
#define SERIALIZE_ARRAY(member, size)
Definition: serialize.hh:658
uint64_t diskUnit
Definition: access.h:61
Addr getAddr() const
Definition: packet.hh:726
unsigned numContexts() const
Definition: system.hh:206
uint64_t kernStart
Definition: access.h:56
Addr getKernelStart() const
Returns the address the kernel starts at.
Definition: system.hh:599
Tsunami I/O Space mapping including RTC/timer interrupts.
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
A Packet is used to encapsulate a transfer between two objects in the memory system (e...
Definition: packet.hh:255
AlphaBackdoor(const Params *p)
Definition: backdoor.cc:65
void setBadAddress()
Definition: packet.hh:718
Bitfield< 15 > system
Definition: misc.hh:999
#define ALPHA_ACCESS_VERSION
Definition: access.h:38
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:643
#define UNSERIALIZE_ARRAY(member, size)
Definition: serialize.hh:661
Tick frequency() const
Return the freqency of the RTC.
Definition: tsunami_io.cc:81
uint32_t intrClockFrequency
Definition: access.h:51
Generic interface for platforms.
Declaration of the Packet class.
std::ostream CheckpointOut
Definition: serialize.hh:68
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: backdoor.cc:201
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:163
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
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
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: backdoor.cc:306
uint64_t console_in()
Definition: terminal.cc:312
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:157
uint64_t diskOperation
Definition: access.h:65
Addr getKernelEnd() const
Returns the address the kernel ends at.
Definition: system.hh:605
uint64_t cpuStack[64]
Definition: access.h:72
uint64_t diskBlock
Definition: access.h:64
uint64_t entryPoint
Definition: access.h:58
uint64_t kernEnd
Definition: access.h:57

Generated on Fri Feb 28 2020 16:27:00 for gem5 by doxygen 1.8.13