* Rick Strong
*/
+#include "sim/system.hh"
+
#include "arch/remote_gdb.hh"
#include "arch/utility.hh"
#include "base/loader/object_file.hh"
#include "base/loader/symtab.hh"
#include "base/str.hh"
#include "base/trace.hh"
+#include "config/use_kvm.hh"
+#if USE_KVM
+#include "cpu/kvm/base.hh"
+#include "cpu/kvm/vm.hh"
+#endif
+#include "cpu/base.hh"
#include "cpu/thread_context.hh"
#include "debug/Loader.hh"
#include "debug/WorkItems.hh"
#include "sim/byteswap.hh"
#include "sim/debug.hh"
#include "sim/full_system.hh"
-#include "sim/system.hh"
/**
* To avoid linking errors with LTO, only include the header if we
*/
#if THE_ISA != NULL_ISA
#include "kern/kernel_stats.hh"
+
#endif
using namespace std;
System::System(Params *p)
: MemObject(p), _systemPort("system_port", this),
_numContexts(0),
+ multiThread(p->multi_thread),
pagePtr(0),
init_param(p->init_param),
physProxy(_systemPort, p->cache_line_size),
kernel(nullptr),
loadAddrMask(p->load_addr_mask),
loadAddrOffset(p->load_offset),
- nextPID(0),
+#if USE_KVM
+ kvmVM(p->kvm_vm),
+#else
+ kvmVM(nullptr),
+#endif
physmem(name() + ".physmem", p->memories, p->mmap_using_noreserve),
memoryMode(p->mem_mode),
_cacheLineSize(p->cache_line_size),
workItemsBegin(0),
workItemsEnd(0),
numWorkIds(p->num_work_ids),
+ thermalModel(p->thermal_model),
_params(p),
totalNumInsts(0),
instEventQueue("system instruction-based event queue")
// add self to global system list
systemList.push_back(this);
+#if USE_KVM
+ if (kvmVM) {
+ kvmVM->setSystem(this);
+ }
+#endif
+
if (FullSystem) {
kernelSymtab = new SymbolTable;
if (!debugSymbolTable)
}
}
- // increment the number of running systms
+ // increment the number of running systems
numSystemsRunning++;
// Set back pointers to the system in all memories
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
-System::registerThreadContext(ThreadContext *tc, int assigned)
+ContextID
+System::registerThreadContext(ThreadContext *tc, ContextID assigned)
{
int id;
- if (assigned == -1) {
+ if (assigned == InvalidContextID) {
for (id = 0; id < threadContexts.size(); id++) {
if (!threadContexts[id])
break;
GDBListener *gdbl = new GDBListener(rgdb, port + id);
gdbl->listen();
- if (rgdb_wait != -1 && rgdb_wait == id)
- gdbl->accept();
+ BaseCPU *cpu = tc->getCpuPtr();
+ if (cpu->waitForRemoteGDB()) {
+ inform("%s: Waiting for a remote GDB connection on port %d.\n",
+ cpu->name(), gdbl->getPort());
+ gdbl->accept();
+ }
if (remoteGDB.size() <= id) {
remoteGDB.resize(id + 1);
}
}
void
-System::replaceThreadContext(ThreadContext *tc, int context_id)
+System::replaceThreadContext(ThreadContext *tc, ContextID context_id)
{
if (context_id >= threadContexts.size()) {
panic("replaceThreadContext: bad id, %d >= %d\n",
remoteGDB[context_id]->replaceThreadContext(tc);
}
+bool
+System::validKvmEnvironment() const
+{
+#if USE_KVM
+ if (threadContexts.empty())
+ return false;
+
+ for (auto tc : threadContexts) {
+ if (dynamic_cast<BaseKvmCPU*>(tc->getCpuPtr()) == nullptr) {
+ return false;
+ }
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
Addr
System::allocPhysPages(int npages)
{
if (FullSystem)
kernelSymtab->serialize("kernel_symtab", cp);
SERIALIZE_SCALAR(pagePtr);
- SERIALIZE_SCALAR(nextPID);
serializeSymtab(cp);
// also serialize the memories in the system
if (FullSystem)
kernelSymtab->unserialize("kernel_symtab", cp);
UNSERIALIZE_SCALAR(pagePtr);
- UNSERIALIZE_SCALAR(nextPID);
unserializeSymtab(cp);
// also unserialize the memories in the system
void
System::regStats()
{
+ MemObject::regStats();
+
for (uint32_t j = 0; j < numWorkIds ; j++) {
workItemStats[j] = new Stats::Histogram();
stringstream namestr;