system.hh revision 1806
1/*
2 * Copyright (c) 2002-2005 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/statistics.hh"
36#include "cpu/pc_event.hh"
37#include "kern/system_events.hh"
38#include "sim/sim_object.hh"
39
40class BaseCPU;
41class ExecContext;
42class GDBListener;
43class MemoryController;
44class ObjectFile;
45class PhysicalMemory;
46class Platform;
47class RemoteGDB;
48class SymbolTable;
49namespace Kernel { class Binning; }
50
51class System : public SimObject
52{
53  public:
54    MemoryController *memctrl;
55    PhysicalMemory *physmem;
56    Platform *platform;
57    PCEventQueue pcEventQueue;
58    uint64_t init_param;
59
60    std::vector<ExecContext *> execContexts;
61    int numcpus;
62
63    int getNumCPUs()
64    {
65        if (numcpus != execContexts.size())
66            panic("cpu array not fully populated!");
67
68        return numcpus;
69    }
70
71    /** kernel Symbol table */
72    SymbolTable *kernelSymtab;
73
74    /** console symbol table */
75    SymbolTable *consoleSymtab;
76
77    /** pal symbol table */
78    SymbolTable *palSymtab;
79
80    /** Object pointer for the kernel code */
81    ObjectFile *kernel;
82
83    /** Object pointer for the console code */
84    ObjectFile *console;
85
86    /** Object pointer for the PAL code */
87    ObjectFile *pal;
88
89    /** Begining of kernel code */
90    Addr kernelStart;
91
92    /** End of kernel code */
93    Addr kernelEnd;
94
95    /** Entry point in the kernel to start at */
96    Addr kernelEntry;
97
98    Kernel::Binning *kernelBinning;
99
100#ifdef DEBUG
101    /** Event to halt the simulator if the console calls panic() */
102    BreakPCEvent *consolePanicEvent;
103#endif
104
105  public:
106    std::vector<RemoteGDB *> remoteGDB;
107    std::vector<GDBListener *> gdbListen;
108    bool breakpoint();
109
110  public:
111    struct Params
112    {
113        std::string name;
114        Tick boot_cpu_frequency;
115        MemoryController *memctrl;
116        PhysicalMemory *physmem;
117        uint64_t init_param;
118        bool bin;
119        std::vector<std::string> binned_fns;
120        bool bin_int;
121
122        std::string kernel_path;
123        std::string console_path;
124        std::string palcode;
125        std::string boot_osflags;
126
127        std::string readfile;
128        uint64_t system_type;
129        uint64_t system_rev;
130    };
131    Params *params;
132
133    System(Params *p);
134    ~System();
135
136    void startup();
137
138  public:
139    /**
140     * Set the m5AlphaAccess pointer in the console
141     */
142    void setAlphaAccess(Addr access);
143
144    /**
145     * Returns the addess the kernel starts at.
146     * @return address the kernel starts at
147     */
148    Addr getKernelStart() const { return kernelStart; }
149
150    /**
151     * Returns the addess the kernel ends at.
152     * @return address the kernel ends at
153     */
154    Addr getKernelEnd() const { return kernelEnd; }
155
156    /**
157     * Returns the addess the entry point to the kernel code.
158     * @return entry point of the kernel code
159     */
160    Addr getKernelEntry() const { return kernelEntry; }
161
162    int registerExecContext(ExecContext *xc, int xcIndex);
163    void replaceExecContext(ExecContext *xc, int xcIndex);
164
165    void regStats();
166    void serialize(std::ostream &os);
167    void unserialize(Checkpoint *cp, const std::string &section);
168
169  public:
170    ////////////////////////////////////////////
171    //
172    // STATIC GLOBAL SYSTEM LIST
173    //
174    ////////////////////////////////////////////
175
176    static std::vector<System *> systemList;
177    static int numSystemsRunning;
178
179    static void printSystems();
180};
181
182#endif // __SYSTEM_HH__
183