system.hh revision 1070
1/*
2 * Copyright (c) 2002-2004 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29#ifndef __SYSTEM_HH__
30#define __SYSTEM_HH__
31
32#include <string>
33#include <vector>
34
35#include "base/loader/symtab.hh"
36#include "base/statistics.hh"
37#include "cpu/pc_event.hh"
38#include "kern/system_events.hh"
39#include "sim/sim_object.hh"
40
41class MemoryController;
42class PhysicalMemory;
43class Platform;
44class RemoteGDB;
45class GDBListener;
46class ObjectFile;
47class ExecContext;
48namespace Kernel { class Binning; }
49
50class System : public SimObject
51{
52  public:
53    MemoryController *memctrl;
54    PhysicalMemory *physmem;
55    Platform *platform;
56    PCEventQueue pcEventQueue;
57    uint64_t init_param;
58
59    std::vector<ExecContext *> execContexts;
60
61    /** kernel Symbol table */
62    SymbolTable *kernelSymtab;
63
64    /** console symbol table */
65    SymbolTable *consoleSymtab;
66
67    /** Object pointer for the kernel code */
68    ObjectFile *kernel;
69
70    /** Object pointer for the console code */
71    ObjectFile *console;
72
73    /** Object pointer for the PAL code */
74    ObjectFile *pal;
75
76    /** Begining of kernel code */
77    Addr kernelStart;
78
79    /** End of kernel code */
80    Addr kernelEnd;
81
82    /** Entry point in the kernel to start at */
83    Addr kernelEntry;
84
85    Kernel::Binning *kernelBinning;
86
87#ifdef DEBUG
88    /** Event to halt the simulator if the console calls panic() */
89    BreakPCEvent *consolePanicEvent;
90#endif
91
92  public:
93    std::vector<RemoteGDB *> remoteGDB;
94    std::vector<GDBListener *> gdbListen;
95    bool breakpoint();
96
97  public:
98    struct Params
99    {
100        std::string name;
101        MemoryController *memctrl;
102        PhysicalMemory *physmem;
103        uint64_t init_param;
104        bool bin;
105        std::vector<std::string> binned_fns;
106
107        std::string kernel_path;
108        std::string console_path;
109        std::string palcode;
110        std::string boot_osflags;
111
112        std::string readfile;
113        uint64_t system_type;
114        uint64_t system_rev;
115    };
116    Params *params;
117
118    System(Params *p);
119    ~System();
120
121  public:
122    /**
123     * Returns the addess the kernel starts at.
124     * @return address the kernel starts at
125     */
126    Addr getKernelStart() const { return kernelStart; }
127
128    /**
129     * Returns the addess the kernel ends at.
130     * @return address the kernel ends at
131     */
132    Addr getKernelEnd() const { return kernelEnd; }
133
134    /**
135     * Returns the addess the entry point to the kernel code.
136     * @return entry point of the kernel code
137     */
138    Addr getKernelEntry() const { return kernelEntry; }
139
140    int registerExecContext(ExecContext *xc);
141    void replaceExecContext(ExecContext *xc, int xcIndex);
142
143    void regStats();
144    void serialize(std::ostream &os);
145    void unserialize(Checkpoint *cp, const std::string &section);
146
147  public:
148    ////////////////////////////////////////////
149    //
150    // STATIC GLOBAL SYSTEM LIST
151    //
152    ////////////////////////////////////////////
153
154    static std::vector<System *> systemList;
155    static int numSystemsRunning;
156
157    static void printSystems();
158};
159
160#endif // __SYSTEM_HH__
161