registers.hh revision 13759
111723Sar4jc@virginia.edu/* 211723Sar4jc@virginia.edu * Copyright (c) 2013 ARM Limited 311723Sar4jc@virginia.edu * Copyright (c) 2014-2015 Sven Karlsson 411723Sar4jc@virginia.edu * All rights reserved 511723Sar4jc@virginia.edu * 611723Sar4jc@virginia.edu * The license below extends only to copyright in the software and shall 711723Sar4jc@virginia.edu * not be construed as granting a license to any other intellectual 811723Sar4jc@virginia.edu * property including but not limited to intellectual property relating 911723Sar4jc@virginia.edu * to a hardware implementation of the functionality of the software 1011723Sar4jc@virginia.edu * licensed hereunder. You may use the software subject to the license 1111723Sar4jc@virginia.edu * terms below provided that you ensure that this notice is replicated 1211723Sar4jc@virginia.edu * unmodified and in its entirety in all distributions of the software, 1311723Sar4jc@virginia.edu * modified or unmodified, in source code or in binary form. 1411723Sar4jc@virginia.edu * 1511723Sar4jc@virginia.edu * Copyright (c) 2016 RISC-V Foundation 1611723Sar4jc@virginia.edu * Copyright (c) 2016 The University of Virginia 1711723Sar4jc@virginia.edu * All rights reserved. 1811723Sar4jc@virginia.edu * 1911723Sar4jc@virginia.edu * Redistribution and use in source and binary forms, with or without 2011723Sar4jc@virginia.edu * modification, are permitted provided that the following conditions are 2111723Sar4jc@virginia.edu * met: redistributions of source code must retain the above copyright 2211723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer; 2311723Sar4jc@virginia.edu * redistributions in binary form must reproduce the above copyright 2411723Sar4jc@virginia.edu * notice, this list of conditions and the following disclaimer in the 2511723Sar4jc@virginia.edu * documentation and/or other materials provided with the distribution; 2611723Sar4jc@virginia.edu * neither the name of the copyright holders nor the names of its 2711723Sar4jc@virginia.edu * contributors may be used to endorse or promote products derived from 2811723Sar4jc@virginia.edu * this software without specific prior written permission. 2911723Sar4jc@virginia.edu * 3011723Sar4jc@virginia.edu * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 3111723Sar4jc@virginia.edu * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 3211723Sar4jc@virginia.edu * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 3311723Sar4jc@virginia.edu * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 3411723Sar4jc@virginia.edu * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 3511723Sar4jc@virginia.edu * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 3611723Sar4jc@virginia.edu * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 3711723Sar4jc@virginia.edu * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 3811723Sar4jc@virginia.edu * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 3911723Sar4jc@virginia.edu * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 4011723Sar4jc@virginia.edu * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4111723Sar4jc@virginia.edu * 4211723Sar4jc@virginia.edu * Authors: Andreas Hansson 4311723Sar4jc@virginia.edu * Sven Karlsson 4411723Sar4jc@virginia.edu * Alec Roelke 4511723Sar4jc@virginia.edu */ 4611723Sar4jc@virginia.edu 4711723Sar4jc@virginia.edu#ifndef __ARCH_RISCV_REGISTERS_HH__ 4811723Sar4jc@virginia.edu#define __ARCH_RISCV_REGISTERS_HH__ 4911723Sar4jc@virginia.edu 5011723Sar4jc@virginia.edu#include <map> 5111723Sar4jc@virginia.edu#include <string> 5212119Sar4jc@virginia.edu#include <vector> 5311723Sar4jc@virginia.edu 5412104Snathanael.premillieu@arm.com#include "arch/generic/types.hh" 5513610Sgiacomo.gabrielli@arm.com#include "arch/generic/vec_pred_reg.hh" 5612109SRekai.GonzalezAlberquilla@arm.com#include "arch/generic/vec_reg.hh" 5711911SBrandon.Potter@amd.com#include "arch/isa_traits.hh" 5811723Sar4jc@virginia.edu#include "arch/riscv/generated/max_inst_regs.hh" 5911723Sar4jc@virginia.edu#include "base/types.hh" 6011723Sar4jc@virginia.edu 6111723Sar4jc@virginia.edunamespace RiscvISA { 6211723Sar4jc@virginia.edu 6311723Sar4jc@virginia.eduusing RiscvISAInst::MaxInstSrcRegs; 6411723Sar4jc@virginia.eduusing RiscvISAInst::MaxInstDestRegs; 6511723Sar4jc@virginia.educonst int MaxMiscDestRegs = 1; 6611723Sar4jc@virginia.edu 6713610Sgiacomo.gabrielli@arm.com// Not applicable to RISC-V 6813610Sgiacomo.gabrielli@arm.comusing VecElem = ::DummyVecElem; 6913610Sgiacomo.gabrielli@arm.comusing VecReg = ::DummyVecReg; 7013610Sgiacomo.gabrielli@arm.comusing ConstVecReg = ::DummyConstVecReg; 7113610Sgiacomo.gabrielli@arm.comusing VecRegContainer = ::DummyVecRegContainer; 7213610Sgiacomo.gabrielli@arm.comconstexpr unsigned NumVecElemPerVecReg = ::DummyNumVecElemPerVecReg; 7313610Sgiacomo.gabrielli@arm.comconstexpr size_t VecRegSizeBytes = ::DummyVecRegSizeBytes; 7413610Sgiacomo.gabrielli@arm.com 7513610Sgiacomo.gabrielli@arm.com// Not applicable to RISC-V 7613610Sgiacomo.gabrielli@arm.comusing VecPredReg = ::DummyVecPredReg; 7713610Sgiacomo.gabrielli@arm.comusing ConstVecPredReg = ::DummyConstVecPredReg; 7813610Sgiacomo.gabrielli@arm.comusing VecPredRegContainer = ::DummyVecPredRegContainer; 7913610Sgiacomo.gabrielli@arm.comconstexpr size_t VecPredRegSizeBits = ::DummyVecPredRegSizeBits; 8013610Sgiacomo.gabrielli@arm.comconstexpr bool VecPredRegHasPackedRepr = ::DummyVecPredRegHasPackedRepr; 8112109SRekai.GonzalezAlberquilla@arm.com 8211723Sar4jc@virginia.educonst int NumIntArchRegs = 32; 8311726Sar4jc@virginia.educonst int NumMicroIntRegs = 1; 8411726Sar4jc@virginia.educonst int NumIntRegs = NumIntArchRegs + NumMicroIntRegs; 8511725Sar4jc@virginia.educonst int NumFloatRegs = 32; 8613610Sgiacomo.gabrielli@arm.com 8713610Sgiacomo.gabrielli@arm.comconst unsigned NumVecRegs = 1; // Not applicable to RISC-V 8813610Sgiacomo.gabrielli@arm.com // (1 to prevent warnings) 8913610Sgiacomo.gabrielli@arm.comconst int NumVecPredRegs = 1; // Not applicable to RISC-V 9013610Sgiacomo.gabrielli@arm.com // (1 to prevent warnings) 9113610Sgiacomo.gabrielli@arm.com 9211723Sar4jc@virginia.educonst int NumCCRegs = 0; 9311723Sar4jc@virginia.edu 9411723Sar4jc@virginia.edu// Semantically meaningful register indices 9511723Sar4jc@virginia.educonst int ZeroReg = 0; 9611723Sar4jc@virginia.educonst int ReturnAddrReg = 1; 9711723Sar4jc@virginia.educonst int StackPointerReg = 2; 9811723Sar4jc@virginia.educonst int GlobalPointerReg = 3; 9911723Sar4jc@virginia.educonst int ThreadPointerReg = 4; 10011723Sar4jc@virginia.educonst int FramePointerReg = 8; 10112139Sar4jc@virginia.educonst int ReturnValueReg = 10; 10212119Sar4jc@virginia.educonst std::vector<int> ReturnValueRegs = {10, 11}; 10312119Sar4jc@virginia.educonst std::vector<int> ArgumentRegs = {10, 11, 12, 13, 14, 15, 16, 17}; 10411726Sar4jc@virginia.educonst int AMOTempReg = 32; 10511723Sar4jc@virginia.edu 10612413Sar4jc@virginia.educonst int SyscallPseudoReturnReg = 10; 10712413Sar4jc@virginia.educonst std::vector<int> SyscallArgumentRegs = {10, 11, 12, 13, 14, 15, 16}; 10812413Sar4jc@virginia.educonst int SyscallNumReg = 17; 10912413Sar4jc@virginia.edu 11012119Sar4jc@virginia.educonst std::vector<std::string> IntRegNames = { 11112119Sar4jc@virginia.edu "zero", "ra", "sp", "gp", 11211723Sar4jc@virginia.edu "tp", "t0", "t1", "t2", 11311723Sar4jc@virginia.edu "s0", "s1", "a0", "a1", 11411723Sar4jc@virginia.edu "a2", "a3", "a4", "a5", 11511723Sar4jc@virginia.edu "a6", "a7", "s2", "s3", 11611723Sar4jc@virginia.edu "s4", "s5", "s6", "s7", 11711723Sar4jc@virginia.edu "s8", "s9", "s10", "s11", 11812119Sar4jc@virginia.edu "t3", "t4", "t5", "t6" 11912119Sar4jc@virginia.edu}; 12012119Sar4jc@virginia.educonst std::vector<std::string> FloatRegNames = { 12112119Sar4jc@virginia.edu "ft0", "ft1", "ft2", "ft3", 12212119Sar4jc@virginia.edu "ft4", "ft5", "ft6", "ft7", 12312119Sar4jc@virginia.edu "fs0", "fs1", "fa0", "fa1", 12412119Sar4jc@virginia.edu "fa2", "fa3", "fa4", "fa5", 12512119Sar4jc@virginia.edu "fa6", "fa7", "fs2", "fs3", 12612119Sar4jc@virginia.edu "fs4", "fs5", "fs6", "fs7", 12712119Sar4jc@virginia.edu "fs8", "fs9", "fs10", "fs11", 12812119Sar4jc@virginia.edu "ft8", "ft9", "ft10", "ft11" 12912119Sar4jc@virginia.edu}; 13011723Sar4jc@virginia.edu 13111723Sar4jc@virginia.eduenum MiscRegIndex { 13212695Sar4jc@virginia.edu MISCREG_PRV = 0, 13312695Sar4jc@virginia.edu MISCREG_ISA, 13412695Sar4jc@virginia.edu MISCREG_VENDORID, 13512695Sar4jc@virginia.edu MISCREG_ARCHID, 13612695Sar4jc@virginia.edu MISCREG_IMPID, 13712695Sar4jc@virginia.edu MISCREG_HARTID, 13812695Sar4jc@virginia.edu MISCREG_STATUS, 13912695Sar4jc@virginia.edu MISCREG_IP, 14012695Sar4jc@virginia.edu MISCREG_IE, 14112695Sar4jc@virginia.edu MISCREG_CYCLE, 14212695Sar4jc@virginia.edu MISCREG_TIME, 14312695Sar4jc@virginia.edu MISCREG_INSTRET, 14412695Sar4jc@virginia.edu MISCREG_HPMCOUNTER03, 14512695Sar4jc@virginia.edu MISCREG_HPMCOUNTER04, 14612695Sar4jc@virginia.edu MISCREG_HPMCOUNTER05, 14712695Sar4jc@virginia.edu MISCREG_HPMCOUNTER06, 14812695Sar4jc@virginia.edu MISCREG_HPMCOUNTER07, 14912695Sar4jc@virginia.edu MISCREG_HPMCOUNTER08, 15012695Sar4jc@virginia.edu MISCREG_HPMCOUNTER09, 15112695Sar4jc@virginia.edu MISCREG_HPMCOUNTER10, 15212695Sar4jc@virginia.edu MISCREG_HPMCOUNTER11, 15312695Sar4jc@virginia.edu MISCREG_HPMCOUNTER12, 15412695Sar4jc@virginia.edu MISCREG_HPMCOUNTER13, 15512695Sar4jc@virginia.edu MISCREG_HPMCOUNTER14, 15612695Sar4jc@virginia.edu MISCREG_HPMCOUNTER15, 15712695Sar4jc@virginia.edu MISCREG_HPMCOUNTER16, 15812695Sar4jc@virginia.edu MISCREG_HPMCOUNTER17, 15912695Sar4jc@virginia.edu MISCREG_HPMCOUNTER18, 16012695Sar4jc@virginia.edu MISCREG_HPMCOUNTER19, 16112695Sar4jc@virginia.edu MISCREG_HPMCOUNTER20, 16212695Sar4jc@virginia.edu MISCREG_HPMCOUNTER21, 16312695Sar4jc@virginia.edu MISCREG_HPMCOUNTER22, 16412695Sar4jc@virginia.edu MISCREG_HPMCOUNTER23, 16512695Sar4jc@virginia.edu MISCREG_HPMCOUNTER24, 16612695Sar4jc@virginia.edu MISCREG_HPMCOUNTER25, 16712695Sar4jc@virginia.edu MISCREG_HPMCOUNTER26, 16812695Sar4jc@virginia.edu MISCREG_HPMCOUNTER27, 16912695Sar4jc@virginia.edu MISCREG_HPMCOUNTER28, 17012695Sar4jc@virginia.edu MISCREG_HPMCOUNTER29, 17112695Sar4jc@virginia.edu MISCREG_HPMCOUNTER30, 17212695Sar4jc@virginia.edu MISCREG_HPMCOUNTER31, 17312695Sar4jc@virginia.edu MISCREG_HPMEVENT03, 17412695Sar4jc@virginia.edu MISCREG_HPMEVENT04, 17512695Sar4jc@virginia.edu MISCREG_HPMEVENT05, 17612695Sar4jc@virginia.edu MISCREG_HPMEVENT06, 17712695Sar4jc@virginia.edu MISCREG_HPMEVENT07, 17812695Sar4jc@virginia.edu MISCREG_HPMEVENT08, 17912695Sar4jc@virginia.edu MISCREG_HPMEVENT09, 18012695Sar4jc@virginia.edu MISCREG_HPMEVENT10, 18112695Sar4jc@virginia.edu MISCREG_HPMEVENT11, 18212695Sar4jc@virginia.edu MISCREG_HPMEVENT12, 18312695Sar4jc@virginia.edu MISCREG_HPMEVENT13, 18412695Sar4jc@virginia.edu MISCREG_HPMEVENT14, 18512695Sar4jc@virginia.edu MISCREG_HPMEVENT15, 18612695Sar4jc@virginia.edu MISCREG_HPMEVENT16, 18712695Sar4jc@virginia.edu MISCREG_HPMEVENT17, 18812695Sar4jc@virginia.edu MISCREG_HPMEVENT18, 18912695Sar4jc@virginia.edu MISCREG_HPMEVENT19, 19012695Sar4jc@virginia.edu MISCREG_HPMEVENT20, 19112695Sar4jc@virginia.edu MISCREG_HPMEVENT21, 19212695Sar4jc@virginia.edu MISCREG_HPMEVENT22, 19312695Sar4jc@virginia.edu MISCREG_HPMEVENT23, 19412695Sar4jc@virginia.edu MISCREG_HPMEVENT24, 19512695Sar4jc@virginia.edu MISCREG_HPMEVENT25, 19612695Sar4jc@virginia.edu MISCREG_HPMEVENT26, 19712695Sar4jc@virginia.edu MISCREG_HPMEVENT27, 19812695Sar4jc@virginia.edu MISCREG_HPMEVENT28, 19912695Sar4jc@virginia.edu MISCREG_HPMEVENT29, 20012695Sar4jc@virginia.edu MISCREG_HPMEVENT30, 20112695Sar4jc@virginia.edu MISCREG_HPMEVENT31, 20212695Sar4jc@virginia.edu MISCREG_TSELECT, 20312695Sar4jc@virginia.edu MISCREG_TDATA1, 20412695Sar4jc@virginia.edu MISCREG_TDATA2, 20512695Sar4jc@virginia.edu MISCREG_TDATA3, 20612695Sar4jc@virginia.edu MISCREG_DCSR, 20712695Sar4jc@virginia.edu MISCREG_DPC, 20812695Sar4jc@virginia.edu MISCREG_DSCRATCH, 20911723Sar4jc@virginia.edu 21012695Sar4jc@virginia.edu MISCREG_MEDELEG, 21112695Sar4jc@virginia.edu MISCREG_MIDELEG, 21212695Sar4jc@virginia.edu MISCREG_MTVEC, 21312695Sar4jc@virginia.edu MISCREG_MCOUNTEREN, 21412695Sar4jc@virginia.edu MISCREG_MSCRATCH, 21512695Sar4jc@virginia.edu MISCREG_MEPC, 21612695Sar4jc@virginia.edu MISCREG_MCAUSE, 21712695Sar4jc@virginia.edu MISCREG_MTVAL, 21812695Sar4jc@virginia.edu MISCREG_PMPCFG0, 21912695Sar4jc@virginia.edu // pmpcfg1 rv32 only 22012695Sar4jc@virginia.edu MISCREG_PMPCFG2, 22112695Sar4jc@virginia.edu // pmpcfg3 rv32 only 22212695Sar4jc@virginia.edu MISCREG_PMPADDR00, 22312695Sar4jc@virginia.edu MISCREG_PMPADDR01, 22412695Sar4jc@virginia.edu MISCREG_PMPADDR02, 22512695Sar4jc@virginia.edu MISCREG_PMPADDR03, 22612695Sar4jc@virginia.edu MISCREG_PMPADDR04, 22712695Sar4jc@virginia.edu MISCREG_PMPADDR05, 22812695Sar4jc@virginia.edu MISCREG_PMPADDR06, 22912695Sar4jc@virginia.edu MISCREG_PMPADDR07, 23012695Sar4jc@virginia.edu MISCREG_PMPADDR08, 23112695Sar4jc@virginia.edu MISCREG_PMPADDR09, 23212695Sar4jc@virginia.edu MISCREG_PMPADDR10, 23312695Sar4jc@virginia.edu MISCREG_PMPADDR11, 23412695Sar4jc@virginia.edu MISCREG_PMPADDR12, 23512695Sar4jc@virginia.edu MISCREG_PMPADDR13, 23612695Sar4jc@virginia.edu MISCREG_PMPADDR14, 23712695Sar4jc@virginia.edu MISCREG_PMPADDR15, 23811723Sar4jc@virginia.edu 23912695Sar4jc@virginia.edu MISCREG_SEDELEG, 24012695Sar4jc@virginia.edu MISCREG_SIDELEG, 24112695Sar4jc@virginia.edu MISCREG_STVEC, 24212695Sar4jc@virginia.edu MISCREG_SCOUNTEREN, 24312695Sar4jc@virginia.edu MISCREG_SSCRATCH, 24412695Sar4jc@virginia.edu MISCREG_SEPC, 24512695Sar4jc@virginia.edu MISCREG_SCAUSE, 24612695Sar4jc@virginia.edu MISCREG_STVAL, 24712695Sar4jc@virginia.edu MISCREG_SATP, 24811723Sar4jc@virginia.edu 24912695Sar4jc@virginia.edu MISCREG_UTVEC, 25012695Sar4jc@virginia.edu MISCREG_USCRATCH, 25112695Sar4jc@virginia.edu MISCREG_UEPC, 25212695Sar4jc@virginia.edu MISCREG_UCAUSE, 25312695Sar4jc@virginia.edu MISCREG_UTVAL, 25412695Sar4jc@virginia.edu MISCREG_FFLAGS, 25512695Sar4jc@virginia.edu MISCREG_FRM, 25611963Sar4jc@virginia.edu 25712695Sar4jc@virginia.edu NUM_MISCREGS 25812695Sar4jc@virginia.edu}; 25912695Sar4jc@virginia.educonst int NumMiscRegs = NUM_MISCREGS; 26012695Sar4jc@virginia.edu 26112695Sar4jc@virginia.eduenum CSRIndex { 26212695Sar4jc@virginia.edu CSR_USTATUS = 0x000, 26312695Sar4jc@virginia.edu CSR_UIE = 0x004, 26412695Sar4jc@virginia.edu CSR_UTVEC = 0x005, 26512695Sar4jc@virginia.edu CSR_USCRATCH = 0x040, 26612695Sar4jc@virginia.edu CSR_UEPC = 0x041, 26712695Sar4jc@virginia.edu CSR_UCAUSE = 0x042, 26812695Sar4jc@virginia.edu CSR_UTVAL = 0x043, 26912695Sar4jc@virginia.edu CSR_UIP = 0x044, 27012695Sar4jc@virginia.edu CSR_FFLAGS = 0x001, 27112695Sar4jc@virginia.edu CSR_FRM = 0x002, 27212695Sar4jc@virginia.edu CSR_FCSR = 0x003, 27312695Sar4jc@virginia.edu CSR_CYCLE = 0xC00, 27412695Sar4jc@virginia.edu CSR_TIME = 0xC01, 27512695Sar4jc@virginia.edu CSR_INSTRET = 0xC02, 27612695Sar4jc@virginia.edu CSR_HPMCOUNTER03 = 0xC03, 27712695Sar4jc@virginia.edu CSR_HPMCOUNTER04 = 0xC04, 27812695Sar4jc@virginia.edu CSR_HPMCOUNTER05 = 0xC05, 27912695Sar4jc@virginia.edu CSR_HPMCOUNTER06 = 0xC06, 28012695Sar4jc@virginia.edu CSR_HPMCOUNTER07 = 0xC07, 28112695Sar4jc@virginia.edu CSR_HPMCOUNTER08 = 0xC08, 28212695Sar4jc@virginia.edu CSR_HPMCOUNTER09 = 0xC09, 28312695Sar4jc@virginia.edu CSR_HPMCOUNTER10 = 0xC0A, 28412695Sar4jc@virginia.edu CSR_HPMCOUNTER11 = 0xC0B, 28512695Sar4jc@virginia.edu CSR_HPMCOUNTER12 = 0xC0C, 28612695Sar4jc@virginia.edu CSR_HPMCOUNTER13 = 0xC0D, 28712695Sar4jc@virginia.edu CSR_HPMCOUNTER14 = 0xC0E, 28812695Sar4jc@virginia.edu CSR_HPMCOUNTER15 = 0xC0F, 28912695Sar4jc@virginia.edu CSR_HPMCOUNTER16 = 0xC10, 29012695Sar4jc@virginia.edu CSR_HPMCOUNTER17 = 0xC11, 29112695Sar4jc@virginia.edu CSR_HPMCOUNTER18 = 0xC12, 29212695Sar4jc@virginia.edu CSR_HPMCOUNTER19 = 0xC13, 29312695Sar4jc@virginia.edu CSR_HPMCOUNTER20 = 0xC14, 29412695Sar4jc@virginia.edu CSR_HPMCOUNTER21 = 0xC15, 29512695Sar4jc@virginia.edu CSR_HPMCOUNTER22 = 0xC16, 29612695Sar4jc@virginia.edu CSR_HPMCOUNTER23 = 0xC17, 29712695Sar4jc@virginia.edu CSR_HPMCOUNTER24 = 0xC18, 29812695Sar4jc@virginia.edu CSR_HPMCOUNTER25 = 0xC19, 29912695Sar4jc@virginia.edu CSR_HPMCOUNTER26 = 0xC1A, 30012695Sar4jc@virginia.edu CSR_HPMCOUNTER27 = 0xC1B, 30112695Sar4jc@virginia.edu CSR_HPMCOUNTER28 = 0xC1C, 30212695Sar4jc@virginia.edu CSR_HPMCOUNTER29 = 0xC1D, 30312695Sar4jc@virginia.edu CSR_HPMCOUNTER30 = 0xC1E, 30412695Sar4jc@virginia.edu CSR_HPMCOUNTER31 = 0xC1F, 30512695Sar4jc@virginia.edu // HPMCOUNTERH rv32 only 30612695Sar4jc@virginia.edu 30712695Sar4jc@virginia.edu CSR_SSTATUS = 0x100, 30812695Sar4jc@virginia.edu CSR_SEDELEG = 0x102, 30912695Sar4jc@virginia.edu CSR_SIDELEG = 0x103, 31012695Sar4jc@virginia.edu CSR_SIE = 0x104, 31112695Sar4jc@virginia.edu CSR_STVEC = 0x105, 31212695Sar4jc@virginia.edu CSR_SSCRATCH = 0x140, 31312695Sar4jc@virginia.edu CSR_SEPC = 0x141, 31412695Sar4jc@virginia.edu CSR_SCAUSE = 0x142, 31512695Sar4jc@virginia.edu CSR_STVAL = 0x143, 31612695Sar4jc@virginia.edu CSR_SIP = 0x144, 31712695Sar4jc@virginia.edu CSR_SATP = 0x180, 31812695Sar4jc@virginia.edu 31912695Sar4jc@virginia.edu CSR_MVENDORID = 0xF11, 32012695Sar4jc@virginia.edu CSR_MARCHID = 0xF12, 32112695Sar4jc@virginia.edu CSR_MIMPID = 0xF13, 32212695Sar4jc@virginia.edu CSR_MHARTID = 0xF14, 32312695Sar4jc@virginia.edu CSR_MSTATUS = 0x300, 32412695Sar4jc@virginia.edu CSR_MISA = 0x301, 32512695Sar4jc@virginia.edu CSR_MEDELEG = 0x302, 32612695Sar4jc@virginia.edu CSR_MIDELEG = 0x303, 32712695Sar4jc@virginia.edu CSR_MIE = 0x304, 32812695Sar4jc@virginia.edu CSR_MTVEC = 0x305, 32912695Sar4jc@virginia.edu CSR_MSCRATCH = 0x340, 33012695Sar4jc@virginia.edu CSR_MEPC = 0x341, 33112695Sar4jc@virginia.edu CSR_MCAUSE = 0x342, 33212695Sar4jc@virginia.edu CSR_MTVAL = 0x343, 33312695Sar4jc@virginia.edu CSR_MIP = 0x344, 33412695Sar4jc@virginia.edu CSR_PMPCFG0 = 0x3A0, 33512695Sar4jc@virginia.edu // pmpcfg1 rv32 only 33612695Sar4jc@virginia.edu CSR_PMPCFG2 = 0x3A2, 33712695Sar4jc@virginia.edu // pmpcfg3 rv32 only 33812695Sar4jc@virginia.edu CSR_PMPADDR00 = 0x3B0, 33912695Sar4jc@virginia.edu CSR_PMPADDR01 = 0x3B1, 34012695Sar4jc@virginia.edu CSR_PMPADDR02 = 0x3B2, 34112695Sar4jc@virginia.edu CSR_PMPADDR03 = 0x3B3, 34212695Sar4jc@virginia.edu CSR_PMPADDR04 = 0x3B4, 34312695Sar4jc@virginia.edu CSR_PMPADDR05 = 0x3B5, 34412695Sar4jc@virginia.edu CSR_PMPADDR06 = 0x3B6, 34512695Sar4jc@virginia.edu CSR_PMPADDR07 = 0x3B7, 34612695Sar4jc@virginia.edu CSR_PMPADDR08 = 0x3B8, 34712695Sar4jc@virginia.edu CSR_PMPADDR09 = 0x3B9, 34812695Sar4jc@virginia.edu CSR_PMPADDR10 = 0x3BA, 34912695Sar4jc@virginia.edu CSR_PMPADDR11 = 0x3BB, 35012695Sar4jc@virginia.edu CSR_PMPADDR12 = 0x3BC, 35112695Sar4jc@virginia.edu CSR_PMPADDR13 = 0x3BD, 35212695Sar4jc@virginia.edu CSR_PMPADDR14 = 0x3BE, 35312695Sar4jc@virginia.edu CSR_PMPADDR15 = 0x3BF, 35412695Sar4jc@virginia.edu CSR_MCYCLE = 0xB00, 35512695Sar4jc@virginia.edu CSR_MINSTRET = 0xB02, 35612695Sar4jc@virginia.edu CSR_MHPMCOUNTER03 = 0xC03, 35712695Sar4jc@virginia.edu CSR_MHPMCOUNTER04 = 0xC04, 35812695Sar4jc@virginia.edu CSR_MHPMCOUNTER05 = 0xC05, 35912695Sar4jc@virginia.edu CSR_MHPMCOUNTER06 = 0xC06, 36012695Sar4jc@virginia.edu CSR_MHPMCOUNTER07 = 0xC07, 36112695Sar4jc@virginia.edu CSR_MHPMCOUNTER08 = 0xC08, 36212695Sar4jc@virginia.edu CSR_MHPMCOUNTER09 = 0xC09, 36312695Sar4jc@virginia.edu CSR_MHPMCOUNTER10 = 0xC0A, 36412695Sar4jc@virginia.edu CSR_MHPMCOUNTER11 = 0xC0B, 36512695Sar4jc@virginia.edu CSR_MHPMCOUNTER12 = 0xC0C, 36612695Sar4jc@virginia.edu CSR_MHPMCOUNTER13 = 0xC0D, 36712695Sar4jc@virginia.edu CSR_MHPMCOUNTER14 = 0xC0E, 36812695Sar4jc@virginia.edu CSR_MHPMCOUNTER15 = 0xC0F, 36912695Sar4jc@virginia.edu CSR_MHPMCOUNTER16 = 0xC10, 37012695Sar4jc@virginia.edu CSR_MHPMCOUNTER17 = 0xC11, 37112695Sar4jc@virginia.edu CSR_MHPMCOUNTER18 = 0xC12, 37212695Sar4jc@virginia.edu CSR_MHPMCOUNTER19 = 0xC13, 37312695Sar4jc@virginia.edu CSR_MHPMCOUNTER20 = 0xC14, 37412695Sar4jc@virginia.edu CSR_MHPMCOUNTER21 = 0xC15, 37512695Sar4jc@virginia.edu CSR_MHPMCOUNTER22 = 0xC16, 37612695Sar4jc@virginia.edu CSR_MHPMCOUNTER23 = 0xC17, 37712695Sar4jc@virginia.edu CSR_MHPMCOUNTER24 = 0xC18, 37812695Sar4jc@virginia.edu CSR_MHPMCOUNTER25 = 0xC19, 37912695Sar4jc@virginia.edu CSR_MHPMCOUNTER26 = 0xC1A, 38012695Sar4jc@virginia.edu CSR_MHPMCOUNTER27 = 0xC1B, 38112695Sar4jc@virginia.edu CSR_MHPMCOUNTER28 = 0xC1C, 38212695Sar4jc@virginia.edu CSR_MHPMCOUNTER29 = 0xC1D, 38312695Sar4jc@virginia.edu CSR_MHPMCOUNTER30 = 0xC1E, 38412695Sar4jc@virginia.edu CSR_MHPMCOUNTER31 = 0xC1F, 38512695Sar4jc@virginia.edu // MHPMCOUNTERH rv32 only 38612695Sar4jc@virginia.edu CSR_MHPMEVENT03 = 0x323, 38712695Sar4jc@virginia.edu CSR_MHPMEVENT04 = 0x324, 38812695Sar4jc@virginia.edu CSR_MHPMEVENT05 = 0x325, 38912695Sar4jc@virginia.edu CSR_MHPMEVENT06 = 0x326, 39012695Sar4jc@virginia.edu CSR_MHPMEVENT07 = 0x327, 39112695Sar4jc@virginia.edu CSR_MHPMEVENT08 = 0x328, 39212695Sar4jc@virginia.edu CSR_MHPMEVENT09 = 0x329, 39312695Sar4jc@virginia.edu CSR_MHPMEVENT10 = 0x32A, 39412695Sar4jc@virginia.edu CSR_MHPMEVENT11 = 0x32B, 39512695Sar4jc@virginia.edu CSR_MHPMEVENT12 = 0x32C, 39612695Sar4jc@virginia.edu CSR_MHPMEVENT13 = 0x32D, 39712695Sar4jc@virginia.edu CSR_MHPMEVENT14 = 0x32E, 39812695Sar4jc@virginia.edu CSR_MHPMEVENT15 = 0x32F, 39912695Sar4jc@virginia.edu CSR_MHPMEVENT16 = 0x330, 40012695Sar4jc@virginia.edu CSR_MHPMEVENT17 = 0x331, 40112695Sar4jc@virginia.edu CSR_MHPMEVENT18 = 0x332, 40212695Sar4jc@virginia.edu CSR_MHPMEVENT19 = 0x333, 40312695Sar4jc@virginia.edu CSR_MHPMEVENT20 = 0x334, 40412695Sar4jc@virginia.edu CSR_MHPMEVENT21 = 0x335, 40512695Sar4jc@virginia.edu CSR_MHPMEVENT22 = 0x336, 40612695Sar4jc@virginia.edu CSR_MHPMEVENT23 = 0x337, 40712695Sar4jc@virginia.edu CSR_MHPMEVENT24 = 0x338, 40812695Sar4jc@virginia.edu CSR_MHPMEVENT25 = 0x339, 40912695Sar4jc@virginia.edu CSR_MHPMEVENT26 = 0x33A, 41012695Sar4jc@virginia.edu CSR_MHPMEVENT27 = 0x33B, 41112695Sar4jc@virginia.edu CSR_MHPMEVENT28 = 0x33C, 41212695Sar4jc@virginia.edu CSR_MHPMEVENT29 = 0x33D, 41312695Sar4jc@virginia.edu CSR_MHPMEVENT30 = 0x33E, 41412695Sar4jc@virginia.edu CSR_MHPMEVENT31 = 0x33F, 41512695Sar4jc@virginia.edu 41612695Sar4jc@virginia.edu CSR_TSELECT = 0x7A0, 41712695Sar4jc@virginia.edu CSR_TDATA1 = 0x7A1, 41812695Sar4jc@virginia.edu CSR_TDATA2 = 0x7A2, 41912695Sar4jc@virginia.edu CSR_TDATA3 = 0x7A3, 42012695Sar4jc@virginia.edu CSR_DCSR = 0x7B0, 42112695Sar4jc@virginia.edu CSR_DPC = 0x7B1, 42212695Sar4jc@virginia.edu CSR_DSCRATCH = 0x7B2 42311723Sar4jc@virginia.edu}; 42411723Sar4jc@virginia.edu 42512695Sar4jc@virginia.edustruct CSRMetadata 42612695Sar4jc@virginia.edu{ 42712695Sar4jc@virginia.edu const std::string name; 42812695Sar4jc@virginia.edu const int physIndex; 42912695Sar4jc@virginia.edu}; 43012119Sar4jc@virginia.edu 43112695Sar4jc@virginia.educonst std::map<int, CSRMetadata> CSRData = { 43212695Sar4jc@virginia.edu {CSR_USTATUS, {"ustatus", MISCREG_STATUS}}, 43312695Sar4jc@virginia.edu {CSR_UIE, {"uie", MISCREG_IE}}, 43412695Sar4jc@virginia.edu {CSR_UTVEC, {"utvec", MISCREG_UTVEC}}, 43512695Sar4jc@virginia.edu {CSR_USCRATCH, {"uscratch", MISCREG_USCRATCH}}, 43612695Sar4jc@virginia.edu {CSR_UEPC, {"uepc", MISCREG_UEPC}}, 43712695Sar4jc@virginia.edu {CSR_UCAUSE, {"ucause", MISCREG_UCAUSE}}, 43812695Sar4jc@virginia.edu {CSR_UTVAL, {"utval", MISCREG_UTVAL}}, 43912695Sar4jc@virginia.edu {CSR_UIP, {"uip", MISCREG_IP}}, 44012695Sar4jc@virginia.edu {CSR_FFLAGS, {"fflags", MISCREG_FFLAGS}}, 44112695Sar4jc@virginia.edu {CSR_FRM, {"frm", MISCREG_FRM}}, 44212695Sar4jc@virginia.edu {CSR_FCSR, {"fcsr", MISCREG_FFLAGS}}, // Actually FRM << 5 | FFLAGS 44312695Sar4jc@virginia.edu {CSR_CYCLE, {"cycle", MISCREG_CYCLE}}, 44412695Sar4jc@virginia.edu {CSR_TIME, {"time", MISCREG_TIME}}, 44512695Sar4jc@virginia.edu {CSR_INSTRET, {"instret", MISCREG_INSTRET}}, 44612695Sar4jc@virginia.edu {CSR_HPMCOUNTER03, {"hpmcounter03", MISCREG_HPMCOUNTER03}}, 44712695Sar4jc@virginia.edu {CSR_HPMCOUNTER04, {"hpmcounter04", MISCREG_HPMCOUNTER04}}, 44812695Sar4jc@virginia.edu {CSR_HPMCOUNTER05, {"hpmcounter05", MISCREG_HPMCOUNTER05}}, 44912695Sar4jc@virginia.edu {CSR_HPMCOUNTER06, {"hpmcounter06", MISCREG_HPMCOUNTER06}}, 45012695Sar4jc@virginia.edu {CSR_HPMCOUNTER07, {"hpmcounter07", MISCREG_HPMCOUNTER07}}, 45112695Sar4jc@virginia.edu {CSR_HPMCOUNTER08, {"hpmcounter08", MISCREG_HPMCOUNTER08}}, 45212695Sar4jc@virginia.edu {CSR_HPMCOUNTER09, {"hpmcounter09", MISCREG_HPMCOUNTER09}}, 45312695Sar4jc@virginia.edu {CSR_HPMCOUNTER10, {"hpmcounter10", MISCREG_HPMCOUNTER10}}, 45412695Sar4jc@virginia.edu {CSR_HPMCOUNTER11, {"hpmcounter11", MISCREG_HPMCOUNTER11}}, 45512695Sar4jc@virginia.edu {CSR_HPMCOUNTER12, {"hpmcounter12", MISCREG_HPMCOUNTER12}}, 45612695Sar4jc@virginia.edu {CSR_HPMCOUNTER13, {"hpmcounter13", MISCREG_HPMCOUNTER13}}, 45712695Sar4jc@virginia.edu {CSR_HPMCOUNTER14, {"hpmcounter14", MISCREG_HPMCOUNTER14}}, 45812695Sar4jc@virginia.edu {CSR_HPMCOUNTER15, {"hpmcounter15", MISCREG_HPMCOUNTER15}}, 45912695Sar4jc@virginia.edu {CSR_HPMCOUNTER16, {"hpmcounter16", MISCREG_HPMCOUNTER16}}, 46012695Sar4jc@virginia.edu {CSR_HPMCOUNTER17, {"hpmcounter17", MISCREG_HPMCOUNTER17}}, 46112695Sar4jc@virginia.edu {CSR_HPMCOUNTER18, {"hpmcounter18", MISCREG_HPMCOUNTER18}}, 46212695Sar4jc@virginia.edu {CSR_HPMCOUNTER19, {"hpmcounter19", MISCREG_HPMCOUNTER19}}, 46312695Sar4jc@virginia.edu {CSR_HPMCOUNTER20, {"hpmcounter20", MISCREG_HPMCOUNTER20}}, 46412695Sar4jc@virginia.edu {CSR_HPMCOUNTER21, {"hpmcounter21", MISCREG_HPMCOUNTER21}}, 46512695Sar4jc@virginia.edu {CSR_HPMCOUNTER22, {"hpmcounter22", MISCREG_HPMCOUNTER22}}, 46612695Sar4jc@virginia.edu {CSR_HPMCOUNTER23, {"hpmcounter23", MISCREG_HPMCOUNTER23}}, 46712695Sar4jc@virginia.edu {CSR_HPMCOUNTER24, {"hpmcounter24", MISCREG_HPMCOUNTER24}}, 46812695Sar4jc@virginia.edu {CSR_HPMCOUNTER25, {"hpmcounter25", MISCREG_HPMCOUNTER25}}, 46912695Sar4jc@virginia.edu {CSR_HPMCOUNTER26, {"hpmcounter26", MISCREG_HPMCOUNTER26}}, 47012695Sar4jc@virginia.edu {CSR_HPMCOUNTER27, {"hpmcounter27", MISCREG_HPMCOUNTER27}}, 47112695Sar4jc@virginia.edu {CSR_HPMCOUNTER28, {"hpmcounter28", MISCREG_HPMCOUNTER28}}, 47212695Sar4jc@virginia.edu {CSR_HPMCOUNTER29, {"hpmcounter29", MISCREG_HPMCOUNTER29}}, 47312695Sar4jc@virginia.edu {CSR_HPMCOUNTER30, {"hpmcounter30", MISCREG_HPMCOUNTER30}}, 47412695Sar4jc@virginia.edu {CSR_HPMCOUNTER31, {"hpmcounter31", MISCREG_HPMCOUNTER31}}, 47512119Sar4jc@virginia.edu 47612695Sar4jc@virginia.edu {CSR_SSTATUS, {"sstatus", MISCREG_STATUS}}, 47712695Sar4jc@virginia.edu {CSR_SEDELEG, {"sedeleg", MISCREG_SEDELEG}}, 47812695Sar4jc@virginia.edu {CSR_SIDELEG, {"sideleg", MISCREG_SIDELEG}}, 47912695Sar4jc@virginia.edu {CSR_SIE, {"sie", MISCREG_IE}}, 48012695Sar4jc@virginia.edu {CSR_STVEC, {"stvec", MISCREG_STVEC}}, 48112695Sar4jc@virginia.edu {CSR_SSCRATCH, {"sscratch", MISCREG_SSCRATCH}}, 48212695Sar4jc@virginia.edu {CSR_SEPC, {"sepc", MISCREG_SEPC}}, 48312695Sar4jc@virginia.edu {CSR_SCAUSE, {"scause", MISCREG_SCAUSE}}, 48412695Sar4jc@virginia.edu {CSR_STVAL, {"stval", MISCREG_STVAL}}, 48512695Sar4jc@virginia.edu {CSR_SIP, {"sip", MISCREG_IP}}, 48612695Sar4jc@virginia.edu {CSR_SATP, {"satp", MISCREG_SATP}}, 48712119Sar4jc@virginia.edu 48812695Sar4jc@virginia.edu {CSR_MVENDORID, {"mvendorid", MISCREG_VENDORID}}, 48912695Sar4jc@virginia.edu {CSR_MARCHID, {"marchid", MISCREG_ARCHID}}, 49012695Sar4jc@virginia.edu {CSR_MIMPID, {"mimpid", MISCREG_IMPID}}, 49112695Sar4jc@virginia.edu {CSR_MHARTID, {"mhartid", MISCREG_HARTID}}, 49212695Sar4jc@virginia.edu {CSR_MSTATUS, {"mstatus", MISCREG_STATUS}}, 49312695Sar4jc@virginia.edu {CSR_MISA, {"misa", MISCREG_ISA}}, 49412695Sar4jc@virginia.edu {CSR_MEDELEG, {"medeleg", MISCREG_MEDELEG}}, 49512695Sar4jc@virginia.edu {CSR_MIDELEG, {"mideleg", MISCREG_MIDELEG}}, 49612695Sar4jc@virginia.edu {CSR_MIE, {"mie", MISCREG_IE}}, 49712695Sar4jc@virginia.edu {CSR_MTVEC, {"mtvec", MISCREG_MTVEC}}, 49812695Sar4jc@virginia.edu {CSR_MSCRATCH, {"mscratch", MISCREG_MSCRATCH}}, 49912695Sar4jc@virginia.edu {CSR_MEPC, {"mepc", MISCREG_MEPC}}, 50012695Sar4jc@virginia.edu {CSR_MCAUSE, {"mcause", MISCREG_MCAUSE}}, 50112695Sar4jc@virginia.edu {CSR_MTVAL, {"mtval", MISCREG_MTVAL}}, 50212695Sar4jc@virginia.edu {CSR_MIP, {"mip", MISCREG_IP}}, 50312695Sar4jc@virginia.edu {CSR_PMPCFG0, {"pmpcfg0", MISCREG_PMPCFG0}}, 50412695Sar4jc@virginia.edu // pmpcfg1 rv32 only 50512695Sar4jc@virginia.edu {CSR_PMPCFG2, {"pmpcfg2", MISCREG_PMPCFG2}}, 50612695Sar4jc@virginia.edu // pmpcfg3 rv32 only 50712695Sar4jc@virginia.edu {CSR_PMPADDR00, {"pmpaddr0", MISCREG_PMPADDR00}}, 50812695Sar4jc@virginia.edu {CSR_PMPADDR01, {"pmpaddr1", MISCREG_PMPADDR01}}, 50912695Sar4jc@virginia.edu {CSR_PMPADDR02, {"pmpaddr2", MISCREG_PMPADDR02}}, 51012695Sar4jc@virginia.edu {CSR_PMPADDR03, {"pmpaddr3", MISCREG_PMPADDR03}}, 51112695Sar4jc@virginia.edu {CSR_PMPADDR04, {"pmpaddr4", MISCREG_PMPADDR04}}, 51212695Sar4jc@virginia.edu {CSR_PMPADDR05, {"pmpaddr5", MISCREG_PMPADDR05}}, 51312695Sar4jc@virginia.edu {CSR_PMPADDR06, {"pmpaddr6", MISCREG_PMPADDR06}}, 51412695Sar4jc@virginia.edu {CSR_PMPADDR07, {"pmpaddr7", MISCREG_PMPADDR07}}, 51512695Sar4jc@virginia.edu {CSR_PMPADDR08, {"pmpaddr8", MISCREG_PMPADDR08}}, 51612695Sar4jc@virginia.edu {CSR_PMPADDR09, {"pmpaddr9", MISCREG_PMPADDR09}}, 51712695Sar4jc@virginia.edu {CSR_PMPADDR10, {"pmpaddr10", MISCREG_PMPADDR10}}, 51812695Sar4jc@virginia.edu {CSR_PMPADDR11, {"pmpaddr11", MISCREG_PMPADDR11}}, 51912695Sar4jc@virginia.edu {CSR_PMPADDR12, {"pmpaddr12", MISCREG_PMPADDR12}}, 52012695Sar4jc@virginia.edu {CSR_PMPADDR13, {"pmpaddr13", MISCREG_PMPADDR13}}, 52112695Sar4jc@virginia.edu {CSR_PMPADDR14, {"pmpaddr14", MISCREG_PMPADDR14}}, 52212695Sar4jc@virginia.edu {CSR_PMPADDR15, {"pmpaddr15", MISCREG_PMPADDR15}}, 52312695Sar4jc@virginia.edu {CSR_MCYCLE, {"mcycle", MISCREG_CYCLE}}, 52412695Sar4jc@virginia.edu {CSR_MINSTRET, {"minstret", MISCREG_INSTRET}}, 52512695Sar4jc@virginia.edu {CSR_MHPMCOUNTER03, {"mhpmcounter03", MISCREG_HPMCOUNTER03}}, 52612695Sar4jc@virginia.edu {CSR_MHPMCOUNTER04, {"mhpmcounter04", MISCREG_HPMCOUNTER04}}, 52712695Sar4jc@virginia.edu {CSR_MHPMCOUNTER05, {"mhpmcounter05", MISCREG_HPMCOUNTER05}}, 52812695Sar4jc@virginia.edu {CSR_MHPMCOUNTER06, {"mhpmcounter06", MISCREG_HPMCOUNTER06}}, 52912695Sar4jc@virginia.edu {CSR_MHPMCOUNTER07, {"mhpmcounter07", MISCREG_HPMCOUNTER07}}, 53012695Sar4jc@virginia.edu {CSR_MHPMCOUNTER08, {"mhpmcounter08", MISCREG_HPMCOUNTER08}}, 53112695Sar4jc@virginia.edu {CSR_MHPMCOUNTER09, {"mhpmcounter09", MISCREG_HPMCOUNTER09}}, 53212695Sar4jc@virginia.edu {CSR_MHPMCOUNTER10, {"mhpmcounter10", MISCREG_HPMCOUNTER10}}, 53312695Sar4jc@virginia.edu {CSR_MHPMCOUNTER11, {"mhpmcounter11", MISCREG_HPMCOUNTER11}}, 53412695Sar4jc@virginia.edu {CSR_MHPMCOUNTER12, {"mhpmcounter12", MISCREG_HPMCOUNTER12}}, 53512695Sar4jc@virginia.edu {CSR_MHPMCOUNTER13, {"mhpmcounter13", MISCREG_HPMCOUNTER13}}, 53612695Sar4jc@virginia.edu {CSR_MHPMCOUNTER14, {"mhpmcounter14", MISCREG_HPMCOUNTER14}}, 53712695Sar4jc@virginia.edu {CSR_MHPMCOUNTER15, {"mhpmcounter15", MISCREG_HPMCOUNTER15}}, 53812695Sar4jc@virginia.edu {CSR_MHPMCOUNTER16, {"mhpmcounter16", MISCREG_HPMCOUNTER16}}, 53912695Sar4jc@virginia.edu {CSR_MHPMCOUNTER17, {"mhpmcounter17", MISCREG_HPMCOUNTER17}}, 54012695Sar4jc@virginia.edu {CSR_MHPMCOUNTER18, {"mhpmcounter18", MISCREG_HPMCOUNTER18}}, 54112695Sar4jc@virginia.edu {CSR_MHPMCOUNTER19, {"mhpmcounter19", MISCREG_HPMCOUNTER19}}, 54212695Sar4jc@virginia.edu {CSR_MHPMCOUNTER20, {"mhpmcounter20", MISCREG_HPMCOUNTER20}}, 54312695Sar4jc@virginia.edu {CSR_MHPMCOUNTER21, {"mhpmcounter21", MISCREG_HPMCOUNTER21}}, 54412695Sar4jc@virginia.edu {CSR_MHPMCOUNTER22, {"mhpmcounter22", MISCREG_HPMCOUNTER22}}, 54512695Sar4jc@virginia.edu {CSR_MHPMCOUNTER23, {"mhpmcounter23", MISCREG_HPMCOUNTER23}}, 54612695Sar4jc@virginia.edu {CSR_MHPMCOUNTER24, {"mhpmcounter24", MISCREG_HPMCOUNTER24}}, 54712695Sar4jc@virginia.edu {CSR_MHPMCOUNTER25, {"mhpmcounter25", MISCREG_HPMCOUNTER25}}, 54812695Sar4jc@virginia.edu {CSR_MHPMCOUNTER26, {"mhpmcounter26", MISCREG_HPMCOUNTER26}}, 54912695Sar4jc@virginia.edu {CSR_MHPMCOUNTER27, {"mhpmcounter27", MISCREG_HPMCOUNTER27}}, 55012695Sar4jc@virginia.edu {CSR_MHPMCOUNTER28, {"mhpmcounter28", MISCREG_HPMCOUNTER28}}, 55112695Sar4jc@virginia.edu {CSR_MHPMCOUNTER29, {"mhpmcounter29", MISCREG_HPMCOUNTER29}}, 55212695Sar4jc@virginia.edu {CSR_MHPMCOUNTER30, {"mhpmcounter30", MISCREG_HPMCOUNTER30}}, 55312695Sar4jc@virginia.edu {CSR_MHPMCOUNTER31, {"mhpmcounter31", MISCREG_HPMCOUNTER31}}, 55412695Sar4jc@virginia.edu {CSR_MHPMEVENT03, {"mhpmevent03", MISCREG_HPMEVENT03}}, 55512695Sar4jc@virginia.edu {CSR_MHPMEVENT04, {"mhpmevent04", MISCREG_HPMEVENT04}}, 55612695Sar4jc@virginia.edu {CSR_MHPMEVENT05, {"mhpmevent05", MISCREG_HPMEVENT05}}, 55712695Sar4jc@virginia.edu {CSR_MHPMEVENT06, {"mhpmevent06", MISCREG_HPMEVENT06}}, 55812695Sar4jc@virginia.edu {CSR_MHPMEVENT07, {"mhpmevent07", MISCREG_HPMEVENT07}}, 55912695Sar4jc@virginia.edu {CSR_MHPMEVENT08, {"mhpmevent08", MISCREG_HPMEVENT08}}, 56012695Sar4jc@virginia.edu {CSR_MHPMEVENT09, {"mhpmevent09", MISCREG_HPMEVENT09}}, 56112695Sar4jc@virginia.edu {CSR_MHPMEVENT10, {"mhpmevent10", MISCREG_HPMEVENT10}}, 56212695Sar4jc@virginia.edu {CSR_MHPMEVENT11, {"mhpmevent11", MISCREG_HPMEVENT11}}, 56312695Sar4jc@virginia.edu {CSR_MHPMEVENT12, {"mhpmevent12", MISCREG_HPMEVENT12}}, 56412695Sar4jc@virginia.edu {CSR_MHPMEVENT13, {"mhpmevent13", MISCREG_HPMEVENT13}}, 56512695Sar4jc@virginia.edu {CSR_MHPMEVENT14, {"mhpmevent14", MISCREG_HPMEVENT14}}, 56612695Sar4jc@virginia.edu {CSR_MHPMEVENT15, {"mhpmevent15", MISCREG_HPMEVENT15}}, 56712695Sar4jc@virginia.edu {CSR_MHPMEVENT16, {"mhpmevent16", MISCREG_HPMEVENT16}}, 56812695Sar4jc@virginia.edu {CSR_MHPMEVENT17, {"mhpmevent17", MISCREG_HPMEVENT17}}, 56912695Sar4jc@virginia.edu {CSR_MHPMEVENT18, {"mhpmevent18", MISCREG_HPMEVENT18}}, 57012695Sar4jc@virginia.edu {CSR_MHPMEVENT19, {"mhpmevent19", MISCREG_HPMEVENT19}}, 57112695Sar4jc@virginia.edu {CSR_MHPMEVENT20, {"mhpmevent20", MISCREG_HPMEVENT20}}, 57212695Sar4jc@virginia.edu {CSR_MHPMEVENT21, {"mhpmevent21", MISCREG_HPMEVENT21}}, 57312695Sar4jc@virginia.edu {CSR_MHPMEVENT22, {"mhpmevent22", MISCREG_HPMEVENT22}}, 57412695Sar4jc@virginia.edu {CSR_MHPMEVENT23, {"mhpmevent23", MISCREG_HPMEVENT23}}, 57512695Sar4jc@virginia.edu {CSR_MHPMEVENT24, {"mhpmevent24", MISCREG_HPMEVENT24}}, 57612695Sar4jc@virginia.edu {CSR_MHPMEVENT25, {"mhpmevent25", MISCREG_HPMEVENT25}}, 57712695Sar4jc@virginia.edu {CSR_MHPMEVENT26, {"mhpmevent26", MISCREG_HPMEVENT26}}, 57812695Sar4jc@virginia.edu {CSR_MHPMEVENT27, {"mhpmevent27", MISCREG_HPMEVENT27}}, 57912695Sar4jc@virginia.edu {CSR_MHPMEVENT28, {"mhpmevent28", MISCREG_HPMEVENT28}}, 58012695Sar4jc@virginia.edu {CSR_MHPMEVENT29, {"mhpmevent29", MISCREG_HPMEVENT29}}, 58112695Sar4jc@virginia.edu {CSR_MHPMEVENT30, {"mhpmevent30", MISCREG_HPMEVENT30}}, 58212695Sar4jc@virginia.edu {CSR_MHPMEVENT31, {"mhpmevent31", MISCREG_HPMEVENT31}}, 58312119Sar4jc@virginia.edu 58412695Sar4jc@virginia.edu {CSR_TSELECT, {"tselect", MISCREG_TSELECT}}, 58512695Sar4jc@virginia.edu {CSR_TDATA1, {"tdata1", MISCREG_TDATA1}}, 58612695Sar4jc@virginia.edu {CSR_TDATA2, {"tdata2", MISCREG_TDATA2}}, 58712695Sar4jc@virginia.edu {CSR_TDATA3, {"tdata3", MISCREG_TDATA3}}, 58812695Sar4jc@virginia.edu {CSR_DCSR, {"dcsr", MISCREG_DCSR}}, 58912695Sar4jc@virginia.edu {CSR_DPC, {"dpc", MISCREG_DPC}}, 59012695Sar4jc@virginia.edu {CSR_DSCRATCH, {"dscratch", MISCREG_DSCRATCH}} 59112695Sar4jc@virginia.edu}; 59212695Sar4jc@virginia.edu 59312850Salec.roelke@gmail.com/** 59412850Salec.roelke@gmail.com * These fields are specified in the RISC-V Instruction Set Manual, Volume II, 59512850Salec.roelke@gmail.com * v1.10, accessible at www.riscv.org. in Figure 3.7. The main register that 59612850Salec.roelke@gmail.com * uses these fields is the MSTATUS register, which is shadowed by two others 59712850Salec.roelke@gmail.com * accessible at lower privilege levels (SSTATUS and USTATUS) that can't see 59812850Salec.roelke@gmail.com * the fields for higher privileges. 59912850Salec.roelke@gmail.com */ 60012850Salec.roelke@gmail.comBitUnion64(STATUS) 60112850Salec.roelke@gmail.com Bitfield<63> sd; 60212850Salec.roelke@gmail.com Bitfield<35, 34> sxl; 60312850Salec.roelke@gmail.com Bitfield<33, 32> uxl; 60412850Salec.roelke@gmail.com Bitfield<22> tsr; 60512850Salec.roelke@gmail.com Bitfield<21> tw; 60612850Salec.roelke@gmail.com Bitfield<20> tvm; 60712850Salec.roelke@gmail.com Bitfield<19> mxr; 60812850Salec.roelke@gmail.com Bitfield<18> sum; 60912850Salec.roelke@gmail.com Bitfield<17> mprv; 61012850Salec.roelke@gmail.com Bitfield<16, 15> xs; 61112850Salec.roelke@gmail.com Bitfield<14, 13> fs; 61212850Salec.roelke@gmail.com Bitfield<12, 11> mpp; 61312850Salec.roelke@gmail.com Bitfield<8> spp; 61412850Salec.roelke@gmail.com Bitfield<7> mpie; 61512850Salec.roelke@gmail.com Bitfield<5> spie; 61612850Salec.roelke@gmail.com Bitfield<4> upie; 61712850Salec.roelke@gmail.com Bitfield<3> mie; 61812850Salec.roelke@gmail.com Bitfield<1> sie; 61912850Salec.roelke@gmail.com Bitfield<0> uie; 62012850Salec.roelke@gmail.comEndBitUnion(STATUS) 62112850Salec.roelke@gmail.com 62212850Salec.roelke@gmail.com/** 62312850Salec.roelke@gmail.com * These fields are specified in the RISC-V Instruction Set Manual, Volume II, 62412850Salec.roelke@gmail.com * v1.10 in Figures 3.11 and 3.12, accessible at www.riscv.org. Both the MIP 62512850Salec.roelke@gmail.com * and MIE registers have the same fields, so accesses to either should use 62612850Salec.roelke@gmail.com * this bit union. 62712850Salec.roelke@gmail.com */ 62812850Salec.roelke@gmail.comBitUnion64(INTERRUPT) 62912850Salec.roelke@gmail.com Bitfield<11> mei; 63012850Salec.roelke@gmail.com Bitfield<9> sei; 63112850Salec.roelke@gmail.com Bitfield<8> uei; 63212850Salec.roelke@gmail.com Bitfield<7> mti; 63312850Salec.roelke@gmail.com Bitfield<5> sti; 63412850Salec.roelke@gmail.com Bitfield<4> uti; 63512850Salec.roelke@gmail.com Bitfield<3> msi; 63612850Salec.roelke@gmail.com Bitfield<1> ssi; 63712850Salec.roelke@gmail.com Bitfield<0> usi; 63812850Salec.roelke@gmail.comEndBitUnion(INTERRUPT) 63912850Salec.roelke@gmail.com 64013612Sgabeblack@google.comconst off_t MXL_OFFSET = (sizeof(uint64_t) * 8 - 2); 64112695Sar4jc@virginia.educonst off_t SXL_OFFSET = 34; 64212695Sar4jc@virginia.educonst off_t UXL_OFFSET = 32; 64312695Sar4jc@virginia.educonst off_t FS_OFFSET = 13; 64412695Sar4jc@virginia.educonst off_t FRM_OFFSET = 5; 64512695Sar4jc@virginia.edu 64613612Sgabeblack@google.comconst RegVal ISA_MXL_MASK = 3ULL << MXL_OFFSET; 64713612Sgabeblack@google.comconst RegVal ISA_EXT_MASK = mask(26); 64813612Sgabeblack@google.comconst RegVal MISA_MASK = ISA_MXL_MASK | ISA_EXT_MASK; 64912695Sar4jc@virginia.edu 65013612Sgabeblack@google.comconst RegVal STATUS_SD_MASK = 1ULL << ((sizeof(uint64_t) * 8) - 1); 65113612Sgabeblack@google.comconst RegVal STATUS_SXL_MASK = 3ULL << SXL_OFFSET; 65213612Sgabeblack@google.comconst RegVal STATUS_UXL_MASK = 3ULL << UXL_OFFSET; 65313612Sgabeblack@google.comconst RegVal STATUS_TSR_MASK = 1ULL << 22; 65413612Sgabeblack@google.comconst RegVal STATUS_TW_MASK = 1ULL << 21; 65513612Sgabeblack@google.comconst RegVal STATUS_TVM_MASK = 1ULL << 20; 65613612Sgabeblack@google.comconst RegVal STATUS_MXR_MASK = 1ULL << 19; 65713612Sgabeblack@google.comconst RegVal STATUS_SUM_MASK = 1ULL << 18; 65813612Sgabeblack@google.comconst RegVal STATUS_MPRV_MASK = 1ULL << 17; 65913612Sgabeblack@google.comconst RegVal STATUS_XS_MASK = 3ULL << 15; 66013612Sgabeblack@google.comconst RegVal STATUS_FS_MASK = 3ULL << FS_OFFSET; 66113612Sgabeblack@google.comconst RegVal STATUS_MPP_MASK = 3ULL << 11; 66213612Sgabeblack@google.comconst RegVal STATUS_SPP_MASK = 1ULL << 8; 66313612Sgabeblack@google.comconst RegVal STATUS_MPIE_MASK = 1ULL << 7; 66413612Sgabeblack@google.comconst RegVal STATUS_SPIE_MASK = 1ULL << 5; 66513612Sgabeblack@google.comconst RegVal STATUS_UPIE_MASK = 1ULL << 4; 66613612Sgabeblack@google.comconst RegVal STATUS_MIE_MASK = 1ULL << 3; 66713612Sgabeblack@google.comconst RegVal STATUS_SIE_MASK = 1ULL << 1; 66813612Sgabeblack@google.comconst RegVal STATUS_UIE_MASK = 1ULL << 0; 66913612Sgabeblack@google.comconst RegVal MSTATUS_MASK = STATUS_SD_MASK | STATUS_SXL_MASK | 67013612Sgabeblack@google.com STATUS_UXL_MASK | STATUS_TSR_MASK | 67113612Sgabeblack@google.com STATUS_TW_MASK | STATUS_TVM_MASK | 67213612Sgabeblack@google.com STATUS_MXR_MASK | STATUS_SUM_MASK | 67313612Sgabeblack@google.com STATUS_MPRV_MASK | STATUS_XS_MASK | 67413612Sgabeblack@google.com STATUS_FS_MASK | STATUS_MPP_MASK | 67513612Sgabeblack@google.com STATUS_SPP_MASK | STATUS_MPIE_MASK | 67613612Sgabeblack@google.com STATUS_SPIE_MASK | STATUS_UPIE_MASK | 67713612Sgabeblack@google.com STATUS_MIE_MASK | STATUS_SIE_MASK | 67813612Sgabeblack@google.com STATUS_UIE_MASK; 67913612Sgabeblack@google.comconst RegVal SSTATUS_MASK = STATUS_SD_MASK | STATUS_UXL_MASK | 68013612Sgabeblack@google.com STATUS_MXR_MASK | STATUS_SUM_MASK | 68113612Sgabeblack@google.com STATUS_XS_MASK | STATUS_FS_MASK | 68213612Sgabeblack@google.com STATUS_SPP_MASK | STATUS_SPIE_MASK | 68313612Sgabeblack@google.com STATUS_UPIE_MASK | STATUS_SIE_MASK | 68413612Sgabeblack@google.com STATUS_UIE_MASK; 68513612Sgabeblack@google.comconst RegVal USTATUS_MASK = STATUS_SD_MASK | STATUS_MXR_MASK | 68613612Sgabeblack@google.com STATUS_SUM_MASK | STATUS_XS_MASK | 68713612Sgabeblack@google.com STATUS_FS_MASK | STATUS_UPIE_MASK | 68813612Sgabeblack@google.com STATUS_UIE_MASK; 68912695Sar4jc@virginia.edu 69013612Sgabeblack@google.comconst RegVal MEI_MASK = 1ULL << 11; 69113612Sgabeblack@google.comconst RegVal SEI_MASK = 1ULL << 9; 69213612Sgabeblack@google.comconst RegVal UEI_MASK = 1ULL << 8; 69313612Sgabeblack@google.comconst RegVal MTI_MASK = 1ULL << 7; 69413612Sgabeblack@google.comconst RegVal STI_MASK = 1ULL << 5; 69513612Sgabeblack@google.comconst RegVal UTI_MASK = 1ULL << 4; 69613612Sgabeblack@google.comconst RegVal MSI_MASK = 1ULL << 3; 69713612Sgabeblack@google.comconst RegVal SSI_MASK = 1ULL << 1; 69813612Sgabeblack@google.comconst RegVal USI_MASK = 1ULL << 0; 69913612Sgabeblack@google.comconst RegVal MI_MASK = MEI_MASK | SEI_MASK | UEI_MASK | 70013612Sgabeblack@google.com MTI_MASK | STI_MASK | UTI_MASK | 70113612Sgabeblack@google.com MSI_MASK | SSI_MASK | USI_MASK; 70213612Sgabeblack@google.comconst RegVal SI_MASK = SEI_MASK | UEI_MASK | 70313612Sgabeblack@google.com STI_MASK | UTI_MASK | 70413612Sgabeblack@google.com SSI_MASK | USI_MASK; 70513612Sgabeblack@google.comconst RegVal UI_MASK = UEI_MASK | UTI_MASK | USI_MASK; 70613612Sgabeblack@google.comconst RegVal FFLAGS_MASK = (1 << FRM_OFFSET) - 1; 70713612Sgabeblack@google.comconst RegVal FRM_MASK = 0x7; 70812695Sar4jc@virginia.edu 70913612Sgabeblack@google.comconst std::map<int, RegVal> CSRMasks = { 71012695Sar4jc@virginia.edu {CSR_USTATUS, USTATUS_MASK}, 71112695Sar4jc@virginia.edu {CSR_UIE, UI_MASK}, 71212695Sar4jc@virginia.edu {CSR_UIP, UI_MASK}, 71312695Sar4jc@virginia.edu {CSR_FFLAGS, FFLAGS_MASK}, 71412695Sar4jc@virginia.edu {CSR_FRM, FRM_MASK}, 71512695Sar4jc@virginia.edu {CSR_FCSR, FFLAGS_MASK | (FRM_MASK << FRM_OFFSET)}, 71612695Sar4jc@virginia.edu {CSR_SSTATUS, SSTATUS_MASK}, 71712695Sar4jc@virginia.edu {CSR_SIE, SI_MASK}, 71812695Sar4jc@virginia.edu {CSR_SIP, SI_MASK}, 71912695Sar4jc@virginia.edu {CSR_MSTATUS, MSTATUS_MASK}, 72012695Sar4jc@virginia.edu {CSR_MISA, MISA_MASK}, 72112695Sar4jc@virginia.edu {CSR_MIE, MI_MASK}, 72212695Sar4jc@virginia.edu {CSR_MIP, MI_MASK} 72312119Sar4jc@virginia.edu}; 72412119Sar4jc@virginia.edu 72511723Sar4jc@virginia.edu} 72611723Sar4jc@virginia.edu 72711723Sar4jc@virginia.edu#endif // __ARCH_RISCV_REGISTERS_HH__ 728