system.hh revision 1634
16145Snate@binkert.org/*
26145Snate@binkert.org * Copyright (c) 2002-2004 The Regents of The University of Michigan
36145Snate@binkert.org * All rights reserved.
46145Snate@binkert.org *
56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without
66145Snate@binkert.org * modification, are permitted provided that the following conditions are
76145Snate@binkert.org * met: redistributions of source code must retain the above copyright
86145Snate@binkert.org * notice, this list of conditions and the following disclaimer;
96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright
106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the
116145Snate@binkert.org * documentation and/or other materials provided with the distribution;
126145Snate@binkert.org * neither the name of the copyright holders nor the names of its
136145Snate@binkert.org * contributors may be used to endorse or promote products derived from
146145Snate@binkert.org * this software without specific prior written permission.
156145Snate@binkert.org *
166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276145Snate@binkert.org */
286145Snate@binkert.org
296154Snate@binkert.org#ifndef __SYSTEM_HH__
306145Snate@binkert.org#define __SYSTEM_HH__
316145Snate@binkert.org
326145Snate@binkert.org#include <string>
337039Snate@binkert.org#include <vector>
347039Snate@binkert.org
357039Snate@binkert.org#include "base/statistics.hh"
367039Snate@binkert.org#include "cpu/pc_event.hh"
377039Snate@binkert.org#include "kern/system_events.hh"
386145Snate@binkert.org#include "sim/sim_object.hh"
396145Snate@binkert.org
407039Snate@binkert.orgclass BaseCPU;
417039Snate@binkert.orgclass ExecContext;
426145Snate@binkert.orgclass GDBListener;
437039Snate@binkert.orgclass MemoryController;
447039Snate@binkert.orgclass ObjectFile;
457039Snate@binkert.orgclass PhysicalMemory;
467039Snate@binkert.orgclass Platform;
477039Snate@binkert.orgclass RemoteGDB;
487039Snate@binkert.orgclass SymbolTable;
496145Snate@binkert.orgnamespace Kernel { class Binning; }
506145Snate@binkert.org
517039Snate@binkert.orgclass System : public SimObject
527039Snate@binkert.org{
536145Snate@binkert.org  public:
547039Snate@binkert.org    MemoryController *memctrl;
557039Snate@binkert.org    PhysicalMemory *physmem;
567039Snate@binkert.org    Platform *platform;
577039Snate@binkert.org    PCEventQueue pcEventQueue;
587039Snate@binkert.org    uint64_t init_param;
597039Snate@binkert.org
607039Snate@binkert.org    std::vector<ExecContext *> execContexts;
616145Snate@binkert.org
626145Snate@binkert.org    /** kernel Symbol table */
637039Snate@binkert.org    SymbolTable *kernelSymtab;
647055Snate@binkert.org
656145Snate@binkert.org    /** console symbol table */
667039Snate@binkert.org    SymbolTable *consoleSymtab;
676145Snate@binkert.org
686145Snate@binkert.org    /** pal symbol table */
696145Snate@binkert.org    SymbolTable *palSymtab;
706145Snate@binkert.org
71    /** Object pointer for the kernel code */
72    ObjectFile *kernel;
73
74    /** Object pointer for the console code */
75    ObjectFile *console;
76
77    /** Object pointer for the PAL code */
78    ObjectFile *pal;
79
80    /** Begining of kernel code */
81    Addr kernelStart;
82
83    /** End of kernel code */
84    Addr kernelEnd;
85
86    /** Entry point in the kernel to start at */
87    Addr kernelEntry;
88
89    Kernel::Binning *kernelBinning;
90
91#ifdef DEBUG
92    /** Event to halt the simulator if the console calls panic() */
93    BreakPCEvent *consolePanicEvent;
94#endif
95
96  public:
97    std::vector<RemoteGDB *> remoteGDB;
98    std::vector<GDBListener *> gdbListen;
99    bool breakpoint();
100
101  public:
102    struct Params
103    {
104        std::string name;
105        Tick boot_cpu_frequency;
106        MemoryController *memctrl;
107        PhysicalMemory *physmem;
108        uint64_t init_param;
109        bool bin;
110        std::vector<std::string> binned_fns;
111        bool bin_int;
112
113        std::string kernel_path;
114        std::string console_path;
115        std::string palcode;
116        std::string boot_osflags;
117
118        std::string readfile;
119        uint64_t system_type;
120        uint64_t system_rev;
121    };
122    Params *params;
123
124    System(Params *p);
125    ~System();
126
127    void startup();
128
129  public:
130    /**
131     * Returns the addess the kernel starts at.
132     * @return address the kernel starts at
133     */
134    Addr getKernelStart() const { return kernelStart; }
135
136    /**
137     * Returns the addess the kernel ends at.
138     * @return address the kernel ends at
139     */
140    Addr getKernelEnd() const { return kernelEnd; }
141
142    /**
143     * Returns the addess the entry point to the kernel code.
144     * @return entry point of the kernel code
145     */
146    Addr getKernelEntry() const { return kernelEntry; }
147
148    int registerExecContext(ExecContext *xc);
149    void replaceExecContext(ExecContext *xc, int xcIndex);
150
151    void regStats();
152    void serialize(std::ostream &os);
153    void unserialize(Checkpoint *cp, const std::string &section);
154
155  public:
156    ////////////////////////////////////////////
157    //
158    // STATIC GLOBAL SYSTEM LIST
159    //
160    ////////////////////////////////////////////
161
162    static std::vector<System *> systemList;
163    static int numSystemsRunning;
164
165    static void printSystems();
166};
167
168#endif // __SYSTEM_HH__
169