summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-08-07 09:59:13 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-08-07 09:59:13 +0100
commit53e777d6838ac3ca80e6557626f9e99fd93dd0f7 (patch)
tree9029d3e7f1e158beac24761f2c9c690b3918d734 /src/sim
parent3e26756f1dfe1ddd1d7f5e458771c9bf79acb09a (diff)
downloadgem5-53e777d6838ac3ca80e6557626f9e99fd93dd0f7.tar.xz
base: Declare a type for context IDs
Context IDs used to be declared as ad hoc (usually as int). This changeset introduces a typedef for ContextIDs and a constant for invalid context IDs.
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/process.hh4
-rw-r--r--src/sim/system.cc8
-rw-r--r--src/sim/system.hh7
3 files changed, 10 insertions, 9 deletions
diff --git a/src/sim/process.hh b/src/sim/process.hh
index 82a84a935..f509b81c7 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -75,7 +75,7 @@ class Process : public SimObject
System *system;
// thread contexts associated with this process
- std::vector<int> contextIds;
+ std::vector<ContextID> contextIds;
// number of CPUs (esxec contexts, really) assigned to this process.
unsigned int numCpus() { return contextIds.size(); }
@@ -160,7 +160,7 @@ class Process : public SimObject
// After getting registered with system object, tell process which
// system-wide context id it is assigned.
- void assignThreadContext(int context_id)
+ void assignThreadContext(ContextID context_id)
{
contextIds.push_back(context_id);
}
diff --git a/src/sim/system.cc b/src/sim/system.cc
index c5e2e0b96..d0418d99b 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -209,11 +209,11 @@ bool System::breakpoint()
*/
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;
@@ -305,7 +305,7 @@ System::initState()
}
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",
diff --git a/src/sim/system.hh b/src/sim/system.hh
index 97d271d3a..634c78a6a 100644
--- a/src/sim/system.hh
+++ b/src/sim/system.hh
@@ -197,7 +197,7 @@ class System : public MemObject
std::vector<ThreadContext *> threadContexts;
int _numContexts;
- ThreadContext *getThreadContext(ThreadID tid)
+ ThreadContext *getThreadContext(ContextID tid)
{
return threadContexts[tid];
}
@@ -514,8 +514,9 @@ class System : public MemObject
/// @return Starting address of first page
Addr allocPhysPages(int npages);
- int registerThreadContext(ThreadContext *tc, int assigned=-1);
- void replaceThreadContext(ThreadContext *tc, int context_id);
+ ContextID registerThreadContext(ThreadContext *tc,
+ ContextID assigned = InvalidContextID);
+ void replaceThreadContext(ThreadContext *tc, ContextID context_id);
void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;