priv.hh revision 12287
112287Sgabeblack@google.com/* 212287Sgabeblack@google.com * Copyright (c) 2006-2007 The Regents of The University of Michigan 312287Sgabeblack@google.com * All rights reserved 412287Sgabeblack@google.com * Copyright 2017 Google Inc. 512287Sgabeblack@google.com * 612287Sgabeblack@google.com * Redistribution and use in source and binary forms, with or without 712287Sgabeblack@google.com * modification, are permitted provided that the following conditions are 812287Sgabeblack@google.com * met: redistributions of source code must retain the above copyright 912287Sgabeblack@google.com * notice, this list of conditions and the following disclaimer; 1012287Sgabeblack@google.com * redistributions in binary form must reproduce the above copyright 1112287Sgabeblack@google.com * notice, this list of conditions and the following disclaimer in the 1212287Sgabeblack@google.com * documentation and/or other materials provided with the distribution; 1312287Sgabeblack@google.com * neither the name of the copyright holders nor the names of its 1412287Sgabeblack@google.com * contributors may be used to endorse or promote products derived from 1512287Sgabeblack@google.com * this software without specific prior written permission. 1612287Sgabeblack@google.com * 1712287Sgabeblack@google.com * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1812287Sgabeblack@google.com * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1912287Sgabeblack@google.com * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 2012287Sgabeblack@google.com * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 2112287Sgabeblack@google.com * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 2212287Sgabeblack@google.com * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 2312287Sgabeblack@google.com * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2412287Sgabeblack@google.com * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2512287Sgabeblack@google.com * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2612287Sgabeblack@google.com * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 2712287Sgabeblack@google.com * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2812287Sgabeblack@google.com * 2912287Sgabeblack@google.com * Authors: Ali Saidi 3012287Sgabeblack@google.com * Gabe Black 3112287Sgabeblack@google.com * Steve Reinhardt 3212287Sgabeblack@google.com */ 3312287Sgabeblack@google.com 3412287Sgabeblack@google.com#ifndef __ARCH_SPARC_INSTS_PRIV_HH__ 3512287Sgabeblack@google.com#define __ARCH_SPARC_INSTS_PRIV_HH__ 3612287Sgabeblack@google.com 3712287Sgabeblack@google.com#include "arch/sparc/insts/static_inst.hh" 3812287Sgabeblack@google.com 3912287Sgabeblack@google.comnamespace SparcISA 4012287Sgabeblack@google.com{ 4112287Sgabeblack@google.com 4212287Sgabeblack@google.com/** 4312287Sgabeblack@google.com * Base class for privelege mode operations. 4412287Sgabeblack@google.com */ 4512287Sgabeblack@google.comclass Priv : public SparcStaticInst 4612287Sgabeblack@google.com{ 4712287Sgabeblack@google.com protected: 4812287Sgabeblack@google.com using SparcStaticInst::SparcStaticInst; 4912287Sgabeblack@google.com std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 5012287Sgabeblack@google.com}; 5112287Sgabeblack@google.com 5212287Sgabeblack@google.comclass PrivReg : public Priv 5312287Sgabeblack@google.com{ 5412287Sgabeblack@google.com protected: 5512287Sgabeblack@google.com PrivReg(const char *mnem, ExtMachInst _machInst, 5612287Sgabeblack@google.com OpClass __opClass, char const * _regName) : 5712287Sgabeblack@google.com Priv(mnem, _machInst, __opClass), regName(_regName) 5812287Sgabeblack@google.com {} 5912287Sgabeblack@google.com 6012287Sgabeblack@google.com char const *regName; 6112287Sgabeblack@google.com}; 6212287Sgabeblack@google.com 6312287Sgabeblack@google.com// This class is for instructions that explicitly read control 6412287Sgabeblack@google.com// registers. It provides a special generateDisassembly function. 6512287Sgabeblack@google.comclass RdPriv : public PrivReg 6612287Sgabeblack@google.com{ 6712287Sgabeblack@google.com protected: 6812287Sgabeblack@google.com using PrivReg::PrivReg; 6912287Sgabeblack@google.com std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 7012287Sgabeblack@google.com}; 7112287Sgabeblack@google.com 7212287Sgabeblack@google.com// This class is for instructions that explicitly write control 7312287Sgabeblack@google.com// registers. It provides a special generateDisassembly function. 7412287Sgabeblack@google.comclass WrPriv : public PrivReg 7512287Sgabeblack@google.com{ 7612287Sgabeblack@google.com protected: 7712287Sgabeblack@google.com using PrivReg::PrivReg; 7812287Sgabeblack@google.com std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 7912287Sgabeblack@google.com}; 8012287Sgabeblack@google.com 8112287Sgabeblack@google.com/** 8212287Sgabeblack@google.com * Base class for privelege mode operations with immediates. 8312287Sgabeblack@google.com */ 8412287Sgabeblack@google.comclass PrivImm : public Priv 8512287Sgabeblack@google.com{ 8612287Sgabeblack@google.com protected: 8712287Sgabeblack@google.com // Constructor 8812287Sgabeblack@google.com PrivImm(const char *mnem, ExtMachInst _machInst, OpClass __opClass) : 8912287Sgabeblack@google.com Priv(mnem, _machInst, __opClass), imm(bits(_machInst, 12, 0)) 9012287Sgabeblack@google.com {} 9112287Sgabeblack@google.com 9212287Sgabeblack@google.com int32_t imm; 9312287Sgabeblack@google.com}; 9412287Sgabeblack@google.com 9512287Sgabeblack@google.com// This class is for instructions that explicitly write control 9612287Sgabeblack@google.com// registers. It provides a special generateDisassembly function. 9712287Sgabeblack@google.comclass WrPrivImm : public PrivImm 9812287Sgabeblack@google.com{ 9912287Sgabeblack@google.com protected: 10012287Sgabeblack@google.com // Constructor 10112287Sgabeblack@google.com WrPrivImm(const char *mnem, ExtMachInst _machInst, 10212287Sgabeblack@google.com OpClass __opClass, char const *_regName) : 10312287Sgabeblack@google.com PrivImm(mnem, _machInst, __opClass), regName(_regName) 10412287Sgabeblack@google.com {} 10512287Sgabeblack@google.com 10612287Sgabeblack@google.com std::string generateDisassembly(Addr pc, const SymbolTable *symtab) const; 10712287Sgabeblack@google.com 10812287Sgabeblack@google.com char const *regName; 10912287Sgabeblack@google.com} 11012287Sgabeblack@google.com; 11112287Sgabeblack@google.com} 11212287Sgabeblack@google.com 11312287Sgabeblack@google.com#endif //__ARCH_SPARC_INSTS_PRIV_HH__ 114