misc.hh revision 9211
14684SN/A/* 25419SN/A * Copyright (c) 2007-2008 The Hewlett-Packard Development Company 34684SN/A * All rights reserved. 44684SN/A * 57087SN/A * The license below extends only to copyright in the software and shall 67087SN/A * not be construed as granting a license to any other intellectual 77087SN/A * property including but not limited to intellectual property relating 87087SN/A * to a hardware implementation of the functionality of the software 97087SN/A * licensed hereunder. You may use the software subject to the license 107087SN/A * terms below provided that you ensure that this notice is replicated 117087SN/A * unmodified and in its entirety in all distributions of the software, 127087SN/A * modified or unmodified, in source code or in binary form. 134684SN/A * 147087SN/A * Redistribution and use in source and binary forms, with or without 157087SN/A * modification, are permitted provided that the following conditions are 167087SN/A * met: redistributions of source code must retain the above copyright 177087SN/A * notice, this list of conditions and the following disclaimer; 187087SN/A * redistributions in binary form must reproduce the above copyright 197087SN/A * notice, this list of conditions and the following disclaimer in the 207087SN/A * documentation and/or other materials provided with the distribution; 217087SN/A * neither the name of the copyright holders nor the names of its 224684SN/A * contributors may be used to endorse or promote products derived from 237087SN/A * this software without specific prior written permission. 244684SN/A * 254684SN/A * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 264684SN/A * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 274684SN/A * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 284684SN/A * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 294684SN/A * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 304684SN/A * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 314684SN/A * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 324684SN/A * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 334684SN/A * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 344684SN/A * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 354684SN/A * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 364684SN/A * 374684SN/A * Authors: Gabe Black 384684SN/A */ 394684SN/A 404684SN/A#ifndef __ARCH_X86_MISCREGS_HH__ 414684SN/A#define __ARCH_X86_MISCREGS_HH__ 424684SN/A 437629Sgblack@eecs.umich.edu#include "arch/x86/regs/segment.hh" 445025SN/A#include "arch/x86/x86_traits.hh" 454684SN/A#include "base/bitunion.hh" 464684SN/A 475086SN/A//These get defined in some system headers (at least termbits.h). That confuses 485086SN/A//things here significantly. 495086SN/A#undef CR0 505086SN/A#undef CR2 515086SN/A#undef CR3 525086SN/A 534684SN/Anamespace X86ISA 544684SN/A{ 554684SN/A enum CondFlagBit { 564684SN/A CFBit = 1 << 0, 574684SN/A PFBit = 1 << 2, 584684SN/A ECFBit = 1 << 3, 594684SN/A AFBit = 1 << 4, 604684SN/A EZFBit = 1 << 5, 614684SN/A ZFBit = 1 << 6, 624684SN/A SFBit = 1 << 7, 634868SN/A DFBit = 1 << 10, 644684SN/A OFBit = 1 << 11 654684SN/A }; 664684SN/A 679010Snilay@cs.wisc.edu const uint32_t cfofMask = CFBit | OFBit; 689211Snilay@cs.wisc.edu const uint32_t ccFlagMask = PFBit | AFBit | ZFBit | SFBit; 699010Snilay@cs.wisc.edu 705426SN/A enum RFLAGBit { 715426SN/A TFBit = 1 << 8, 725426SN/A IFBit = 1 << 9, 735426SN/A NTBit = 1 << 14, 745426SN/A RFBit = 1 << 16, 755426SN/A VMBit = 1 << 17, 765426SN/A ACBit = 1 << 18, 775426SN/A VIFBit = 1 << 19, 785426SN/A VIPBit = 1 << 20, 795426SN/A IDBit = 1 << 21 805426SN/A }; 815426SN/A 824700SN/A enum MiscRegIndex 834700SN/A { 844700SN/A // Control registers 854700SN/A // Most of these are invalid. 864862SN/A MISCREG_CR_BASE, 874862SN/A MISCREG_CR0 = MISCREG_CR_BASE, 884700SN/A MISCREG_CR1, 894700SN/A MISCREG_CR2, 904700SN/A MISCREG_CR3, 914700SN/A MISCREG_CR4, 924700SN/A MISCREG_CR5, 934700SN/A MISCREG_CR6, 944700SN/A MISCREG_CR7, 954700SN/A MISCREG_CR8, 964700SN/A MISCREG_CR9, 974700SN/A MISCREG_CR10, 984700SN/A MISCREG_CR11, 994700SN/A MISCREG_CR12, 1004700SN/A MISCREG_CR13, 1014700SN/A MISCREG_CR14, 1024700SN/A MISCREG_CR15, 1034700SN/A 1044700SN/A // Debug registers 1055025SN/A MISCREG_DR_BASE = MISCREG_CR_BASE + NumCRegs, 1064862SN/A MISCREG_DR0 = MISCREG_DR_BASE, 1074700SN/A MISCREG_DR1, 1084700SN/A MISCREG_DR2, 1094700SN/A MISCREG_DR3, 1104700SN/A MISCREG_DR4, 1114700SN/A MISCREG_DR5, 1124700SN/A MISCREG_DR6, 1134700SN/A MISCREG_DR7, 1144700SN/A 1154700SN/A // Flags register 1165025SN/A MISCREG_RFLAGS = MISCREG_DR_BASE + NumDRegs, 1174700SN/A 1185429SN/A //Register to keep handy values like the CPU mode in. 1195429SN/A MISCREG_M5_REG, 1205429SN/A 1215138SN/A /* 1225138SN/A * Model Specific Registers 1235138SN/A */ 1245138SN/A // Time stamp counter 1255138SN/A MISCREG_TSC, 1265138SN/A 1275138SN/A MISCREG_MTRRCAP, 1285138SN/A 1295138SN/A MISCREG_SYSENTER_CS, 1305138SN/A MISCREG_SYSENTER_ESP, 1315138SN/A MISCREG_SYSENTER_EIP, 1325138SN/A 1335138SN/A MISCREG_MCG_CAP, 1345138SN/A MISCREG_MCG_STATUS, 1355138SN/A MISCREG_MCG_CTL, 1365138SN/A 1375138SN/A MISCREG_DEBUG_CTL_MSR, 1385138SN/A 1395138SN/A MISCREG_LAST_BRANCH_FROM_IP, 1405138SN/A MISCREG_LAST_BRANCH_TO_IP, 1415138SN/A MISCREG_LAST_EXCEPTION_FROM_IP, 1425138SN/A MISCREG_LAST_EXCEPTION_TO_IP, 1435138SN/A 1445138SN/A MISCREG_MTRR_PHYS_BASE_BASE, 1455138SN/A MISCREG_MTRR_PHYS_BASE_0 = MISCREG_MTRR_PHYS_BASE_BASE, 1465138SN/A MISCREG_MTRR_PHYS_BASE_1, 1475138SN/A MISCREG_MTRR_PHYS_BASE_2, 1485138SN/A MISCREG_MTRR_PHYS_BASE_3, 1495138SN/A MISCREG_MTRR_PHYS_BASE_4, 1505138SN/A MISCREG_MTRR_PHYS_BASE_5, 1515138SN/A MISCREG_MTRR_PHYS_BASE_6, 1525138SN/A MISCREG_MTRR_PHYS_BASE_7, 1536346SN/A MISCREG_MTRR_PHYS_BASE_END, 1545138SN/A 1556346SN/A MISCREG_MTRR_PHYS_MASK_BASE = MISCREG_MTRR_PHYS_BASE_END, 1565138SN/A MISCREG_MTRR_PHYS_MASK_0 = MISCREG_MTRR_PHYS_MASK_BASE, 1575138SN/A MISCREG_MTRR_PHYS_MASK_1, 1585138SN/A MISCREG_MTRR_PHYS_MASK_2, 1595138SN/A MISCREG_MTRR_PHYS_MASK_3, 1605138SN/A MISCREG_MTRR_PHYS_MASK_4, 1615138SN/A MISCREG_MTRR_PHYS_MASK_5, 1625138SN/A MISCREG_MTRR_PHYS_MASK_6, 1635138SN/A MISCREG_MTRR_PHYS_MASK_7, 1646346SN/A MISCREG_MTRR_PHYS_MASK_END, 1655138SN/A 1666346SN/A MISCREG_MTRR_FIX_64K_00000 = MISCREG_MTRR_PHYS_MASK_END, 1675138SN/A MISCREG_MTRR_FIX_16K_80000, 1685138SN/A MISCREG_MTRR_FIX_16K_A0000, 1695138SN/A MISCREG_MTRR_FIX_4K_C0000, 1705149SN/A MISCREG_MTRR_FIX_4K_C8000, 1715138SN/A MISCREG_MTRR_FIX_4K_D0000, 1725138SN/A MISCREG_MTRR_FIX_4K_D8000, 1735138SN/A MISCREG_MTRR_FIX_4K_E0000, 1745138SN/A MISCREG_MTRR_FIX_4K_E8000, 1755138SN/A MISCREG_MTRR_FIX_4K_F0000, 1765138SN/A MISCREG_MTRR_FIX_4K_F8000, 1775138SN/A 1785138SN/A MISCREG_PAT, 1795138SN/A 1805138SN/A MISCREG_DEF_TYPE, 1815138SN/A 1825138SN/A MISCREG_MC_CTL_BASE, 1835138SN/A MISCREG_MC0_CTL = MISCREG_MC_CTL_BASE, 1845138SN/A MISCREG_MC1_CTL, 1855138SN/A MISCREG_MC2_CTL, 1865138SN/A MISCREG_MC3_CTL, 1875138SN/A MISCREG_MC4_CTL, 1885419SN/A MISCREG_MC5_CTL, 1895419SN/A MISCREG_MC6_CTL, 1905419SN/A MISCREG_MC7_CTL, 1916346SN/A MISCREG_MC_CTL_END, 1925138SN/A 1936346SN/A MISCREG_MC_STATUS_BASE = MISCREG_MC_CTL_END, 1945138SN/A MISCREG_MC0_STATUS = MISCREG_MC_STATUS_BASE, 1955138SN/A MISCREG_MC1_STATUS, 1965138SN/A MISCREG_MC2_STATUS, 1975138SN/A MISCREG_MC3_STATUS, 1985138SN/A MISCREG_MC4_STATUS, 1995419SN/A MISCREG_MC5_STATUS, 2005419SN/A MISCREG_MC6_STATUS, 2015419SN/A MISCREG_MC7_STATUS, 2026346SN/A MISCREG_MC_STATUS_END, 2035138SN/A 2046346SN/A MISCREG_MC_ADDR_BASE = MISCREG_MC_STATUS_END, 2055138SN/A MISCREG_MC0_ADDR = MISCREG_MC_ADDR_BASE, 2065138SN/A MISCREG_MC1_ADDR, 2075138SN/A MISCREG_MC2_ADDR, 2085138SN/A MISCREG_MC3_ADDR, 2095138SN/A MISCREG_MC4_ADDR, 2105419SN/A MISCREG_MC5_ADDR, 2115419SN/A MISCREG_MC6_ADDR, 2125419SN/A MISCREG_MC7_ADDR, 2136346SN/A MISCREG_MC_ADDR_END, 2145138SN/A 2156346SN/A MISCREG_MC_MISC_BASE = MISCREG_MC_ADDR_END, 2165138SN/A MISCREG_MC0_MISC = MISCREG_MC_MISC_BASE, 2175138SN/A MISCREG_MC1_MISC, 2185138SN/A MISCREG_MC2_MISC, 2195138SN/A MISCREG_MC3_MISC, 2205138SN/A MISCREG_MC4_MISC, 2215419SN/A MISCREG_MC5_MISC, 2225419SN/A MISCREG_MC6_MISC, 2235419SN/A MISCREG_MC7_MISC, 2246346SN/A MISCREG_MC_MISC_END, 2255138SN/A 2265135SN/A // Extended feature enable register 2276346SN/A MISCREG_EFER = MISCREG_MC_MISC_END, 2285135SN/A 2295138SN/A MISCREG_STAR, 2305138SN/A MISCREG_LSTAR, 2315138SN/A MISCREG_CSTAR, 2325138SN/A 2335138SN/A MISCREG_SF_MASK, 2345138SN/A 2355138SN/A MISCREG_KERNEL_GS_BASE, 2365138SN/A 2375138SN/A MISCREG_TSC_AUX, 2385138SN/A 2395138SN/A MISCREG_PERF_EVT_SEL_BASE, 2405138SN/A MISCREG_PERF_EVT_SEL0 = MISCREG_PERF_EVT_SEL_BASE, 2415138SN/A MISCREG_PERF_EVT_SEL1, 2425138SN/A MISCREG_PERF_EVT_SEL2, 2435138SN/A MISCREG_PERF_EVT_SEL3, 2446346SN/A MISCREG_PERF_EVT_SEL_END, 2455138SN/A 2466346SN/A MISCREG_PERF_EVT_CTR_BASE = MISCREG_PERF_EVT_SEL_END, 2475138SN/A MISCREG_PERF_EVT_CTR0 = MISCREG_PERF_EVT_CTR_BASE, 2485138SN/A MISCREG_PERF_EVT_CTR1, 2495138SN/A MISCREG_PERF_EVT_CTR2, 2505138SN/A MISCREG_PERF_EVT_CTR3, 2516346SN/A MISCREG_PERF_EVT_CTR_END, 2525138SN/A 2536346SN/A MISCREG_SYSCFG = MISCREG_PERF_EVT_CTR_END, 2545138SN/A 2555138SN/A MISCREG_IORR_BASE_BASE, 2565138SN/A MISCREG_IORR_BASE0 = MISCREG_IORR_BASE_BASE, 2575138SN/A MISCREG_IORR_BASE1, 2586346SN/A MISCREG_IORR_BASE_END, 2595138SN/A 2606346SN/A MISCREG_IORR_MASK_BASE = MISCREG_IORR_BASE_END, 2615138SN/A MISCREG_IORR_MASK0 = MISCREG_IORR_MASK_BASE, 2625138SN/A MISCREG_IORR_MASK1, 2636346SN/A MISCREG_IORR_MASK_END, 2645138SN/A 2656346SN/A MISCREG_TOP_MEM = MISCREG_IORR_MASK_END, 2665138SN/A MISCREG_TOP_MEM2, 2675138SN/A 2685138SN/A MISCREG_VM_CR, 2695138SN/A MISCREG_IGNNE, 2705138SN/A MISCREG_SMM_CTL, 2715138SN/A MISCREG_VM_HSAVE_PA, 2725138SN/A 2735138SN/A /* 2745138SN/A * Segment registers 2755138SN/A */ 2764700SN/A // Segment selectors 2774862SN/A MISCREG_SEG_SEL_BASE, 2784862SN/A MISCREG_ES = MISCREG_SEG_SEL_BASE, 2794700SN/A MISCREG_CS, 2804700SN/A MISCREG_SS, 2814700SN/A MISCREG_DS, 2824700SN/A MISCREG_FS, 2834700SN/A MISCREG_GS, 2845294SN/A MISCREG_HS, 2855294SN/A MISCREG_TSL, 2865294SN/A MISCREG_TSG, 2875294SN/A MISCREG_LS, 2885294SN/A MISCREG_MS, 2895294SN/A MISCREG_TR, 2905294SN/A MISCREG_IDTR, 2914700SN/A 2924700SN/A // Hidden segment base field 2935294SN/A MISCREG_SEG_BASE_BASE = MISCREG_SEG_SEL_BASE + NUM_SEGMENTREGS, 2944862SN/A MISCREG_ES_BASE = MISCREG_SEG_BASE_BASE, 2954700SN/A MISCREG_CS_BASE, 2964700SN/A MISCREG_SS_BASE, 2974700SN/A MISCREG_DS_BASE, 2984700SN/A MISCREG_FS_BASE, 2994700SN/A MISCREG_GS_BASE, 3005294SN/A MISCREG_HS_BASE, 3015294SN/A MISCREG_TSL_BASE, 3025294SN/A MISCREG_TSG_BASE, 3035294SN/A MISCREG_LS_BASE, 3045294SN/A MISCREG_MS_BASE, 3055294SN/A MISCREG_TR_BASE, 3065294SN/A MISCREG_IDTR_BASE, 3074700SN/A 3085289SN/A // The effective segment base, ie what is actually added to an 3095289SN/A // address. In 64 bit mode this can be different from the above, 3105289SN/A // namely 0. 3115294SN/A MISCREG_SEG_EFF_BASE_BASE = MISCREG_SEG_BASE_BASE + NUM_SEGMENTREGS, 3125289SN/A MISCREG_ES_EFF_BASE = MISCREG_SEG_EFF_BASE_BASE, 3135289SN/A MISCREG_CS_EFF_BASE, 3145289SN/A MISCREG_SS_EFF_BASE, 3155289SN/A MISCREG_DS_EFF_BASE, 3165289SN/A MISCREG_FS_EFF_BASE, 3175289SN/A MISCREG_GS_EFF_BASE, 3185294SN/A MISCREG_HS_EFF_BASE, 3195294SN/A MISCREG_TSL_EFF_BASE, 3205294SN/A MISCREG_TSG_EFF_BASE, 3215294SN/A MISCREG_LS_EFF_BASE, 3225294SN/A MISCREG_MS_EFF_BASE, 3235294SN/A MISCREG_TR_EFF_BASE, 3245294SN/A MISCREG_IDTR_EFF_BASE, 3255289SN/A 3264700SN/A // Hidden segment limit field 3275294SN/A MISCREG_SEG_LIMIT_BASE = MISCREG_SEG_EFF_BASE_BASE + NUM_SEGMENTREGS, 3284862SN/A MISCREG_ES_LIMIT = MISCREG_SEG_LIMIT_BASE, 3294700SN/A MISCREG_CS_LIMIT, 3304700SN/A MISCREG_SS_LIMIT, 3314700SN/A MISCREG_DS_LIMIT, 3324700SN/A MISCREG_FS_LIMIT, 3334700SN/A MISCREG_GS_LIMIT, 3345294SN/A MISCREG_HS_LIMIT, 3355294SN/A MISCREG_TSL_LIMIT, 3365294SN/A MISCREG_TSG_LIMIT, 3375294SN/A MISCREG_LS_LIMIT, 3385294SN/A MISCREG_MS_LIMIT, 3395294SN/A MISCREG_TR_LIMIT, 3405294SN/A MISCREG_IDTR_LIMIT, 3414700SN/A 3424700SN/A // Hidden segment limit attributes 3435294SN/A MISCREG_SEG_ATTR_BASE = MISCREG_SEG_LIMIT_BASE + NUM_SEGMENTREGS, 3444862SN/A MISCREG_ES_ATTR = MISCREG_SEG_ATTR_BASE, 3454700SN/A MISCREG_CS_ATTR, 3464700SN/A MISCREG_SS_ATTR, 3474700SN/A MISCREG_DS_ATTR, 3484700SN/A MISCREG_FS_ATTR, 3494700SN/A MISCREG_GS_ATTR, 3505294SN/A MISCREG_HS_ATTR, 3515294SN/A MISCREG_TSL_ATTR, 3525294SN/A MISCREG_TSG_ATTR, 3535294SN/A MISCREG_LS_ATTR, 3545294SN/A MISCREG_MS_ATTR, 3554700SN/A MISCREG_TR_ATTR, 3565294SN/A MISCREG_IDTR_ATTR, 3574700SN/A 3585082SN/A // Floating point control registers 3595294SN/A MISCREG_X87_TOP = 3605294SN/A MISCREG_SEG_ATTR_BASE + NUM_SEGMENTREGS, 3615082SN/A 3626362SN/A MISCREG_MXCSR, 3636362SN/A MISCREG_FCW, 3646362SN/A MISCREG_FSW, 3656362SN/A MISCREG_FTW, 3666362SN/A MISCREG_FTAG, 3676362SN/A MISCREG_FISEG, 3686362SN/A MISCREG_FIOFF, 3696362SN/A MISCREG_FOSEG, 3706362SN/A MISCREG_FOOFF, 3716362SN/A MISCREG_FOP, 3726362SN/A 3734700SN/A //XXX Add "Model-Specific Registers" 3744700SN/A 3755360SN/A MISCREG_APIC_BASE, 3765360SN/A 3775360SN/A // "Fake" MSRs for internally implemented devices 3785357SN/A MISCREG_PCI_CONFIG_ADDRESS, 3795357SN/A 3805082SN/A NUM_MISCREGS 3814700SN/A }; 3824700SN/A 3835025SN/A static inline MiscRegIndex 3845025SN/A MISCREG_CR(int index) 3855025SN/A { 3866346SN/A assert(index >= 0 && index < NumCRegs); 3875025SN/A return (MiscRegIndex)(MISCREG_CR_BASE + index); 3885025SN/A } 3895025SN/A 3905025SN/A static inline MiscRegIndex 3915025SN/A MISCREG_DR(int index) 3925025SN/A { 3936346SN/A assert(index >= 0 && index < NumDRegs); 3945025SN/A return (MiscRegIndex)(MISCREG_DR_BASE + index); 3955025SN/A } 3965025SN/A 3975025SN/A static inline MiscRegIndex 3985138SN/A MISCREG_MTRR_PHYS_BASE(int index) 3995138SN/A { 4006346SN/A assert(index >= 0 && index < (MISCREG_MTRR_PHYS_BASE_END - 4016346SN/A MISCREG_MTRR_PHYS_BASE_BASE)); 4025138SN/A return (MiscRegIndex)(MISCREG_MTRR_PHYS_BASE_BASE + index); 4035138SN/A } 4045138SN/A 4055138SN/A static inline MiscRegIndex 4065138SN/A MISCREG_MTRR_PHYS_MASK(int index) 4075138SN/A { 4086346SN/A assert(index >= 0 && index < (MISCREG_MTRR_PHYS_MASK_END - 4096346SN/A MISCREG_MTRR_PHYS_MASK_BASE)); 4105138SN/A return (MiscRegIndex)(MISCREG_MTRR_PHYS_MASK_BASE + index); 4115138SN/A } 4125138SN/A 4135138SN/A static inline MiscRegIndex 4145138SN/A MISCREG_MC_CTL(int index) 4155138SN/A { 4166346SN/A assert(index >= 0 && index < (MISCREG_MC_CTL_END - 4176346SN/A MISCREG_MC_CTL_BASE)); 4185138SN/A return (MiscRegIndex)(MISCREG_MC_CTL_BASE + index); 4195138SN/A } 4205138SN/A 4215138SN/A static inline MiscRegIndex 4225138SN/A MISCREG_MC_STATUS(int index) 4235138SN/A { 4246346SN/A assert(index >= 0 && index < (MISCREG_MC_STATUS_END - 4256346SN/A MISCREG_MC_STATUS_BASE)); 4265138SN/A return (MiscRegIndex)(MISCREG_MC_STATUS_BASE + index); 4275138SN/A } 4285138SN/A 4295138SN/A static inline MiscRegIndex 4305138SN/A MISCREG_MC_ADDR(int index) 4315138SN/A { 4326346SN/A assert(index >= 0 && index < (MISCREG_MC_ADDR_END - 4336346SN/A MISCREG_MC_ADDR_BASE)); 4345138SN/A return (MiscRegIndex)(MISCREG_MC_ADDR_BASE + index); 4355138SN/A } 4365138SN/A 4375138SN/A static inline MiscRegIndex 4385138SN/A MISCREG_MC_MISC(int index) 4395138SN/A { 4406346SN/A assert(index >= 0 && index < (MISCREG_MC_MISC_END - 4416346SN/A MISCREG_MC_MISC_BASE)); 4425138SN/A return (MiscRegIndex)(MISCREG_MC_MISC_BASE + index); 4435138SN/A } 4445138SN/A 4455138SN/A static inline MiscRegIndex 4465138SN/A MISCREG_PERF_EVT_SEL(int index) 4475138SN/A { 4486346SN/A assert(index >= 0 && index < (MISCREG_PERF_EVT_SEL_END - 4496346SN/A MISCREG_PERF_EVT_SEL_BASE)); 4505138SN/A return (MiscRegIndex)(MISCREG_PERF_EVT_SEL_BASE + index); 4515138SN/A } 4525138SN/A 4535138SN/A static inline MiscRegIndex 4545138SN/A MISCREG_PERF_EVT_CTR(int index) 4555138SN/A { 4566346SN/A assert(index >= 0 && index < (MISCREG_PERF_EVT_CTR_END - 4576346SN/A MISCREG_PERF_EVT_CTR_BASE)); 4585138SN/A return (MiscRegIndex)(MISCREG_PERF_EVT_CTR_BASE + index); 4595138SN/A } 4605138SN/A 4615138SN/A static inline MiscRegIndex 4625138SN/A MISCREG_IORR_BASE(int index) 4635138SN/A { 4646346SN/A assert(index >= 0 && index < (MISCREG_IORR_BASE_END - 4656346SN/A MISCREG_IORR_BASE_BASE)); 4665138SN/A return (MiscRegIndex)(MISCREG_IORR_BASE_BASE + index); 4675138SN/A } 4685138SN/A 4695138SN/A static inline MiscRegIndex 4705138SN/A MISCREG_IORR_MASK(int index) 4715138SN/A { 4726346SN/A assert(index >= 0 && index < (MISCREG_IORR_MASK_END - 4736346SN/A MISCREG_IORR_MASK_BASE)); 4745138SN/A return (MiscRegIndex)(MISCREG_IORR_MASK_BASE + index); 4755138SN/A } 4765138SN/A 4775138SN/A static inline MiscRegIndex 4785025SN/A MISCREG_SEG_SEL(int index) 4795025SN/A { 4806346SN/A assert(index >= 0 && index < NUM_SEGMENTREGS); 4815025SN/A return (MiscRegIndex)(MISCREG_SEG_SEL_BASE + index); 4825025SN/A } 4835025SN/A 4845025SN/A static inline MiscRegIndex 4855025SN/A MISCREG_SEG_BASE(int index) 4865025SN/A { 4876346SN/A assert(index >= 0 && index < NUM_SEGMENTREGS); 4885025SN/A return (MiscRegIndex)(MISCREG_SEG_BASE_BASE + index); 4895025SN/A } 4905025SN/A 4915025SN/A static inline MiscRegIndex 4925289SN/A MISCREG_SEG_EFF_BASE(int index) 4935289SN/A { 4946346SN/A assert(index >= 0 && index < NUM_SEGMENTREGS); 4955289SN/A return (MiscRegIndex)(MISCREG_SEG_EFF_BASE_BASE + index); 4965289SN/A } 4975289SN/A 4985289SN/A static inline MiscRegIndex 4995025SN/A MISCREG_SEG_LIMIT(int index) 5005025SN/A { 5016346SN/A assert(index >= 0 && index < NUM_SEGMENTREGS); 5025025SN/A return (MiscRegIndex)(MISCREG_SEG_LIMIT_BASE + index); 5035025SN/A } 5045025SN/A 5055025SN/A static inline MiscRegIndex 5065025SN/A MISCREG_SEG_ATTR(int index) 5075025SN/A { 5086346SN/A assert(index >= 0 && index < NUM_SEGMENTREGS); 5095025SN/A return (MiscRegIndex)(MISCREG_SEG_ATTR_BASE + index); 5105025SN/A } 5115025SN/A 5124700SN/A /** 5134700SN/A * A type to describe the condition code bits of the RFLAGS register, 5144700SN/A * plus two flags, EZF and ECF, which are only visible to microcode. 5154700SN/A */ 5164684SN/A BitUnion64(CCFlagBits) 5175138SN/A Bitfield<11> of; 5185138SN/A Bitfield<7> sf; 5195138SN/A Bitfield<6> zf; 5205138SN/A Bitfield<5> ezf; 5215138SN/A Bitfield<4> af; 5225138SN/A Bitfield<3> ecf; 5235138SN/A Bitfield<2> pf; 5245138SN/A Bitfield<0> cf; 5254684SN/A EndBitUnion(CCFlagBits) 5264700SN/A 5274700SN/A /** 5284700SN/A * RFLAGS 5294700SN/A */ 5304700SN/A BitUnion64(RFLAGS) 5315138SN/A Bitfield<21> id; // ID Flag 5325138SN/A Bitfield<20> vip; // Virtual Interrupt Pending 5335138SN/A Bitfield<19> vif; // Virtual Interrupt Flag 5345138SN/A Bitfield<18> ac; // Alignment Check 5355138SN/A Bitfield<17> vm; // Virtual-8086 Mode 5365138SN/A Bitfield<16> rf; // Resume Flag 5375138SN/A Bitfield<14> nt; // Nested Task 5385138SN/A Bitfield<13, 12> iopl; // I/O Privilege Level 5395138SN/A Bitfield<11> of; // Overflow Flag 5405138SN/A Bitfield<10> df; // Direction Flag 5415138SN/A Bitfield<9> intf; // Interrupt Flag 5425138SN/A Bitfield<8> tf; // Trap Flag 5435138SN/A Bitfield<7> sf; // Sign Flag 5445138SN/A Bitfield<6> zf; // Zero Flag 5455138SN/A Bitfield<4> af; // Auxiliary Flag 5465138SN/A Bitfield<2> pf; // Parity Flag 5475138SN/A Bitfield<0> cf; // Carry Flag 5484700SN/A EndBitUnion(RFLAGS) 5494700SN/A 5505429SN/A BitUnion64(HandyM5Reg) 5515429SN/A Bitfield<0> mode; 5525429SN/A Bitfield<3, 1> submode; 5535429SN/A Bitfield<5, 4> cpl; 5546141SN/A Bitfield<6> paging; 5556141SN/A Bitfield<7> prot; 5566142SN/A Bitfield<9, 8> defOp; 5576142SN/A Bitfield<11, 10> altOp; 5586142SN/A Bitfield<13, 12> defAddr; 5596142SN/A Bitfield<15, 14> altAddr; 5606142SN/A Bitfield<17, 16> stack; 5615429SN/A EndBitUnion(HandyM5Reg) 5625429SN/A 5634700SN/A /** 5644700SN/A * Control registers 5654700SN/A */ 5664700SN/A BitUnion64(CR0) 5675138SN/A Bitfield<31> pg; // Paging 5685138SN/A Bitfield<30> cd; // Cache Disable 5695138SN/A Bitfield<29> nw; // Not Writethrough 5705138SN/A Bitfield<18> am; // Alignment Mask 5715138SN/A Bitfield<16> wp; // Write Protect 5725138SN/A Bitfield<5> ne; // Numeric Error 5735138SN/A Bitfield<4> et; // Extension Type 5745138SN/A Bitfield<3> ts; // Task Switched 5755138SN/A Bitfield<2> em; // Emulation 5765138SN/A Bitfield<1> mp; // Monitor Coprocessor 5775138SN/A Bitfield<0> pe; // Protection Enabled 5784700SN/A EndBitUnion(CR0) 5794700SN/A 5804700SN/A // Page Fault Virtual Address 5814700SN/A BitUnion64(CR2) 5824700SN/A Bitfield<31, 0> legacy; 5834700SN/A EndBitUnion(CR2) 5844700SN/A 5854700SN/A BitUnion64(CR3) 5865138SN/A Bitfield<51, 12> longPdtb; // Long Mode Page-Directory-Table 5874700SN/A // Base Address 5885138SN/A Bitfield<31, 12> pdtb; // Non-PAE Addressing Page-Directory-Table 5894700SN/A // Base Address 5905138SN/A Bitfield<31, 5> paePdtb; // PAE Addressing Page-Directory-Table 5914700SN/A // Base Address 5925138SN/A Bitfield<4> pcd; // Page-Level Cache Disable 5935138SN/A Bitfield<3> pwt; // Page-Level Writethrough 5944700SN/A EndBitUnion(CR3) 5954700SN/A 5964700SN/A BitUnion64(CR4) 5975138SN/A Bitfield<10> osxmmexcpt; // Operating System Unmasked 5984700SN/A // Exception Support 5995138SN/A Bitfield<9> osfxsr; // Operating System FXSave/FSRSTOR Support 6005138SN/A Bitfield<8> pce; // Performance-Monitoring Counter Enable 6015138SN/A Bitfield<7> pge; // Page-Global Enable 6025138SN/A Bitfield<6> mce; // Machine Check Enable 6035138SN/A Bitfield<5> pae; // Physical-Address Extension 6045138SN/A Bitfield<4> pse; // Page Size Extensions 6055138SN/A Bitfield<3> de; // Debugging Extensions 6065138SN/A Bitfield<2> tsd; // Time Stamp Disable 6075138SN/A Bitfield<1> pvi; // Protected-Mode Virtual Interrupts 6085138SN/A Bitfield<0> vme; // Virtual-8086 Mode Extensions 6094700SN/A EndBitUnion(CR4) 6104700SN/A 6114700SN/A BitUnion64(CR8) 6125138SN/A Bitfield<3, 0> tpr; // Task Priority Register 6135138SN/A EndBitUnion(CR8) 6145138SN/A 6155925SN/A BitUnion64(DR6) 6165925SN/A Bitfield<0> b0; 6175925SN/A Bitfield<1> b1; 6185925SN/A Bitfield<2> b2; 6195925SN/A Bitfield<3> b3; 6205925SN/A Bitfield<13> bd; 6215925SN/A Bitfield<14> bs; 6225925SN/A Bitfield<15> bt; 6235925SN/A EndBitUnion(DR6) 6245925SN/A 6255925SN/A BitUnion64(DR7) 6265925SN/A Bitfield<0> l0; 6275925SN/A Bitfield<1> g0; 6285925SN/A Bitfield<2> l1; 6295925SN/A Bitfield<3> g1; 6305925SN/A Bitfield<4> l2; 6315925SN/A Bitfield<5> g2; 6325925SN/A Bitfield<6> l3; 6335925SN/A Bitfield<7> g3; 6345925SN/A Bitfield<8> le; 6355925SN/A Bitfield<9> ge; 6365925SN/A Bitfield<13> gd; 6375925SN/A Bitfield<17, 16> rw0; 6385925SN/A Bitfield<19, 18> len0; 6395925SN/A Bitfield<21, 20> rw1; 6405925SN/A Bitfield<23, 22> len1; 6415925SN/A Bitfield<25, 24> rw2; 6425925SN/A Bitfield<27, 26> len2; 6435925SN/A Bitfield<29, 28> rw3; 6445925SN/A Bitfield<31, 30> len3; 6455925SN/A EndBitUnion(DR7) 6465925SN/A 6475138SN/A // MTRR capabilities 6485138SN/A BitUnion64(MTRRcap) 6495138SN/A Bitfield<7, 0> vcnt; // Variable-Range Register Count 6505138SN/A Bitfield<8> fix; // Fixed-Range Registers 6515138SN/A Bitfield<10> wc; // Write-Combining 6525138SN/A EndBitUnion(MTRRcap) 6535138SN/A 6545138SN/A /** 6555138SN/A * SYSENTER configuration registers 6565138SN/A */ 6575138SN/A BitUnion64(SysenterCS) 6585138SN/A Bitfield<15, 0> targetCS; 6595138SN/A EndBitUnion(SysenterCS) 6605138SN/A 6615138SN/A BitUnion64(SysenterESP) 6625138SN/A Bitfield<31, 0> targetESP; 6635138SN/A EndBitUnion(SysenterESP) 6645138SN/A 6655138SN/A BitUnion64(SysenterEIP) 6665138SN/A Bitfield<31, 0> targetEIP; 6675138SN/A EndBitUnion(SysenterEIP) 6685138SN/A 6695138SN/A /** 6705138SN/A * Global machine check registers 6715138SN/A */ 6725138SN/A BitUnion64(McgCap) 6735138SN/A Bitfield<7, 0> count; // Number of error reporting register banks 6745138SN/A Bitfield<8> MCGCP; // MCG_CTL register present. 6755138SN/A EndBitUnion(McgCap) 6765138SN/A 6775138SN/A BitUnion64(McgStatus) 6785138SN/A Bitfield<0> ripv; // Restart-IP valid 6795138SN/A Bitfield<1> eipv; // Error-IP valid 6805138SN/A Bitfield<2> mcip; // Machine check in-progress 6815138SN/A EndBitUnion(McgStatus) 6825138SN/A 6835138SN/A BitUnion64(DebugCtlMsr) 6845138SN/A Bitfield<0> lbr; // Last-branch record 6855138SN/A Bitfield<1> btf; // Branch single step 6865138SN/A Bitfield<2> pb0; // Performance monitoring pin control 0 6875138SN/A Bitfield<3> pb1; // Performance monitoring pin control 1 6885138SN/A Bitfield<4> pb2; // Performance monitoring pin control 2 6895138SN/A Bitfield<5> pb3; // Performance monitoring pin control 3 6905138SN/A /*uint64_t pb(int index) 6915138SN/A { 6925138SN/A return bits(__data, index + 2); 6935138SN/A }*/ 6945138SN/A EndBitUnion(DebugCtlMsr) 6955138SN/A 6965138SN/A BitUnion64(MtrrPhysBase) 6975138SN/A Bitfield<7, 0> type; // Default memory type 6985138SN/A Bitfield<51, 12> physbase; // Range physical base address 6995138SN/A EndBitUnion(MtrrPhysBase) 7005138SN/A 7015138SN/A BitUnion64(MtrrPhysMask) 7025138SN/A Bitfield<11> valid; // MTRR pair enable 7035138SN/A Bitfield<51, 12> physmask; // Range physical mask 7045138SN/A EndBitUnion(MtrrPhysMask) 7055138SN/A 7065138SN/A BitUnion64(MtrrFixed) 7075138SN/A /*uint64_t type(int index) 7085138SN/A { 7095138SN/A return bits(__data, index * 8 + 7, index * 8); 7105138SN/A }*/ 7115138SN/A EndBitUnion(MtrrFixed) 7125138SN/A 7135138SN/A BitUnion64(Pat) 7145138SN/A /*uint64_t pa(int index) 7155138SN/A { 7165138SN/A return bits(__data, index * 8 + 2, index * 8); 7175138SN/A }*/ 7185138SN/A EndBitUnion(Pat) 7195138SN/A 7205138SN/A BitUnion64(MtrrDefType) 7215138SN/A Bitfield<7, 0> type; // Default type 7225138SN/A Bitfield<10> fe; // Fixed range enable 7235138SN/A Bitfield<11> e; // MTRR enable 7245138SN/A EndBitUnion(MtrrDefType) 7255138SN/A 7265138SN/A /** 7275138SN/A * Machine check 7285138SN/A */ 7295138SN/A BitUnion64(McStatus) 7305138SN/A Bitfield<15,0> mcaErrorCode; 7315138SN/A Bitfield<31,16> modelSpecificCode; 7325138SN/A Bitfield<56,32> otherInfo; 7335138SN/A Bitfield<57> pcc; // Processor-context corrupt 7345138SN/A Bitfield<58> addrv; // Error-address register valid 7355138SN/A Bitfield<59> miscv; // Miscellaneous-error register valid 7365138SN/A Bitfield<60> en; // Error condition enabled 7375138SN/A Bitfield<61> uc; // Uncorrected error 7385138SN/A Bitfield<62> over; // Status register overflow 7395138SN/A Bitfield<63> val; // Valid 7405138SN/A EndBitUnion(McStatus) 7415138SN/A 7425138SN/A BitUnion64(McCtl) 7435138SN/A /*uint64_t en(int index) 7445138SN/A { 7455138SN/A return bits(__data, index); 7465138SN/A }*/ 7475138SN/A EndBitUnion(McCtl) 7485138SN/A 7495138SN/A // Extended feature enable register 7505138SN/A BitUnion64(Efer) 7515138SN/A Bitfield<0> sce; // System call extensions 7525138SN/A Bitfield<8> lme; // Long mode enable 7535138SN/A Bitfield<10> lma; // Long mode active 7545138SN/A Bitfield<11> nxe; // No-execute enable 7555138SN/A Bitfield<12> svme; // Secure virtual machine enable 7565138SN/A Bitfield<14> ffxsr; // Fast fxsave/fxrstor 7575138SN/A EndBitUnion(Efer) 7585138SN/A 7595138SN/A BitUnion64(Star) 7605138SN/A Bitfield<31,0> targetEip; 7615138SN/A Bitfield<47,32> syscallCsAndSs; 7625138SN/A Bitfield<63,48> sysretCsAndSs; 7635138SN/A EndBitUnion(Star) 7645138SN/A 7655138SN/A BitUnion64(SfMask) 7665138SN/A Bitfield<31,0> mask; 7675138SN/A EndBitUnion(SfMask) 7685138SN/A 7695138SN/A BitUnion64(PerfEvtSel) 7705138SN/A Bitfield<7,0> eventMask; 7715138SN/A Bitfield<15,8> unitMask; 7725138SN/A Bitfield<16> usr; // User mode 7735138SN/A Bitfield<17> os; // Operating-system mode 7745138SN/A Bitfield<18> e; // Edge detect 7755138SN/A Bitfield<19> pc; // Pin control 7765138SN/A Bitfield<20> intEn; // Interrupt enable 7775138SN/A Bitfield<22> en; // Counter enable 7785138SN/A Bitfield<23> inv; // Invert mask 7795138SN/A Bitfield<31,24> counterMask; 7805138SN/A EndBitUnion(PerfEvtSel) 7815138SN/A 7825138SN/A BitUnion32(Syscfg) 7835138SN/A Bitfield<18> mfde; // MtrrFixDramEn 7845138SN/A Bitfield<19> mfdm; // MtrrFixDramModEn 7855138SN/A Bitfield<20> mvdm; // MtrrVarDramEn 7865138SN/A Bitfield<21> tom2; // MtrrTom2En 7875138SN/A EndBitUnion(Syscfg) 7885138SN/A 7895138SN/A BitUnion64(IorrBase) 7905138SN/A Bitfield<3> wr; // WrMem Enable 7915138SN/A Bitfield<4> rd; // RdMem Enable 7925138SN/A Bitfield<51,12> physbase; // Range physical base address 7935138SN/A EndBitUnion(IorrBase) 7945138SN/A 7955138SN/A BitUnion64(IorrMask) 7965138SN/A Bitfield<11> v; // I/O register pair enable (valid) 7975138SN/A Bitfield<51,12> physmask; // Range physical mask 7985138SN/A EndBitUnion(IorrMask) 7995138SN/A 8005138SN/A BitUnion64(Tom) 8015138SN/A Bitfield<51,23> physAddr; // Top of memory physical address 8025138SN/A EndBitUnion(Tom) 8035138SN/A 8045138SN/A BitUnion64(VmCrMsr) 8055138SN/A Bitfield<0> dpd; 8065138SN/A Bitfield<1> rInit; 8075138SN/A Bitfield<2> disA20M; 8085138SN/A EndBitUnion(VmCrMsr) 8095138SN/A 8105138SN/A BitUnion64(IgnneMsr) 8115138SN/A Bitfield<0> ignne; 8125138SN/A EndBitUnion(IgnneMsr) 8135138SN/A 8145138SN/A BitUnion64(SmmCtlMsr) 8155138SN/A Bitfield<0> dismiss; 8165138SN/A Bitfield<1> enter; 8175138SN/A Bitfield<2> smiCycle; 8185138SN/A Bitfield<3> exit; 8195138SN/A Bitfield<4> rsmCycle; 8205138SN/A EndBitUnion(SmmCtlMsr) 8214700SN/A 8224700SN/A /** 8234700SN/A * Segment Selector 8244700SN/A */ 8254700SN/A BitUnion64(SegSelector) 8265294SN/A // The following bitfield is not defined in the ISA, but it's useful 8275294SN/A // when checking selectors in larger data types to make sure they 8285294SN/A // aren't too large. 8295294SN/A Bitfield<63, 3> esi; // Extended selector 8305138SN/A Bitfield<15, 3> si; // Selector Index 8315138SN/A Bitfield<2> ti; // Table Indicator 8325138SN/A Bitfield<1, 0> rpl; // Requestor Privilege Level 8334700SN/A EndBitUnion(SegSelector) 8344700SN/A 8354700SN/A /** 8364700SN/A * Segment Descriptors 8374700SN/A */ 8384700SN/A 8394700SN/A BitUnion64(SegDescriptor) 8404700SN/A Bitfield<63, 56> baseHigh; 8414700SN/A Bitfield<39, 16> baseLow; 8425138SN/A Bitfield<55> g; // Granularity 8435138SN/A Bitfield<54> d; // Default Operand Size 8445138SN/A Bitfield<54> b; // Default Operand Size 8455138SN/A Bitfield<53> l; // Long Attribute Bit 8465138SN/A Bitfield<52> avl; // Available To Software 8474700SN/A Bitfield<51, 48> limitHigh; 8484700SN/A Bitfield<15, 0> limitLow; 8495138SN/A Bitfield<47> p; // Present 8505138SN/A Bitfield<46, 45> dpl; // Descriptor Privilege-Level 8515138SN/A Bitfield<44> s; // System 8524700SN/A SubBitUnion(type, 43, 40) 8534700SN/A // Specifies whether this descriptor is for code or data. 8544700SN/A Bitfield<43> codeOrData; 8554700SN/A 8564700SN/A // These bit fields are for code segments 8575138SN/A Bitfield<42> c; // Conforming 8585138SN/A Bitfield<41> r; // Readable 8594700SN/A 8604700SN/A // These bit fields are for data segments 8615138SN/A Bitfield<42> e; // Expand-Down 8625138SN/A Bitfield<41> w; // Writable 8634700SN/A 8644700SN/A // This is used for both code and data segments. 8655138SN/A Bitfield<40> a; // Accessed 8664700SN/A EndSubBitUnion(type) 8674700SN/A EndBitUnion(SegDescriptor) 8684700SN/A 8695138SN/A BitUnion64(SegAttr) 8706222SN/A Bitfield<1, 0> dpl; 8716222SN/A Bitfield<2> unusable; 8726222SN/A Bitfield<3> defaultSize; 8736222SN/A Bitfield<4> longMode; 8746222SN/A Bitfield<5> avl; 8756222SN/A Bitfield<6> granularity; 8766222SN/A Bitfield<7> present; 8776222SN/A Bitfield<11, 8> type; 8786222SN/A Bitfield<12> writable; 8796222SN/A Bitfield<13> readable; 8806222SN/A Bitfield<14> expandDown; 8816222SN/A Bitfield<15> system; 8825138SN/A EndBitUnion(SegAttr) 8835138SN/A 8844700SN/A BitUnion64(GateDescriptor) 8854700SN/A Bitfield<63, 48> offsetHigh; // Target Code-Segment Offset 8864700SN/A Bitfield<15, 0> offsetLow; // Target Code-Segment Offset 8874700SN/A Bitfield<31, 16> selector; // Target Code-Segment Selector 8885138SN/A Bitfield<47> p; // Present 8895138SN/A Bitfield<46, 45> dpl; // Descriptor Privilege-Level 8904700SN/A Bitfield<43, 40> type; 8914700SN/A Bitfield<36, 32> count; // Parameter Count 8924700SN/A EndBitUnion(GateDescriptor) 8934700SN/A 8944700SN/A /** 8954700SN/A * Descriptor-Table Registers 8964700SN/A */ 8974700SN/A BitUnion64(GDTR) 8984700SN/A EndBitUnion(GDTR) 8994700SN/A 9004700SN/A BitUnion64(IDTR) 9014700SN/A EndBitUnion(IDTR) 9024700SN/A 9034700SN/A BitUnion64(LDTR) 9044700SN/A EndBitUnion(LDTR) 9054700SN/A 9064700SN/A /** 9074700SN/A * Task Register 9084700SN/A */ 9094700SN/A BitUnion64(TR) 9104700SN/A EndBitUnion(TR) 9115360SN/A 9125360SN/A 9135360SN/A /** 9145360SN/A * Local APIC Base Register 9155360SN/A */ 9165360SN/A BitUnion64(LocalApicBase) 9175360SN/A Bitfield<51, 12> base; 9185360SN/A Bitfield<11> enable; 9195360SN/A Bitfield<8> bsp; 9205360SN/A EndBitUnion(LocalApicBase) 9218902Sandreas.hansson@arm.com} 9224684SN/A 9234684SN/A#endif // __ARCH_X86_INTREGS_HH__ 924