projects
/
gem5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ISA: Simplify various implementations of completeAcc.
[gem5.git]
/
src
/
sim
/
system.cc
diff --git
a/src/sim/system.cc
b/src/sim/system.cc
index eb0655aa55a3b612ac99c466696badb27e99954d..45e06616da83929bfd217a348e6658dfbe2179af 100644
(file)
--- a/
src/sim/system.cc
+++ b/
src/sim/system.cc
@@
-38,10
+38,14
@@
#include "base/loader/symtab.hh"
#include "base/trace.hh"
#include "cpu/thread_context.hh"
#include "base/loader/symtab.hh"
#include "base/trace.hh"
#include "cpu/thread_context.hh"
+#include "config/full_system.hh"
+#include "config/the_isa.hh"
#include "mem/mem_object.hh"
#include "mem/physical.hh"
#include "sim/byteswap.hh"
#include "sim/system.hh"
#include "mem/mem_object.hh"
#include "mem/physical.hh"
#include "sim/byteswap.hh"
#include "sim/system.hh"
+#include "sim/debug.hh"
+
#if FULL_SYSTEM
#include "arch/vtophys.hh"
#include "kern/kernel_stats.hh"
#if FULL_SYSTEM
#include "arch/vtophys.hh"
#include "kern/kernel_stats.hh"
@@
-57,13
+61,15
@@
vector<System *> System::systemList;
int System::numSystemsRunning = 0;
System::System(Params *p)
int System::numSystemsRunning = 0;
System::System(Params *p)
- : SimObject(p
->name), physmem(p->physmem), numcpu
s(0),
+ : SimObject(p
), physmem(p->physmem), _numContext
s(0),
#if FULL_SYSTEM
init_param(p->init_param),
functionalPort(p->name + "-fport"),
virtPort(p->name + "-vport"),
#if FULL_SYSTEM
init_param(p->init_param),
functionalPort(p->name + "-fport"),
virtPort(p->name + "-vport"),
+ loadAddrMask(p->load_addr_mask),
#else
page_ptr(0),
#else
page_ptr(0),
+ next_PID(0),
#endif
memoryMode(p->mem_mode), _params(p)
{
#endif
memoryMode(p->mem_mode), _params(p)
{
@@
-93,16
+99,18
@@
System::System(Params *p)
* Load the kernel code into memory
*/
if (params()->kernel == "") {
* Load the kernel code into memory
*/
if (params()->kernel == "") {
-
warn
("No kernel set for full system simulation. Assuming you know what"
+
inform
("No kernel set for full system simulation. Assuming you know what"
" you're doing...\n");
} else {
// Load kernel code
kernel = createObjectFile(params()->kernel);
" you're doing...\n");
} else {
// Load kernel code
kernel = createObjectFile(params()->kernel);
+ inform("kernel located at: %s", params()->kernel);
+
if (kernel == NULL)
fatal("Could not load kernel file %s", params()->kernel);
// Load program sections into memory
if (kernel == NULL)
fatal("Could not load kernel file %s", params()->kernel);
// Load program sections into memory
- kernel->loadSections(&functionalPort,
L
oadAddrMask);
+ kernel->loadSections(&functionalPort,
l
oadAddrMask);
// setup entry points
kernelStart = kernel->textBase();
// setup entry points
kernelStart = kernel->textBase();
@@
-111,16
+119,16
@@
System::System(Params *p)
// load symbols
if (!kernel->loadGlobalSymbols(kernelSymtab))
// load symbols
if (!kernel->loadGlobalSymbols(kernelSymtab))
-
panic
("could not load kernel symbols\n");
+
fatal
("could not load kernel symbols\n");
if (!kernel->loadLocalSymbols(kernelSymtab))
if (!kernel->loadLocalSymbols(kernelSymtab))
-
panic
("could not load kernel local symbols\n");
+
fatal
("could not load kernel local symbols\n");
if (!kernel->loadGlobalSymbols(debugSymbolTable))
if (!kernel->loadGlobalSymbols(debugSymbolTable))
-
panic
("could not load kernel symbols\n");
+
fatal
("could not load kernel symbols\n");
if (!kernel->loadLocalSymbols(debugSymbolTable))
if (!kernel->loadLocalSymbols(debugSymbolTable))
-
panic
("could not load kernel local symbols\n");
+
fatal
("could not load kernel local symbols\n");
DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd);
DPRINTF(Loader, "Kernel start = %#x\n", kernelStart);
DPRINTF(Loader, "Kernel end = %#x\n", kernelEnd);
@@
-144,9
+152,6
@@
System::~System()
#endif // FULL_SYSTEM}
}
#endif // FULL_SYSTEM}
}
-int rgdb_wait = -1;
-int rgdb_enable = true;
-
void
System::setMemoryMode(Enums::MemoryMode mode)
{
void
System::setMemoryMode(Enums::MemoryMode mode)
{
@@
-161,33
+166,43
@@
bool System::breakpoint()
return false;
}
return false;
}
+/**
+ * Setting rgdb_wait to a positive integer waits for a remote debugger to
+ * connect to that context ID before continuing. This should really
+ be a parameter on the CPU object or something...
+ */
+int rgdb_wait = -1;
+
int
int
-System::registerThreadContext(ThreadContext *tc, int
i
d)
+System::registerThreadContext(ThreadContext *tc, int
assigne
d)
{
{
- if (id == -1) {
+ int id;
+ if (assigned == -1) {
for (id = 0; id < threadContexts.size(); id++) {
if (!threadContexts[id])
break;
}
for (id = 0; id < threadContexts.size(); id++) {
if (!threadContexts[id])
break;
}
- }
- if (threadContexts.size() <= id)
- threadContexts.resize(id + 1);
+ if (threadContexts.size() <= id)
+ threadContexts.resize(id + 1);
+ } else {
+ if (threadContexts.size() <= assigned)
+ threadContexts.resize(assigned + 1);
+ id = assigned;
+ }
if (threadContexts[id])
if (threadContexts[id])
-
panic
("Cannot have two CPUs with the same id (%d)\n", id);
+
fatal
("Cannot have two CPUs with the same id (%d)\n", id);
threadContexts[id] = tc;
threadContexts[id] = tc;
-
numcpu
s++;
+
_numContext
s++;
- if (rgdb_enable) {
+ int port = getRemoteGDBPort();
+ if (port) {
RemoteGDB *rgdb = new RemoteGDB(this, tc);
RemoteGDB *rgdb = new RemoteGDB(this, tc);
- GDBListener *gdbl = new GDBListener(rgdb,
7000
+ id);
+ GDBListener *gdbl = new GDBListener(rgdb,
port
+ id);
gdbl->listen();
gdbl->listen();
- /**
- * Uncommenting this line waits for a remote debugger to
- * connect to the simulator before continuing.
- */
+
if (rgdb_wait != -1 && rgdb_wait == id)
gdbl->accept();
if (rgdb_wait != -1 && rgdb_wait == id)
gdbl->accept();
@@
-201,25
+216,38
@@
System::registerThreadContext(ThreadContext *tc, int id)
return id;
}
return id;
}
+int
+System::numRunningContexts()
+{
+ int running = 0;
+ for (int i = 0; i < _numContexts; ++i) {
+ if (threadContexts[i]->status() != ThreadContext::Halted)
+ ++running;
+ }
+ return running;
+}
+
void
System::startup()
{
void
System::startup()
{
+#if FULL_SYSTEM
int i;
for (i = 0; i < threadContexts.size(); i++)
TheISA::startupCPU(threadContexts[i], i);
int i;
for (i = 0; i < threadContexts.size(); i++)
TheISA::startupCPU(threadContexts[i], i);
+#endif
}
void
}
void
-System::replaceThreadContext(ThreadContext *tc, int id)
+System::replaceThreadContext(ThreadContext *tc, int
context_
id)
{
{
- if (id >= threadContexts.size()) {
+ if (
context_
id >= threadContexts.size()) {
panic("replaceThreadContext: bad id, %d >= %d\n",
panic("replaceThreadContext: bad id, %d >= %d\n",
- id, threadContexts.size());
+
context_
id, threadContexts.size());
}
}
- threadContexts[id] = tc;
- if (id < remoteGDB.size())
- remoteGDB[id]->replaceThreadContext(tc);
+ threadContexts[
context_
id] = tc;
+ if (
context_
id < remoteGDB.size())
+ remoteGDB[
context_
id]->replaceThreadContext(tc);
}
#if !FULL_SYSTEM
}
#if !FULL_SYSTEM
@@
-232,6
+260,19
@@
System::new_page()
fatal("Out of memory, please increase size of physical memory.");
return return_addr;
}
fatal("Out of memory, please increase size of physical memory.");
return return_addr;
}
+
+Addr
+System::memSize()
+{
+ return physmem->size();
+}
+
+Addr
+System::freeMemSize()
+{
+ return physmem->size() - (page_ptr << LogVMPageSize);
+}
+
#endif
void
#endif
void
@@
-239,7
+280,9
@@
System::serialize(ostream &os)
{
#if FULL_SYSTEM
kernelSymtab->serialize("kernel_symtab", os);
{
#if FULL_SYSTEM
kernelSymtab->serialize("kernel_symtab", os);
-#endif // FULL_SYSTEM
+#else // !FULL_SYSTEM
+ SERIALIZE_SCALAR(page_ptr);
+#endif
}
}
@@
-248,7
+291,9
@@
System::unserialize(Checkpoint *cp, const string §ion)
{
#if FULL_SYSTEM
kernelSymtab->unserialize("kernel_symtab", cp, section);
{
#if FULL_SYSTEM
kernelSymtab->unserialize("kernel_symtab", cp, section);
-#endif // FULL_SYSTEM
+#else // !FULL_SYSTEM
+ UNSERIALIZE_SCALAR(page_ptr);
+#endif
}
void
}
void
@@
-276,11
+321,7
@@
const char *System::MemoryModeStrings[3] = {"invalid", "atomic",
System *
SystemParams::create()
{
System *
SystemParams::create()
{
- System::Params *p = new System::Params;
- p->name = name;
- p->physmem = physmem;
- p->mem_mode = mem_mode;
- return new System(p);
+ return new System(this);
}
#endif
}
#endif