system.hh revision 5222
1/* 2 * Copyright .AN) 2007 MIPS Technologies, Inc. All Rights Reserved 3 * 4 * This software is part of the M5 simulator. 5 * 6 * THIS IS A LEGAL AGREEMENT. BY DOWNLOADING, USING, COPYING, CREATING 7 * DERIVATIVE WORKS, AND/OR DISTRIBUTING THIS SOFTWARE YOU ARE AGREEING 8 * TO THESE TERMS AND CONDITIONS. 9 * 10 * Permission is granted to use, copy, create derivative works and 11 * distribute this software and such derivative works for any purpose, 12 * so long as (1) the copyright notice above, this grant of permission, 13 * and the disclaimer below appear in all copies and derivative works 14 * made, (2) the copyright notice above is augmented as appropriate to 15 * reflect the addition of any new copyrightable work in a derivative 16 * work (e.g., Copyright .AN) <Publication Year> Copyright Owner), and (3) 17 * the name of MIPS Technologies, Inc. ($B!H(BMIPS$B!I(B) is not used in any 18 * advertising or publicity pertaining to the use or distribution of 19 * this software without specific, written prior authorization. 20 * 21 * THIS SOFTWARE IS PROVIDED $B!H(BAS IS.$B!I(B MIPS MAKES NO WARRANTIES AND 22 * DISCLAIMS ALL WARRANTIES, WHETHER EXPRESS, STATUTORY, IMPLIED OR 23 * OTHERWISE, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 25 * NON-INFRINGEMENT OF THIRD PARTY RIGHTS, REGARDING THIS SOFTWARE. 26 * IN NO EVENT SHALL MIPS BE LIABLE FOR ANY DAMAGES, INCLUDING DIRECT, 27 * INDIRECT, INCIDENTAL, CONSEQUENTIAL, SPECIAL, OR PUNITIVE DAMAGES OF 28 * ANY KIND OR NATURE, ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT, 29 * THIS SOFTWARE AND/OR THE USE OF THIS SOFTWARE, WHETHER SUCH LIABILITY 30 * IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE OR 31 * STRICT LIABILITY), OR OTHERWISE, EVEN IF MIPS HAS BEEN WARNED OF THE 32 * POSSIBILITY OF ANY SUCH LOSS OR DAMAGE IN ADVANCE. 33 * 34 * Authors: Ali G. Saidi 35 * Lisa R. Hsu 36 * Nathan L. Binkert 37 */ 38 39#ifndef __ARCH_MIPS_LINUX_SYSTEM_HH__ 40#define __ARCH_MIPS_LINUX_SYSTEM_HH__ 41 42class ThreadContext; 43 44class BreakPCEvent; 45class IdleStartEvent; 46 47#include "arch/mips/idle_event.hh" 48#include "arch/mips/system.hh" 49#include "kern/linux/events.hh" 50#include "params/LinuxMipsSystem.hh" 51 52using namespace MipsISA; 53using namespace Linux; 54 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