system.hh revision 5222
19913Ssteve.reinhardt@amd.com/*
213610Sgiacomo.gabrielli@arm.com * Copyright .AN) 2007 MIPS Technologies, Inc.  All Rights Reserved
312109SRekai.GonzalezAlberquilla@arm.com *
412109SRekai.GonzalezAlberquilla@arm.com * This software is part of the M5 simulator.
512109SRekai.GonzalezAlberquilla@arm.com *
612109SRekai.GonzalezAlberquilla@arm.com * THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
712109SRekai.GonzalezAlberquilla@arm.com * DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
812109SRekai.GonzalezAlberquilla@arm.com * TO THESE TERMS AND CONDITIONS.
912109SRekai.GonzalezAlberquilla@arm.com *
1012109SRekai.GonzalezAlberquilla@arm.com * Permission is granted to use, copy, create derivative works and
1112109SRekai.GonzalezAlberquilla@arm.com * distribute this software and such derivative works for any purpose,
1212109SRekai.GonzalezAlberquilla@arm.com * so long as (1) the copyright notice above, this grant of permission,
1312109SRekai.GonzalezAlberquilla@arm.com * and the disclaimer below appear in all copies and derivative works
149913Ssteve.reinhardt@amd.com * made, (2) the copyright notice above is augmented as appropriate to
159913Ssteve.reinhardt@amd.com * reflect the addition of any new copyrightable work in a derivative
169913Ssteve.reinhardt@amd.com * work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3)
179913Ssteve.reinhardt@amd.com * the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any
189913Ssteve.reinhardt@amd.com * advertising or publicity pertaining to the use or distribution of
199913Ssteve.reinhardt@amd.com * this software without specific, written prior authorization.
209913Ssteve.reinhardt@amd.com *
219913Ssteve.reinhardt@amd.com * THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B  MIPS MAKES NO WARRANTIES AND
229913Ssteve.reinhardt@amd.com * DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
239913Ssteve.reinhardt@amd.com * OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
249913Ssteve.reinhardt@amd.com * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
259913Ssteve.reinhardt@amd.com * NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
269913Ssteve.reinhardt@amd.com * IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
279913Ssteve.reinhardt@amd.com * INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
289913Ssteve.reinhardt@amd.com * ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
299913Ssteve.reinhardt@amd.com * THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
309913Ssteve.reinhardt@amd.com * IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
319913Ssteve.reinhardt@amd.com * STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
329913Ssteve.reinhardt@amd.com * POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
339913Ssteve.reinhardt@amd.com *
349913Ssteve.reinhardt@amd.com * Authors: Ali G. Saidi
359913Ssteve.reinhardt@amd.com *          Lisa R. Hsu
369913Ssteve.reinhardt@amd.com *          Nathan L. Binkert
379913Ssteve.reinhardt@amd.com */
389913Ssteve.reinhardt@amd.com
399913Ssteve.reinhardt@amd.com#ifndef __ARCH_MIPS_LINUX_SYSTEM_HH__
409913Ssteve.reinhardt@amd.com#define __ARCH_MIPS_LINUX_SYSTEM_HH__
419913Ssteve.reinhardt@amd.com
429913Ssteve.reinhardt@amd.comclass ThreadContext;
439913Ssteve.reinhardt@amd.com
449913Ssteve.reinhardt@amd.comclass BreakPCEvent;
4512106SRekai.GonzalezAlberquilla@arm.comclass IdleStartEvent;
469913Ssteve.reinhardt@amd.com
479913Ssteve.reinhardt@amd.com#include "arch/mips/idle_event.hh"
4812109SRekai.GonzalezAlberquilla@arm.com#include "arch/mips/system.hh"
4912109SRekai.GonzalezAlberquilla@arm.com#include "kern/linux/events.hh"
5013610Sgiacomo.gabrielli@arm.com#include "params/LinuxMipsSystem.hh"
519920Syasuko.eckert@amd.com
529913Ssteve.reinhardt@amd.comusing namespace MipsISA;
539913Ssteve.reinhardt@amd.comusing namespace Linux;
5412104Snathanael.premillieu@arm.com
55/**
56 * This class contains linux specific system code (Loading, Events).
57 * It points to objects that are the system binaries to load and patches them
58 * appropriately to work in simulator.
59 */
60class LinuxMipsSystem : public MipsSystem
61{
62  private:
63    class SkipDelayLoopEvent : public SkipFuncEvent
64    {
65      public:
66        SkipDelayLoopEvent(PCEventQueue *q, const std::string &desc, Addr addr)
67            : SkipFuncEvent(q, desc, addr) {}
68        virtual void process(ThreadContext *tc);
69    };
70
71    class PrintThreadInfo : public PCEvent
72    {
73      public:
74        PrintThreadInfo(PCEventQueue *q, const std::string &desc, Addr addr)
75            : PCEvent(q, desc, addr) {}
76        virtual void process(ThreadContext *tc);
77    };
78
79
80    /**
81     * Addresses defining where the kernel bootloader places various
82     * elements.  Details found in include/asm-mips/system.h
83     */
84    Addr KernelStart; // Lookup the symbol swapper_pg_dir
85
86  public:
87    Addr InitStack() const { return KernelStart + 0x02000; }
88    Addr EmptyPGT() const  { return KernelStart + 0x04000; }
89    Addr EmptyPGE() const  { return KernelStart + 0x08000; }
90    Addr ZeroPGE() const   { return KernelStart + 0x0A000; }
91    Addr StartAddr() const { return KernelStart + 0x10000; }
92
93    Addr Param() const { return ZeroPGE() + 0x0; }
94    Addr CommandLine() const { return Param() + 0x0; }
95    Addr InitrdStart() const { return Param() + 0x100; }
96    Addr InitrdSize() const { return Param() + 0x108; }
97    static const int CommandLineSize = 256;
98
99  private:
100#ifndef NDEBUG
101    /** Event to halt the simulator if the kernel calls panic()  */
102    BreakPCEvent *kernelPanicEvent;
103
104    /** Event to halt the simulator if the kernel calls die_if_kernel  */
105    BreakPCEvent *kernelDieEvent;
106#endif
107
108    /**
109     * Event to skip determine_cpu_caches() because we don't support
110     * the IPRs that the code can access to figure out cache sizes
111     */
112    SkipFuncEvent *skipCacheProbeEvent;
113
114    /** PC based event to skip the ide_delay_50ms() call */
115    SkipFuncEvent *skipIdeDelay50msEvent;
116
117    /**
118     * PC based event to skip the dprink() call and emulate its
119     * functionality
120     */
121    DebugPrintkEvent *debugPrintkEvent;
122
123    /**
124     * Skip calculate_delay_loop() rather than waiting for this to be
125     * calculated
126     */
127    SkipDelayLoopEvent *skipDelayLoopEvent;
128
129    /**
130     * Event to print information about thread switches if the trace flag
131     * Thread is set
132     */
133    PrintThreadInfo *printThreadEvent;
134
135    /** Grab the PCBB of the idle process when it starts */
136    IdleStartEvent *idleStartEvent;
137
138  public:
139    typedef LinuxMipsSystemParams Params;
140    LinuxMipsSystem(Params *p);
141    ~LinuxMipsSystem();
142
143    void setDelayLoop(ThreadContext *tc);
144};
145
146#endif // __ARCH_MIPS_LINUX_SYSTEM_HH__
147