/*
* Copyright (c) 2002-2005 The Regents of The University of Michigan
+ * Copyright (c) 2011 Regents of the University of California
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* Authors: Steve Reinhardt
* Lisa Hsu
* Nathan Binkert
+ * Rick Strong
*/
#ifndef __SYSTEM_HH__
#include "mem/port.hh"
#include "params/System.hh"
#include "sim/sim_object.hh"
+
#if FULL_SYSTEM
#include "kern/system_events.hh"
-#include "mem/vport.hh"
#endif
class BaseCPU;
#if FULL_SYSTEM
class Platform;
+class FunctionalPort;
+class VirtualPort;
#endif
class GDBListener;
-namespace TheISA
-{
- class RemoteGDB;
-}
+class BaseRemoteGDB;
class System : public SimObject
{
std::vector<ThreadContext *> threadContexts;
int _numContexts;
- ThreadContext * getThreadContext(int tid)
+ ThreadContext *getThreadContext(ThreadID tid)
{
return threadContexts[tid];
}
int numContexts()
{
- if (_numContexts != threadContexts.size())
- panic("cpu array not fully populated!");
-
+ assert(_numContexts == (int)threadContexts.size());
return _numContexts;
}
+ /** Return number of running (non-halted) thread contexts in
+ * system. These threads could be Active or Suspended. */
+ int numRunningContexts();
+
#if FULL_SYSTEM
Platform *platform;
uint64_t init_param;
/** Port to physical memory used for writing object files into ram at
* boot.*/
- FunctionalPort functionalPort;
- VirtualPort virtPort;
+ FunctionalPort *functionalPort;
+ VirtualPort *virtPort;
/** kernel symbol table */
SymbolTable *kernelSymtab;
/** Entry point in the kernel to start at */
Addr kernelEntry;
+ /** Mask that should be anded for binary/symbol loading.
+ * This allows one two different OS requirements for the same ISA to be
+ * handled. Some OSes are compiled for a virtual address and need to be
+ * loaded into physical memory that starts at address 0, while other
+ * bare metal tools generate images that start at address 0.
+ */
+ Addr loadAddrMask;
+
#else
- int page_ptr;
+ Addr pagePtr;
protected:
- uint64_t next_PID;
+ uint64_t nextPID;
public:
uint64_t allocatePID()
{
- return next_PID++;
+ return nextPID++;
}
+ /** Amount of physical memory that is still free */
+ Addr freeMemSize();
+
+ /** Amount of physical memory that exists */
+ Addr memSize();
+
#endif // FULL_SYSTEM
protected:
Enums::MemoryMode memoryMode;
+ uint64_t workItemsBegin;
+ uint64_t workItemsEnd;
+ std::vector<bool> activeCpus;
+
+ public:
+ /**
+ * Called by pseudo_inst to track the number of work items started by this
+ * system.
+ */
+ uint64_t
+ incWorkItemsBegin()
+ {
+ return ++workItemsBegin;
+ }
+
+ /**
+ * Called by pseudo_inst to track the number of work items completed by
+ * this system.
+ */
+ uint64_t
+ incWorkItemsEnd()
+ {
+ return ++workItemsEnd;
+ }
+
+ /**
+ * Called by pseudo_inst to mark the cpus actively executing work items.
+ * Returns the total number of cpus that have executed work item begin or
+ * ends.
+ */
+ int
+ markWorkItem(int index)
+ {
+ int count = 0;
+ assert(index < activeCpus.size());
+ activeCpus[index] = true;
+ for (std::vector<bool>::iterator i = activeCpus.begin();
+ i < activeCpus.end(); i++) {
+ if (*i) count++;
+ }
+ return count;
+ }
#if FULL_SYSTEM
/**
#endif
public:
- std::vector<TheISA::RemoteGDB *> remoteGDB;
+ std::vector<BaseRemoteGDB *> remoteGDB;
std::vector<GDBListener *> gdbListen;
bool breakpoint();
System(Params *p);
~System();
- void startup();
+ void initState();
const Params *params() const { return (const Params *)_params; }
#endif // FULL_SYSTEM
- int registerThreadContext(ThreadContext *tc);
+ int registerThreadContext(ThreadContext *tc, int assigned=-1);
void replaceThreadContext(ThreadContext *tc, int context_id);
void serialize(std::ostream &os);
void unserialize(Checkpoint *cp, const std::string §ion);
+ virtual void resume();
public:
+ Counter totalNumInsts;
+ EventQueue instEventQueue;
+
////////////////////////////////////////////
//
// STATIC GLOBAL SYSTEM LIST