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