system.hh revision 887
12497SN/A/*
210719SMarco.Balboni@ARM.com * Copyright (c) 2003 The Regents of The University of Michigan
38711SN/A * All rights reserved.
48711SN/A *
58711SN/A * Redistribution and use in source and binary forms, with or without
68711SN/A * modification, are permitted provided that the following conditions are
78711SN/A * met: redistributions of source code must retain the above copyright
88711SN/A * notice, this list of conditions and the following disclaimer;
98711SN/A * redistributions in binary form must reproduce the above copyright
108711SN/A * notice, this list of conditions and the following disclaimer in the
118711SN/A * documentation and/or other materials provided with the distribution;
128711SN/A * neither the name of the copyright holders nor the names of its
138711SN/A * contributors may be used to endorse or promote products derived from
142497SN/A * this software without specific prior written permission.
152497SN/A *
162497SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172497SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182497SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192497SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202497SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212497SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222497SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232497SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242497SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252497SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262497SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272497SN/A */
282497SN/A
292497SN/A#ifndef __LINUX_SYSTEM_HH__
302497SN/A#define __LINUX_SYSTEM_HH__
312497SN/A
322497SN/A#include <vector>
332497SN/A
342497SN/A#include "sim/system.hh"
352497SN/A#include "sim/host.hh"
362497SN/A#include "targetarch/isa_traits.hh"
372497SN/A
382497SN/A#include <map>
392665SN/A
402665SN/A/**
418715SN/A * MAGIC address where the kernel arguments should go. Defined as
428922SN/A * PARAM in linux kernel alpha-asm.
432497SN/A */
442497SN/Aconst Addr PARAM_ADDR =  ULL(0xfffffc000030a000);
452497SN/A
462982SN/Aclass ExecContext;
4710405Sandreas.hansson@arm.comclass ElfObject;
482497SN/Aclass SymbolTable;
492497SN/A
502846SN/Aclass BreakPCEvent;
512548SN/Aclass LinuxSkipDelayLoopEvent;
5210405Sandreas.hansson@arm.comclass SkipFuncEvent;
5310405Sandreas.hansson@arm.comclass FnEvent;
5410405Sandreas.hansson@arm.comclass AlphaArguments;
552497SN/A
5610405Sandreas.hansson@arm.com/**
5710405Sandreas.hansson@arm.com * This class contains linux specific system code (Loading, Events, Binning).
587523SN/A * It points to objects that are the system binaries to load and patches them
598851SN/A * appropriately to work in simulator.
608948SN/A */
618948SN/Aclass LinuxSystem : public System
628851SN/A{
639095SN/A  private:
6410405Sandreas.hansson@arm.com    /** Object pointer for the kernel code */
658922SN/A    ElfObject *kernel;
669715SN/A
679715SN/A    /** Object pointer for the console code */
688851SN/A    ElfObject *console;
698851SN/A
708948SN/A    /** kernel Symbol table */
718948SN/A    SymbolTable *kernelSymtab;
728915SN/A
739031SN/A    /** console symbol table */
749095SN/A    SymbolTable *consoleSymtab;
7510405Sandreas.hansson@arm.com
769036SN/A    /** Event to halt the simulator if the kernel calls panic()  */
778922SN/A    BreakPCEvent *kernelPanicEvent;
789715SN/A
799715SN/A    /** Event to halt the simulator if the console calls panic() */
808915SN/A    BreakPCEvent *consolePanicEvent;
818915SN/A
828948SN/A    /** Event to skip determine_cpu_caches() because we don't support the
838851SN/A     * IPRs that the code can access to figure out cache sizes
849095SN/A     */
8510888Sandreas.hansson@arm.com    SkipFuncEvent *skipCacheProbeEvent;
868922SN/A
879715SN/A    /** PC based event to skip the ide_delay_50ms() call */
889715SN/A    SkipFuncEvent *skipIdeDelay50msEvent;
898851SN/A
908851SN/A    /** Skip calculate_delay_loop() rather than waiting for this to be
917523SN/A     * calculated
927523SN/A     */
937523SN/A    LinuxSkipDelayLoopEvent *skipDelayLoopEvent;
9410405Sandreas.hansson@arm.com
959715SN/A    /** Begining of kernel code */
9610405Sandreas.hansson@arm.com    Addr kernelStart;
9710405Sandreas.hansson@arm.com
9810405Sandreas.hansson@arm.com    /** End of kernel code */
9910405Sandreas.hansson@arm.com    Addr kernelEnd;
1009715SN/A
1019715SN/A    /** Entry point in the kernel to start at */
1028948SN/A    Addr kernelEntry;
10310405Sandreas.hansson@arm.com
1043244SN/A    bool bin;
1058975SN/A    std::vector<string> binned_fns;
1069032SN/A
1073244SN/A  public:
10810405Sandreas.hansson@arm.com    std::vector<RemoteGDB *>   remoteGDB;
1099036SN/A    std::vector<GDBListener *> gdbListen;
1109036SN/A
1119612SN/A    LinuxSystem(const std::string _name,
1129712SN/A                const uint64_t _init_param,
1139612SN/A                MemoryController *_memCtrl,
11410405Sandreas.hansson@arm.com                PhysicalMemory *_physmem,
1159036SN/A                const std::string &kernel_path,
1169715SN/A                const std::string &console_path,
11710405Sandreas.hansson@arm.com                const std::string &palcode,
1188949SN/A                const std::string &boot_osflags,
1193244SN/A                const bool _bin,
1203244SN/A                const std::vector<std::string> &_binned_fns);
1213244SN/A
12210405Sandreas.hansson@arm.com    ~LinuxSystem();
1238949SN/A
1245197SN/A    void setDelayLoop(ExecContext *xc);
1259712SN/A
1269712SN/A    int registerExecContext(ExecContext *xc);
1279712SN/A    void replaceExecContext(ExecContext *xc, int xcIndex);
1289712SN/A
1299712SN/A    /**
13010719SMarco.Balboni@ARM.com     * Returns the addess the kernel starts at.
13110719SMarco.Balboni@ARM.com     * @return address the kernel starts at
13210719SMarco.Balboni@ARM.com     */
13310719SMarco.Balboni@ARM.com    Addr getKernelStart() const { return kernelStart; }
13410719SMarco.Balboni@ARM.com
13510719SMarco.Balboni@ARM.com    /**
13610719SMarco.Balboni@ARM.com     * Returns the addess the kernel ends at.
13710719SMarco.Balboni@ARM.com     * @return address the kernel ends at
13810719SMarco.Balboni@ARM.com     */
13910719SMarco.Balboni@ARM.com    Addr getKernelEnd() const { return kernelEnd; }
14010719SMarco.Balboni@ARM.com
1418915SN/A    /**
14210656Sandreas.hansson@arm.com     * Returns the addess the entry point to the kernel code.
14310656Sandreas.hansson@arm.com     * @return entry point of the kernel code
14410656Sandreas.hansson@arm.com     */
14511284Sandreas.hansson@arm.com    Addr getKernelEntry() const { return kernelEntry; }
14610656Sandreas.hansson@arm.com
1479612SN/A
1489712SN/A    bool breakpoint();
1498948SN/A};
1508975SN/A
15110405Sandreas.hansson@arm.com#endif // __LINUX_SYSTEM_HH__
1528975SN/A