system.hh revision 887
18853Sandreas.hansson@arm.com/*
28853Sandreas.hansson@arm.com * Copyright (c) 2003 The Regents of The University of Michigan
38853Sandreas.hansson@arm.com * All rights reserved.
48853Sandreas.hansson@arm.com *
58853Sandreas.hansson@arm.com * Redistribution and use in source and binary forms, with or without
68853Sandreas.hansson@arm.com * modification, are permitted provided that the following conditions are
78853Sandreas.hansson@arm.com * met: redistributions of source code must retain the above copyright
88853Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer;
98853Sandreas.hansson@arm.com * redistributions in binary form must reproduce the above copyright
108853Sandreas.hansson@arm.com * notice, this list of conditions and the following disclaimer in the
118853Sandreas.hansson@arm.com * documentation and/or other materials provided with the distribution;
128853Sandreas.hansson@arm.com * neither the name of the copyright holders nor the names of its
138853Sandreas.hansson@arm.com * contributors may be used to endorse or promote products derived from
148853Sandreas.hansson@arm.com * this software without specific prior written permission.
158853Sandreas.hansson@arm.com *
168853Sandreas.hansson@arm.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
178853Sandreas.hansson@arm.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
188853Sandreas.hansson@arm.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
198853Sandreas.hansson@arm.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
208853Sandreas.hansson@arm.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
218853Sandreas.hansson@arm.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
228853Sandreas.hansson@arm.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
238853Sandreas.hansson@arm.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
248853Sandreas.hansson@arm.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
258853Sandreas.hansson@arm.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
268853Sandreas.hansson@arm.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
278853Sandreas.hansson@arm.com */
288853Sandreas.hansson@arm.com
298853Sandreas.hansson@arm.com#ifndef __LINUX_SYSTEM_HH__
308853Sandreas.hansson@arm.com#define __LINUX_SYSTEM_HH__
318853Sandreas.hansson@arm.com
328853Sandreas.hansson@arm.com#include <vector>
338853Sandreas.hansson@arm.com
348853Sandreas.hansson@arm.com#include "sim/system.hh"
358853Sandreas.hansson@arm.com#include "sim/host.hh"
368853Sandreas.hansson@arm.com#include "targetarch/isa_traits.hh"
378853Sandreas.hansson@arm.com
388853Sandreas.hansson@arm.com#include <map>
398853Sandreas.hansson@arm.com
408853Sandreas.hansson@arm.com/**
418853Sandreas.hansson@arm.com * MAGIC address where the kernel arguments should go. Defined as
428853Sandreas.hansson@arm.com * PARAM in linux kernel alpha-asm.
438853Sandreas.hansson@arm.com */
448853Sandreas.hansson@arm.comconst Addr PARAM_ADDR =  ULL(0xfffffc000030a000);
458853Sandreas.hansson@arm.com
468853Sandreas.hansson@arm.comclass ExecContext;
478853Sandreas.hansson@arm.comclass ElfObject;
488853Sandreas.hansson@arm.comclass SymbolTable;
498853Sandreas.hansson@arm.com
508853Sandreas.hansson@arm.comclass BreakPCEvent;
518853Sandreas.hansson@arm.comclass LinuxSkipDelayLoopEvent;
528853Sandreas.hansson@arm.comclass SkipFuncEvent;
538853Sandreas.hansson@arm.comclass FnEvent;
548853Sandreas.hansson@arm.comclass AlphaArguments;
558853Sandreas.hansson@arm.com
568853Sandreas.hansson@arm.com/**
578853Sandreas.hansson@arm.com * This class contains linux specific system code (Loading, Events, Binning).
588853Sandreas.hansson@arm.com * It points to objects that are the system binaries to load and patches them
598853Sandreas.hansson@arm.com * appropriately to work in simulator.
608853Sandreas.hansson@arm.com */
618853Sandreas.hansson@arm.comclass LinuxSystem : public System
628853Sandreas.hansson@arm.com{
638853Sandreas.hansson@arm.com  private:
648853Sandreas.hansson@arm.com    /** Object pointer for the kernel code */
658853Sandreas.hansson@arm.com    ElfObject *kernel;
668853Sandreas.hansson@arm.com
678853Sandreas.hansson@arm.com    /** Object pointer for the console code */
688853Sandreas.hansson@arm.com    ElfObject *console;
69
70    /** kernel Symbol table */
71    SymbolTable *kernelSymtab;
72
73    /** console symbol table */
74    SymbolTable *consoleSymtab;
75
76    /** Event to halt the simulator if the kernel calls panic()  */
77    BreakPCEvent *kernelPanicEvent;
78
79    /** Event to halt the simulator if the console calls panic() */
80    BreakPCEvent *consolePanicEvent;
81
82    /** Event to skip determine_cpu_caches() because we don't support the
83     * IPRs that the code can access to figure out cache sizes
84     */
85    SkipFuncEvent *skipCacheProbeEvent;
86
87    /** PC based event to skip the ide_delay_50ms() call */
88    SkipFuncEvent *skipIdeDelay50msEvent;
89
90    /** Skip calculate_delay_loop() rather than waiting for this to be
91     * calculated
92     */
93    LinuxSkipDelayLoopEvent *skipDelayLoopEvent;
94
95    /** Begining of kernel code */
96    Addr kernelStart;
97
98    /** End of kernel code */
99    Addr kernelEnd;
100
101    /** Entry point in the kernel to start at */
102    Addr kernelEntry;
103
104    bool bin;
105    std::vector<string> binned_fns;
106
107  public:
108    std::vector<RemoteGDB *>   remoteGDB;
109    std::vector<GDBListener *> gdbListen;
110
111    LinuxSystem(const std::string _name,
112                const uint64_t _init_param,
113                MemoryController *_memCtrl,
114                PhysicalMemory *_physmem,
115                const std::string &kernel_path,
116                const std::string &console_path,
117                const std::string &palcode,
118                const std::string &boot_osflags,
119                const bool _bin,
120                const std::vector<std::string> &_binned_fns);
121
122    ~LinuxSystem();
123
124    void setDelayLoop(ExecContext *xc);
125
126    int registerExecContext(ExecContext *xc);
127    void replaceExecContext(ExecContext *xc, int xcIndex);
128
129    /**
130     * Returns the addess the kernel starts at.
131     * @return address the kernel starts at
132     */
133    Addr getKernelStart() const { return kernelStart; }
134
135    /**
136     * Returns the addess the kernel ends at.
137     * @return address the kernel ends at
138     */
139    Addr getKernelEnd() const { return kernelEnd; }
140
141    /**
142     * Returns the addess the entry point to the kernel code.
143     * @return entry point of the kernel code
144     */
145    Addr getKernelEntry() const { return kernelEntry; }
146
147
148    bool breakpoint();
149};
150
151#endif // __LINUX_SYSTEM_HH__
152