1// Copyright (c) 2006 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 --- 148 unchanged lines hidden (view full) --- 157 if(fault == NoFault) 158 { 159 //Write the resulting state to the execution context 160 %(op_wb)s; 161 } 162 163 return fault; 164 } |
165}}; |
166 |
167def template LoadInitiateAcc {{ |
168 Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s * xc, 169 Trace::InstRecord * traceData) const 170 { 171 Fault fault = NoFault; 172 Addr EA; 173 uint%(mem_acc_size)s_t Mem; |
174 %(op_decl)s; 175 %(op_rd)s; |
176 %(ea_code)s; 177 DPRINTF(Sparc, "%s: The address is 0x%x\n", mnemonic, EA); 178 %(fault_check)s; 179 if(fault == NoFault) 180 { 181 fault = xc->read(EA, (uint%(mem_acc_size)s_t&)Mem, 0); 182 } 183 return fault; 184 } |
185}}; |
186 |
187def template LoadCompleteAcc {{ |
188 Fault %(class_name)s::completeAcc(PacketPtr pkt, %(CPU_exec_context)s * xc, 189 Trace::InstRecord * traceData) const 190 { 191 Fault fault = NoFault; |
192 %(op_decl)s; 193 %(op_rd)s; |
194 Mem = pkt->get<typeof(Mem)>(); 195 %(code)s; 196 if(fault == NoFault) 197 { |
198 %(op_wb)s; |
199 } 200 return fault; 201 } 202}}; 203 204//This template provides the execute functions for a store 205def template StoreExecute {{ 206 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, --- 20 unchanged lines hidden (view full) --- 227 if(fault == NoFault) 228 { 229 //Write the resulting state to the execution context 230 %(op_wb)s; 231 } 232 233 return fault; 234 } |
235}}; |
236 |
237def template StoreInitiateAcc {{ |
238 Fault %(class_name)s::initiateAcc(%(CPU_exec_context)s * xc, 239 Trace::InstRecord * traceData) const 240 { 241 Fault fault = NoFault; 242 bool storeCond = true; 243 Addr EA; 244 %(op_decl)s; 245 %(op_rd)s; --- 10 unchanged lines hidden (view full) --- 256 } 257 if(fault == NoFault) 258 { 259 //Write the resulting state to the execution context 260 %(op_wb)s; 261 } 262 return fault; 263 } |
264}}; |
265 |
266def template StoreCompleteAcc {{ |
267 Fault %(class_name)s::completeAcc(PacketPtr, %(CPU_exec_context)s * xc, 268 Trace::InstRecord * traceData) const 269 { 270 return NoFault; 271 } 272}}; 273 274//This delcares the initiateAcc function in memory operations 275def template InitiateAccDeclare {{ 276 Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const; 277}}; 278 279//This declares the completeAcc function in memory operations 280def template CompleteAccDeclare {{ 281 Fault completeAcc(PacketPtr, %(CPU_exec_context)s *, Trace::InstRecord *) const; 282}}; 283 284//Here are some code snippets which check for various fault conditions 285let {{ |
286 LoadFuncs = [LoadExecute, LoadInitiateAcc, LoadCompleteAcc] 287 StoreFuncs = [StoreExecute, StoreInitiateAcc, StoreCompleteAcc] |
288 # The LSB can be zero, since it's really the MSB in doubles and quads 289 # and we're dealing with doubles 290 BlockAlignmentFaultCheck = ''' 291 if(RD & 0xe) 292 fault = new IllegalInstruction; 293 else if(EA & 0x3f) 294 fault = new MemAddressNotAligned; 295 ''' --- 17 unchanged lines hidden (view full) --- 313}}; 314 315//This function properly generates the execute functions for one of the 316//templates above. This is needed because in one case, ea computation, 317//fault checks and the actual code all occur in the same function, 318//and in the other they're distributed across two. Also note that for 319//execute functions, the name of the base class doesn't matter. 320let {{ |
321 def doSplitExecute(execute, name, Name, opt_flags, microParam): 322 iop = InstObjParams(name, Name, '', microParam, opt_flags) 323 (execf, initf, compf) = execute 324 return execf.subst(iop) + initf.subst(iop) + compf.subst(iop) |
325 326 327 def doDualSplitExecute(code, eaRegCode, eaImmCode, execute, 328 faultCode, nameReg, nameImm, NameReg, NameImm, opt_flags): 329 executeCode = '' 330 for (eaCode, name, Name) in ( 331 (eaRegCode, nameReg, NameReg), 332 (eaImmCode, nameImm, NameImm)): |
333 microParams = {"code": code, "ea_code": eaCode, 334 "fault_check": faultCode} 335 executeCode += doSplitExecute(execute, name, Name, |
336 opt_flags, microParams) 337 return executeCode 338}}; |