system.hh revision 1067
1/*
2 * Copyright (c) 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 __LINUX_SYSTEM_HH__
30#define __LINUX_SYSTEM_HH__
31
32#include <vector>
33
34#include "sim/system.hh"
35#include "sim/host.hh"
36#include "targetarch/isa_traits.hh"
37
38#include <map>
39
40/**
41 * MAGIC address where the kernel arguments should go. Defined as
42 * PARAM in linux kernel alpha-asm.
43 */
44const Addr PARAM_ADDR =  ULL(0xfffffc000030a000);
45
46class ExecContext;
47class ElfObject;
48class SymbolTable;
49class DebugPrintkEvent;
50class BreakPCEvent;
51class LinuxSkipDelayLoopEvent;
52class SkipFuncEvent;
53class FnEvent;
54class AlphaArguments;
55class PrintThreadInfo;
56
57/**
58 * This class contains linux specific system code (Loading, Events, Binning).
59 * It points to objects that are the system binaries to load and patches them
60 * appropriately to work in simulator.
61 */
62class LinuxSystem : public System
63{
64  private:
65    /** Object pointer for the kernel code */
66    ElfObject *kernel;
67
68    /** Object pointer for the console code */
69    ElfObject *console;
70
71    /** kernel Symbol table */
72    SymbolTable *kernelSymtab;
73
74    /** console symbol table */
75    SymbolTable *consoleSymtab;
76
77    /** Event to halt the simulator if the kernel calls panic()  */
78    BreakPCEvent *kernelPanicEvent;
79
80    /** Event to halt the simulator if the console calls panic() */
81    BreakPCEvent *consolePanicEvent;
82
83    /** Event to skip determine_cpu_caches() because we don't support the
84     * IPRs that the code can access to figure out cache sizes
85     */
86    SkipFuncEvent *skipCacheProbeEvent;
87
88    /** PC based event to skip the ide_delay_50ms() call */
89    SkipFuncEvent *skipIdeDelay50msEvent;
90
91    /** PC based event to skip the dprink() call and emulate its functionality */
92    DebugPrintkEvent *debugPrintkEvent;
93
94    /** Skip calculate_delay_loop() rather than waiting for this to be
95     * calculated
96     */
97    LinuxSkipDelayLoopEvent *skipDelayLoopEvent;
98
99    PrintThreadInfo *printThreadEvent;
100
101    /** Begining of kernel code */
102    Addr kernelStart;
103
104    /** End of kernel code */
105    Addr kernelEnd;
106
107    /** Entry point in the kernel to start at */
108    Addr kernelEntry;
109
110    bool bin;
111    std::vector<string> binned_fns;
112
113  public:
114    std::vector<RemoteGDB *>   remoteGDB;
115    std::vector<GDBListener *> gdbListen;
116
117    LinuxSystem(const std::string _name,
118                const uint64_t _init_param,
119                MemoryController *_memCtrl,
120                PhysicalMemory *_physmem,
121                const std::string &kernel_path,
122                const std::string &console_path,
123                const std::string &palcode,
124                const std::string &boot_osflags,
125                const bool _bin,
126                const std::vector<std::string> &_binned_fns);
127
128    ~LinuxSystem();
129
130    void setDelayLoop(ExecContext *xc);
131
132    int registerExecContext(ExecContext *xc);
133    void replaceExecContext(ExecContext *xc, int xcIndex);
134
135    /**
136     * Returns the addess the kernel starts at.
137     * @return address the kernel starts at
138     */
139    Addr getKernelStart() const { return kernelStart; }
140
141    /**
142     * Returns the addess the kernel ends at.
143     * @return address the kernel ends at
144     */
145    Addr getKernelEnd() const { return kernelEnd; }
146
147    /**
148     * Returns the addess the entry point to the kernel code.
149     * @return entry point of the kernel code
150     */
151    Addr getKernelEntry() const { return kernelEntry; }
152
153
154    bool breakpoint();
155};
156
157#endif // __LINUX_SYSTEM_HH__
158