tlbi_op.hh revision 12605
1/* 2 * Copyright (c) 2018 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated 11 * unmodified and in its entirety in all distributions of the software, 12 * modified or unmodified, in source code or in binary form. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions are 16 * met: redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer; 18 * redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution; 21 * neither the name of the copyright holders nor the names of its 22 * contributors may be used to endorse or promote products derived from 23 * this software without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 * 37 * Authors: Giacomo Travaglini 38 */ 39 40#ifndef __ARCH_ARM_TLBI_HH__ 41#define __ARCH_ARM_TLBI_HH__ 42 43#include "arch/arm/system.hh" 44#include "arch/arm/tlb.hh" 45#include "cpu/thread_context.hh" 46 47/** 48 * @file 49 * The file contains the definition of a set of TLB Invalidate 50 * Instructions. Those are the ISA interface for TLB flushing 51 * operations. 52 */ 53namespace ArmISA { 54 55class TLBIOp 56{ 57 public: 58 TLBIOp(ExceptionLevel _targetEL, bool _secure) 59 : secureLookup(_secure), targetEL(_targetEL) 60 {} 61 62 virtual ~TLBIOp() {} 63 virtual void operator()(ThreadContext* tc) {} 64 65 /** 66 * Broadcast the TLB Invalidate operation to all 67 * TLBs in the Arm system. 68 * @param tc Thread Context 69 */ 70 void 71 broadcast(ThreadContext *tc) 72 { 73 System *sys = tc->getSystemPtr(); 74 for (int x = 0; x < sys->numContexts(); x++) { 75 ThreadContext *oc = sys->getThreadContext(x); 76 (*this)(oc); 77 } 78 } 79 80 protected: 81 bool secureLookup; 82 ExceptionLevel targetEL; 83}; 84 85/** TLB Invalidate All */ 86class TLBIALL : public TLBIOp 87{ 88 public: 89 TLBIALL(ExceptionLevel _targetEL, bool _secure) 90 : TLBIOp(_targetEL, _secure) 91 {} 92 93 void operator()(ThreadContext* tc) override; 94}; 95 96/** Instruction TLB Invalidate All */ 97class ITLBIALL : public TLBIOp 98{ 99 public: 100 ITLBIALL(ExceptionLevel _targetEL, bool _secure) 101 : TLBIOp(_targetEL, _secure) 102 {} 103 104 void broadcast(ThreadContext *tc) = delete; 105 106 void operator()(ThreadContext* tc) override; 107}; 108 109/** Data TLB Invalidate All */ 110class DTLBIALL : public TLBIOp 111{ 112 public: 113 DTLBIALL(ExceptionLevel _targetEL, bool _secure) 114 : TLBIOp(_targetEL, _secure) 115 {} 116 117 void broadcast(ThreadContext *tc) = delete; 118 119 void operator()(ThreadContext* tc) override; 120}; 121 122/** TLB Invalidate by ASID match */ 123class TLBIASID : public TLBIOp 124{ 125 public: 126 TLBIASID(ExceptionLevel _targetEL, bool _secure, uint16_t _asid) 127 : TLBIOp(_targetEL, _secure), asid(_asid) 128 {} 129 130 void operator()(ThreadContext* tc) override; 131 132 protected: 133 uint16_t asid; 134}; 135 136/** Instruction TLB Invalidate by ASID match */ 137class ITLBIASID : public TLBIOp 138{ 139 public: 140 ITLBIASID(ExceptionLevel _targetEL, bool _secure, uint16_t _asid) 141 : TLBIOp(_targetEL, _secure), asid(_asid) 142 {} 143 144 void broadcast(ThreadContext *tc) = delete; 145 146 void operator()(ThreadContext* tc) override; 147 148 protected: 149 uint16_t asid; 150}; 151 152/** Data TLB Invalidate by ASID match */ 153class DTLBIASID : public TLBIOp 154{ 155 public: 156 DTLBIASID(ExceptionLevel _targetEL, bool _secure, uint16_t _asid) 157 : TLBIOp(_targetEL, _secure), asid(_asid) 158 {} 159 160 void broadcast(ThreadContext *tc) = delete; 161 162 void operator()(ThreadContext* tc) override; 163 164 protected: 165 uint16_t asid; 166}; 167 168/** TLB Invalidate All, Non-Secure */ 169class TLBIALLN : public TLBIOp 170{ 171 public: 172 TLBIALLN(ExceptionLevel _targetEL, bool _hyp) 173 : TLBIOp(_targetEL, false), hyp(_hyp) 174 {} 175 176 void operator()(ThreadContext* tc) override; 177 178 protected: 179 bool hyp; 180}; 181 182/** TLB Invalidate by VA, All ASID */ 183class TLBIMVAA : public TLBIOp 184{ 185 public: 186 TLBIMVAA(ExceptionLevel _targetEL, bool _secure, 187 Addr _addr, bool _hyp) 188 : TLBIOp(_targetEL, _secure), addr(_addr), hyp(_hyp) 189 {} 190 191 void operator()(ThreadContext* tc) override; 192 193 protected: 194 Addr addr; 195 bool hyp; 196}; 197 198/** TLB Invalidate by VA */ 199class TLBIMVA : public TLBIOp 200{ 201 public: 202 TLBIMVA(ExceptionLevel _targetEL, bool _secure, 203 Addr _addr, uint16_t _asid) 204 : TLBIOp(_targetEL, _secure), addr(_addr), asid(_asid) 205 {} 206 207 void operator()(ThreadContext* tc) override; 208 209 protected: 210 Addr addr; 211 uint16_t asid; 212}; 213 214/** Instruction TLB Invalidate by VA */ 215class ITLBIMVA : public TLBIOp 216{ 217 public: 218 ITLBIMVA(ExceptionLevel _targetEL, bool _secure, 219 Addr _addr, uint16_t _asid) 220 : TLBIOp(_targetEL, _secure), addr(_addr), asid(_asid) 221 {} 222 223 void broadcast(ThreadContext *tc) = delete; 224 225 void operator()(ThreadContext* tc) override; 226 227 protected: 228 Addr addr; 229 uint16_t asid; 230}; 231 232/** Data TLB Invalidate by VA */ 233class DTLBIMVA : public TLBIOp 234{ 235 public: 236 DTLBIMVA(ExceptionLevel _targetEL, bool _secure, 237 Addr _addr, uint16_t _asid) 238 : TLBIOp(_targetEL, _secure), addr(_addr), asid(_asid) 239 {} 240 241 void broadcast(ThreadContext *tc) = delete; 242 243 void operator()(ThreadContext* tc) override; 244 245 protected: 246 Addr addr; 247 uint16_t asid; 248}; 249 250/** TLB Invalidate by Intermediate Physical Address */ 251class TLBIIPA : public TLBIOp 252{ 253 public: 254 TLBIIPA(ExceptionLevel _targetEL, bool _secure, Addr _addr) 255 : TLBIOp(_targetEL, _secure), addr(_addr) 256 {} 257 258 void operator()(ThreadContext* tc) override; 259 260 protected: 261 Addr addr; 262}; 263 264} // namespace ArmISA 265 266#endif //__ARCH_ARM_TLBI_HH__ 267