system.hh revision 1067
12SN/A/*
21762SN/A * Copyright (c) 2002-2004 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
292665Ssaidi@eecs.umich.edu#ifndef __SYSTEM_HH__
302SN/A#define __SYSTEM_HH__
312SN/A
322SN/A#include <string>
332SN/A#include <vector>
342SN/A
352SN/A#include "base/loader/symtab.hh"
362SN/A#include "base/statistics.hh"
372SN/A#include "cpu/pc_event.hh"
382SN/A#include "kern/system_events.hh"
392SN/A#include "sim/sim_object.hh"
402SN/A#include "sim/sw_context.hh"
412SN/A
422SN/Aclass MemoryController;
432SN/Aclass PhysicalMemory;
4456SN/Aclass Platform;
451127SN/Aclass RemoteGDB;
462SN/Aclass GDBListener;
472797Sktlim@umich.edu
482797Sktlim@umich.educlass ExecContext;
492609SN/A
502SN/Aclass System : public SimObject
512SN/A{
522SN/A    // lisa's binning stuff
532SN/A  private:
542SN/A    std::map<const std::string, Stats::MainBin *> fnBins;
551127SN/A    std::map<const Addr, SWContext *> swCtxMap;
562SN/A
571553SN/A  protected:
581553SN/A    std::vector<FnEvent *> fnEvents;
591553SN/A
601553SN/A  public:
611553SN/A    Stats::Scalar<> fnCalls;
622797Sktlim@umich.edu    Stats::MainBin *Kernel;
632901Ssaidi@eecs.umich.edu    Stats::MainBin *User;
642839Sktlim@umich.edu
652901Ssaidi@eecs.umich.edu    Stats::MainBin * getBin(const std::string &name);
662797Sktlim@umich.edu    bool findCaller(std::string, std::string) const;
672901Ssaidi@eecs.umich.edu
682901Ssaidi@eecs.umich.edu    SWContext *findContext(Addr pcb);
692797Sktlim@umich.edu    bool addContext(Addr pcb, SWContext *ctx) {
70265SN/A        return (swCtxMap.insert(make_pair(pcb, ctx))).second;
711553SN/A    }
722797Sktlim@umich.edu    void remContext(Addr pcb) {
732797Sktlim@umich.edu        swCtxMap.erase(pcb);
741553SN/A        return;
751553SN/A    }
761553SN/A    void dumpState(ExecContext *xc) const;
77265SN/A
782797Sktlim@umich.edu    virtual void serialize(std::ostream &os);
792797Sktlim@umich.edu    virtual void unserialize(Checkpoint *cp, const std::string &section);
802SN/A
812SN/A
822SN/A  private:
832SN/A    std::multimap<const std::string, std::string> callerMap;
842SN/A    void populateMap(std::string caller, std::string callee);
852SN/A//
862SN/A
871553SN/A  public:
882SN/A    const uint64_t init_param;
892SN/A    MemoryController *memCtrl;
902SN/A    PhysicalMemory *physmem;
912SN/A    Platform *platform;
921553SN/A    bool bin;
93265SN/A    std::vector<string> binned_fns;
941127SN/A
951127SN/A    PCEventQueue pcEventQueue;
96465SN/A
972499SN/A    std::vector<ExecContext *> execContexts;
98465SN/A
992499SN/A    std::string readfile;
100465SN/A
1012SN/A    virtual int registerExecContext(ExecContext *xc);
1022SN/A    virtual void replaceExecContext(int xcIndex, ExecContext *xc);
1032SN/A
104330SN/A  public:
1052SN/A    System(const std::string _name, const uint64_t _init_param,
1062SN/A           MemoryController *, PhysicalMemory *, const bool,
1072SN/A           const std::vector<string> &binned_fns);
1082SN/A    ~System();
109330SN/A
110330SN/A    virtual Addr getKernelStart() const = 0;
111330SN/A    virtual Addr getKernelEnd() const = 0;
112395SN/A    virtual Addr getKernelEntry() const = 0;
113395SN/A    virtual bool breakpoint() = 0;
1142797Sktlim@umich.edu
115938SN/A  public:
1162609SN/A    ////////////////////////////////////////////
1172609SN/A    //
1182901Ssaidi@eecs.umich.edu    // STATIC GLOBAL SYSTEM LIST
1192901Ssaidi@eecs.umich.edu    //
1202901Ssaidi@eecs.umich.edu    ////////////////////////////////////////////
1212901Ssaidi@eecs.umich.edu
1222797Sktlim@umich.edu    static std::vector<System *> systemList;
1232797Sktlim@umich.edu    static int numSystemsRunning;
1242797Sktlim@umich.edu
1252797Sktlim@umich.edu    static void printSystems();
1262609SN/A};
1271031SN/A
1281031SN/A#endif // __SYSTEM_HH__
1291031SN/A