summaryrefslogtreecommitdiff
path: root/src/dev/arm/vgic.cc
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:03 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:03 +0100
commit76cd4393c08b83fa9006ee7bce1fb62457e053c1 (patch)
treef1d2d109f77a8cf31365143d6eb127b610d924f5 /src/dev/arm/vgic.cc
parentd7a56ee524c976a41fa40e5382a28462de799645 (diff)
downloadgem5-76cd4393c08b83fa9006ee7bce1fb62457e053c1.tar.xz
sim: Refactor the serialization base class
Objects that are can be serialized are supposed to inherit from the Serializable class. This class is meant to provide a unified API for such objects. However, so far it has mainly been used by SimObjects due to some fundamental design limitations. This changeset redesigns to the serialization interface to make it more generic and hide the underlying checkpoint storage. Specifically: * Add a set of APIs to serialize into a subsection of the current object. Previously, objects that needed this functionality would use ad-hoc solutions using nameOut() and section name generation. In the new world, an object that implements the interface has the methods serializeSection() and unserializeSection() that serialize into a named /subsection/ of the current object. Calling serialize() serializes an object into the current section. * Move the name() method from Serializable to SimObject as it is no longer needed for serialization. The fully qualified section name is generated by the main serialization code on the fly as objects serialize sub-objects. * Add a scoped ScopedCheckpointSection helper class. Some objects need to serialize data structures, that are not deriving from Serializable, into subsections. Previously, this was done using nameOut() and manual section name generation. To simplify this, this changeset introduces a ScopedCheckpointSection() helper class. When this class is instantiated, it adds a new /subsection/ and subsequent serialization calls during the lifetime of this helper class happen inside this section (or a subsection in case of nested sections). * The serialize() call is now const which prevents accidental state manipulation during serialization. Objects that rely on modifying state can use the serializeOld() call instead. The default implementation simply calls serialize(). Note: The old-style calls need to be explicitly called using the serializeOld()/serializeSectionOld() style APIs. These are used by default when serializing SimObjects. * Both the input and output checkpoints now use their own named types. This hides underlying checkpoint implementation from objects that need checkpointing and makes it easier to change the underlying checkpoint storage code.
Diffstat (limited to 'src/dev/arm/vgic.cc')
-rw-r--r--src/dev/arm/vgic.cc127
1 files changed, 59 insertions, 68 deletions
diff --git a/src/dev/arm/vgic.cc b/src/dev/arm/vgic.cc
index 4a63c796a..f4a3e8c3f 100644
--- a/src/dev/arm/vgic.cc
+++ b/src/dev/arm/vgic.cc
@@ -56,9 +56,6 @@ VGic::VGic(const Params *p)
maintIntPosted[x] = false;
vIntPosted[x] = false;
}
- for (int c = 0; c < VGIC_CPU_MAX; c++) {
- memset(&vcpuData[c], 0, sizeof(struct vcpuIntData));
- }
assert(sys->numRunningContexts() <= VGIC_CPU_MAX);
}
@@ -437,7 +434,7 @@ VGic::getAddrRanges() const
}
void
-VGic::serialize(std::ostream &os)
+VGic::serialize(CheckpointOut &cp) const
{
Tick interrupt_time[VGIC_CPU_MAX];
for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++) {
@@ -457,42 +454,45 @@ VGic::serialize(std::ostream &os)
SERIALIZE_SCALAR(pioDelay);
SERIALIZE_SCALAR(maintInt);
- for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++) {
- nameOut(os, csprintf("%s.vcpuData%d", name(), cpu));
- uint32_t vctrl_val = vcpuData[cpu].vctrl;
- SERIALIZE_SCALAR(vctrl_val);
- uint32_t hcr_val = vcpuData[cpu].hcr;
- SERIALIZE_SCALAR(hcr_val);
- uint64_t eisr_val = vcpuData[cpu].eisr;
- SERIALIZE_SCALAR(eisr_val);
- uint8_t VMGrp0En_val = vcpuData[cpu].VMGrp0En;
- SERIALIZE_SCALAR(VMGrp0En_val);
- uint8_t VMGrp1En_val = vcpuData[cpu].VMGrp1En;
- SERIALIZE_SCALAR(VMGrp1En_val);
- uint8_t VMAckCtl_val = vcpuData[cpu].VMAckCtl;
- SERIALIZE_SCALAR(VMAckCtl_val);
- uint8_t VMFiqEn_val = vcpuData[cpu].VMFiqEn;
- SERIALIZE_SCALAR(VMFiqEn_val);
- uint8_t VMCBPR_val = vcpuData[cpu].VMCBPR;
- SERIALIZE_SCALAR(VMCBPR_val);
- uint8_t VEM_val = vcpuData[cpu].VEM;
- SERIALIZE_SCALAR(VEM_val);
- uint8_t VMABP_val = vcpuData[cpu].VMABP;
- SERIALIZE_SCALAR(VMABP_val);
- uint8_t VMBP_val = vcpuData[cpu].VMBP;
- SERIALIZE_SCALAR(VMBP_val);
- uint8_t VMPriMask_val = vcpuData[cpu].VMPriMask;
- SERIALIZE_SCALAR(VMPriMask_val);
-
- for (int i = 0; i < NUM_LR; i++) {
- uint32_t lr = vcpuData[cpu].LR[i];
- nameOut(os, csprintf("%s.vcpuData%d.LR%d", name(), cpu, i));
- SERIALIZE_SCALAR(lr);
- }
+ for (uint32_t cpu = 0; cpu < VGIC_CPU_MAX; cpu++)
+ vcpuData[cpu].serializeSection(cp, csprintf("vcpuData%d", cpu));
+}
+
+void
+VGic::vcpuIntData::serialize(CheckpointOut &cp) const
+{
+ uint32_t vctrl_val = vctrl;
+ SERIALIZE_SCALAR(vctrl_val);
+ uint32_t hcr_val = hcr;
+ SERIALIZE_SCALAR(hcr_val);
+ uint64_t eisr_val = eisr;
+ SERIALIZE_SCALAR(eisr_val);
+ uint8_t VMGrp0En_val = VMGrp0En;
+ SERIALIZE_SCALAR(VMGrp0En_val);
+ uint8_t VMGrp1En_val = VMGrp1En;
+ SERIALIZE_SCALAR(VMGrp1En_val);
+ uint8_t VMAckCtl_val = VMAckCtl;
+ SERIALIZE_SCALAR(VMAckCtl_val);
+ uint8_t VMFiqEn_val = VMFiqEn;
+ SERIALIZE_SCALAR(VMFiqEn_val);
+ uint8_t VMCBPR_val = VMCBPR;
+ SERIALIZE_SCALAR(VMCBPR_val);
+ uint8_t VEM_val = VEM;
+ SERIALIZE_SCALAR(VEM_val);
+ uint8_t VMABP_val = VMABP;
+ SERIALIZE_SCALAR(VMABP_val);
+ uint8_t VMBP_val = VMBP;
+ SERIALIZE_SCALAR(VMBP_val);
+ uint8_t VMPriMask_val = VMPriMask;
+ SERIALIZE_SCALAR(VMPriMask_val);
+
+ for (int i = 0; i < NUM_LR; i++) {
+ ScopedCheckpointSection sec_lr(cp, csprintf("LR%d", i));
+ paramOut(cp, "lr", LR[i]);
}
}
-void VGic::unserialize(Checkpoint *cp, const std::string &section)
+void VGic::unserialize(CheckpointIn &cp)
{
DPRINTF(Checkpoint, "Unserializing Arm GIC\n");
@@ -502,37 +502,7 @@ void VGic::unserialize(Checkpoint *cp, const std::string &section)
if (interrupt_time[cpu])
schedule(postVIntEvent[cpu], interrupt_time[cpu]);
- uint32_t tmp;
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "vctrl_val", tmp);
- vcpuData[cpu].vctrl = tmp;
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "hcr_val", tmp);
- vcpuData[cpu].hcr = tmp;
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "eisr_val", vcpuData[cpu].eisr);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMGrp0En_val", vcpuData[cpu].VMGrp0En);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMGrp1En_val", vcpuData[cpu].VMGrp1En);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMAckCtl_val", vcpuData[cpu].VMAckCtl);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMFiqEn_val", vcpuData[cpu].VMFiqEn);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMCBPR_val", vcpuData[cpu].VMCBPR);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VEM_val", vcpuData[cpu].VEM);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMABP_val", vcpuData[cpu].VMABP);
- paramIn(cp, csprintf("%s.vcpuData%d", section, cpu),
- "VMPriMask_val", vcpuData[cpu].VMPriMask);
-
- for (int i = 0; i < NUM_LR; i++) {
- paramIn(cp, csprintf("%s.vcpuData%d.LR%d", section, cpu, i),
- "lr", tmp);
- vcpuData[cpu].LR[i] = tmp;
- }
+ vcpuData[cpu].unserializeSection(cp, csprintf("vcpuData%d", cpu));
}
UNSERIALIZE_ARRAY(maintIntPosted, VGIC_CPU_MAX);
UNSERIALIZE_ARRAY(vIntPosted, VGIC_CPU_MAX);
@@ -542,6 +512,27 @@ void VGic::unserialize(Checkpoint *cp, const std::string &section)
UNSERIALIZE_SCALAR(maintInt);
}
+void
+VGic::vcpuIntData::unserialize(CheckpointIn &cp)
+{
+ paramIn(cp, "vctrl_val", vctrl);
+ paramIn(cp, "hcr_val", hcr);
+ paramIn(cp, "eisr_val", eisr);
+ paramIn(cp, "VMGrp0En_val", VMGrp0En);
+ paramIn(cp, "VMGrp1En_val", VMGrp1En);
+ paramIn(cp, "VMAckCtl_val", VMAckCtl);
+ paramIn(cp, "VMFiqEn_val", VMFiqEn);
+ paramIn(cp, "VMCBPR_val", VMCBPR);
+ paramIn(cp, "VEM_val", VEM);
+ paramIn(cp, "VMABP_val", VMABP);
+ paramIn(cp, "VMPriMask_val", VMPriMask);
+
+ for (int i = 0; i < NUM_LR; i++) {
+ ScopedCheckpointSection sec_lr(cp, csprintf("LR%d", i));
+ paramIn(cp, "lr", LR[i]);
+ }
+}
+
VGic *
VGicParams::create()
{