system.hh revision 803
111878Sandreas.sandberg@arm.com/*
211878Sandreas.sandberg@arm.com * Copyright (c) 2003 The Regents of The University of Michigan
311878Sandreas.sandberg@arm.com * All rights reserved.
411878Sandreas.sandberg@arm.com *
511878Sandreas.sandberg@arm.com * Redistribution and use in source and binary forms, with or without
611878Sandreas.sandberg@arm.com * modification, are permitted provided that the following conditions are
711878Sandreas.sandberg@arm.com * met: redistributions of source code must retain the above copyright
811878Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer;
911878Sandreas.sandberg@arm.com * redistributions in binary form must reproduce the above copyright
1011878Sandreas.sandberg@arm.com * notice, this list of conditions and the following disclaimer in the
1111878Sandreas.sandberg@arm.com * documentation and/or other materials provided with the distribution;
1211878Sandreas.sandberg@arm.com * neither the name of the copyright holders nor the names of its
134126SN/A * contributors may be used to endorse or promote products derived from
148295Snate@binkert.org * this software without specific prior written permission.
154126SN/A *
164126SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
174126SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
184126SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
194126SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
204126SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
214126SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
224126SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
234126SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
244126SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
254126SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
264126SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
274126SN/A */
284126SN/A
294126SN/A#ifndef __SYSTEM_HH__
304126SN/A#define __SYSTEM_HH__
314126SN/A
324126SN/A#include <string>
334126SN/A#include <vector>
344126SN/A
354126SN/A#include "sim/sim_object.hh"
364126SN/A#include "cpu/pc_event.hh"
374126SN/A#include "base/loader/symtab.hh"
384126SN/A
394126SN/A#ifdef FS_MEASURE
404126SN/A#include "base/statistics.hh"
4111878Sandreas.sandberg@arm.com#include "sim/sw_context.hh"
424126SN/A#endif
438296Snate@binkert.org
448296Snate@binkert.orgclass MemoryController;
4511802Sandreas.sandberg@arm.comclass PhysicalMemory;
468295Snate@binkert.orgclass Platform;
478296Snate@binkert.orgclass RemoteGDB;
484126SN/Aclass GDBListener;
4911766Sandreas.sandberg@arm.com
5011802Sandreas.sandberg@arm.comclass ExecContext;
5111802Sandreas.sandberg@arm.com
5211766Sandreas.sandberg@arm.comclass System : public SimObject
538296Snate@binkert.org{
5411878Sandreas.sandberg@arm.com#ifdef FS_MEASURE
5511878Sandreas.sandberg@arm.com  protected:
5611878Sandreas.sandberg@arm.com    std::map<const std::string, Statistics::MainBin *> fnBins;
5711878Sandreas.sandberg@arm.com    std::map<const Addr, SWContext *> swCtxMap;
5811878Sandreas.sandberg@arm.com#endif //FS_MEASURE
5911878Sandreas.sandberg@arm.com
6011878Sandreas.sandberg@arm.com  public:
6111878Sandreas.sandberg@arm.com    const uint64_t init_param;
6211878Sandreas.sandberg@arm.com    MemoryController *memCtrl;
6311878Sandreas.sandberg@arm.com    PhysicalMemory *physmem;
6411878Sandreas.sandberg@arm.com    Platform *platform;
6511878Sandreas.sandberg@arm.com    bool bin;
6611878Sandreas.sandberg@arm.com
6711878Sandreas.sandberg@arm.com    PCEventQueue pcEventQueue;
6811878Sandreas.sandberg@arm.com
6911878Sandreas.sandberg@arm.com    std::vector<ExecContext *> execContexts;
7011878Sandreas.sandberg@arm.com
7111878Sandreas.sandberg@arm.com    virtual int registerExecContext(ExecContext *xc);
7211878Sandreas.sandberg@arm.com    virtual void replaceExecContext(int xcIndex, ExecContext *xc);
7311878Sandreas.sandberg@arm.com
7411878Sandreas.sandberg@arm.com#ifdef FS_MEASURE
7511878Sandreas.sandberg@arm.com    Statistics::Scalar<Counter, Statistics::MainBin> fnCalls;
7611878Sandreas.sandberg@arm.com    Statistics::MainBin *nonPath;
7711878Sandreas.sandberg@arm.com#endif //FS_MEASURE
7811878Sandreas.sandberg@arm.com
7911878Sandreas.sandberg@arm.com  public:
8011878Sandreas.sandberg@arm.com    System(const std::string _name, const uint64_t _init_param,
8111878Sandreas.sandberg@arm.com           MemoryController *, PhysicalMemory *, const bool);
8211878Sandreas.sandberg@arm.com    ~System();
8311878Sandreas.sandberg@arm.com
8411878Sandreas.sandberg@arm.com    virtual Addr getKernelStart() const = 0;
8511878Sandreas.sandberg@arm.com    virtual Addr getKernelEnd() const = 0;
8611878Sandreas.sandberg@arm.com    virtual Addr getKernelEntry() const = 0;
8711878Sandreas.sandberg@arm.com    virtual bool breakpoint() = 0;
8811878Sandreas.sandberg@arm.com
8911878Sandreas.sandberg@arm.com#ifdef FS_MEASURE
9011878Sandreas.sandberg@arm.com    Statistics::MainBin * getBin(const std::string &name);
9111878Sandreas.sandberg@arm.com    virtual bool findCaller(std::string, std::string) const = 0;
9211878Sandreas.sandberg@arm.com
9311878Sandreas.sandberg@arm.com    SWContext *findContext(Addr pcb);
9411878Sandreas.sandberg@arm.com    bool addContext(Addr pcb, SWContext *ctx) {
9511878Sandreas.sandberg@arm.com        return (swCtxMap.insert(make_pair(pcb, ctx))).second;
9611878Sandreas.sandberg@arm.com    }
9711878Sandreas.sandberg@arm.com    void remContext(Addr pcb) {
9811878Sandreas.sandberg@arm.com        swCtxMap.erase(pcb);
9911878Sandreas.sandberg@arm.com        return;
10011878Sandreas.sandberg@arm.com    }
10111878Sandreas.sandberg@arm.com
10211878Sandreas.sandberg@arm.com    virtual void dumpState(ExecContext *xc) const = 0;
10311878Sandreas.sandberg@arm.com#endif //FS_MEASURE
10411878Sandreas.sandberg@arm.com
10511878Sandreas.sandberg@arm.com  public:
10611878Sandreas.sandberg@arm.com    ////////////////////////////////////////////
10711878Sandreas.sandberg@arm.com    //
10811878Sandreas.sandberg@arm.com    // STATIC GLOBAL SYSTEM LIST
10911878Sandreas.sandberg@arm.com    //
11011878Sandreas.sandberg@arm.com    ////////////////////////////////////////////
11111878Sandreas.sandberg@arm.com
11211878Sandreas.sandberg@arm.com    static std::vector<System *> systemList;
11311878Sandreas.sandberg@arm.com    static int numSystemsRunning;
11411878Sandreas.sandberg@arm.com
11511878Sandreas.sandberg@arm.com    static void printSystems();
11611878Sandreas.sandberg@arm.com};
11711878Sandreas.sandberg@arm.com
11811878Sandreas.sandberg@arm.com#endif // __SYSTEM_HH__
11911878Sandreas.sandberg@arm.com