system.cc (8765:659670964330) system.cc (8769:f95b2a679eb0)
1/*
2 * Copyright (c) 2003-2006 The Regents of The University of Michigan
3 * Copyright (c) 2011 Regents of the University of California
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * Nathan Binkert
32 * Ali Saidi
33 * Rick Strong
34 */
35
36#include "arch/isa_traits.hh"
37#include "arch/remote_gdb.hh"
38#include "arch/utility.hh"
1/*
2 * Copyright (c) 2003-2006 The Regents of The University of Michigan
3 * Copyright (c) 2011 Regents of the University of California
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 22 unchanged lines hidden (view full) ---

31 * Nathan Binkert
32 * Ali Saidi
33 * Rick Strong
34 */
35
36#include "arch/isa_traits.hh"
37#include "arch/remote_gdb.hh"
38#include "arch/utility.hh"
39#include "arch/vtophys.hh"
39#include "base/loader/object_file.hh"
40#include "base/loader/symtab.hh"
41#include "base/trace.hh"
40#include "base/loader/object_file.hh"
41#include "base/loader/symtab.hh"
42#include "base/trace.hh"
42#include "config/full_system.hh"
43#include "config/the_isa.hh"
44#include "cpu/thread_context.hh"
45#include "debug/Loader.hh"
43#include "config/the_isa.hh"
44#include "cpu/thread_context.hh"
45#include "debug/Loader.hh"
46#include "kern/kernel_stats.hh"
46#include "mem/mem_object.hh"
47#include "mem/physical.hh"
47#include "mem/mem_object.hh"
48#include "mem/physical.hh"
49#include "mem/vport.hh"
50#include "params/System.hh"
48#include "sim/byteswap.hh"
49#include "sim/debug.hh"
51#include "sim/byteswap.hh"
52#include "sim/debug.hh"
53#include "sim/full_system.hh"
50#include "sim/system.hh"
51
54#include "sim/system.hh"
55
52#if FULL_SYSTEM
53#include "arch/vtophys.hh"
54#include "kern/kernel_stats.hh"
55#include "mem/vport.hh"
56#else
57#include "params/System.hh"
58#endif
59
60using namespace std;
61using namespace TheISA;
62
63vector<System *> System::systemList;
64
65int System::numSystemsRunning = 0;
66
67System::System(Params *p)
68 : SimObject(p), physmem(p->physmem), _numContexts(0), pagePtr(0),
56using namespace std;
57using namespace TheISA;
58
59vector<System *> System::systemList;
60
61int System::numSystemsRunning = 0;
62
63System::System(Params *p)
64 : SimObject(p), physmem(p->physmem), _numContexts(0), pagePtr(0),
69#if FULL_SYSTEM
70 init_param(p->init_param),
71 loadAddrMask(p->load_addr_mask),
65 init_param(p->init_param),
66 loadAddrMask(p->load_addr_mask),
72#endif
73 nextPID(0),
74 memoryMode(p->mem_mode),
75 workItemsBegin(0),
76 workItemsEnd(0),
77 _params(p),
78 totalNumInsts(0),
79 instEventQueue("system instruction-based event queue")
80{

--- 5 unchanged lines hidden (view full) ---

86 */
87 for (int x = 0; x < p->memories.size(); x++) {
88 if (!p->memories[x])
89 continue;
90 memRanges.push_back(RangeSize(p->memories[x]->start(),
91 p->memories[x]->size()));
92 }
93
67 nextPID(0),
68 memoryMode(p->mem_mode),
69 workItemsBegin(0),
70 workItemsEnd(0),
71 _params(p),
72 totalNumInsts(0),
73 instEventQueue("system instruction-based event queue")
74{

--- 5 unchanged lines hidden (view full) ---

80 */
81 for (int x = 0; x < p->memories.size(); x++) {
82 if (!p->memories[x])
83 continue;
84 memRanges.push_back(RangeSize(p->memories[x]->start(),
85 p->memories[x]->size()));
86 }
87
94#if FULL_SYSTEM
95 kernelSymtab = new SymbolTable;
96 if (!debugSymbolTable)
97 debugSymbolTable = new SymbolTable;
88 if (FullSystem) {
89 kernelSymtab = new SymbolTable;
90 if (!debugSymbolTable)
91 debugSymbolTable = new SymbolTable;
98
99
92
93
100 /**
101 * Get a functional port to memory
102 */
103 Port *mem_port;
104 functionalPort = new FunctionalPort(name() + "-fport");
105 mem_port = physmem->getPort("functional");
106 functionalPort->setPeer(mem_port);
107 mem_port->setPeer(functionalPort);
94 /**
95 * Get a functional port to memory
96 */
97 Port *mem_port;
98 functionalPort = new FunctionalPort(name() + "-fport");
99 mem_port = physmem->getPort("functional");
100 functionalPort->setPeer(mem_port);
101 mem_port->setPeer(functionalPort);
108
102
109 virtPort = new VirtualPort(name() + "-fport");
110 mem_port = physmem->getPort("functional");
111 virtPort->setPeer(mem_port);
112 mem_port->setPeer(virtPort);
103 virtPort = new VirtualPort(name() + "-fport");
104 mem_port = physmem->getPort("functional");
105 virtPort->setPeer(mem_port);
106 mem_port->setPeer(virtPort);
113
114
107
108
115 /**
116 * Load the kernel code into memory
117 */
118 if (params()->kernel == "") {
119 inform("No kernel set for full system simulation. Assuming you know what"
120 " you're doing...\n");
121 } else {
122 // Load kernel code
123 kernel = createObjectFile(params()->kernel);
124 inform("kernel located at: %s", params()->kernel);
109 /**
110 * Load the kernel code into memory
111 */
112 if (params()->kernel == "") {
113 inform("No kernel set for full system simulation. "
114 "Assuming you know what you're doing...\n");
115 } else {
116 // Load kernel code
117 kernel = createObjectFile(params()->kernel);
118 inform("kernel located at: %s", params()->kernel);
125
119
126 if (kernel == NULL)
127 fatal("Could not load kernel file %s", params()->kernel);
120 if (kernel == NULL)
121 fatal("Could not load kernel file %s", params()->kernel);
128
122
129 // Load program sections into memory
130 kernel->loadSections(functionalPort, loadAddrMask);
123 // Load program sections into memory
124 kernel->loadSections(functionalPort, loadAddrMask);
131
125
132 // setup entry points
133 kernelStart = kernel->textBase();
134 kernelEnd = kernel->bssBase() + kernel->bssSize();
135 kernelEntry = kernel->entryPoint();
126 // setup entry points
127 kernelStart = kernel->textBase();
128 kernelEnd = kernel->bssBase() + kernel->bssSize();
129 kernelEntry = kernel->entryPoint();
136
130
137 // load symbols
138 if (!kernel->loadGlobalSymbols(kernelSymtab))
139 fatal("could not load kernel symbols\n");
131 // load symbols
132 if (!kernel->loadGlobalSymbols(kernelSymtab))
133 fatal("could not load kernel symbols\n");
140
134
141 if (!kernel->loadLocalSymbols(kernelSymtab))
142 fatal("could not load kernel local symbols\n");
135 if (!kernel->loadLocalSymbols(kernelSymtab))
136 fatal("could not load kernel local symbols\n");
143
137
144 if (!kernel->loadGlobalSymbols(debugSymbolTable))
145 fatal("could not load kernel symbols\n");
138 if (!kernel->loadGlobalSymbols(debugSymbolTable))
139 fatal("could not load kernel symbols\n");
146
140
147 if (!kernel->loadLocalSymbols(debugSymbolTable))
148 fatal("could not load kernel local symbols\n");
141 if (!kernel->loadLocalSymbols(debugSymbolTable))
142 fatal("could not load kernel local symbols\n");
149
143
150 DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
151 DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd);
152 DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry);
153 DPRINTF(Loader, "Kernel loaded...\n");
144 DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
145 DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd);
146 DPRINTF(Loader, "Kernel entry = %#x\n", kernelEntry);
147 DPRINTF(Loader, "Kernel loaded...\n");
148 }
154 }
149 }
155#endif // FULL_SYSTEM
156
157 // increment the number of running systms
158 numSystemsRunning++;
159
160 activeCpus.clear();
161}
162
163System::~System()
164{
150
151 // increment the number of running systms
152 numSystemsRunning++;
153
154 activeCpus.clear();
155}
156
157System::~System()
158{
165#if FULL_SYSTEM
166 delete kernelSymtab;
167 delete kernel;
159 delete kernelSymtab;
160 delete kernel;
168#else
169 panic("System::fixFuncEventAddr needs to be rewritten "
170 "to work with syscall emulation");
171#endif // FULL_SYSTEM}
172}
173
174void
175System::setMemoryMode(Enums::MemoryMode mode)
176{
177 assert(getState() == Drained);
178 memoryMode = mode;
179}

--- 66 unchanged lines hidden (view full) ---

246 ++running;
247 }
248 return running;
249}
250
251void
252System::initState()
253{
161}
162
163void
164System::setMemoryMode(Enums::MemoryMode mode)
165{
166 assert(getState() == Drained);
167 memoryMode = mode;
168}

--- 66 unchanged lines hidden (view full) ---

235 ++running;
236 }
237 return running;
238}
239
240void
241System::initState()
242{
254#if FULL_SYSTEM
255 int i;
256 for (i = 0; i < threadContexts.size(); i++)
257 TheISA::startupCPU(threadContexts[i], i);
258#endif
243 if (FullSystem) {
244 int i;
245 for (i = 0; i < threadContexts.size(); i++)
246 TheISA::startupCPU(threadContexts[i], i);
247 }
259}
260
261void
262System::replaceThreadContext(ThreadContext *tc, int context_id)
263{
264 if (context_id >= threadContexts.size()) {
265 panic("replaceThreadContext: bad id, %d >= %d\n",
266 context_id, threadContexts.size());

--- 42 unchanged lines hidden (view full) ---

309{
310 SimObject::resume();
311 totalNumInsts = 0;
312}
313
314void
315System::serialize(ostream &os)
316{
248}
249
250void
251System::replaceThreadContext(ThreadContext *tc, int context_id)
252{
253 if (context_id >= threadContexts.size()) {
254 panic("replaceThreadContext: bad id, %d >= %d\n",
255 context_id, threadContexts.size());

--- 42 unchanged lines hidden (view full) ---

298{
299 SimObject::resume();
300 totalNumInsts = 0;
301}
302
303void
304System::serialize(ostream &os)
305{
317#if FULL_SYSTEM
318 kernelSymtab->serialize("kernel_symtab", os);
319#endif
306 if (FullSystem)
307 kernelSymtab->serialize("kernel_symtab", os);
320 SERIALIZE_SCALAR(pagePtr);
321 SERIALIZE_SCALAR(nextPID);
322}
323
324
325void
326System::unserialize(Checkpoint *cp, const string &section)
327{
308 SERIALIZE_SCALAR(pagePtr);
309 SERIALIZE_SCALAR(nextPID);
310}
311
312
313void
314System::unserialize(Checkpoint *cp, const string &section)
315{
328#if FULL_SYSTEM
329 kernelSymtab->unserialize("kernel_symtab", cp, section);
330#endif
316 if (FullSystem)
317 kernelSymtab->unserialize("kernel_symtab", cp, section);
331 UNSERIALIZE_SCALAR(pagePtr);
332 UNSERIALIZE_SCALAR(nextPID);
333}
334
335void
336System::printSystems()
337{
338 vector<System *>::iterator i = systemList.begin();

--- 8 unchanged lines hidden (view full) ---

347printSystems()
348{
349 System::printSystems();
350}
351
352const char *System::MemoryModeStrings[3] = {"invalid", "atomic",
353 "timing"};
354
318 UNSERIALIZE_SCALAR(pagePtr);
319 UNSERIALIZE_SCALAR(nextPID);
320}
321
322void
323System::printSystems()
324{
325 vector<System *>::iterator i = systemList.begin();

--- 8 unchanged lines hidden (view full) ---

334printSystems()
335{
336 System::printSystems();
337}
338
339const char *System::MemoryModeStrings[3] = {"invalid", "atomic",
340 "timing"};
341
355#if !FULL_SYSTEM
356
357System *
358SystemParams::create()
359{
360 return new System(this);
361}
342System *
343SystemParams::create()
344{
345 return new System(this);
346}
362
363#endif