isa.hh revision 13114
16313Sgblack@eecs.umich.edu/*
26313Sgblack@eecs.umich.edu * Copyright (c) 2009 The Regents of The University of Michigan
36313Sgblack@eecs.umich.edu * All rights reserved.
46313Sgblack@eecs.umich.edu *
56313Sgblack@eecs.umich.edu * Redistribution and use in source and binary forms, with or without
66313Sgblack@eecs.umich.edu * modification, are permitted provided that the following conditions are
76313Sgblack@eecs.umich.edu * met: redistributions of source code must retain the above copyright
86313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer;
96313Sgblack@eecs.umich.edu * redistributions in binary form must reproduce the above copyright
106313Sgblack@eecs.umich.edu * notice, this list of conditions and the following disclaimer in the
116313Sgblack@eecs.umich.edu * documentation and/or other materials provided with the distribution;
126313Sgblack@eecs.umich.edu * neither the name of the copyright holders nor the names of its
136313Sgblack@eecs.umich.edu * contributors may be used to endorse or promote products derived from
146313Sgblack@eecs.umich.edu * this software without specific prior written permission.
156313Sgblack@eecs.umich.edu *
166313Sgblack@eecs.umich.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
176313Sgblack@eecs.umich.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
186313Sgblack@eecs.umich.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
196313Sgblack@eecs.umich.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
206313Sgblack@eecs.umich.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
216313Sgblack@eecs.umich.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
226313Sgblack@eecs.umich.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
236313Sgblack@eecs.umich.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
246313Sgblack@eecs.umich.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
256313Sgblack@eecs.umich.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
266313Sgblack@eecs.umich.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
276313Sgblack@eecs.umich.edu *
286313Sgblack@eecs.umich.edu * Authors: Gabe Black
296313Sgblack@eecs.umich.edu */
306313Sgblack@eecs.umich.edu
316313Sgblack@eecs.umich.edu#ifndef __ARCH_X86_ISA_HH__
326313Sgblack@eecs.umich.edu#define __ARCH_X86_ISA_HH__
336313Sgblack@eecs.umich.edu
348229Snate@binkert.org#include <iostream>
358229Snate@binkert.org#include <string>
368229Snate@binkert.org
377629Sgblack@eecs.umich.edu#include "arch/x86/regs/float.hh"
387629Sgblack@eecs.umich.edu#include "arch/x86/regs/misc.hh"
398229Snate@binkert.org#include "arch/x86/registers.hh"
406336Sgblack@eecs.umich.edu#include "base/types.hh"
4112106SRekai.GonzalezAlberquilla@arm.com#include "cpu/reg_class.hh"
429384SAndreas.Sandberg@arm.com#include "sim/sim_object.hh"
436336Sgblack@eecs.umich.edu
446313Sgblack@eecs.umich.educlass Checkpoint;
456313Sgblack@eecs.umich.educlass EventManager;
466336Sgblack@eecs.umich.educlass ThreadContext;
479384SAndreas.Sandberg@arm.comstruct X86ISAParams;
486313Sgblack@eecs.umich.edu
496313Sgblack@eecs.umich.edunamespace X86ISA
506313Sgblack@eecs.umich.edu{
519384SAndreas.Sandberg@arm.com    class ISA : public SimObject
526313Sgblack@eecs.umich.edu    {
536313Sgblack@eecs.umich.edu      protected:
546336Sgblack@eecs.umich.edu        MiscReg regVal[NUM_MISCREGS];
556336Sgblack@eecs.umich.edu        void updateHandyM5Reg(Efer efer, CR0 cr0,
569376Sgblack@eecs.umich.edu                SegAttr csAttr, SegAttr ssAttr, RFLAGS rflags,
579376Sgblack@eecs.umich.edu                ThreadContext *tc);
586313Sgblack@eecs.umich.edu
596313Sgblack@eecs.umich.edu      public:
609384SAndreas.Sandberg@arm.com        typedef X86ISAParams Params;
619384SAndreas.Sandberg@arm.com
626313Sgblack@eecs.umich.edu        void clear();
636313Sgblack@eecs.umich.edu
649384SAndreas.Sandberg@arm.com        ISA(Params *p);
659384SAndreas.Sandberg@arm.com        const Params *params() const;
666336Sgblack@eecs.umich.edu
6710698Sandreas.hansson@arm.com        MiscReg readMiscRegNoEffect(int miscReg) const;
686313Sgblack@eecs.umich.edu        MiscReg readMiscReg(int miscReg, ThreadContext *tc);
696313Sgblack@eecs.umich.edu
706336Sgblack@eecs.umich.edu        void setMiscRegNoEffect(int miscReg, MiscReg val);
716336Sgblack@eecs.umich.edu        void setMiscReg(int miscReg, MiscReg val, ThreadContext *tc);
726313Sgblack@eecs.umich.edu
7312106SRekai.GonzalezAlberquilla@arm.com        RegId
7412106SRekai.GonzalezAlberquilla@arm.com        flattenRegId(const RegId& regId) const
7512106SRekai.GonzalezAlberquilla@arm.com        {
7612106SRekai.GonzalezAlberquilla@arm.com            switch (regId.classValue()) {
7712106SRekai.GonzalezAlberquilla@arm.com              case IntRegClass:
7812106SRekai.GonzalezAlberquilla@arm.com                return RegId(IntRegClass, flattenIntIndex(regId.index()));
7912106SRekai.GonzalezAlberquilla@arm.com              case FloatRegClass:
8012106SRekai.GonzalezAlberquilla@arm.com                return RegId(FloatRegClass, flattenFloatIndex(regId.index()));
8112106SRekai.GonzalezAlberquilla@arm.com              case CCRegClass:
8212106SRekai.GonzalezAlberquilla@arm.com                return RegId(CCRegClass, flattenCCIndex(regId.index()));
8312106SRekai.GonzalezAlberquilla@arm.com              case MiscRegClass:
8412106SRekai.GonzalezAlberquilla@arm.com                return RegId(MiscRegClass, flattenMiscIndex(regId.index()));
8512109SRekai.GonzalezAlberquilla@arm.com              default:
8612109SRekai.GonzalezAlberquilla@arm.com                break;
8712106SRekai.GonzalezAlberquilla@arm.com            }
8812106SRekai.GonzalezAlberquilla@arm.com            return regId;
8912106SRekai.GonzalezAlberquilla@arm.com        }
9012106SRekai.GonzalezAlberquilla@arm.com
916359Sgblack@eecs.umich.edu        int
9210035Sandreas.hansson@arm.com        flattenIntIndex(int reg) const
936359Sgblack@eecs.umich.edu        {
946361Sgblack@eecs.umich.edu            return reg & ~IntFoldBit;
956359Sgblack@eecs.umich.edu        }
966359Sgblack@eecs.umich.edu
976359Sgblack@eecs.umich.edu        int
9810035Sandreas.hansson@arm.com        flattenFloatIndex(int reg) const
996359Sgblack@eecs.umich.edu        {
1006359Sgblack@eecs.umich.edu            if (reg >= NUM_FLOATREGS) {
1016359Sgblack@eecs.umich.edu                reg = FLOATREG_STACK(reg - NUM_FLOATREGS,
1026359Sgblack@eecs.umich.edu                                     regVal[MISCREG_X87_TOP]);
1036359Sgblack@eecs.umich.edu            }
1046359Sgblack@eecs.umich.edu            return reg;
1056359Sgblack@eecs.umich.edu        }
1066313Sgblack@eecs.umich.edu
1079920Syasuko.eckert@amd.com        int
10812109SRekai.GonzalezAlberquilla@arm.com        flattenVecIndex(int reg) const
10912109SRekai.GonzalezAlberquilla@arm.com        {
11012109SRekai.GonzalezAlberquilla@arm.com            return reg;
11112109SRekai.GonzalezAlberquilla@arm.com        }
11212109SRekai.GonzalezAlberquilla@arm.com
11312109SRekai.GonzalezAlberquilla@arm.com        int
11412109SRekai.GonzalezAlberquilla@arm.com        flattenVecElemIndex(int reg) const
11512109SRekai.GonzalezAlberquilla@arm.com        {
11612109SRekai.GonzalezAlberquilla@arm.com            return reg;
11712109SRekai.GonzalezAlberquilla@arm.com        }
11812109SRekai.GonzalezAlberquilla@arm.com
11912109SRekai.GonzalezAlberquilla@arm.com        int
12010035Sandreas.hansson@arm.com        flattenCCIndex(int reg) const
1219920Syasuko.eckert@amd.com        {
1229920Syasuko.eckert@amd.com            return reg;
1239920Syasuko.eckert@amd.com        }
1249920Syasuko.eckert@amd.com
12510033SAli.Saidi@ARM.com        int
12610035Sandreas.hansson@arm.com        flattenMiscIndex(int reg) const
12710033SAli.Saidi@ARM.com        {
12810033SAli.Saidi@ARM.com            return reg;
12910033SAli.Saidi@ARM.com        }
13010033SAli.Saidi@ARM.com
13111168Sandreas.hansson@arm.com        void serialize(CheckpointOut &cp) const override;
13211168Sandreas.hansson@arm.com        void unserialize(CheckpointIn &cp) override;
13310905Sandreas.sandberg@arm.com
1349461Snilay@cs.wisc.edu        void startup(ThreadContext *tc);
1359553Sandreas.hansson@arm.com
1369553Sandreas.hansson@arm.com        /// Explicitly import the otherwise hidden startup
1379553Sandreas.hansson@arm.com        using SimObject::startup;
1389553Sandreas.hansson@arm.com
1396313Sgblack@eecs.umich.edu    };
1406313Sgblack@eecs.umich.edu}
1416313Sgblack@eecs.umich.edu
1426313Sgblack@eecs.umich.edu#endif
143