system.hh revision 5222
15222Sksewell@umich.edu/*
25222Sksewell@umich.edu * Copyright .AN) 2007 MIPS Technologies, Inc.  All Rights Reserved
35222Sksewell@umich.edu *
45222Sksewell@umich.edu * This software is part of the M5 simulator.
55222Sksewell@umich.edu *
65222Sksewell@umich.edu * THIS IS A LEGAL AGREEMENT.  BY DOWNLOADING, USING, COPYING, CREATING
75222Sksewell@umich.edu * DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING
85222Sksewell@umich.edu * TO THESE TERMS AND CONDITIONS.
95222Sksewell@umich.edu *
105222Sksewell@umich.edu * Permission is granted to use, copy, create derivative works and
115222Sksewell@umich.edu * distribute this software and such derivative works for any purpose,
125222Sksewell@umich.edu * so long as (1) the copyright notice above, this grant of permission,
135222Sksewell@umich.edu * and the disclaimer below appear in all copies and derivative works
145222Sksewell@umich.edu * made, (2) the copyright notice above is augmented as appropriate to
155222Sksewell@umich.edu * reflect the addition of any new copyrightable work in a derivative
165222Sksewell@umich.edu * work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3)
175222Sksewell@umich.edu * the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any
185222Sksewell@umich.edu * advertising or publicity pertaining to the use or distribution of
195222Sksewell@umich.edu * this software without specific, written prior authorization.
205222Sksewell@umich.edu *
215222Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B  MIPS MAKES NO WARRANTIES AND
225222Sksewell@umich.edu * DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR
235222Sksewell@umich.edu * OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
245222Sksewell@umich.edu * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND
255222Sksewell@umich.edu * NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE.
265222Sksewell@umich.edu * IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT,
275222Sksewell@umich.edu * INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF
285222Sksewell@umich.edu * ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT,
295222Sksewell@umich.edu * THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY
305222Sksewell@umich.edu * IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR
315222Sksewell@umich.edu * STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE
325222Sksewell@umich.edu * POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE.
335222Sksewell@umich.edu *
345222Sksewell@umich.edu * Authors: Ali G. Saidi
355222Sksewell@umich.edu *          Lisa R. Hsu
365222Sksewell@umich.edu *          Nathan L. Binkert
375222Sksewell@umich.edu */
385222Sksewell@umich.edu
395222Sksewell@umich.edu#ifndef __ARCH_MIPS_LINUX_SYSTEM_HH__
405222Sksewell@umich.edu#define __ARCH_MIPS_LINUX_SYSTEM_HH__
415222Sksewell@umich.edu
425222Sksewell@umich.educlass ThreadContext;
435222Sksewell@umich.edu
445222Sksewell@umich.educlass BreakPCEvent;
455222Sksewell@umich.educlass IdleStartEvent;
465222Sksewell@umich.edu
475222Sksewell@umich.edu#include "arch/mips/idle_event.hh"
485222Sksewell@umich.edu#include "arch/mips/system.hh"
495222Sksewell@umich.edu#include "kern/linux/events.hh"
505222Sksewell@umich.edu#include "params/LinuxMipsSystem.hh"
515222Sksewell@umich.edu
525222Sksewell@umich.eduusing namespace MipsISA;
535222Sksewell@umich.eduusing namespace Linux;
545222Sksewell@umich.edu
555222Sksewell@umich.edu/**
565222Sksewell@umich.edu * This class contains linux specific system code (Loading, Events).
575222Sksewell@umich.edu * It points to objects that are the system binaries to load and patches them
585222Sksewell@umich.edu * appropriately to work in simulator.
595222Sksewell@umich.edu */
605222Sksewell@umich.educlass LinuxMipsSystem : public MipsSystem
615222Sksewell@umich.edu{
625222Sksewell@umich.edu  private:
635222Sksewell@umich.edu    class SkipDelayLoopEvent : public SkipFuncEvent
645222Sksewell@umich.edu    {
655222Sksewell@umich.edu      public:
665222Sksewell@umich.edu        SkipDelayLoopEvent(PCEventQueue *q, const std::string &desc, Addr addr)
675222Sksewell@umich.edu            : SkipFuncEvent(q, desc, addr) {}
685222Sksewell@umich.edu        virtual void process(ThreadContext *tc);
695222Sksewell@umich.edu    };
705222Sksewell@umich.edu
715222Sksewell@umich.edu    class PrintThreadInfo : public PCEvent
725222Sksewell@umich.edu    {
735222Sksewell@umich.edu      public:
745222Sksewell@umich.edu        PrintThreadInfo(PCEventQueue *q, const std::string &desc, Addr addr)
755222Sksewell@umich.edu            : PCEvent(q, desc, addr) {}
765222Sksewell@umich.edu        virtual void process(ThreadContext *tc);
775222Sksewell@umich.edu    };
785222Sksewell@umich.edu
795222Sksewell@umich.edu
805222Sksewell@umich.edu    /**
815222Sksewell@umich.edu     * Addresses defining where the kernel bootloader places various
825222Sksewell@umich.edu     * elements.  Details found in include/asm-mips/system.h
835222Sksewell@umich.edu     */
845222Sksewell@umich.edu    Addr KernelStart; // Lookup the symbol swapper_pg_dir
855222Sksewell@umich.edu
865222Sksewell@umich.edu  public:
875222Sksewell@umich.edu    Addr InitStack() const { return KernelStart + 0x02000; }
885222Sksewell@umich.edu    Addr EmptyPGT() const  { return KernelStart + 0x04000; }
895222Sksewell@umich.edu    Addr EmptyPGE() const  { return KernelStart + 0x08000; }
905222Sksewell@umich.edu    Addr ZeroPGE() const   { return KernelStart + 0x0A000; }
915222Sksewell@umich.edu    Addr StartAddr() const { return KernelStart + 0x10000; }
925222Sksewell@umich.edu
935222Sksewell@umich.edu    Addr Param() const { return ZeroPGE() + 0x0; }
945222Sksewell@umich.edu    Addr CommandLine() const { return Param() + 0x0; }
955222Sksewell@umich.edu    Addr InitrdStart() const { return Param() + 0x100; }
965222Sksewell@umich.edu    Addr InitrdSize() const { return Param() + 0x108; }
975222Sksewell@umich.edu    static const int CommandLineSize = 256;
985222Sksewell@umich.edu
995222Sksewell@umich.edu  private:
1005222Sksewell@umich.edu#ifndef NDEBUG
1015222Sksewell@umich.edu    /** Event to halt the simulator if the kernel calls panic()  */
1025222Sksewell@umich.edu    BreakPCEvent *kernelPanicEvent;
1035222Sksewell@umich.edu
1045222Sksewell@umich.edu    /** Event to halt the simulator if the kernel calls die_if_kernel  */
1055222Sksewell@umich.edu    BreakPCEvent *kernelDieEvent;
1065222Sksewell@umich.edu#endif
1075222Sksewell@umich.edu
1085222Sksewell@umich.edu    /**
1095222Sksewell@umich.edu     * Event to skip determine_cpu_caches() because we don't support
1105222Sksewell@umich.edu     * the IPRs that the code can access to figure out cache sizes
1115222Sksewell@umich.edu     */
1125222Sksewell@umich.edu    SkipFuncEvent *skipCacheProbeEvent;
1135222Sksewell@umich.edu
1145222Sksewell@umich.edu    /** PC based event to skip the ide_delay_50ms() call */
1155222Sksewell@umich.edu    SkipFuncEvent *skipIdeDelay50msEvent;
1165222Sksewell@umich.edu
1175222Sksewell@umich.edu    /**
1185222Sksewell@umich.edu     * PC based event to skip the dprink() call and emulate its
1195222Sksewell@umich.edu     * functionality
1205222Sksewell@umich.edu     */
1215222Sksewell@umich.edu    DebugPrintkEvent *debugPrintkEvent;
1225222Sksewell@umich.edu
1235222Sksewell@umich.edu    /**
1245222Sksewell@umich.edu     * Skip calculate_delay_loop() rather than waiting for this to be
1255222Sksewell@umich.edu     * calculated
1265222Sksewell@umich.edu     */
1275222Sksewell@umich.edu    SkipDelayLoopEvent *skipDelayLoopEvent;
1285222Sksewell@umich.edu
1295222Sksewell@umich.edu    /**
1305222Sksewell@umich.edu     * Event to print information about thread switches if the trace flag
1315222Sksewell@umich.edu     * Thread is set
1325222Sksewell@umich.edu     */
1335222Sksewell@umich.edu    PrintThreadInfo *printThreadEvent;
1345222Sksewell@umich.edu
1355222Sksewell@umich.edu    /** Grab the PCBB of the idle process when it starts */
1365222Sksewell@umich.edu    IdleStartEvent *idleStartEvent;
1375222Sksewell@umich.edu
1385222Sksewell@umich.edu  public:
1395222Sksewell@umich.edu    typedef LinuxMipsSystemParams Params;
1405222Sksewell@umich.edu    LinuxMipsSystem(Params *p);
1415222Sksewell@umich.edu    ~LinuxMipsSystem();
1425222Sksewell@umich.edu
1435222Sksewell@umich.edu    void setDelayLoop(ThreadContext *tc);
1445222Sksewell@umich.edu};
1455222Sksewell@umich.edu
1465222Sksewell@umich.edu#endif // __ARCH_MIPS_LINUX_SYSTEM_HH__
147