isa_traits.hh revision 6974
12023SN/A/*
25268Sksewell@umich.edu * Copyright (c) 2003-2005 The Regents of The University of Michigan
35254Sksewell@umich.edu * Copyright (c) 2007 MIPS Technologies, Inc.
45254Sksewell@umich.edu * All rights reserved.
52023SN/A *
65254Sksewell@umich.edu * Redistribution and use in source and binary forms, with or without
75254Sksewell@umich.edu * modification, are permitted provided that the following conditions are
85254Sksewell@umich.edu * met: redistributions of source code must retain the above copyright
95254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer;
105254Sksewell@umich.edu * redistributions in binary form must reproduce the above copyright
115254Sksewell@umich.edu * notice, this list of conditions and the following disclaimer in the
125254Sksewell@umich.edu * documentation and/or other materials provided with the distribution;
135254Sksewell@umich.edu * neither the name of the copyright holders nor the names of its
145254Sksewell@umich.edu * contributors may be used to endorse or promote products derived from
155254Sksewell@umich.edu * this software without specific prior written permission.
162023SN/A *
175254Sksewell@umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
185254Sksewell@umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
195254Sksewell@umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
205254Sksewell@umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
215254Sksewell@umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
225254Sksewell@umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
235254Sksewell@umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
245254Sksewell@umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
255254Sksewell@umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
265254Sksewell@umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
275254Sksewell@umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
282665Ssaidi@eecs.umich.edu *
295254Sksewell@umich.edu * Authors: Gabe Black
305254Sksewell@umich.edu *          Korey Sewell
315222Sksewell@umich.edu *          Jaidev Patwardhan
322023SN/A */
332023SN/A
342028SN/A#ifndef __ARCH_MIPS_ISA_TRAITS_HH__
352028SN/A#define __ARCH_MIPS_ISA_TRAITS_HH__
362023SN/A
372597SN/A#include "arch/mips/types.hh"
385254Sksewell@umich.edu#include "arch/mips/mips_core_specific.hh"
396216Snate@binkert.org#include "base/types.hh"
405222Sksewell@umich.edu#include "config/full_system.hh"
412023SN/A
422239SN/Anamespace LittleEndianGuest {};
432239SN/A
442131SN/Aclass StaticInstPtr;
452023SN/A
462131SN/Anamespace MipsISA
472023SN/A{
482525SN/A
496378Sgblack@eecs.umich.eduusing namespace LittleEndianGuest;
502023SN/A
516378Sgblack@eecs.umich.eduStaticInstPtr decodeInst(ExtMachInst);
523093Sksewell@umich.edu
536378Sgblack@eecs.umich.edu// MIPS DOES have a delay slot
546378Sgblack@eecs.umich.edu#define ISA_HAS_DELAY_SLOT 1
552239SN/A
566378Sgblack@eecs.umich.educonst Addr PageShift = 13;
576378Sgblack@eecs.umich.educonst Addr PageBytes = ULL(1) << PageShift;
586378Sgblack@eecs.umich.educonst Addr Page_Mask = ~(PageBytes - 1);
596378Sgblack@eecs.umich.educonst Addr PageOffset = PageBytes - 1;
605222Sksewell@umich.edu
615222Sksewell@umich.edu
626378Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////
636378Sgblack@eecs.umich.edu//
646378Sgblack@eecs.umich.edu//  Translation stuff
656378Sgblack@eecs.umich.edu//
665222Sksewell@umich.edu
676378Sgblack@eecs.umich.educonst Addr PteShift = 3;
686378Sgblack@eecs.umich.educonst Addr NPtePageShift = PageShift - PteShift;
696378Sgblack@eecs.umich.educonst Addr NPtePage = ULL(1) << NPtePageShift;
706378Sgblack@eecs.umich.educonst Addr PteMask = NPtePage - 1;
715222Sksewell@umich.edu
726378Sgblack@eecs.umich.edu//// All 'Mapped' segments go through the TLB
736378Sgblack@eecs.umich.edu//// All other segments are translated by dropping the MSB, to give
746378Sgblack@eecs.umich.edu//// the corresponding physical address
756378Sgblack@eecs.umich.edu// User Segment - Mapped
766378Sgblack@eecs.umich.educonst Addr USegBase = ULL(0x0);
776378Sgblack@eecs.umich.educonst Addr USegEnd = ULL(0x7FFFFFFF);
785222Sksewell@umich.edu
796378Sgblack@eecs.umich.edu// Kernel Segment 0 - Unmapped
806378Sgblack@eecs.umich.educonst Addr KSeg0End = ULL(0x9FFFFFFF);
816378Sgblack@eecs.umich.educonst Addr KSeg0Base =  ULL(0x80000000);
826378Sgblack@eecs.umich.educonst Addr KSeg0Mask = ULL(0x1FFFFFFF);
835222Sksewell@umich.edu
846378Sgblack@eecs.umich.edu// Kernel Segment 1 - Unmapped, Uncached
856378Sgblack@eecs.umich.educonst Addr KSeg1End = ULL(0xBFFFFFFF);
866378Sgblack@eecs.umich.educonst Addr KSeg1Base = ULL(0xA0000000);
876378Sgblack@eecs.umich.educonst Addr KSeg1Mask = ULL(0x1FFFFFFF);
885222Sksewell@umich.edu
896378Sgblack@eecs.umich.edu// Kernel/Supervisor Segment - Mapped
906378Sgblack@eecs.umich.educonst Addr KSSegEnd = ULL(0xDFFFFFFF);
916378Sgblack@eecs.umich.educonst Addr KSSegBase = ULL(0xC0000000);
925222Sksewell@umich.edu
936378Sgblack@eecs.umich.edu// Kernel Segment 3 - Mapped
946378Sgblack@eecs.umich.educonst Addr KSeg3End = ULL(0xFFFFFFFF);
956378Sgblack@eecs.umich.educonst Addr KSeg3Base = ULL(0xE0000000);
965222Sksewell@umich.edu
975222Sksewell@umich.edu
986378Sgblack@eecs.umich.edu// For loading... XXX This maybe could be USegEnd?? --ali
996378Sgblack@eecs.umich.educonst Addr LoadAddrMask = ULL(0xffffffffff);
1005222Sksewell@umich.edu
1016378Sgblack@eecs.umich.eduinline Addr Phys2K0Seg(Addr addr)
1026378Sgblack@eecs.umich.edu{
1036378Sgblack@eecs.umich.edu    return addr | KSeg0Base;
1046378Sgblack@eecs.umich.edu}
1055254Sksewell@umich.edu
1065254Sksewell@umich.edu
1076378Sgblack@eecs.umich.educonst unsigned VABits = 32;
1086378Sgblack@eecs.umich.educonst unsigned PABits = 32; // Is this correct?
1096378Sgblack@eecs.umich.educonst Addr VAddrImplMask = (ULL(1) << VABits) - 1;
1106378Sgblack@eecs.umich.educonst Addr VAddrUnImplMask = ~VAddrImplMask;
1116378Sgblack@eecs.umich.eduinline Addr VAddrImpl(Addr a) { return a & VAddrImplMask; }
1126378Sgblack@eecs.umich.eduinline Addr VAddrVPN(Addr a) { return a >> MipsISA::PageShift; }
1136378Sgblack@eecs.umich.eduinline Addr VAddrOffset(Addr a) { return a & MipsISA::PageOffset; }
1145254Sksewell@umich.edu
1156378Sgblack@eecs.umich.educonst Addr PAddrImplMask = (ULL(1) << PABits) - 1;
1165222Sksewell@umich.edu
1176378Sgblack@eecs.umich.edu////////////////////////////////////////////////////////////////////////
1186378Sgblack@eecs.umich.edu//
1196378Sgblack@eecs.umich.edu//  Interrupt levels
1206378Sgblack@eecs.umich.edu//
1216378Sgblack@eecs.umich.eduenum InterruptLevels
1226378Sgblack@eecs.umich.edu{
1236378Sgblack@eecs.umich.edu    INTLEVEL_SOFTWARE_MIN = 4,
1246378Sgblack@eecs.umich.edu    INTLEVEL_SOFTWARE_MAX = 19,
1255222Sksewell@umich.edu
1266378Sgblack@eecs.umich.edu    INTLEVEL_EXTERNAL_MIN = 20,
1276378Sgblack@eecs.umich.edu    INTLEVEL_EXTERNAL_MAX = 34,
1285222Sksewell@umich.edu
1296378Sgblack@eecs.umich.edu    INTLEVEL_IRQ0 = 20,
1306378Sgblack@eecs.umich.edu    INTLEVEL_IRQ1 = 21,
1316378Sgblack@eecs.umich.edu    INTINDEX_ETHERNET = 0,
1326378Sgblack@eecs.umich.edu    INTINDEX_SCSI = 1,
1336378Sgblack@eecs.umich.edu    INTLEVEL_IRQ2 = 22,
1346378Sgblack@eecs.umich.edu    INTLEVEL_IRQ3 = 23,
1355222Sksewell@umich.edu
1366378Sgblack@eecs.umich.edu    INTLEVEL_SERIAL = 33,
1375222Sksewell@umich.edu
1386378Sgblack@eecs.umich.edu    NumInterruptLevels = INTLEVEL_EXTERNAL_MAX
1396378Sgblack@eecs.umich.edu};
1405222Sksewell@umich.edu
1416378Sgblack@eecs.umich.edu// MIPS modes
1426378Sgblack@eecs.umich.eduenum mode_type
1436378Sgblack@eecs.umich.edu{
1446378Sgblack@eecs.umich.edu    mode_kernel = 0,        // kernel
1456378Sgblack@eecs.umich.edu    mode_supervisor = 1,    // supervisor
1466378Sgblack@eecs.umich.edu    mode_user = 2,          // user mode
1476378Sgblack@eecs.umich.edu    mode_debug = 3,         // debug mode
1486378Sgblack@eecs.umich.edu    mode_number             // number of modes
1496378Sgblack@eecs.umich.edu};
1502131SN/A
1516378Sgblack@eecs.umich.edu// return a no-op instruction... used for instruction fetch faults
1526378Sgblack@eecs.umich.educonst ExtMachInst NoopMachInst = 0x00000000;
1532131SN/A
1546378Sgblack@eecs.umich.educonst int LogVMPageSize = 13;       // 8K bytes
1556378Sgblack@eecs.umich.educonst int VMPageSize = (1 << LogVMPageSize);
1562131SN/A
1576378Sgblack@eecs.umich.educonst int BranchPredAddrShiftAmt = 2; // instructions are 4-byte aligned
1582131SN/A
1596378Sgblack@eecs.umich.educonst int MachineBytes = 4;
1606378Sgblack@eecs.umich.educonst int WordBytes = 4;
1616378Sgblack@eecs.umich.educonst int HalfwordBytes = 2;
1626378Sgblack@eecs.umich.educonst int ByteBytes = 1;
1636378Sgblack@eecs.umich.edu
1646378Sgblack@eecs.umich.educonst int ANNOTE_NONE = 0;
1656378Sgblack@eecs.umich.educonst uint32_t ITOUCH_ANNOTE = 0xffffffff;
1666378Sgblack@eecs.umich.edu
1676974Stjones1@inf.ed.ac.uk// Memory accesses cannot be unaligned
1686974Stjones1@inf.ed.ac.ukconst bool HasUnalignedMemAcc = false;
1696974Stjones1@inf.ed.ac.uk
1702023SN/A};
1712023SN/A
1722028SN/A#endif // __ARCH_MIPS_ISA_TRAITS_HH__
173