sim_object.cc revision 11793
13170Sstever@eecs.umich.edu/* 29383SAli.Saidi@ARM.com * Copyright (c) 2001-2005 The Regents of The University of Michigan 39383SAli.Saidi@ARM.com * Copyright (c) 2010 Advanced Micro Devices, Inc. 49383SAli.Saidi@ARM.com * All rights reserved. 59383SAli.Saidi@ARM.com * 69383SAli.Saidi@ARM.com * Redistribution and use in source and binary forms, with or without 79383SAli.Saidi@ARM.com * modification, are permitted provided that the following conditions are 89383SAli.Saidi@ARM.com * met: redistributions of source code must retain the above copyright 99383SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer; 109383SAli.Saidi@ARM.com * redistributions in binary form must reproduce the above copyright 119383SAli.Saidi@ARM.com * notice, this list of conditions and the following disclaimer in the 129383SAli.Saidi@ARM.com * documentation and/or other materials provided with the distribution; 139383SAli.Saidi@ARM.com * neither the name of the copyright holders nor the names of its 145254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from 155254Sksewell@umich.edu * this software without specific prior written permission. 163170Sstever@eecs.umich.edu * 175254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 185254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 195254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 205254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 215254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 225254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 235254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 245254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 255254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 265254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 273170Sstever@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 285254Sksewell@umich.edu * 295254Sksewell@umich.edu * Authors: Steve Reinhardt 305254Sksewell@umich.edu * Nathan Binkert 315254Sksewell@umich.edu */ 325254Sksewell@umich.edu 335254Sksewell@umich.edu#include "sim/sim_object.hh" 345254Sksewell@umich.edu 355254Sksewell@umich.edu#include <cassert> 365254Sksewell@umich.edu 375254Sksewell@umich.edu#include "base/callback.hh" 385254Sksewell@umich.edu#include "base/inifile.hh" 393170Sstever@eecs.umich.edu#include "base/match.hh" 405254Sksewell@umich.edu#include "base/misc.hh" 413170Sstever@eecs.umich.edu#include "base/trace.hh" 423170Sstever@eecs.umich.edu#include "base/types.hh" 433170Sstever@eecs.umich.edu#include "debug/Checkpoint.hh" 443170Sstever@eecs.umich.edu#include "sim/probe/probe.hh" 453170Sstever@eecs.umich.edu#include "sim/stats.hh" 463170Sstever@eecs.umich.edu 473170Sstever@eecs.umich.eduusing namespace std; 483170Sstever@eecs.umich.edu 493170Sstever@eecs.umich.edu 503170Sstever@eecs.umich.edu//////////////////////////////////////////////////////////////////////// 513170Sstever@eecs.umich.edu// 526329Sgblack@eecs.umich.edu// SimObject member definitions 5312334Sgabeblack@google.com// 544661Sksewell@umich.edu//////////////////////////////////////////////////////////////////////// 558232Snate@binkert.org 569383SAli.Saidi@ARM.com// 573170Sstever@eecs.umich.edu// static list of all SimObjects, used for initialization etc. 583170Sstever@eecs.umich.edu// 593170Sstever@eecs.umich.eduSimObject::SimObjectList SimObject::simObjectList; 603170Sstever@eecs.umich.edu 619383SAli.Saidi@ARM.com// 629383SAli.Saidi@ARM.com// SimObject constructor: used to maintain static simObjectList 639383SAli.Saidi@ARM.com// 649383SAli.Saidi@ARM.comSimObject::SimObject(const Params *p) 659383SAli.Saidi@ARM.com : EventManager(getEventQueue(p->eventq_index)), _params(p) 669383SAli.Saidi@ARM.com{ 679383SAli.Saidi@ARM.com#ifdef DEBUG 689383SAli.Saidi@ARM.com doDebugBreak = false; 6910574Sandreas.hansson@arm.com#endif 709383SAli.Saidi@ARM.com simObjectList.push_back(this); 719383SAli.Saidi@ARM.com probeManager = new ProbeManager(this); 729383SAli.Saidi@ARM.com} 739383SAli.Saidi@ARM.com 749383SAli.Saidi@ARM.comSimObject::~SimObject() 756378Sgblack@eecs.umich.edu{ 763170Sstever@eecs.umich.edu delete probeManager; 773170Sstever@eecs.umich.edu} 7812749Sgiacomo.travaglini@arm.com 793170Sstever@eecs.umich.eduvoid 807783SGiacomo.Gabrielli@arm.comSimObject::init() 817783SGiacomo.Gabrielli@arm.com{ 8211435Smitch.hayenga@arm.com} 836378Sgblack@eecs.umich.edu 8411435Smitch.hayenga@arm.comvoid 853170Sstever@eecs.umich.eduSimObject::loadState(CheckpointIn &cp) 863170Sstever@eecs.umich.edu{ 873170Sstever@eecs.umich.edu if (cp.sectionExists(name())) { 8810030SAli.Saidi@ARM.com DPRINTF(Checkpoint, "unserializing\n"); 8910030SAli.Saidi@ARM.com // This works despite name() returning a fully qualified name 9010030SAli.Saidi@ARM.com // since we are at the top level. 9110030SAli.Saidi@ARM.com unserializeSection(cp, name()); 9210030SAli.Saidi@ARM.com } else { 9310030SAli.Saidi@ARM.com DPRINTF(Checkpoint, "no checkpoint section found\n"); 943170Sstever@eecs.umich.edu } 9512749Sgiacomo.travaglini@arm.com} 963170Sstever@eecs.umich.edu 974661Sksewell@umich.eduvoid 984661Sksewell@umich.eduSimObject::initState() 994661Sksewell@umich.edu{ 1004661Sksewell@umich.edu} 1014661Sksewell@umich.edu 1024661Sksewell@umich.eduvoid 1037783SGiacomo.Gabrielli@arm.comSimObject::startup() 1047783SGiacomo.Gabrielli@arm.com{ 1054661Sksewell@umich.edu} 1064661Sksewell@umich.edu 1074661Sksewell@umich.edu// 1084661Sksewell@umich.edu// no default statistics, so nothing to do in base implementation 1094661Sksewell@umich.edu// 1107783SGiacomo.Gabrielli@arm.comvoid 1114661Sksewell@umich.eduSimObject::regStats() 1124661Sksewell@umich.edu{ 1134661Sksewell@umich.edu} 1144661Sksewell@umich.edu 1154661Sksewell@umich.eduvoid 1164661Sksewell@umich.eduSimObject::resetStats() 1174661Sksewell@umich.edu{ 1184661Sksewell@umich.edu} 1196425Sksewell@umich.edu 1205714Shsul@eecs.umich.edu/** 1214661Sksewell@umich.edu * No probe points by default, so do nothing in base. 1227823Ssteve.reinhardt@amd.com */ 1234661Sksewell@umich.eduvoid 1244661Sksewell@umich.eduSimObject::regProbePoints() 1254661Sksewell@umich.edu{ 12611435Smitch.hayenga@arm.com} 1276378Sgblack@eecs.umich.edu 12811435Smitch.hayenga@arm.com/** 1294661Sksewell@umich.edu * No probe listeners by default, so do nothing in base. 13011435Smitch.hayenga@arm.com */ 1316378Sgblack@eecs.umich.eduvoid 13211435Smitch.hayenga@arm.comSimObject::regProbeListeners() 1334661Sksewell@umich.edu{ 1344661Sksewell@umich.edu} 1354661Sksewell@umich.edu 1364661Sksewell@umich.eduProbeManager * 1374661Sksewell@umich.eduSimObject::getProbeManager() 1384661Sksewell@umich.edu{ 1393170Sstever@eecs.umich.edu return probeManager; 1403170Sstever@eecs.umich.edu} 1413170Sstever@eecs.umich.edu 14212218Snikos.nikoleris@arm.com// 14312218Snikos.nikoleris@arm.com// static function: serialize all SimObjects. 14412218Snikos.nikoleris@arm.com// 14512218Snikos.nikoleris@arm.comvoid 14612218Snikos.nikoleris@arm.comSimObject::serializeAll(CheckpointOut &cp) 14712218Snikos.nikoleris@arm.com{ 14812218Snikos.nikoleris@arm.com SimObjectList::reverse_iterator ri = simObjectList.rbegin(); 1493170Sstever@eecs.umich.edu SimObjectList::reverse_iterator rend = simObjectList.rend(); 1503170Sstever@eecs.umich.edu 1513170Sstever@eecs.umich.edu for (; ri != rend; ++ri) { 152 SimObject *obj = *ri; 153 // This works despite name() returning a fully qualified name 154 // since we are at the top level. 155 obj->serializeSection(cp, obj->name()); 156 } 157} 158 159 160#ifdef DEBUG 161// 162// static function: flag which objects should have the debugger break 163// 164void 165SimObject::debugObjectBreak(const string &objs) 166{ 167 SimObjectList::const_iterator i = simObjectList.begin(); 168 SimObjectList::const_iterator end = simObjectList.end(); 169 170 ObjectMatch match(objs); 171 for (; i != end; ++i) { 172 SimObject *obj = *i; 173 obj->doDebugBreak = match.match(obj->name()); 174 } 175} 176 177void 178debugObjectBreak(const char *objs) 179{ 180 SimObject::debugObjectBreak(string(objs)); 181} 182#endif 183 184SimObject * 185SimObject::find(const char *name) 186{ 187 SimObjectList::const_iterator i = simObjectList.begin(); 188 SimObjectList::const_iterator end = simObjectList.end(); 189 190 for (; i != end; ++i) { 191 SimObject *obj = *i; 192 if (obj->name() == name) 193 return obj; 194 } 195 196 return NULL; 197} 198