system.hh revision 5268
15222Sksewell@umich.edu/*
25268Sksewell@umich.edu * Copyright (c) 2004-2006 The Regents of The University of Michigan
35254Sksewell@umich.edu * All rights reserved.
45222Sksewell@umich.edu *
55254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
65254Sksewell@umich.edu * modification, are permitted provided that the following conditions are
75254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
85254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
95254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
105254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
115254Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
125254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
135254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
145254Sksewell@umich.edu * this software without specific prior written permission.
155222Sksewell@umich.edu *
165254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
175254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
185254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
195254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
205254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
215254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
225254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
235254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
245254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
265254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
275222Sksewell@umich.edu *
285254Sksewell@umich.edu * Authors: Ali Saidi
295254Sksewell@umich.edu *          Lisa Hsu
305254Sksewell@umich.edu *          Nathan Binkert
315222Sksewell@umich.edu */
325222Sksewell@umich.edu
335222Sksewell@umich.edu#ifndef __ARCH_MIPS_LINUX_SYSTEM_HH__
345222Sksewell@umich.edu#define __ARCH_MIPS_LINUX_SYSTEM_HH__
355222Sksewell@umich.edu
365222Sksewell@umich.educlass ThreadContext;
375222Sksewell@umich.edu
385222Sksewell@umich.educlass BreakPCEvent;
395222Sksewell@umich.educlass IdleStartEvent;
405222Sksewell@umich.edu
415222Sksewell@umich.edu#include "arch/mips/idle_event.hh"
425222Sksewell@umich.edu#include "arch/mips/system.hh"
435222Sksewell@umich.edu#include "kern/linux/events.hh"
445222Sksewell@umich.edu#include "params/LinuxMipsSystem.hh"
455222Sksewell@umich.edu
465222Sksewell@umich.eduusing namespace MipsISA;
475222Sksewell@umich.eduusing namespace Linux;
485222Sksewell@umich.edu
495222Sksewell@umich.edu/**
505222Sksewell@umich.edu * This class contains linux specific system code (Loading, Events).
515222Sksewell@umich.edu * It points to objects that are the system binaries to load and patches them
525222Sksewell@umich.edu * appropriately to work in simulator.
535222Sksewell@umich.edu */
545222Sksewell@umich.educlass LinuxMipsSystem : public MipsSystem
555222Sksewell@umich.edu{
565222Sksewell@umich.edu  private:
575222Sksewell@umich.edu    class SkipDelayLoopEvent : public SkipFuncEvent
585222Sksewell@umich.edu    {
595222Sksewell@umich.edu      public:
605222Sksewell@umich.edu        SkipDelayLoopEvent(PCEventQueue *q, const std::string &desc, Addr addr)
615222Sksewell@umich.edu            : SkipFuncEvent(q, desc, addr) {}
625222Sksewell@umich.edu        virtual void process(ThreadContext *tc);
635222Sksewell@umich.edu    };
645222Sksewell@umich.edu
655222Sksewell@umich.edu    class PrintThreadInfo : public PCEvent
665222Sksewell@umich.edu    {
675222Sksewell@umich.edu      public:
685222Sksewell@umich.edu        PrintThreadInfo(PCEventQueue *q, const std::string &desc, Addr addr)
695222Sksewell@umich.edu            : PCEvent(q, desc, addr) {}
705222Sksewell@umich.edu        virtual void process(ThreadContext *tc);
715222Sksewell@umich.edu    };
725222Sksewell@umich.edu
735222Sksewell@umich.edu
745222Sksewell@umich.edu    /**
755222Sksewell@umich.edu     * Addresses defining where the kernel bootloader places various
765222Sksewell@umich.edu     * elements.  Details found in include/asm-mips/system.h
775222Sksewell@umich.edu     */
785222Sksewell@umich.edu    Addr KernelStart; // Lookup the symbol swapper_pg_dir
795222Sksewell@umich.edu
805222Sksewell@umich.edu  public:
815222Sksewell@umich.edu    Addr InitStack() const { return KernelStart + 0x02000; }
825222Sksewell@umich.edu    Addr EmptyPGT() const  { return KernelStart + 0x04000; }
835222Sksewell@umich.edu    Addr EmptyPGE() const  { return KernelStart + 0x08000; }
845222Sksewell@umich.edu    Addr ZeroPGE() const   { return KernelStart + 0x0A000; }
855222Sksewell@umich.edu    Addr StartAddr() const { return KernelStart + 0x10000; }
865222Sksewell@umich.edu
875222Sksewell@umich.edu    Addr Param() const { return ZeroPGE() + 0x0; }
885222Sksewell@umich.edu    Addr CommandLine() const { return Param() + 0x0; }
895222Sksewell@umich.edu    Addr InitrdStart() const { return Param() + 0x100; }
905222Sksewell@umich.edu    Addr InitrdSize() const { return Param() + 0x108; }
915222Sksewell@umich.edu    static const int CommandLineSize = 256;
925222Sksewell@umich.edu
935222Sksewell@umich.edu  private:
945222Sksewell@umich.edu#ifndef NDEBUG
955222Sksewell@umich.edu    /** Event to halt the simulator if the kernel calls panic()  */
965222Sksewell@umich.edu    BreakPCEvent *kernelPanicEvent;
975222Sksewell@umich.edu
985222Sksewell@umich.edu    /** Event to halt the simulator if the kernel calls die_if_kernel  */
995222Sksewell@umich.edu    BreakPCEvent *kernelDieEvent;
1005222Sksewell@umich.edu#endif
1015222Sksewell@umich.edu
1025222Sksewell@umich.edu    /**
1035222Sksewell@umich.edu     * Event to skip determine_cpu_caches() because we don't support
1045222Sksewell@umich.edu     * the IPRs that the code can access to figure out cache sizes
1055222Sksewell@umich.edu     */
1065222Sksewell@umich.edu    SkipFuncEvent *skipCacheProbeEvent;
1075222Sksewell@umich.edu
1085222Sksewell@umich.edu    /** PC based event to skip the ide_delay_50ms() call */
1095222Sksewell@umich.edu    SkipFuncEvent *skipIdeDelay50msEvent;
1105222Sksewell@umich.edu
1115222Sksewell@umich.edu    /**
1125222Sksewell@umich.edu     * PC based event to skip the dprink() call and emulate its
1135222Sksewell@umich.edu     * functionality
1145222Sksewell@umich.edu     */
1155222Sksewell@umich.edu    DebugPrintkEvent *debugPrintkEvent;
1165222Sksewell@umich.edu
1175222Sksewell@umich.edu    /**
1185222Sksewell@umich.edu     * Skip calculate_delay_loop() rather than waiting for this to be
1195222Sksewell@umich.edu     * calculated
1205222Sksewell@umich.edu     */
1215222Sksewell@umich.edu    SkipDelayLoopEvent *skipDelayLoopEvent;
1225222Sksewell@umich.edu
1235222Sksewell@umich.edu    /**
1245222Sksewell@umich.edu     * Event to print information about thread switches if the trace flag
1255222Sksewell@umich.edu     * Thread is set
1265222Sksewell@umich.edu     */
1275222Sksewell@umich.edu    PrintThreadInfo *printThreadEvent;
1285222Sksewell@umich.edu
1295222Sksewell@umich.edu    /** Grab the PCBB of the idle process when it starts */
1305222Sksewell@umich.edu    IdleStartEvent *idleStartEvent;
1315222Sksewell@umich.edu
1325222Sksewell@umich.edu  public:
1335222Sksewell@umich.edu    typedef LinuxMipsSystemParams Params;
1345222Sksewell@umich.edu    LinuxMipsSystem(Params *p);
1355222Sksewell@umich.edu    ~LinuxMipsSystem();
1365222Sksewell@umich.edu
1375222Sksewell@umich.edu    void setDelayLoop(ThreadContext *tc);
1385222Sksewell@umich.edu};
1395222Sksewell@umich.edu
1405222Sksewell@umich.edu#endif // __ARCH_MIPS_LINUX_SYSTEM_HH__
141