gem5  v19.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
system.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-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: Ali Saidi
29  * Nathan Binkert
30  */
31 
32 #include "arch/alpha/system.hh"
33 
34 #include <sys/signal.h>
35 
36 #include "arch/alpha/ev5.hh"
37 #include "arch/alpha/faults.hh"
38 #include "arch/vtophys.hh"
40 #include "base/loader/symtab.hh"
41 #include "base/trace.hh"
42 #include "debug/Loader.hh"
44 #include "params/AlphaSystem.hh"
45 #include "sim/byteswap.hh"
46 
47 using namespace AlphaISA;
48 
50  : System(p), intrFreq(0), virtProxy(getSystemPort(), p->cache_line_size)
51 {
53  palSymtab = new SymbolTable;
54 
55 
59  // Load Console Code
61  if (console == NULL)
62  fatal("Could not load console file %s", params()->console);
63 
64  // Load pal file
66  if (pal == NULL)
67  fatal("Could not load PALcode file %s", params()->pal);
68 
69  // load symbols
71  panic("could not load console symbols\n");
72 
74  panic("could not load pal symbols\n");
75 
77  panic("could not load pal symbols\n");
78 
80  panic("could not load console symbols\n");
81 
83  panic("could not load pal symbols\n");
84 
86  panic("could not load pal symbols\n");
87 
88 
89 }
90 
92 {
93  delete consoleSymtab;
94  delete console;
95  delete pal;
96 #ifdef DEBUG
97  delete consolePanicEvent;
98 #endif
99 }
100 
101 void
103 {
104  Addr addr = 0;
105 
106  // Moved from the constructor to here since it relies on the
107  // address map being resolved in the interconnect
108 
109  // Call the initialisation of the super class
111 
112  for (auto *tc: threadContexts) {
113  int cpuId = tc->contextId();
114  initIPRs(tc, cpuId);
115 
116  tc->setIntReg(16, cpuId);
117  tc->setIntReg(0, cpuId);
118 
119  Addr base = tc->readMiscRegNoEffect(IPR_PAL_BASE);
120  Addr offset = ResetFault().vect();
121 
122  tc->pcState(base + offset);
123 
124  tc->activate();
125  }
126 
127  // Load program sections into memory
130 
137  if (consoleSymtab->findAddress("env_booted_osflags", addr)) {
138  virtProxy.writeBlob(addr, params()->boot_osflags.c_str(),
139  strlen(params()->boot_osflags.c_str()));
140  }
141 
146  if (consoleSymtab->findAddress("m5_rpb", addr)) {
147  uint64_t data;
148  data = htole(params()->system_type);
149  virtProxy.write(addr+0x50, data);
150  data = htole(params()->system_rev);
151  virtProxy.write(addr+0x58, data);
152  } else
153  panic("could not find hwrpb\n");
154 }
155 
156 void
158 {
159  // Setup all the function events now that we have a system and a symbol
160  // table
161  setupFuncEvents();
162 }
163 
164 void
166 {
167 #ifndef NDEBUG
168  consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic");
169 #endif
170 }
171 
203 Addr
205 {
206  // mask for just the opcode, Ra, and Rb fields (not the offset)
207  const uint32_t inst_mask = 0xffff0000;
208  // ldah gp,X(pv): opcode 9, Ra = 29, Rb = 27
209  const uint32_t gp_ldah_pattern = (9 << 26) | (29 << 21) | (27 << 16);
210  // lda gp,Y(gp): opcode 8, Ra = 29, rb = 29
211  const uint32_t gp_lda_pattern = (8 << 26) | (29 << 21) | (29 << 16);
212 
213  uint32_t i1 = virtProxy.read<uint32_t>(addr);
214  uint32_t i2 = virtProxy.read<uint32_t>(addr + sizeof(MachInst));
215 
216  if ((i1 & inst_mask) == gp_ldah_pattern &&
217  (i2 & inst_mask) == gp_lda_pattern) {
218  Addr new_addr = addr + 2 * sizeof(MachInst);
219  DPRINTF(Loader, "fixFuncEventAddr: %p -> %p", addr, new_addr);
220  return new_addr;
221  } else {
222  return addr;
223  }
224 }
225 
226 void
228 {
229  Addr addr = 0;
230  if (consoleSymtab->findAddress("m5AlphaAccess", addr)) {
231  virtProxy.write(addr, htole(Phys2K0Seg(access)));
232  } else {
233  panic("could not find m5AlphaAccess\n");
234  }
235 }
236 
237 void
239 {
240  consoleSymtab->serialize("console_symtab", cp);
241  palSymtab->serialize("pal_symtab", cp);
242 }
243 
244 void
246 {
247  consoleSymtab->unserialize("console_symtab", cp);
248  palSymtab->unserialize("pal_symtab", cp);
249 }
250 
251 AlphaSystem *
252 AlphaSystemParams::create()
253 {
254  return new AlphaSystem(this);
255 }
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
#define DPRINTF(x,...)
Definition: trace.hh:229
BreakPCEvent * consolePanicEvent
Event to halt the simulator if the console calls panic()
Definition: system.hh:89
virtual void setupFuncEvents()
Setup all the function events.
Definition: system.cc:165
AlphaSystem(Params *p)
Definition: system.cc:49
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:175
SymbolTable * consoleSymtab
console symbol table
Definition: system.hh:76
bool write(const PortProxy &proxy) const
Definition: memory_image.cc:50
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:64
ip6_addr_t addr
Definition: inet.hh:335
AlphaSystemParams Params
Definition: system.hh:49
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:284
ObjectFile * console
Object pointer for the console code.
Definition: system.hh:82
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
Definition: symtab.cc:45
Definition: system.hh:77
void startup() override
Override startup() to provide a path to call setupFuncEvents()
Definition: system.cc:157
Bitfield< 23, 0 > offset
Definition: types.hh:154
Definition: cprintf.cc:42
uint32_t MachInst
Definition: types.hh:40
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Definition: system.hh:218
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: system.cc:349
virtual MemoryImage buildImage() const =0
void setAlphaAccess(Addr access)
Set the m5AlphaAccess pointer in the console.
Definition: system.cc:227
T htole(T value)
Definition: byteswap.hh:144
void unserializeSymtab(CheckpointIn &cp) override
If needed, unserialize additional symbol table entries for a specific subclass of this system...
Definition: system.cc:245
ObjectFile * pal
Object pointer for the PAL code.
Definition: system.hh:85
Addr fixFuncEventAddr(Addr addr) override
This function fixes up addresses that are used to match PCs for hooking simulator events on to target...
Definition: system.cc:204
bool findAddress(const std::string &symbol, Addr &address) const
Definition: symtab.hh:97
Addr loadAddrMask
Mask that should be anded for binary/symbol loading.
Definition: system.hh:245
void writeBlob(Addr addr, const void *p, int size) const
Same as tryWriteBlob, but insists on success.
Definition: port_proxy.hh:189
FaultVect vect()
Definition: faults.hh:94
Bitfield< 51, 12 > base
Definition: pagetable.hh:142
virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:96
std::vector< ThreadContext * > threadContexts
Definition: system.hh:190
~AlphaSystem()
Definition: system.cc:91
void initState() override
Initialise the state of the system.
Definition: system.cc:102
void serialize(const std::string &base, CheckpointOut &cp) const
Definition: symtab.cc:113
SymbolTable * palSymtab
pal symbol table
Definition: system.hh:79
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
const Params * params() const
Definition: system.hh:100
void serializeSymtab(CheckpointOut &cp) const override
Serialization stuff.
Definition: system.cc:238
void initIPRs(ThreadContext *tc, int cpuId)
Definition: ev5.cc:69
FSTranslatingPortProxy virtProxy
Proxy used to copy arguments directly into kernel memory.
Definition: system.hh:98
std::ostream CheckpointOut
Definition: serialize.hh:68
MemoryImage & mask(Addr m)
TranslatingPortProxy Object Declaration for FS.
void unserialize(const std::string &base, CheckpointIn &cp)
Definition: symtab.cc:127
void write(Addr address, const T &data) const
Write object T to address.
Definition: port_proxy.hh:293
Addr Phys2K0Seg(Addr addr)
Definition: ev5.hh:61
Bitfield< 0 > p
const char data[]
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:90

Generated on Fri Feb 28 2020 16:26:55 for gem5 by doxygen 1.8.13