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-2006 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  */
30 
31 #include "arch/sparc/system.hh"
32 
33 #include "arch/sparc/faults.hh"
34 #include "arch/vtophys.hh"
36 #include "base/loader/symtab.hh"
37 #include "base/trace.hh"
38 #include "mem/physical.hh"
39 #include "params/SparcSystem.hh"
40 #include "sim/byteswap.hh"
41 
42 namespace
43 {
44 
45 ObjectFile *
46 loadFirmwareImage(const std::string &fname, const std::string &name)
47 {
48  ObjectFile *obj = createObjectFile(fname, true);
49  fatal_if(!obj, "Could not load %s %s.", name, fname);
50  return obj;
51 }
52 
53 } // anonymous namespace
54 
56  : System(p), sysTick(0)
57 {
64 
65  reset = loadFirmwareImage(params()->reset_bin, "reset binary");
66  openboot = loadFirmwareImage(params()->openboot_bin, "openboot binary");
67  hypervisor = loadFirmwareImage(
68  params()->hypervisor_bin, "hypervisor binary");
69  nvram = loadFirmwareImage(params()->nvram_bin, "nvram image");
70  hypervisor_desc = loadFirmwareImage(
71  params()->hypervisor_desc_bin, "hypervisor description image");
72  partition_desc = loadFirmwareImage(
73  params()->partition_desc_bin, "partition description image");
74 
75  // load symbols
77  panic("could not load reset symbols\n");
78 
80  panic("could not load openboot symbols\n");
81 
83  panic("could not load hypervisor symbols\n");
84 
86  panic("could not load nvram symbols\n");
87 
89  panic("could not load hypervisor description symbols\n");
90 
92  panic("could not load partition description symbols\n");
93 
94  // load symbols into debug table
96  panic("could not load reset symbols\n");
97 
99  panic("could not load openboot symbols\n");
100 
102  panic("could not load hypervisor symbols\n");
103 
104  // Strip off the rom address so when the hypervisor is copied into memory we
105  // have symbols still
106  if (!hypervisor->loadLocalSymbols(debugSymbolTable, 0, 0, 0xFFFFFF))
107  panic("could not load hypervisor symbols\n");
108 
110  panic("could not load reset symbols\n");
111 
113  panic("could not load hypervisor description symbols\n");
114 
116  panic("could not load partition description symbols\n");
117 
118 }
119 
120 namespace
121 {
122 
123 void
124 writeFirmwareImage(ObjectFile *obj, Addr addr, const PortProxy &proxy)
125 {
126  MemoryImage image = obj->buildImage();
127 
128  // If the entry point isn't somewhere in the image, we assume we need to
129  // move where it's loaded so that it is.
130  if (addr < image.minAddr() || addr >= image.maxAddr()) {
131  // Move the image by the difference between the expected entry address,
132  // and the entry point in the object file.
133  image.offset(addr - obj->entryPoint());
134  }
135 
136  image.write(proxy);
137 }
138 
139 } // anonymous namespace
140 
141 void
143 {
144  // Call the initialisation of the super class
146 
147  writeFirmwareImage(reset, params()->reset_addr, physProxy);
148  writeFirmwareImage(openboot, params()->openboot_addr, physProxy);
149  writeFirmwareImage(hypervisor, params()->hypervisor_addr, physProxy);
150  writeFirmwareImage(nvram, params()->nvram_addr, physProxy);
151  writeFirmwareImage(
152  hypervisor_desc, params()->hypervisor_desc_addr, physProxy);
153  writeFirmwareImage(
154  partition_desc, params()->partition_desc_addr, physProxy);
155 
156  // @todo any fixup code over writing data in binaries on setting break
157  // events on functions should happen here.
158 
159  if (threadContexts.empty())
160  return;
161 
162  // Other CPUs will get activated by IPIs.
163  auto *tc = threadContexts[0];
165  tc->activate();
166 }
167 
169 {
170  delete resetSymtab;
171  delete hypervisorSymtab;
172  delete openbootSymtab;
173  delete nvramSymtab;
174  delete hypervisorDescSymtab;
175  delete partitionDescSymtab;
176  delete reset;
177  delete openboot;
178  delete hypervisor;
179  delete nvram;
180  delete hypervisor_desc;
181  delete partition_desc;
182 }
183 
184 void
186 {
187  resetSymtab->serialize("reset_symtab", cp);
188  hypervisorSymtab->serialize("hypervisor_symtab", cp);
189  openbootSymtab->serialize("openboot_symtab", cp);
190  nvramSymtab->serialize("nvram_symtab", cp);
191  hypervisorDescSymtab->serialize("hypervisor_desc_symtab", cp);
192  partitionDescSymtab->serialize("partition_desc_symtab", cp);
193 }
194 
195 
196 void
198 {
199  resetSymtab->unserialize("reset_symtab", cp);
200  hypervisorSymtab->unserialize("hypervisor_symtab", cp);
201  openbootSymtab->unserialize("openboot_symtab", cp);
202  nvramSymtab->unserialize("nvram_symtab", cp);
203  hypervisorDescSymtab->unserialize("hypervisor_desc_symtab", cp);
204  partitionDescSymtab->unserialize("partition_desc_symtab", cp);
205 }
206 
207 SparcSystem *
208 SparcSystemParams::create()
209 {
210  return new SparcSystem(this);
211 }
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:167
SymbolTable * partitionDescSymtab
partition desc symbol table?
Definition: system.hh:76
const std::string & name()
Definition: trace.cc:54
bool write(const PortProxy &proxy) const
Definition: memory_image.cc:50
ObjectFile * createObjectFile(const std::string &fname, bool raw)
Definition: object_file.cc:64
SymbolTable * hypervisorDescSymtab
hypervisor desc symbol table?
Definition: system.hh:73
ObjectFile * hypervisor
Object pointer for the hypervisor code.
Definition: system.hh:82
ip6_addr_t addr
Definition: inet.hh:335
SymbolTable * openbootSymtab
openboot symbol table
Definition: system.hh:67
SymbolTable * debugSymbolTable
Global unified debugging symbol table (for target).
Definition: symtab.cc:45
Definition: system.hh:77
void unserializeSymtab(CheckpointIn &cp) override
If needed, unserialize additional symbol table entries for a specific subclass of this system...
Definition: system.cc:197
Definition: cprintf.cc:42
SparcSystem(Params *p)
Definition: system.cc:55
PortProxy physProxy
Port to physical memory used for writing object files into ram at boot.
Definition: system.hh:218
Addr minAddr() const
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: system.cc:349
virtual MemoryImage buildImage() const =0
SymbolTable * hypervisorSymtab
hypervison binary symbol table
Definition: system.hh:64
~SparcSystem()
Definition: system.cc:168
Addr maxAddr() const
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
MemoryImage & offset(Addr by)
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
Definition: logging.hh:203
SymbolTable * resetSymtab
reset binary symbol table
Definition: system.hh:61
void serialize(const std::string &base, CheckpointOut &cp) const
Definition: symtab.cc:113
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ObjectFile * reset
Object pointer for the reset binary.
Definition: system.hh:79
SparcSystemParams Params
Definition: system.hh:47
SymbolTable * nvramSymtab
nvram symbol table?
Definition: system.hh:70
This object is a proxy for a port or other object which implements the functional response protocol...
Definition: port_proxy.hh:82
void invoke(ThreadContext *tc, const StaticInstPtr &inst=StaticInst::nullStaticInstPtr)
Definition: faults.cc:561
std::ostream CheckpointOut
Definition: serialize.hh:68
Addr entryPoint() const
Definition: object_file.hh:131
ObjectFile * nvram
Object pointer for the nvram image.
Definition: system.hh:88
void unserialize(const std::string &base, CheckpointIn &cp)
Definition: symtab.cc:127
ObjectFile * partition_desc
Object pointer for the partition description image.
Definition: system.hh:94
void initState() override
initState() is called on each SimObject when not restoring from a checkpoint.
Definition: system.cc:142
void serializeSymtab(CheckpointOut &cp) const override
Serialization stuff.
Definition: system.cc:185
ObjectFile * openboot
Object pointer for the openboot code.
Definition: system.hh:85
Bitfield< 0 > p
const Params * params() const
Definition: system.hh:100
virtual bool loadGlobalSymbols(SymbolTable *symtab, Addr base=0, Addr offset=0, Addr mask=MaxAddr)
Definition: object_file.hh:90
ObjectFile * hypervisor_desc
Object pointer for the hypervisor description image.
Definition: system.hh:91

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