system.hh revision 11359
17585SAli.Saidi@arm.com/* 210037SARM gem5 Developers * Copyright (c) 2010-2013 ARM Limited 37585SAli.Saidi@arm.com * All rights reserved 47585SAli.Saidi@arm.com * 57585SAli.Saidi@arm.com * The license below extends only to copyright in the software and shall 67585SAli.Saidi@arm.com * not be construed as granting a license to any other intellectual 77585SAli.Saidi@arm.com * property including but not limited to intellectual property relating 87585SAli.Saidi@arm.com * to a hardware implementation of the functionality of the software 97585SAli.Saidi@arm.com * licensed hereunder. You may use the software subject to the license 107585SAli.Saidi@arm.com * terms below provided that you ensure that this notice is replicated 117585SAli.Saidi@arm.com * unmodified and in its entirety in all distributions of the software, 127585SAli.Saidi@arm.com * modified or unmodified, in source code or in binary form. 137585SAli.Saidi@arm.com * 147585SAli.Saidi@arm.com * Copyright (c) 2002-2005 The Regents of The University of Michigan 157585SAli.Saidi@arm.com * All rights reserved. 167585SAli.Saidi@arm.com * 177585SAli.Saidi@arm.com * Redistribution and use in source and binary forms, with or without 187585SAli.Saidi@arm.com * modification, are permitted provided that the following conditions are 197585SAli.Saidi@arm.com * met: redistributions of source code must retain the above copyright 207585SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer; 217585SAli.Saidi@arm.com * redistributions in binary form must reproduce the above copyright 227585SAli.Saidi@arm.com * notice, this list of conditions and the following disclaimer in the 237585SAli.Saidi@arm.com * documentation and/or other materials provided with the distribution; 247585SAli.Saidi@arm.com * neither the name of the copyright holders nor the names of its 257585SAli.Saidi@arm.com * contributors may be used to endorse or promote products derived from 267585SAli.Saidi@arm.com * this software without specific prior written permission. 277585SAli.Saidi@arm.com * 287585SAli.Saidi@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 297585SAli.Saidi@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 307585SAli.Saidi@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 317585SAli.Saidi@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 327585SAli.Saidi@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 337585SAli.Saidi@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 347585SAli.Saidi@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 357585SAli.Saidi@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 367585SAli.Saidi@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 377585SAli.Saidi@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 387585SAli.Saidi@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 397585SAli.Saidi@arm.com * 407585SAli.Saidi@arm.com * Authors: Ali Saidi 417585SAli.Saidi@arm.com */ 427585SAli.Saidi@arm.com 437585SAli.Saidi@arm.com#ifndef __ARCH_ARM_LINUX_SYSTEM_HH__ 447585SAli.Saidi@arm.com#define __ARCH_ARM_LINUX_SYSTEM_HH__ 457585SAli.Saidi@arm.com 469332Sdam.sunwoo@arm.com#include <cstdio> 479332Sdam.sunwoo@arm.com#include <map> 487585SAli.Saidi@arm.com#include <string> 497585SAli.Saidi@arm.com#include <vector> 507585SAli.Saidi@arm.com 517585SAli.Saidi@arm.com#include "arch/arm/system.hh" 529332Sdam.sunwoo@arm.com#include "base/output.hh" 537585SAli.Saidi@arm.com#include "kern/linux/events.hh" 547585SAli.Saidi@arm.com#include "params/LinuxArmSystem.hh" 559332Sdam.sunwoo@arm.com#include "sim/core.hh" 569332Sdam.sunwoo@arm.com 579332Sdam.sunwoo@arm.comclass DumpStatsPCEvent; 587585SAli.Saidi@arm.com 5910810Sbr@bsdpad.comclass LinuxArmSystem : public GenericArmSystem 607585SAli.Saidi@arm.com{ 619332Sdam.sunwoo@arm.com protected: 629332Sdam.sunwoo@arm.com DumpStatsPCEvent *dumpStatsPCEvent; 639332Sdam.sunwoo@arm.com 647585SAli.Saidi@arm.com public: 657585SAli.Saidi@arm.com /** Boilerplate params code */ 667585SAli.Saidi@arm.com typedef LinuxArmSystemParams Params; 677585SAli.Saidi@arm.com const Params * 687585SAli.Saidi@arm.com params() const 697585SAli.Saidi@arm.com { 707585SAli.Saidi@arm.com return dynamic_cast<const Params *>(_params); 717585SAli.Saidi@arm.com } 727585SAli.Saidi@arm.com 739332Sdam.sunwoo@arm.com /** When enabled, dump stats/task info on context switches for 749332Sdam.sunwoo@arm.com * Streamline and per-thread cache occupancy studies, etc. */ 759332Sdam.sunwoo@arm.com bool enableContextSwitchStatsDump; 769332Sdam.sunwoo@arm.com 779332Sdam.sunwoo@arm.com /** This map stores a mapping of OS process IDs to internal Task IDs. The 789332Sdam.sunwoo@arm.com * mapping is done because the stats system doesn't tend to like vectors 799332Sdam.sunwoo@arm.com * that are much greater than 1000 items and the entire process space is 809332Sdam.sunwoo@arm.com * 65K. */ 819332Sdam.sunwoo@arm.com std::map<uint32_t, uint32_t> taskMap; 829332Sdam.sunwoo@arm.com 839332Sdam.sunwoo@arm.com /** This is a file that is placed in the run directory that prints out 849332Sdam.sunwoo@arm.com * mappings between taskIds and OS process IDs */ 8511359Sandreas@sandberg.pp.se OutputStream* taskFile; 869332Sdam.sunwoo@arm.com 877585SAli.Saidi@arm.com LinuxArmSystem(Params *p); 887585SAli.Saidi@arm.com ~LinuxArmSystem(); 897585SAli.Saidi@arm.com 907733SAli.Saidi@ARM.com void initState(); 917733SAli.Saidi@ARM.com 929332Sdam.sunwoo@arm.com void startup(); 939332Sdam.sunwoo@arm.com 949332Sdam.sunwoo@arm.com /** This function creates a new task Id for the given pid. 959332Sdam.sunwoo@arm.com * @param tc thread context that is currentyl executing */ 969332Sdam.sunwoo@arm.com void mapPid(ThreadContext* tc, uint32_t pid); 979332Sdam.sunwoo@arm.com 987585SAli.Saidi@arm.com private: 997585SAli.Saidi@arm.com /** Event to halt the simulator if the kernel calls panic() */ 1009649SAndreas.Sandberg@ARM.com PCEvent *kernelPanicEvent; 1019649SAndreas.Sandberg@ARM.com 1029649SAndreas.Sandberg@ARM.com /** Event to halt the simulator if the kernel calls oopses */ 1039649SAndreas.Sandberg@ARM.com PCEvent *kernelOopsEvent; 1049649SAndreas.Sandberg@ARM.com 1058143SAli.Saidi@ARM.com /** 1068143SAli.Saidi@ARM.com * PC based event to skip udelay(<time>) calls and quiesce the 1078143SAli.Saidi@ARM.com * processor for the appropriate amount of time. This is not functionally 1088143SAli.Saidi@ARM.com * required but does speed up simulation. 1098143SAli.Saidi@ARM.com */ 1108143SAli.Saidi@ARM.com Linux::UDelayEvent *uDelaySkipEvent; 1118143SAli.Saidi@ARM.com 1128143SAli.Saidi@ARM.com /** Another PC based skip event for const_udelay(). Similar to the udelay 1138143SAli.Saidi@ARM.com * skip, but this function precomputes the first multiply that is done 1148143SAli.Saidi@ARM.com * in the generic case since the parameter is known at compile time. 1158143SAli.Saidi@ARM.com * Thus we need to do some division to get back to us. 1168143SAli.Saidi@ARM.com */ 1178143SAli.Saidi@ARM.com Linux::UDelayEvent *constUDelaySkipEvent; 1188527SAli.Saidi@ARM.com 1197585SAli.Saidi@arm.com}; 1207585SAli.Saidi@arm.com 1219332Sdam.sunwoo@arm.comclass DumpStatsPCEvent : public PCEvent 1229332Sdam.sunwoo@arm.com{ 1239332Sdam.sunwoo@arm.com public: 1249332Sdam.sunwoo@arm.com DumpStatsPCEvent(PCEventQueue *q, const std::string &desc, Addr addr) 1259332Sdam.sunwoo@arm.com : PCEvent(q, desc, addr) 1269332Sdam.sunwoo@arm.com {} 1279332Sdam.sunwoo@arm.com 1289332Sdam.sunwoo@arm.com virtual void process(ThreadContext* tc); 1299332Sdam.sunwoo@arm.com}; 1309332Sdam.sunwoo@arm.com 1319332Sdam.sunwoo@arm.com 1327585SAli.Saidi@arm.com#endif // __ARCH_ARM_LINUX_SYSTEM_HH__ 1337585SAli.Saidi@arm.com 134