system.hh revision 3536
12SN/A/* 21762SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan 32SN/A * All rights reserved. 42SN/A * 52SN/A * Redistribution and use in source and binary forms, with or without 62SN/A * modification, are permitted provided that the following conditions are 72SN/A * met: redistributions of source code must retain the above copyright 82SN/A * notice, this list of conditions and the following disclaimer; 92SN/A * redistributions in binary form must reproduce the above copyright 102SN/A * notice, this list of conditions and the following disclaimer in the 112SN/A * documentation and/or other materials provided with the distribution; 122SN/A * neither the name of the copyright holders nor the names of its 132SN/A * contributors may be used to endorse or promote products derived from 142SN/A * this software without specific prior written permission. 152SN/A * 162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 272665Ssaidi@eecs.umich.edu * 282665Ssaidi@eecs.umich.edu * Authors: Steve Reinhardt 292665Ssaidi@eecs.umich.edu * Lisa Hsu 302665Ssaidi@eecs.umich.edu * Nathan Binkert 312SN/A */ 322SN/A 332SN/A#ifndef __SYSTEM_HH__ 342SN/A#define __SYSTEM_HH__ 352SN/A 362SN/A#include <string> 3775SN/A#include <vector> 382SN/A 392439SN/A#include "base/loader/symtab.hh" 402439SN/A#include "base/misc.hh" 41603SN/A#include "base/statistics.hh" 422986Sgblack@eecs.umich.edu#include "config/full_system.hh" 43603SN/A#include "cpu/pc_event.hh" 442520SN/A#include "mem/port.hh" 452378SN/A#include "sim/sim_object.hh" 462378SN/A#if FULL_SYSTEM 47722SN/A#include "kern/system_events.hh" 482521SN/A#include "mem/vport.hh" 492378SN/A#endif 50312SN/A 511634SN/Aclass BaseCPU; 522680Sktlim@umich.educlass ThreadContext; 531634SN/Aclass ObjectFile; 542521SN/Aclass PhysicalMemory; 552378SN/A 562378SN/A#if FULL_SYSTEM 57803SN/Aclass Platform; 582378SN/Aclass GDBListener; 593536Sgblack@eecs.umich.edunamespace TheISA 603536Sgblack@eecs.umich.edu{ 613536Sgblack@eecs.umich.edu class RemoteGDB; 623536Sgblack@eecs.umich.edu} 632378SN/A#endif 642SN/A 652SN/Aclass System : public SimObject 662SN/A{ 67603SN/A public: 682901Ssaidi@eecs.umich.edu 692902Ssaidi@eecs.umich.edu static const char *MemoryModeStrings[3]; 702902Ssaidi@eecs.umich.edu 713202Shsul@eecs.umich.edu SimObject::MemoryMode getMemoryMode() { assert(memoryMode); return memoryMode; } 722901Ssaidi@eecs.umich.edu 732901Ssaidi@eecs.umich.edu /** Change the memory mode of the system. This should only be called by the 742901Ssaidi@eecs.umich.edu * python!! 752901Ssaidi@eecs.umich.edu * @param mode Mode to change to (atomic/timing) 762901Ssaidi@eecs.umich.edu */ 773202Shsul@eecs.umich.edu void setMemoryMode(SimObject::MemoryMode mode); 782901Ssaidi@eecs.umich.edu 792521SN/A PhysicalMemory *physmem; 802SN/A PCEventQueue pcEventQueue; 812SN/A 822680Sktlim@umich.edu std::vector<ThreadContext *> threadContexts; 831806SN/A int numcpus; 841806SN/A 851806SN/A int getNumCPUs() 861806SN/A { 872680Sktlim@umich.edu if (numcpus != threadContexts.size()) 881806SN/A panic("cpu array not fully populated!"); 891806SN/A 901806SN/A return numcpus; 911806SN/A } 92180SN/A 932378SN/A#if FULL_SYSTEM 942378SN/A Platform *platform; 952378SN/A uint64_t init_param; 962378SN/A 972520SN/A /** Port to physical memory used for writing object files into ram at 982520SN/A * boot.*/ 992520SN/A FunctionalPort functionalPort; 1002521SN/A VirtualPort virtPort; 1012520SN/A 1021885SN/A /** kernel symbol table */ 1031070SN/A SymbolTable *kernelSymtab; 104954SN/A 1051070SN/A /** Object pointer for the kernel code */ 1061070SN/A ObjectFile *kernel; 1071070SN/A 1081070SN/A /** Begining of kernel code */ 1091070SN/A Addr kernelStart; 1101070SN/A 1111070SN/A /** End of kernel code */ 1121070SN/A Addr kernelEnd; 1131070SN/A 1141070SN/A /** Entry point in the kernel to start at */ 1151070SN/A Addr kernelEntry; 1161070SN/A 1172378SN/A#else 1182378SN/A 1192378SN/A int page_ptr; 1202378SN/A 1212378SN/A 1222378SN/A#endif // FULL_SYSTEM 1232378SN/A 1241885SN/A protected: 1251885SN/A 1263202Shsul@eecs.umich.edu SimObject::MemoryMode memoryMode; 1272901Ssaidi@eecs.umich.edu 1282424SN/A#if FULL_SYSTEM 1291885SN/A /** 1301885SN/A * Fix up an address used to match PCs for hooking simulator 1311885SN/A * events on to target function executions. See comment in 1321885SN/A * system.cc for details. 1331885SN/A */ 1342158SN/A virtual Addr fixFuncEventAddr(Addr addr) = 0; 1351885SN/A 1361885SN/A /** 1371885SN/A * Add a function-based event to the given function, to be looked 1381885SN/A * up in the specified symbol table. 1391885SN/A */ 1401885SN/A template <class T> 1412989Ssaidi@eecs.umich.edu T *addFuncEvent(SymbolTable *symtab, const char *lbl) 1421885SN/A { 1431913SN/A Addr addr = 0; // initialize only to avoid compiler warning 1441885SN/A 1451885SN/A if (symtab->findAddress(lbl, addr)) { 1461885SN/A T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr)); 1471885SN/A return ev; 1481885SN/A } 1491885SN/A 1501885SN/A return NULL; 1511885SN/A } 1521885SN/A 1531885SN/A /** Add a function-based event to kernel code. */ 1541885SN/A template <class T> 1552989Ssaidi@eecs.umich.edu T *addKernelFuncEvent(const char *lbl) 1561885SN/A { 1571885SN/A return addFuncEvent<T>(kernelSymtab, lbl); 1581885SN/A } 1591885SN/A 1602378SN/A#endif 16177SN/A public: 1622378SN/A#if FULL_SYSTEM 1633536Sgblack@eecs.umich.edu std::vector<TheISA::RemoteGDB *> remoteGDB; 1641070SN/A std::vector<GDBListener *> gdbListen; 1652158SN/A virtual bool breakpoint() = 0; 1662378SN/A#endif // FULL_SYSTEM 1671070SN/A 1681070SN/A public: 1691070SN/A struct Params 1701070SN/A { 1711070SN/A std::string name; 1722521SN/A PhysicalMemory *physmem; 1733202Shsul@eecs.umich.edu SimObject::MemoryMode mem_mode; 1742378SN/A 1752378SN/A#if FULL_SYSTEM 1761634SN/A Tick boot_cpu_frequency; 1772567SN/A std::string boot_osflags; 1781070SN/A uint64_t init_param; 1791070SN/A 1801070SN/A std::string kernel_path; 1812158SN/A std::string readfile; 1822358SN/A std::string symbolfile; 1832378SN/A#endif 1842158SN/A }; 1851070SN/A 1862158SN/A protected: 1872158SN/A Params *_params; 1881070SN/A 1892158SN/A public: 1901070SN/A System(Params *p); 1912SN/A ~System(); 1922SN/A 1931129SN/A void startup(); 1941129SN/A 1952158SN/A const Params *params() const { return (const Params *)_params; } 1962158SN/A 1971070SN/A public: 1982378SN/A 1992378SN/A#if FULL_SYSTEM 2001070SN/A /** 2011070SN/A * Returns the addess the kernel starts at. 2021070SN/A * @return address the kernel starts at 2031070SN/A */ 2041070SN/A Addr getKernelStart() const { return kernelStart; } 2051070SN/A 2061070SN/A /** 2071070SN/A * Returns the addess the kernel ends at. 2081070SN/A * @return address the kernel ends at 2091070SN/A */ 2101070SN/A Addr getKernelEnd() const { return kernelEnd; } 2111070SN/A 2121070SN/A /** 2131070SN/A * Returns the addess the entry point to the kernel code. 2141070SN/A * @return entry point of the kernel code 2151070SN/A */ 2161070SN/A Addr getKernelEntry() const { return kernelEntry; } 2171070SN/A 2182378SN/A#else 2192378SN/A 2202378SN/A Addr new_page(); 2212378SN/A 2222378SN/A#endif // FULL_SYSTEM 2232378SN/A 2242680Sktlim@umich.edu int registerThreadContext(ThreadContext *tc, int tcIndex); 2252680Sktlim@umich.edu void replaceThreadContext(ThreadContext *tc, int tcIndex); 2261070SN/A 2271070SN/A void serialize(std::ostream &os); 2281070SN/A void unserialize(Checkpoint *cp, const std::string §ion); 2292SN/A 23077SN/A public: 2312SN/A //////////////////////////////////////////// 2322SN/A // 2332SN/A // STATIC GLOBAL SYSTEM LIST 2342SN/A // 2352SN/A //////////////////////////////////////////// 2362SN/A 2372SN/A static std::vector<System *> systemList; 2382SN/A static int numSystemsRunning; 2392SN/A 2402SN/A static void printSystems(); 2412158SN/A 2422158SN/A 2432SN/A}; 2442SN/A 2452SN/A#endif // __SYSTEM_HH__ 246