system.hh revision 451
1/*
2 * Copyright (c) 2003 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 __LINUX_SYSTEM_HH__
30#define __LINUX_SYSTEM_HH__
31
32#include <vector>
33
34#include "sim/system.hh"
35#include "targetarch/isa_traits.hh"
36
37#ifdef FS_MEASURE
38#include <map>
39#endif
40
41class ExecContext;
42class ElfObject;
43class SymbolTable;
44
45class BreakPCEvent;
46class LinuxBadAddrEvent;
47class LinuxSkipFuncEvent;
48class LinuxPrintfEvent;
49class LinuxDebugPrintfEvent;
50class LinuxDumpMbufEvent;
51#ifdef FS_MEASURE
52class FnEvent;
53#endif
54class AlphaArguments;
55
56class LinuxSystem : public System
57{
58  private:
59    ElfObject *kernel;
60    ElfObject *console;
61    ElfObject *bootloader;
62
63    SymbolTable *kernelSymtab;
64    SymbolTable *bootloaderSymtab;
65    SymbolTable *consoleSymtab;
66
67#ifdef FS_MEASURE
68    //INSTRUMENTATION CODEGEN BEGIN ONE
69    Statistics::MainBin *esIntrBin;
70    Statistics::MainBin *esRxeofBin;
71    Statistics::MainBin *esNewbufBin;
72    Statistics::MainBin *esDmaLoadBin;
73    Statistics::MainBin *dmaMapLoadBin;
74    Statistics::MainBin *etherInputBin;
75    Statistics::MainBin *netisrInputBin;
76    Statistics::MainBin *schednetisrIsrBin;
77    Statistics::MainBin *ipintrBin;
78    Statistics::MainBin *ipDooptionsBin;
79    Statistics::MainBin *ipReassBin;
80    Statistics::MainBin *tcpInputBin;
81    Statistics::MainBin *sbappendBin;
82    Statistics::MainBin *readBin;
83    Statistics::MainBin *sooReadBin;
84    Statistics::MainBin *orecvBin;
85    Statistics::MainBin *recvitBin;
86    Statistics::MainBin *soreceiveBin;
87    Statistics::MainBin *osendBin;
88    Statistics::MainBin *writeBin;
89    Statistics::MainBin *sooWriteBin;
90    Statistics::MainBin *senditBin;
91    Statistics::MainBin *sosendBin;
92    Statistics::MainBin *tcpSosendBin;
93    Statistics::MainBin *tcpOutputBin;
94    Statistics::MainBin *ipOutputBin;
95    Statistics::MainBin *etherOutputBin;
96    Statistics::MainBin *esStartBin;
97    Statistics::MainBin *esTransmitBin;
98    Statistics::MainBin *esTxeofBin;
99    Statistics::MainBin *idleThreadBin;
100    //INSTRUMENTATION CODEGEN END
101#endif //FS_MEASURE
102
103    BreakPCEvent *kernelPanicEvent;
104    BreakPCEvent *consolePanicEvent;
105    LinuxBadAddrEvent *badaddrEvent;
106    LinuxSkipFuncEvent *skipPowerStateEvent;
107    LinuxSkipFuncEvent *skipScavengeBootEvent;
108    LinuxPrintfEvent *printfEvent;
109    LinuxDebugPrintfEvent *debugPrintfEvent;
110    LinuxDebugPrintfEvent *debugPrintfrEvent;
111    LinuxDumpMbufEvent *dumpMbufEvent;
112#ifdef FS_MEASURE
113    //INSTRUMENTATION CODEGEN BEGIN TWO
114    FnEvent *esIntrEvent;
115    FnEvent *esRxeofEvent;
116    FnEvent *esNewbufEvent;
117    FnEvent *esDmaLoadEvent;
118    FnEvent *dmaMapLoadEvent;
119    FnEvent *etherInputEvent;
120    FnEvent *netisrInputEvent;
121    FnEvent *schednetisrIsrEvent;
122    FnEvent *ipintrEvent;
123    FnEvent *ipDooptionsEvent;
124    FnEvent *ipReassEvent;
125    FnEvent *tcpInputEvent;
126    FnEvent *sbappendEvent;
127    FnEvent *readEvent;
128    FnEvent *sooReadEvent;
129    FnEvent *orecvEvent;
130    FnEvent *recvitEvent;
131    FnEvent *soreceiveEvent;
132    FnEvent *osendEvent;
133    FnEvent *writeEvent;
134    FnEvent *sooWriteEvent;
135    FnEvent *senditEvent;
136    FnEvent *sosendEvent;
137    FnEvent *tcpSosendEvent;
138    FnEvent *tcpOutputEvent;
139    FnEvent *ipOutputEvent;
140    FnEvent *etherOutputEvent;
141    FnEvent *esStartEvent;
142    FnEvent *esTransmitEvent;
143    FnEvent *esTxeofEvent;
144    FnEvent *idleThreadEvent;
145    //INSTRUMENTATION CODEGEN END
146#endif //FS_MEASURE
147
148  private:
149
150    Addr kernelStart;
151    Addr kernelEnd;
152    Addr kernelEntry;
153    bool bin;
154
155#ifdef FS_MEASURE
156    std::multimap<const std::string, std::string> callerMap;
157    void populateMap(std::string caller, std::string callee);
158#endif
159
160  public:
161    std::vector<RemoteGDB *>   remoteGDB;
162    std::vector<GDBListener *> gdbListen;
163
164  public:
165    LinuxSystem(const std::string _name,
166                const uint64_t _init_param,
167                MemoryController *_memCtrl,
168                PhysicalMemory *_physmem,
169                const std::string &kernel_path,
170                const std::string &console_path,
171                const std::string &palcode,
172                const std::string &boot_osflags,
173        const std::string &bootloader_path,
174                                const bool _bin);
175    ~LinuxSystem();
176
177    int registerExecContext(ExecContext *xc);
178    void replaceExecContext(ExecContext *xc, int xcIndex);
179
180    Addr getKernelStart() const { return kernelStart; }
181    Addr getKernelEnd() const { return kernelEnd; }
182    Addr getKernelEntry() const { return kernelEntry; }
183    bool breakpoint();
184
185    static void Printf(AlphaArguments args);
186    static void DumpMbuf(AlphaArguments args);
187
188#ifdef FS_MEASURE
189    bool findCaller(std::string callee, std::string caller) const;
190    void dumpState(ExecContext *xc) const;
191#endif //FS_MEASURE
192};
193
194#endif // __LINUX_SYSTEM_HH__
195