1// Copyright (c) 2007 The Regents of The University of Michigan 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: redistributions of source code must retain the above copyright 7// notice, this list of conditions and the following disclaimer; 8// redistributions in binary form must reproduce the above copyright 9// notice, this list of conditions and the following disclaimer in the 10// documentation and/or other materials provided with the distribution; 11// neither the name of the copyright holders nor the names of its 12// contributors may be used to endorse or promote products derived from 13// this software without specific prior written permission. 14// 15// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26// 27// Authors: Gabe Black 28// Ali Saidi 29 30// This template provides the execute functions for a swap 31def template SwapExecute {{
|
101 Trace::InstRecord * traceData) const 102 { 103 Fault fault = NoFault; 104 %(op_decl)s; 105 106 getMem(pkt, Mem, traceData); 107 uint64_t mem_data = Mem; 108 109 if (fault == NoFault) { 110 // Handle the swapping 111 %(postacc_code)s; 112 } 113 if (fault == NoFault) { 114 // Write the resulting state to the execution context 115 %(op_wb)s; 116 } 117 118 return fault; 119 } 120}}; 121 122let {{ 123 SwapFuncs = [SwapExecute, SwapInitiateAcc, SwapCompleteAcc] 124}}; 125 126 127def format Swap(code, postacc_code, mem_flags, *opt_flags) {{ 128 mem_flags = makeList(mem_flags) 129 mem_flags = [ 'Request::%s' % flag for flag in mem_flags ] 130 flags = string.join(mem_flags, '|') 131 132 (header_output, 133 decoder_output, 134 exec_output, 135 decode_block) = doMemFormat(code, SwapFuncs, '', name, Name, flags, 136 ["IsStoreConditional"], postacc_code) 137}}; 138 139def format SwapAlt(code, postacc_code, mem_flags, *opt_flags) {{ 140 mem_flags = makeList(mem_flags) 141 mem_flags = [ 'Request::%s' % flag for flag in mem_flags ] 142 mem_flags.append("EXT_ASI") 143 flags = string.join(mem_flags, '|') 144 (header_output, 145 decoder_output, 146 exec_output, 147 decode_block) = doMemFormat(code, SwapFuncs, AlternateASIPrivFaultCheck, 148 name, Name, flags, ["IsStoreConditional"], postacc_code) 149}}; 150 151 152let {{ 153 def doCasFormat(code, execute, faultCode, name, Name, mem_flags, opt_flags, postacc_code = ''): 154 addrCalcReg = 'EA = Rs1;' 155 iop = InstObjParams(name, Name, 'Mem', 156 {"code": code, "postacc_code" : postacc_code, 157 "fault_check": faultCode, "ea_code": addrCalcReg, 158 "EA_trunc" : TruncateEA}, opt_flags) 159 header_output = MemDeclare.subst(iop) 160 decoder_output = BasicConstructor.subst(iop) 161 decode_block = BasicDecode.subst(iop) 162 microParams = {"code": code, "postacc_code" : postacc_code, 163 "ea_code" : addrCalcReg, "fault_check" : faultCode, 164 "EA_trunc" : TruncateEA} 165 exec_output = doSplitExecute(execute, name, Name, mem_flags, 166 ["IsStoreConditional"], microParams); 167 return (header_output, decoder_output, exec_output + EACompExecute.subst(iop), decode_block) 168}}; 169 170 171def format CasAlt(code, postacc_code, mem_flags, *opt_flags) {{ 172 mem_flags = makeList(mem_flags) 173 mem_flags = [ 'Request::%s' % flag for flag in mem_flags ] 174 mem_flags.append("EXT_ASI") 175 flags = string.join(mem_flags, '|') 176 (header_output, 177 decoder_output, 178 exec_output, 179 decode_block) = doCasFormat(code, SwapFuncs, AlternateASIPrivFaultCheck, 180 name, Name, flags, ["IsStoreConditional"], postacc_code) 181}}; 182 183
|