system.hh revision 2665
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" 42603SN/A#include "cpu/pc_event.hh" 432520SN/A#include "mem/port.hh" 442378SN/A#include "sim/sim_object.hh" 452378SN/A#if FULL_SYSTEM 46722SN/A#include "kern/system_events.hh" 472521SN/A#include "mem/vport.hh" 482378SN/A#endif 49312SN/A 501634SN/Aclass BaseCPU; 511634SN/Aclass ExecContext; 521634SN/Aclass ObjectFile; 532521SN/Aclass PhysicalMemory; 542378SN/A 552378SN/A#if FULL_SYSTEM 56803SN/Aclass Platform; 572378SN/Aclass GDBListener; 582SN/Aclass RemoteGDB; 591070SN/Anamespace Kernel { class Binning; } 602378SN/A#endif 612SN/A 622SN/Aclass System : public SimObject 632SN/A{ 64603SN/A public: 652521SN/A PhysicalMemory *physmem; 662SN/A PCEventQueue pcEventQueue; 672SN/A 68180SN/A std::vector<ExecContext *> execContexts; 691806SN/A int numcpus; 701806SN/A 711806SN/A int getNumCPUs() 721806SN/A { 731806SN/A if (numcpus != execContexts.size()) 741806SN/A panic("cpu array not fully populated!"); 751806SN/A 761806SN/A return numcpus; 771806SN/A } 78180SN/A 792378SN/A#if FULL_SYSTEM 802378SN/A Platform *platform; 812378SN/A uint64_t init_param; 822378SN/A 832520SN/A /** Port to physical memory used for writing object files into ram at 842520SN/A * boot.*/ 852520SN/A FunctionalPort functionalPort; 862521SN/A VirtualPort virtPort; 872520SN/A 881885SN/A /** kernel symbol table */ 891070SN/A SymbolTable *kernelSymtab; 90954SN/A 911070SN/A /** Object pointer for the kernel code */ 921070SN/A ObjectFile *kernel; 931070SN/A 941070SN/A /** Begining of kernel code */ 951070SN/A Addr kernelStart; 961070SN/A 971070SN/A /** End of kernel code */ 981070SN/A Addr kernelEnd; 991070SN/A 1001070SN/A /** Entry point in the kernel to start at */ 1011070SN/A Addr kernelEntry; 1021070SN/A 1031070SN/A Kernel::Binning *kernelBinning; 1041070SN/A 1052378SN/A#else 1062378SN/A 1072378SN/A int page_ptr; 1082378SN/A 1092378SN/A 1102378SN/A#endif // FULL_SYSTEM 1112378SN/A 1121885SN/A protected: 1131885SN/A 1142424SN/A#if FULL_SYSTEM 1151885SN/A /** 1161885SN/A * Fix up an address used to match PCs for hooking simulator 1171885SN/A * events on to target function executions. See comment in 1181885SN/A * system.cc for details. 1191885SN/A */ 1202158SN/A virtual Addr fixFuncEventAddr(Addr addr) = 0; 1211885SN/A 1221885SN/A /** 1231885SN/A * Add a function-based event to the given function, to be looked 1241885SN/A * up in the specified symbol table. 1251885SN/A */ 1261885SN/A template <class T> 1271885SN/A T *System::addFuncEvent(SymbolTable *symtab, const char *lbl) 1281885SN/A { 1291913SN/A Addr addr = 0; // initialize only to avoid compiler warning 1301885SN/A 1311885SN/A if (symtab->findAddress(lbl, addr)) { 1321885SN/A T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr)); 1331885SN/A return ev; 1341885SN/A } 1351885SN/A 1361885SN/A return NULL; 1371885SN/A } 1381885SN/A 1391885SN/A /** Add a function-based event to kernel code. */ 1401885SN/A template <class T> 1411885SN/A T *System::addKernelFuncEvent(const char *lbl) 1421885SN/A { 1431885SN/A return addFuncEvent<T>(kernelSymtab, lbl); 1441885SN/A } 1451885SN/A 1462378SN/A#endif 14777SN/A public: 1482378SN/A#if FULL_SYSTEM 1491070SN/A std::vector<RemoteGDB *> remoteGDB; 1501070SN/A std::vector<GDBListener *> gdbListen; 1512158SN/A virtual bool breakpoint() = 0; 1522378SN/A#endif // FULL_SYSTEM 1531070SN/A 1541070SN/A public: 1551070SN/A struct Params 1561070SN/A { 1571070SN/A std::string name; 1582521SN/A PhysicalMemory *physmem; 1592378SN/A 1602378SN/A#if FULL_SYSTEM 1611634SN/A Tick boot_cpu_frequency; 1622567SN/A std::string boot_osflags; 1631070SN/A uint64_t init_param; 1641070SN/A bool bin; 1651070SN/A std::vector<std::string> binned_fns; 1661082SN/A bool bin_int; 1671070SN/A 1681070SN/A std::string kernel_path; 1692158SN/A std::string readfile; 1702378SN/A#endif 1712158SN/A }; 1721070SN/A 1732158SN/A protected: 1742158SN/A Params *_params; 1751070SN/A 1762158SN/A public: 1771070SN/A System(Params *p); 1782SN/A ~System(); 1792SN/A 1801129SN/A void startup(); 1811129SN/A 1822158SN/A const Params *params() const { return (const Params *)_params; } 1832158SN/A 1841070SN/A public: 1852378SN/A 1862378SN/A#if FULL_SYSTEM 1871070SN/A /** 1881070SN/A * Returns the addess the kernel starts at. 1891070SN/A * @return address the kernel starts at 1901070SN/A */ 1911070SN/A Addr getKernelStart() const { return kernelStart; } 1921070SN/A 1931070SN/A /** 1941070SN/A * Returns the addess the kernel ends at. 1951070SN/A * @return address the kernel ends at 1961070SN/A */ 1971070SN/A Addr getKernelEnd() const { return kernelEnd; } 1981070SN/A 1991070SN/A /** 2001070SN/A * Returns the addess the entry point to the kernel code. 2011070SN/A * @return entry point of the kernel code 2021070SN/A */ 2031070SN/A Addr getKernelEntry() const { return kernelEntry; } 2041070SN/A 2052378SN/A#else 2062378SN/A 2072378SN/A Addr new_page(); 2082378SN/A 2092378SN/A#endif // FULL_SYSTEM 2102378SN/A 2111806SN/A int registerExecContext(ExecContext *xc, int xcIndex); 2121070SN/A void replaceExecContext(ExecContext *xc, int xcIndex); 2131070SN/A 2141070SN/A void regStats(); 2151070SN/A void serialize(std::ostream &os); 2161070SN/A void unserialize(Checkpoint *cp, const std::string §ion); 2172SN/A 21877SN/A public: 2192SN/A //////////////////////////////////////////// 2202SN/A // 2212SN/A // STATIC GLOBAL SYSTEM LIST 2222SN/A // 2232SN/A //////////////////////////////////////////// 2242SN/A 2252SN/A static std::vector<System *> systemList; 2262SN/A static int numSystemsRunning; 2272SN/A 2282SN/A static void printSystems(); 2292158SN/A 2302158SN/A 2312SN/A}; 2322SN/A 2332SN/A#endif // __SYSTEM_HH__ 234