isa.hh revision 13173
12SN/A/*
21762SN/A * Copyright (c) 2009 The Regents of The University of Michigan
32SN/A * All rights reserved.
42SN/A *
52SN/A * Redistribution and use in source and binary forms, with or without
62SN/A * modification, are permitted provided that the following conditions are
72SN/A * met: redistributions of source code must retain the above copyright
82SN/A * notice, this list of conditions and the following disclaimer;
92SN/A * redistributions in binary form must reproduce the above copyright
102SN/A * notice, this list of conditions and the following disclaimer in the
112SN/A * documentation and/or other materials provided with the distribution;
122SN/A * neither the name of the copyright holders nor the names of its
132SN/A * contributors may be used to endorse or promote products derived from
142SN/A * this software without specific prior written permission.
152SN/A *
162SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
172SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
182SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
192SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
202SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
212SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
222SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
232SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
242SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
252SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
262SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
272665Ssaidi@eecs.umich.edu *
282665Ssaidi@eecs.umich.edu * Authors: Gabe Black
292665Ssaidi@eecs.umich.edu */
302SN/A
312SN/A#ifndef __ARCH_X86_ISA_HH__
325569Snate@binkert.org#define __ARCH_X86_ISA_HH__
335569Snate@binkert.org
342SN/A#include <iostream>
352SN/A#include <string>
362SN/A
372432SN/A#include "arch/x86/regs/float.hh"
381147SN/A#include "arch/x86/regs/misc.hh"
393453Sgblack@eecs.umich.edu#include "arch/x86/registers.hh"
402984Sgblack@eecs.umich.edu#include "base/types.hh"
412984Sgblack@eecs.umich.edu#include "cpu/reg_class.hh"
421147SN/A#include "sim/sim_object.hh"
432517SN/A
446022Sgblack@eecs.umich.educlass Checkpoint;
452984Sgblack@eecs.umich.educlass EventManager;
465358Sgblack@eecs.umich.educlass ThreadContext;
472SN/Astruct X86ISAParams;
482680Sktlim@umich.edu
492SN/Anamespace X86ISA
505569Snate@binkert.org{
515569Snate@binkert.org    class ISA : public SimObject
525569Snate@binkert.org    {
535569Snate@binkert.org      protected:
545569Snate@binkert.org        MiscReg regVal[NUM_MISCREGS];
552SN/A        void updateHandyM5Reg(Efer efer, CR0 cr0,
565569Snate@binkert.org                SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags,
576022Sgblack@eecs.umich.edu                ThreadContext *tc);
586022Sgblack@eecs.umich.edu
596022Sgblack@eecs.umich.edu      public:
606022Sgblack@eecs.umich.edu        typedef X86ISAParams Params;
616022Sgblack@eecs.umich.edu
626022Sgblack@eecs.umich.edu        void clear();
636022Sgblack@eecs.umich.edu
646022Sgblack@eecs.umich.edu        ISA(Params *p);
656022Sgblack@eecs.umich.edu        const Params *params() const;
666022Sgblack@eecs.umich.edu
676022Sgblack@eecs.umich.edu        MiscReg readMiscRegNoEffect(int miscReg) const;
686022Sgblack@eecs.umich.edu        MiscReg readMiscReg(int miscReg, ThreadContext *tc);
696022Sgblack@eecs.umich.edu
706022Sgblack@eecs.umich.edu        void setMiscRegNoEffect(int miscReg, MiscReg val);
716022Sgblack@eecs.umich.edu        void setMiscReg(int miscReg, MiscReg val, ThreadContext *tc);
726022Sgblack@eecs.umich.edu
736022Sgblack@eecs.umich.edu        RegId
746022Sgblack@eecs.umich.edu        flattenRegId(const RegId& regId) const
755569Snate@binkert.org        {
765569Snate@binkert.org            switch (regId.classValue()) {
772SN/A              case IntRegClass:
785569Snate@binkert.org                return RegId(IntRegClass, flattenIntIndex(regId.index()));
795569Snate@binkert.org              case FloatRegClass:
805569Snate@binkert.org                return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
815569Snate@binkert.org              case CCRegClass:
825569Snate@binkert.org                return RegId(CCRegClass, flattenCCIndex(regId.index()));
835569Snate@binkert.org              case MiscRegClass:
845569Snate@binkert.org                return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
855569Snate@binkert.org              default:
865569Snate@binkert.org                break;
875569Snate@binkert.org            }
885569Snate@binkert.org            return regId;
895569Snate@binkert.org        }
906022Sgblack@eecs.umich.edu
916022Sgblack@eecs.umich.edu        int
925569Snate@binkert.org        flattenIntIndex(int reg) const
935569Snate@binkert.org        {
945569Snate@binkert.org            return reg & ~IntFoldBit;
955569Snate@binkert.org        }
965569Snate@binkert.org
975569Snate@binkert.org        int
985569Snate@binkert.org        flattenFloatIndex(int reg) const
995569Snate@binkert.org        {
1005569Snate@binkert.org            if (reg >= NUM_FLOATREGS) {
1015569Snate@binkert.org                reg = FLOATREG_STACK(reg - NUM_FLOATREGS,
1025569Snate@binkert.org                                     regVal[MISCREG_X87_TOP]);
1033453Sgblack@eecs.umich.edu            }
1045569Snate@binkert.org            return reg;
1055569Snate@binkert.org        }
1065569Snate@binkert.org
1072SN/A        int
1085569Snate@binkert.org        flattenVecIndex(int reg) const
1095569Snate@binkert.org        {
1105569Snate@binkert.org            return reg;
1115569Snate@binkert.org        }
1125569Snate@binkert.org
1135569Snate@binkert.org        int
1145569Snate@binkert.org        flattenVecElemIndex(int reg) const
1155569Snate@binkert.org        {
1162SN/A            return reg;
1175569Snate@binkert.org        }
1182SN/A
1195569Snate@binkert.org        int
1205569Snate@binkert.org        flattenCCIndex(int reg) const
1215569Snate@binkert.org        {
1222SN/A            return reg;
1235569Snate@binkert.org        }
1245569Snate@binkert.org
1255569Snate@binkert.org        int
1265569Snate@binkert.org        flattenMiscIndex(int reg) const
1275569Snate@binkert.org        {
1285569Snate@binkert.org            return reg;
1295569Snate@binkert.org        }
1302SN/A
1315569Snate@binkert.org        void serialize(CheckpointOut &cp) const override;
1325569Snate@binkert.org        void unserialize(CheckpointIn &cp) override;
1335569Snate@binkert.org
1345569Snate@binkert.org        void startup(ThreadContext *tc);
1355569Snate@binkert.org
1365569Snate@binkert.org        /// Explicitly import the otherwise hidden startup
1375569Snate@binkert.org        using SimObject::startup;
1382SN/A
1395569Snate@binkert.org    };
1406022Sgblack@eecs.umich.edu}
1416022Sgblack@eecs.umich.edu
1422SN/A#endif
1435569Snate@binkert.org