system.hh revision 1067
12SN/A/*
21762SN/A * Copyright (c) 2004 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu */
282665Ssaidi@eecs.umich.edu
292SN/A#ifndef __LINUX_SYSTEM_HH__
302SN/A#define __LINUX_SYSTEM_HH__
312SN/A
322SN/A#include <vector>
332SN/A
348229Snate@binkert.org#include "sim/system.hh"
358229Snate@binkert.org#include "sim/host.hh"
362SN/A#include "targetarch/isa_traits.hh"
378229Snate@binkert.org
384167Sbinkertn@umich.edu#include <map>
392SN/A
40252SN/A/**
411872SN/A * MAGIC address where the kernel arguments should go. Defined as
42252SN/A * PARAM in linux kernel alpha-asm.
4310905Sandreas.sandberg@arm.com */
442SN/Aconst Addr PARAM_ADDR =  ULL(0xfffffc000030a000);
452SN/A
462SN/Aclass ExecContext;
472SN/Aclass ElfObject;
482SN/Aclass SymbolTable;
492SN/Aclass DebugPrintkEvent;
502SN/Aclass BreakPCEvent;
512SN/Aclass LinuxSkipDelayLoopEvent;
522SN/Aclass SkipFuncEvent;
532SN/Aclass FnEvent;
542SN/Aclass AlphaArguments;
552SN/Aclass PrintThreadInfo;
562SN/A
572SN/A/**
582SN/A * This class contains linux specific system code (Loading, Events, Binning).
592SN/A * It points to objects that are the system binaries to load and patches them
60251SN/A * appropriately to work in simulator.
61251SN/A */
62252SN/Aclass LinuxSystem : public System
6311168Sandreas.hansson@arm.com{
6411168Sandreas.hansson@arm.com  private:
652SN/A    /** Object pointer for the kernel code */
662SN/A    ElfObject *kernel;
672SN/A
682SN/A    /** Object pointer for the console code */
692SN/A    ElfObject *console;
702SN/A
712SN/A    /** kernel Symbol table */
722SN/A    SymbolTable *kernelSymtab;
732SN/A
742SN/A    /** console symbol table */
752SN/A    SymbolTable *consoleSymtab;
762SN/A
772SN/A    /** Event to halt the simulator if the kernel calls panic()  */
782SN/A    BreakPCEvent *kernelPanicEvent;
792SN/A
802SN/A    /** Event to halt the simulator if the console calls panic() */
812SN/A    BreakPCEvent *consolePanicEvent;
822SN/A
832SN/A    /** Event to skip determine_cpu_caches() because we don't support the
842SN/A     * IPRs that the code can access to figure out cache sizes
852SN/A     */
862SN/A    SkipFuncEvent *skipCacheProbeEvent;
872SN/A
882SN/A    /** PC based event to skip the ide_delay_50ms() call */
892SN/A    SkipFuncEvent *skipIdeDelay50msEvent;
902SN/A
912SN/A    /** PC based event to skip the dprink() call and emulate its functionality */
922SN/A    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