system.hh revision 722
113465Sgabeblack@google.com/*
213465Sgabeblack@google.com * Copyright (c) 2003 The Regents of The University of Michigan
313465Sgabeblack@google.com * All rights reserved.
413465Sgabeblack@google.com *
513465Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without
613465Sgabeblack@google.com * modification, are permitted provided that the following conditions are
713465Sgabeblack@google.com * met: redistributions of source code must retain the above copyright
813465Sgabeblack@google.com * notice, this list of conditions and the following disclaimer;
913465Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright
1013465Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the
1113465Sgabeblack@google.com * documentation and/or other materials provided with the distribution;
1213465Sgabeblack@google.com * neither the name of the copyright holders nor the names of its
1313465Sgabeblack@google.com * contributors may be used to endorse or promote products derived from
1413465Sgabeblack@google.com * this software without specific prior written permission.
1513465Sgabeblack@google.com *
1613465Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1713465Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1813465Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1913465Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2013465Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2113465Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2213465Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2313465Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2413465Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2513465Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2613465Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2713465Sgabeblack@google.com */
2813465Sgabeblack@google.com
2913465Sgabeblack@google.com#ifndef __SYSTEM_HH__
3013465Sgabeblack@google.com#define __SYSTEM_HH__
3113465Sgabeblack@google.com
3213465Sgabeblack@google.com#include <string>
3313465Sgabeblack@google.com#include <vector>
3413465Sgabeblack@google.com
3513465Sgabeblack@google.com#include "base/loader/symtab.hh"
3613465Sgabeblack@google.com#include "base/statistics.hh"
3713465Sgabeblack@google.com#include "cpu/pc_event.hh"
3813465Sgabeblack@google.com#include "kern/system_events.hh"
3913465Sgabeblack@google.com#include "sim/sim_object.hh"
4013465Sgabeblack@google.com#include "sim/sw_context.hh"
4113465Sgabeblack@google.com
4213465Sgabeblack@google.comclass MemoryController;
4313465Sgabeblack@google.comclass PhysicalMemory;
4413465Sgabeblack@google.comclass RemoteGDB;
4513465Sgabeblack@google.comclass GDBListener;
4613465Sgabeblack@google.com
4713465Sgabeblack@google.comclass ExecContext;
4813465Sgabeblack@google.com
4913465Sgabeblack@google.comclass System : public SimObject
5013465Sgabeblack@google.com{
5113465Sgabeblack@google.com    // lisa's binning stuff
5213465Sgabeblack@google.com  private:
5313465Sgabeblack@google.com    std::map<const std::string, Statistics::MainBin *> fnBins;
5413465Sgabeblack@google.com    std::map<const Addr, SWContext *> swCtxMap;
5513465Sgabeblack@google.com
5613465Sgabeblack@google.com  protected:
5713465Sgabeblack@google.com    std::vector<FnEvent *> fnEvents;
5813465Sgabeblack@google.com
5913465Sgabeblack@google.com  public:
6013465Sgabeblack@google.com    Statistics::Scalar<> fnCalls;
6113465Sgabeblack@google.com    Statistics::MainBin *Kernel;
6213465Sgabeblack@google.com    Statistics::MainBin *User;
6313465Sgabeblack@google.com
6413465Sgabeblack@google.com    Statistics::MainBin * getBin(const std::string &name);
6513465Sgabeblack@google.com    bool findCaller(std::string, std::string) const;
6613465Sgabeblack@google.com
6713465Sgabeblack@google.com    SWContext *findContext(Addr pcb);
6813465Sgabeblack@google.com    bool addContext(Addr pcb, SWContext *ctx) {
6913465Sgabeblack@google.com        return (swCtxMap.insert(make_pair(pcb, ctx))).second;
7013465Sgabeblack@google.com    }
7113465Sgabeblack@google.com    void remContext(Addr pcb) {
7213465Sgabeblack@google.com        swCtxMap.erase(pcb);
7313465Sgabeblack@google.com        return;
7413465Sgabeblack@google.com    }
7513465Sgabeblack@google.com    void dumpState(ExecContext *xc) const;
7613465Sgabeblack@google.com
7713465Sgabeblack@google.com    virtual void serialize(std::ostream &os);
7813465Sgabeblack@google.com    virtual void unserialize(Checkpoint *cp, const std::string &section);
7913465Sgabeblack@google.com
8013465Sgabeblack@google.com
8113465Sgabeblack@google.com  private:
8213465Sgabeblack@google.com    std::multimap<const std::string, std::string> callerMap;
8313465Sgabeblack@google.com    void populateMap(std::string caller, std::string callee);
8413465Sgabeblack@google.com//
8513465Sgabeblack@google.com
8613465Sgabeblack@google.com  public:
8713465Sgabeblack@google.com    const uint64_t init_param;
8813465Sgabeblack@google.com    MemoryController *memCtrl;
8913465Sgabeblack@google.com    PhysicalMemory *physmem;
9013465Sgabeblack@google.com    bool bin;
9113465Sgabeblack@google.com    std::vector<string> binned_fns;
9213465Sgabeblack@google.com
9313465Sgabeblack@google.com    PCEventQueue pcEventQueue;
9413465Sgabeblack@google.com
9513465Sgabeblack@google.com    std::vector<ExecContext *> execContexts;
9613465Sgabeblack@google.com
9713465Sgabeblack@google.com    virtual int registerExecContext(ExecContext *xc);
9813465Sgabeblack@google.com    virtual void replaceExecContext(int xcIndex, ExecContext *xc);
9913465Sgabeblack@google.com
10013465Sgabeblack@google.com  public:
10113465Sgabeblack@google.com    System(const std::string _name, const uint64_t _init_param,
10213465Sgabeblack@google.com           MemoryController *, PhysicalMemory *, const bool,
10313465Sgabeblack@google.com           const std::vector<string> &binned_fns);
10413465Sgabeblack@google.com    ~System();
10513465Sgabeblack@google.com
10613465Sgabeblack@google.com    virtual Addr getKernelStart() const = 0;
10713465Sgabeblack@google.com    virtual Addr getKernelEnd() const = 0;
10813465Sgabeblack@google.com    virtual Addr getKernelEntry() const = 0;
10913465Sgabeblack@google.com    virtual bool breakpoint() = 0;
11013465Sgabeblack@google.com
11113465Sgabeblack@google.com  public:
11213465Sgabeblack@google.com    ////////////////////////////////////////////
11313465Sgabeblack@google.com    //
11413465Sgabeblack@google.com    // STATIC GLOBAL SYSTEM LIST
11513465Sgabeblack@google.com    //
11613465Sgabeblack@google.com    ////////////////////////////////////////////
11713465Sgabeblack@google.com
11813465Sgabeblack@google.com    static std::vector<System *> systemList;
11913465Sgabeblack@google.com    static int numSystemsRunning;
12013465Sgabeblack@google.com
12113465Sgabeblack@google.com    static void printSystems();
122};
123
124#endif // __SYSTEM_HH__
125