system.hh revision 722
1955SN/A/*
2955SN/A * Copyright (c) 2003 The Regents of The University of Michigan
31762SN/A * All rights reserved.
4955SN/A *
5955SN/A * Redistribution and use in source and binary forms, with or without
6955SN/A * modification, are permitted provided that the following conditions are
7955SN/A * met: redistributions of source code must retain the above copyright
8955SN/A * notice, this list of conditions and the following disclaimer;
9955SN/A * redistributions in binary form must reproduce the above copyright
10955SN/A * notice, this list of conditions and the following disclaimer in the
11955SN/A * documentation and/or other materials provided with the distribution;
12955SN/A * neither the name of the copyright holders nor the names of its
13955SN/A * contributors may be used to endorse or promote products derived from
14955SN/A * this software without specific prior written permission.
15955SN/A *
16955SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17955SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18955SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19955SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20955SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21955SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22955SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23955SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24955SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25955SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26955SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27955SN/A */
282665Ssaidi@eecs.umich.edu
294762Snate@binkert.org#ifndef __SYSTEM_HH__
30955SN/A#define __SYSTEM_HH__
315522Snate@binkert.org
326143Snate@binkert.org#include <string>
334762Snate@binkert.org#include <vector>
345522Snate@binkert.org
35955SN/A#include "base/loader/symtab.hh"
365522Snate@binkert.org#include "base/statistics.hh"
3711974Sgabeblack@google.com#include "cpu/pc_event.hh"
38955SN/A#include "kern/system_events.hh"
395522Snate@binkert.org#include "sim/sim_object.hh"
404202Sbinkertn@umich.edu#include "sim/sw_context.hh"
415742Snate@binkert.org
42955SN/Aclass MemoryController;
434381Sbinkertn@umich.educlass PhysicalMemory;
444381Sbinkertn@umich.educlass RemoteGDB;
458334Snate@binkert.orgclass GDBListener;
46955SN/A
47955SN/Aclass ExecContext;
484202Sbinkertn@umich.edu
49955SN/Aclass System : public SimObject
504382Sbinkertn@umich.edu{
514382Sbinkertn@umich.edu    // lisa's binning stuff
524382Sbinkertn@umich.edu  private:
536654Snate@binkert.org    std::map<const std::string, Statistics::MainBin *> fnBins;
545517Snate@binkert.org    std::map<const Addr, SWContext *> swCtxMap;
558614Sgblack@eecs.umich.edu
567674Snate@binkert.org  protected:
576143Snate@binkert.org    std::vector<FnEvent *> fnEvents;
586143Snate@binkert.org
596143Snate@binkert.org  public:
608233Snate@binkert.org    Statistics::Scalar<> fnCalls;
618233Snate@binkert.org    Statistics::MainBin *Kernel;
628233Snate@binkert.org    Statistics::MainBin *User;
638233Snate@binkert.org
648233Snate@binkert.org    Statistics::MainBin * getBin(const std::string &name);
658334Snate@binkert.org    bool findCaller(std::string, std::string) const;
668334Snate@binkert.org
6710453SAndrew.Bardsley@arm.com    SWContext *findContext(Addr pcb);
6810453SAndrew.Bardsley@arm.com    bool addContext(Addr pcb, SWContext *ctx) {
698233Snate@binkert.org        return (swCtxMap.insert(make_pair(pcb, ctx))).second;
708233Snate@binkert.org    }
718233Snate@binkert.org    void remContext(Addr pcb) {
728233Snate@binkert.org        swCtxMap.erase(pcb);
738233Snate@binkert.org        return;
748233Snate@binkert.org    }
7511983Sgabeblack@google.com    void dumpState(ExecContext *xc) const;
7611983Sgabeblack@google.com
7711983Sgabeblack@google.com    virtual void serialize(std::ostream &os);
7811983Sgabeblack@google.com    virtual void unserialize(Checkpoint *cp, const std::string &section);
7911983Sgabeblack@google.com
8011983Sgabeblack@google.com
8111983Sgabeblack@google.com  private:
8211983Sgabeblack@google.com    std::multimap<const std::string, std::string> callerMap;
8311983Sgabeblack@google.com    void populateMap(std::string caller, std::string callee);
8411983Sgabeblack@google.com//
8511983Sgabeblack@google.com
866143Snate@binkert.org  public:
878233Snate@binkert.org    const uint64_t init_param;
888233Snate@binkert.org    MemoryController *memCtrl;
898233Snate@binkert.org    PhysicalMemory *physmem;
906143Snate@binkert.org    bool bin;
916143Snate@binkert.org    std::vector<string> binned_fns;
926143Snate@binkert.org
9311308Santhony.gutierrez@amd.com    PCEventQueue pcEventQueue;
948233Snate@binkert.org
958233Snate@binkert.org    std::vector<ExecContext *> execContexts;
968233Snate@binkert.org
9711983Sgabeblack@google.com    virtual int registerExecContext(ExecContext *xc);
9811983Sgabeblack@google.com    virtual void replaceExecContext(int xcIndex, ExecContext *xc);
994762Snate@binkert.org
1006143Snate@binkert.org  public:
1018233Snate@binkert.org    System(const std::string _name, const uint64_t _init_param,
1028233Snate@binkert.org           MemoryController *, PhysicalMemory *, const bool,
1038233Snate@binkert.org           const std::vector<string> &binned_fns);
1048233Snate@binkert.org    ~System();
1058233Snate@binkert.org
1066143Snate@binkert.org    virtual Addr getKernelStart() const = 0;
1078233Snate@binkert.org    virtual Addr getKernelEnd() const = 0;
1088233Snate@binkert.org    virtual Addr getKernelEntry() const = 0;
1098233Snate@binkert.org    virtual bool breakpoint() = 0;
1108233Snate@binkert.org
1116143Snate@binkert.org  public:
1126143Snate@binkert.org    ////////////////////////////////////////////
1136143Snate@binkert.org    //
1146143Snate@binkert.org    // STATIC GLOBAL SYSTEM LIST
1156143Snate@binkert.org    //
1166143Snate@binkert.org    ////////////////////////////////////////////
1176143Snate@binkert.org
1186143Snate@binkert.org    static std::vector<System *> systemList;
1196143Snate@binkert.org    static int numSystemsRunning;
1207065Snate@binkert.org
1216143Snate@binkert.org    static void printSystems();
1228233Snate@binkert.org};
1238233Snate@binkert.org
1248233Snate@binkert.org#endif // __SYSTEM_HH__
1258233Snate@binkert.org