system.hh revision 1885
1848SN/A/*
29956SN/A * Copyright (c) 2002-2005 The Regents of The University of Michigan
39956SN/A * All rights reserved.
49956SN/A *
59956SN/A * Redistribution and use in source and binary forms, with or without
69956SN/A * modification, are permitted provided that the following conditions are
79956SN/A * met: redistributions of source code must retain the above copyright
89956SN/A * notice, this list of conditions and the following disclaimer;
99956SN/A * redistributions in binary form must reproduce the above copyright
109956SN/A * notice, this list of conditions and the following disclaimer in the
119956SN/A * documentation and/or other materials provided with the distribution;
129956SN/A * neither the name of the copyright holders nor the names of its
139956SN/A * contributors may be used to endorse or promote products derived from
141762SN/A * this software without specific prior written permission.
15848SN/A *
16848SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17848SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18848SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19848SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20848SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21848SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22848SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23848SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24848SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25848SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26848SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27848SN/A */
28848SN/A
29848SN/A#ifndef __SYSTEM_HH__
30848SN/A#define __SYSTEM_HH__
31848SN/A
32848SN/A#include <string>
33848SN/A#include <vector>
34848SN/A
35848SN/A#include "base/statistics.hh"
36848SN/A#include "base/loader/symtab.hh"
37848SN/A#include "cpu/pc_event.hh"
38848SN/A#include "kern/system_events.hh"
392665SN/A#include "sim/sim_object.hh"
402665SN/A
412665SN/Aclass BaseCPU;
42848SN/Aclass ExecContext;
43848SN/Aclass GDBListener;
44848SN/Aclass MemoryController;
45848SN/Aclass ObjectFile;
46848SN/Aclass PhysicalMemory;
47848SN/Aclass Platform;
4811264Sandreas.sandberg@arm.comclass RemoteGDB;
4911264Sandreas.sandberg@arm.comnamespace Kernel { class Binning; }
50848SN/A
51848SN/Aclass System : public SimObject
52848SN/A{
53848SN/A  public:
54848SN/A    MemoryController *memctrl;
554762SN/A    PhysicalMemory *physmem;
562565SN/A    Platform *platform;
57848SN/A    PCEventQueue pcEventQueue;
58848SN/A    uint64_t init_param;
598229SN/A
608232SN/A    std::vector<ExecContext *> execContexts;
6111264Sandreas.sandberg@arm.com    int numcpus;
6211264Sandreas.sandberg@arm.com
634762SN/A    int getNumCPUs()
64848SN/A    {
65848SN/A        if (numcpus != execContexts.size())
66848SN/A            panic("cpu array not fully populated!");
672107SN/A
68848SN/A        return numcpus;
695034SN/A    }
705034SN/A
712565SN/A    /** kernel symbol table */
722565SN/A    SymbolTable *kernelSymtab;
73849SN/A
74848SN/A    /** console symbol table */
75893SN/A    SymbolTable *consoleSymtab;
765034SN/A
77893SN/A    /** pal symbol table */
78849SN/A    SymbolTable *palSymtab;
791722SN/A
80849SN/A    /** Object pointer for the kernel code */
81849SN/A    ObjectFile *kernel;
82849SN/A
83849SN/A    /** Object pointer for the console code */
84849SN/A    ObjectFile *console;
85849SN/A
86849SN/A    /** Object pointer for the PAL code */
87849SN/A    ObjectFile *pal;
88849SN/A
89849SN/A    /** Begining of kernel code */
90849SN/A    Addr kernelStart;
91849SN/A
92849SN/A    /** End of kernel code */
93849SN/A    Addr kernelEnd;
9411101SN/A
9511101SN/A    /** Entry point in the kernel to start at */
96849SN/A    Addr kernelEntry;
97849SN/A
98849SN/A    Kernel::Binning *kernelBinning;
99849SN/A
100849SN/A#ifdef DEBUG
101849SN/A    /** Event to halt the simulator if the console calls panic() */
102849SN/A    BreakPCEvent *consolePanicEvent;
103849SN/A#endif
104849SN/A
105849SN/A  protected:
106849SN/A
107849SN/A    /**
1081853SN/A     * Fix up an address used to match PCs for hooking simulator
1091853SN/A     * events on to target function executions.  See comment in
110849SN/A     * system.cc for details.
1111722SN/A     */
112849SN/A    Addr fixFuncEventAddr(Addr addr);
1131722SN/A
114849SN/A    /**
1151722SN/A     * Add a function-based event to the given function, to be looked
116849SN/A     * up in the specified symbol table.
1171722SN/A     */
1181722SN/A    template <class T>
1191722SN/A    T *System::addFuncEvent(SymbolTable *symtab, const char *lbl)
120849SN/A    {
1211722SN/A        Addr addr;
1221722SN/A
123849SN/A        if (symtab->findAddress(lbl, addr)) {
1241722SN/A            T *ev = new T(&pcEventQueue, lbl, fixFuncEventAddr(addr));
125849SN/A            return ev;
1262989SN/A        }
127849SN/A
1281722SN/A        return NULL;
129849SN/A    }
1301886SN/A
131849SN/A    /** Add a function-based event to kernel code. */
1321722SN/A    template <class T>
1331817SN/A    T *System::addKernelFuncEvent(const char *lbl)
1341817SN/A    {
1351817SN/A        return addFuncEvent<T>(kernelSymtab, lbl);
136893SN/A    }
137893SN/A
138893SN/A    /** Add a function-based event to PALcode. */
139893SN/A    template <class T>
140893SN/A    T *System::addPalFuncEvent(const char *lbl)
141893SN/A    {
142893SN/A        return addFuncEvent<T>(palSymtab, lbl);
143893SN/A    }
144893SN/A
145893SN/A    /** Add a function-based event to the console code. */
146893SN/A    template <class T>
147893SN/A    T *System::addConsoleFuncEvent(const char *lbl)
148893SN/A    {
149893SN/A        return addFuncEvent<T>(consoleSymtab, lbl);
150893SN/A    }
151893SN/A
152893SN/A  public:
153893SN/A    std::vector<RemoteGDB *> remoteGDB;
154893SN/A    std::vector<GDBListener *> gdbListen;
155893SN/A    bool breakpoint();
156893SN/A
157893SN/A  public:
158893SN/A    struct Params
159893SN/A    {
160893SN/A        std::string name;
1619956SN/A        Tick boot_cpu_frequency;
162849SN/A        MemoryController *memctrl;
163849SN/A        PhysicalMemory *physmem;
164849SN/A        uint64_t init_param;
165849SN/A        bool bin;
166849SN/A        std::vector<std::string> binned_fns;
167849SN/A        bool bin_int;
168849SN/A
169849SN/A        std::string kernel_path;
170849SN/A        std::string console_path;
171849SN/A        std::string palcode;
172849SN/A        std::string boot_osflags;
173849SN/A
174849SN/A        std::string readfile;
175849SN/A        uint64_t system_type;
176849SN/A        uint64_t system_rev;
177893SN/A    };
1781817SN/A    Params *params;
1791817SN/A
1801817SN/A    System(Params *p);
1811817SN/A    ~System();
182849SN/A
183849SN/A    void startup();
184864SN/A
185864SN/A  public:
186864SN/A    /**
187864SN/A     * Set the m5AlphaAccess pointer in the console
188929SN/A     */
189929SN/A    void setAlphaAccess(Addr access);
190929SN/A
191929SN/A    /**
192929SN/A     * Returns the addess the kernel starts at.
193929SN/A     * @return address the kernel starts at
194861SN/A     */
195864SN/A    Addr getKernelStart() const { return kernelStart; }
196861SN/A
197861SN/A    /**
1985772SN/A     * Returns the addess the kernel ends at.
199861SN/A     * @return address the kernel ends at
200861SN/A     */
201861SN/A    Addr getKernelEnd() const { return kernelEnd; }
202861SN/A
203849SN/A    /**
204849SN/A     * Returns the addess the entry point to the kernel code.
205849SN/A     * @return entry point of the kernel code
206849SN/A     */
207849SN/A    Addr getKernelEntry() const { return kernelEntry; }
2085772SN/A
209849SN/A    int registerExecContext(ExecContext *xc, int xcIndex);
2105772SN/A    void replaceExecContext(ExecContext *xc, int xcIndex);
2115772SN/A
2125772SN/A    void regStats();
2135772SN/A    void serialize(std::ostream &os);
2145772SN/A    void unserialize(Checkpoint *cp, const std::string &section);
2155772SN/A
2165772SN/A  public:
2175772SN/A    ////////////////////////////////////////////
2185772SN/A    //
2191817SN/A    // STATIC GLOBAL SYSTEM LIST
2205772SN/A    //
2215772SN/A    ////////////////////////////////////////////
2225772SN/A
2235772SN/A    static std::vector<System *> systemList;
2245772SN/A    static int numSystemsRunning;
2255772SN/A
2265772SN/A    static void printSystems();
2271817SN/A};
2285772SN/A
2295772SN/A#endif // __SYSTEM_HH__
2305772SN/A