system.hh revision 9557
19651SAndreas.Sandberg@ARM.com/*
29651SAndreas.Sandberg@ARM.com * Copyright (c) 2004-2006 The Regents of The University of Michigan
39651SAndreas.Sandberg@ARM.com * All rights reserved.
49651SAndreas.Sandberg@ARM.com *
59651SAndreas.Sandberg@ARM.com * Redistribution and use in source and binary forms, with or without
69651SAndreas.Sandberg@ARM.com * modification, are permitted provided that the following conditions are
79651SAndreas.Sandberg@ARM.com * met: redistributions of source code must retain the above copyright
89651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer;
99651SAndreas.Sandberg@ARM.com * redistributions in binary form must reproduce the above copyright
109651SAndreas.Sandberg@ARM.com * notice, this list of conditions and the following disclaimer in the
119651SAndreas.Sandberg@ARM.com * documentation and/or other materials provided with the distribution;
129651SAndreas.Sandberg@ARM.com * neither the name of the copyright holders nor the names of its
139651SAndreas.Sandberg@ARM.com * contributors may be used to endorse or promote products derived from
149651SAndreas.Sandberg@ARM.com * this software without specific prior written permission.
159651SAndreas.Sandberg@ARM.com *
169651SAndreas.Sandberg@ARM.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
179651SAndreas.Sandberg@ARM.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
189651SAndreas.Sandberg@ARM.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
199651SAndreas.Sandberg@ARM.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
209651SAndreas.Sandberg@ARM.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
219651SAndreas.Sandberg@ARM.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
229651SAndreas.Sandberg@ARM.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
239651SAndreas.Sandberg@ARM.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
249651SAndreas.Sandberg@ARM.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
259651SAndreas.Sandberg@ARM.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
269651SAndreas.Sandberg@ARM.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
279651SAndreas.Sandberg@ARM.com *
289651SAndreas.Sandberg@ARM.com * Authors: Ali Saidi
299651SAndreas.Sandberg@ARM.com *          Lisa Hsu
309651SAndreas.Sandberg@ARM.com *          Nathan Binkert
319651SAndreas.Sandberg@ARM.com */
329651SAndreas.Sandberg@ARM.com
339651SAndreas.Sandberg@ARM.com#ifndef __ARCH_ALPHA_LINUX_SYSTEM_HH__
349651SAndreas.Sandberg@ARM.com#define __ARCH_ALPHA_LINUX_SYSTEM_HH__
359651SAndreas.Sandberg@ARM.com
369651SAndreas.Sandberg@ARM.comclass ThreadContext;
379651SAndreas.Sandberg@ARM.com
389651SAndreas.Sandberg@ARM.comclass BreakPCEvent;
399651SAndreas.Sandberg@ARM.comclass IdleStartEvent;
409651SAndreas.Sandberg@ARM.com
419651SAndreas.Sandberg@ARM.com#include "arch/alpha/idle_event.hh"
429651SAndreas.Sandberg@ARM.com#include "arch/alpha/system.hh"
439651SAndreas.Sandberg@ARM.com#include "kern/linux/events.hh"
449651SAndreas.Sandberg@ARM.com#include "params/LinuxAlphaSystem.hh"
459651SAndreas.Sandberg@ARM.com
469651SAndreas.Sandberg@ARM.com/**
479651SAndreas.Sandberg@ARM.com * This class contains linux specific system code (Loading, Events).
489651SAndreas.Sandberg@ARM.com * It points to objects that are the system binaries to load and patches them
499760Sandreas@sandberg.pp.se * appropriately to work in simulator.
509651SAndreas.Sandberg@ARM.com */
519651SAndreas.Sandberg@ARM.comclass LinuxAlphaSystem : public AlphaSystem
529683Sandreas@sandberg.pp.se{
539753Sandreas@sandberg.pp.se  private:
549651SAndreas.Sandberg@ARM.com    struct SkipDelayLoopEvent : public SkipFuncEvent
559651SAndreas.Sandberg@ARM.com    {
569651SAndreas.Sandberg@ARM.com        SkipDelayLoopEvent(PCEventQueue *q, const std::string &desc, Addr addr)
579651SAndreas.Sandberg@ARM.com            : SkipFuncEvent(q, desc, addr) {}
589651SAndreas.Sandberg@ARM.com        virtual void process(ThreadContext *tc);
599651SAndreas.Sandberg@ARM.com    };
609651SAndreas.Sandberg@ARM.com
619753Sandreas@sandberg.pp.se    struct PrintThreadInfo : public PCEvent
629753Sandreas@sandberg.pp.se    {
639651SAndreas.Sandberg@ARM.com        PrintThreadInfo(PCEventQueue *q, const std::string &desc, Addr addr)
649651SAndreas.Sandberg@ARM.com            : PCEvent(q, desc, addr) {}
659651SAndreas.Sandberg@ARM.com        virtual void process(ThreadContext *tc);
669651SAndreas.Sandberg@ARM.com    };
679651SAndreas.Sandberg@ARM.com
689651SAndreas.Sandberg@ARM.com    /**
699651SAndreas.Sandberg@ARM.com     * Addresses defining where the kernel bootloader places various
709651SAndreas.Sandberg@ARM.com     * elements.  Details found in include/asm-alpha/system.h
719651SAndreas.Sandberg@ARM.com     */
729651SAndreas.Sandberg@ARM.com    Addr KernelStart; // Lookup the symbol swapper_pg_dir
739651SAndreas.Sandberg@ARM.com
749652SAndreas.Sandberg@ARM.com  public:
759652SAndreas.Sandberg@ARM.com    Addr InitStack() const { return KernelStart + 0x02000; }
769651SAndreas.Sandberg@ARM.com    Addr EmptyPGT() const  { return KernelStart + 0x04000; }
779651SAndreas.Sandberg@ARM.com    Addr EmptyPGE() const  { return KernelStart + 0x08000; }
789651SAndreas.Sandberg@ARM.com    Addr ZeroPGE() const   { return KernelStart + 0x0A000; }
799651SAndreas.Sandberg@ARM.com    Addr StartAddr() const { return KernelStart + 0x10000; }
809892Sandreas@sandberg.pp.se
819655SAndreas.Sandberg@ARM.com    Addr Param() const { return ZeroPGE() + 0x0; }
829754Sandreas@sandberg.pp.se    Addr CommandLine() const { return Param() + 0x0; }
839752Sandreas@sandberg.pp.se    Addr InitrdStart() const { return Param() + 0x100; }
849753Sandreas@sandberg.pp.se    Addr InitrdSize() const { return Param() + 0x108; }
859752Sandreas@sandberg.pp.se    static const int CommandLineSize = 256;
869651SAndreas.Sandberg@ARM.com
879651SAndreas.Sandberg@ARM.com  private:
889651SAndreas.Sandberg@ARM.com#ifndef NDEBUG
899651SAndreas.Sandberg@ARM.com    /** Event to halt the simulator if the kernel calls panic()  */
909651SAndreas.Sandberg@ARM.com    BreakPCEvent *kernelPanicEvent;
919651SAndreas.Sandberg@ARM.com
929651SAndreas.Sandberg@ARM.com#if 0
939651SAndreas.Sandberg@ARM.com    /** Event to halt the simulator if the kernel calls die_if_kernel  */
949651SAndreas.Sandberg@ARM.com    BreakPCEvent *kernelDieEvent;
959651SAndreas.Sandberg@ARM.com#endif
969651SAndreas.Sandberg@ARM.com
979651SAndreas.Sandberg@ARM.com#endif
989651SAndreas.Sandberg@ARM.com
999655SAndreas.Sandberg@ARM.com    /**
1009655SAndreas.Sandberg@ARM.com     * Event to skip determine_cpu_caches() because we don't support
1019655SAndreas.Sandberg@ARM.com     * the IPRs that the code can access to figure out cache sizes
1029655SAndreas.Sandberg@ARM.com     */
1039754Sandreas@sandberg.pp.se    SkipFuncEvent *skipCacheProbeEvent;
1049655SAndreas.Sandberg@ARM.com
1059655SAndreas.Sandberg@ARM.com    /** PC based event to skip the ide_delay_50ms() call */
1069655SAndreas.Sandberg@ARM.com    SkipFuncEvent *skipIdeDelay50msEvent;
1079754Sandreas@sandberg.pp.se
1089651SAndreas.Sandberg@ARM.com    /**
1099651SAndreas.Sandberg@ARM.com     * PC based event to skip the dprink() call and emulate its
1109651SAndreas.Sandberg@ARM.com     * functionality
1119651SAndreas.Sandberg@ARM.com     */
1129651SAndreas.Sandberg@ARM.com    Linux::DebugPrintkEvent *debugPrintkEvent;
1139651SAndreas.Sandberg@ARM.com
1149651SAndreas.Sandberg@ARM.com    /**
1159651SAndreas.Sandberg@ARM.com     * Skip calculate_delay_loop() rather than waiting for this to be
1169651SAndreas.Sandberg@ARM.com     * calculated
1179651SAndreas.Sandberg@ARM.com     */
1189651SAndreas.Sandberg@ARM.com    SkipDelayLoopEvent *skipDelayLoopEvent;
1199651SAndreas.Sandberg@ARM.com
1209651SAndreas.Sandberg@ARM.com    /**
1219651SAndreas.Sandberg@ARM.com     * Event to print information about thread switches if the trace flag
1229651SAndreas.Sandberg@ARM.com     * Thread is set
1239651SAndreas.Sandberg@ARM.com     */
1249651SAndreas.Sandberg@ARM.com    PrintThreadInfo *printThreadEvent;
1259651SAndreas.Sandberg@ARM.com
1269651SAndreas.Sandberg@ARM.com    /** Grab the PCBB of the idle process when it starts */
1279651SAndreas.Sandberg@ARM.com    IdleStartEvent *idleStartEvent;
1289651SAndreas.Sandberg@ARM.com
1299651SAndreas.Sandberg@ARM.com  protected:
1309651SAndreas.Sandberg@ARM.com    /** Setup all the function events. Must be done after init() for Alpha since
1319651SAndreas.Sandberg@ARM.com     * fixFuncEvent() requires a function port
1329651SAndreas.Sandberg@ARM.com     */
1339651SAndreas.Sandberg@ARM.com    virtual void setupFuncEvents();
1349651SAndreas.Sandberg@ARM.com
1359651SAndreas.Sandberg@ARM.com  public:
1369651SAndreas.Sandberg@ARM.com    typedef LinuxAlphaSystemParams Params;
1379690Sandreas@sandberg.pp.se    LinuxAlphaSystem(Params *p);
1389690Sandreas@sandberg.pp.se    ~LinuxAlphaSystem();
1399690Sandreas@sandberg.pp.se
1409651SAndreas.Sandberg@ARM.com    /**
1419651SAndreas.Sandberg@ARM.com     * Initialise the system
1429651SAndreas.Sandberg@ARM.com     */
1439651SAndreas.Sandberg@ARM.com    virtual void initState();
1449651SAndreas.Sandberg@ARM.com
1459651SAndreas.Sandberg@ARM.com    void setDelayLoop(ThreadContext *tc);
1469651SAndreas.Sandberg@ARM.com
1479651SAndreas.Sandberg@ARM.com    const Params *params() const { return (const Params *)_params; }
1489651SAndreas.Sandberg@ARM.com};
1499651SAndreas.Sandberg@ARM.com
1509651SAndreas.Sandberg@ARM.com#endif // __ARCH_ALPHA_LINUX_SYSTEM_HH__
1519651SAndreas.Sandberg@ARM.com