gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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/vtophys.hh"
39 #include "base/loader/symtab.hh"
40 #include "base/trace.hh"
41 #include "debug/Loader.hh"
43 #include "params/AlphaSystem.hh"
44 #include "sim/byteswap.hh"
45 
46 using namespace AlphaISA;
47 
49  : System(p), intrFreq(0), virtProxy(getSystemPort(), p->cache_line_size)
50 {
52  palSymtab = new SymbolTable;
53 
54 
58  // Load Console Code
60  if (console == NULL)
61  fatal("Could not load console file %s", params()->console);
62 
63  // Load pal file
65  if (pal == NULL)
66  fatal("Could not load PALcode file %s", params()->pal);
67 
68  // load symbols
70  panic("could not load console symbols\n");
71 
73  panic("could not load pal symbols\n");
74 
76  panic("could not load pal symbols\n");
77 
79  panic("could not load console symbols\n");
80 
82  panic("could not load pal symbols\n");
83 
85  panic("could not load pal symbols\n");
86 
87 
88 }
89 
91 {
92  delete consoleSymtab;
93  delete console;
94  delete pal;
95 #ifdef DEBUG
96  delete consolePanicEvent;
97 #endif
98 }
99 
100 void
102 {
103  Addr addr = 0;
104 
105  // Moved from the constructor to here since it relies on the
106  // address map being resolved in the interconnect
107 
108  // Call the initialisation of the super class
110 
111  // Load program sections into memory
114 
121  if (consoleSymtab->findAddress("env_booted_osflags", addr)) {
122  virtProxy.writeBlob(addr, (uint8_t*)params()->boot_osflags.c_str(),
123  strlen(params()->boot_osflags.c_str()));
124  }
125 
130  if (consoleSymtab->findAddress("m5_rpb", addr)) {
131  uint64_t data;
132  data = htog(params()->system_type);
133  virtProxy.write(addr+0x50, data);
134  data = htog(params()->system_rev);
135  virtProxy.write(addr+0x58, data);
136  } else
137  panic("could not find hwrpb\n");
138 }
139 
140 void
142 {
143  // Setup all the function events now that we have a system and a symbol
144  // table
145  setupFuncEvents();
146 }
147 
148 void
150 {
151 #ifndef NDEBUG
152  consolePanicEvent = addConsoleFuncEvent<BreakPCEvent>("panic");
153 #endif
154 }
155 
187 Addr
189 {
190  // mask for just the opcode, Ra, and Rb fields (not the offset)
191  const uint32_t inst_mask = 0xffff0000;
192  // ldah gp,X(pv): opcode 9, Ra = 29, Rb = 27
193  const uint32_t gp_ldah_pattern = (9 << 26) | (29 << 21) | (27 << 16);
194  // lda gp,Y(gp): opcode 8, Ra = 29, rb = 29
195  const uint32_t gp_lda_pattern = (8 << 26) | (29 << 21) | (29 << 16);
196 
197  uint32_t i1 = virtProxy.read<uint32_t>(addr);
198  uint32_t i2 = virtProxy.read<uint32_t>(addr + sizeof(MachInst));
199 
200  if ((i1 & inst_mask) == gp_ldah_pattern &&
201  (i2 & inst_mask) == gp_lda_pattern) {
202  Addr new_addr = addr + 2 * sizeof(MachInst);
203  DPRINTF(Loader, "fixFuncEventAddr: %p -> %p", addr, new_addr);
204  return new_addr;
205  } else {
206  return addr;
207  }
208 }
209 
210 void
212 {
213  Addr addr = 0;
214  if (consoleSymtab->findAddress("m5AlphaAccess", addr)) {
215  virtProxy.write(addr, htog(Phys2K0Seg(access)));
216  } else {
217  panic("could not find m5AlphaAccess\n");
218  }
219 }
220 
221 void
223 {
224  consoleSymtab->serialize("console_symtab", cp);
225  palSymtab->serialize("pal_symtab", cp);
226 }
227 
228 void
230 {
231  consoleSymtab->unserialize("console_symtab", cp);
232  palSymtab->unserialize("pal_symtab", cp);
233 }
234 
235 AlphaSystem *
236 AlphaSystemParams::create()
237 {
238  return new AlphaSystem(this);
239 }
#define DPRINTF(x,...)
Definition: trace.hh:212
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:149
AlphaSystem(Params *p)
Definition: system.cc:48
T htog(T value)
Definition: byteswap.hh:177
SymbolTable * consoleSymtab
console symbol table
Definition: system.hh:76
#define panic(...)
Definition: misc.hh:153
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=maxAddr)=0
void write(Addr address, T data) const
Write object T to address.
Definition: port_proxy.hh:155
ip6_addr_t addr
Definition: inet.hh:335
AlphaSystemParams Params
Definition: system.hh:49
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:83
void startup() override
Override startup() to provide a path to call setupFuncEvents()
Definition: system.cc:141
bool findAddress(const std::string &symbol, Addr &address) const
Definition: symtab.hh:97
virtual bool loadLocalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=maxAddr)=0
uint32_t MachInst
Definition: types.hh:40
const char data[]
Definition: circlebuf.cc:43
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Definition: system.hh:224
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: system.cc:289
void setAlphaAccess(Addr access)
Set the m5AlphaAccess pointer in the console.
Definition: system.cc:211
virtual void writeBlob(Addr addr, const uint8_t *p, int size) const
Version of writeBlob that translates virt->phys and deals with page boundries.
void unserializeSymtab(CheckpointIn &cp) override
If needed, unserialize additional symbol table entries for a specific subclass of this system...
Definition: system.cc:229
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:188
void serialize(const std::string &base, CheckpointOut &cp) const
Definition: symtab.cc:113
Addr loadAddrMask
Mask that should be anded for binary/symbol loading.
Definition: system.hh:247
const Params * params() const
Definition: system.hh:100
#define fatal(...)
Definition: misc.hh:163
~AlphaSystem()
Definition: system.cc:90
T read(Addr address) const
Read sizeof(T) bytes from address and return as object T.
Definition: port_proxy.hh:146
void initState() override
Initialise the state of the system.
Definition: system.cc:101
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
virtual bool loadSections(PortProxy &mem_proxy, Addr mask=maxAddr, Addr offset=0)
Definition: object_file.cc:93
void serializeSymtab(CheckpointOut &cp) const override
Serialization stuff.
Definition: system.cc:222
FSTranslatingPortProxy virtProxy
Proxy used to copy arguments directly into kernel memory.
Definition: system.hh:98
std::ostream CheckpointOut
Definition: serialize.hh:67
ObjectFile * createObjectFile(const string &fname, bool raw)
Definition: object_file.cc:157
TranslatingPortProxy Object Declaration for FS.
void unserialize(const std::string &base, CheckpointIn &cp)
Definition: symtab.cc:127
Addr Phys2K0Seg(Addr addr)
Definition: ev5.hh:61
Bitfield< 0 > p

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