#define __ARCH_ARM_MACROMEM_HH__
#include "arch/arm/insts/pred_inst.hh"
+#include "arch/arm/tlb.hh"
namespace ArmISA
{
MicroMemOp(const char *mnem, ExtMachInst machInst, OpClass __opClass,
RegIndex _ura, RegIndex _urb, bool _up, uint8_t _imm)
: MicroIntOp(mnem, machInst, __opClass, _ura, _urb, _imm),
- up(_up), memAccessFlags(0)
+ up(_up), memAccessFlags(TLB::MustBeOne | TLB::AlignWord)
{
}
};
#TBB, TBH
for isTbh in (0, 1):
if isTbh:
- eaCode = "EA = Op1 + Op2 * 2"
+ eaCode = '''
+ unsigned memAccessFlags = ArmISA::TLB::AllowUnaligned |
+ ArmISA::TLB::AlignHalfWord |
+ ArmISA::TLB::MustBeOne;
+ EA = Op1 + Op2 * 2
+ '''
accCode = "NPC = readPC(xc) + 2 * (Mem.uh);"
mnem = "tbh"
else:
- eaCode = "EA = Op1 + Op2"
+ eaCode = '''
+ unsigned memAccessFlags = ArmISA::TLB::AllowUnaligned |
+ ArmISA::TLB::AlignByte |
+ ArmISA::TLB::MustBeOne;
+ EA = Op1 + Op2
+ '''
accCode = "NPC = readPC(xc) + 2 * (Mem.ub);"
mnem = "tbb"
- eaCode = "unsigned memAccessFlags = 0;\n" + eaCode
iop = InstObjParams(mnem, mnem.capitalize(), "BranchRegReg",
{'ea_code': eaCode,
'memacc_code': accCode,
eaCode += offset
eaCode += ";"
+ memFlags = ["ArmISA::TLB::MustBeOne", "%d" % (size - 1)]
if prefetch:
Name = "%s_%s" % (mnem.upper(), Name)
- memFlags = ["Request::PREFETCH"]
+ memFlags.append("Request::PREFETCH")
accCode = '''
uint64_t temp = Mem%s;\n
temp = temp;
''' % buildMemSuffix(sign, size)
else:
if ldrex:
- memFlags = ["Request::LLSC"]
+ memFlags.append("Request::LLSC")
Name = "%s_%s" % (mnem.upper(), Name)
- else:
- memFlags = []
accCode = "IWDest = Mem%s;\n" % buildMemSuffix(sign, size)
+
+ if not prefetch and not ldrex:
+ memFlags.append("ArmISA::TLB::AllowUnaligned")
+
if writeback:
accCode += "Base = Base %s;\n" % offset
base = buildMemBase("MemoryImm", post, writeback)
(newHeader,
newDecoder,
- newExec) = RfeBase(name, Name, eaCode, accCode, [], [])
+ newExec) = RfeBase(name, Name, eaCode, accCode,
+ ["ArmISA::TLB::AlignWord", "ArmISA::TLB::MustBeOne"], [])
header_output += newHeader
decoder_output += newDecoder
eaCode += offset
eaCode += ";"
+ memFlags = ["%d" % (size - 1), "ArmISA::TLB::MustBeOne"]
if prefetch:
Name = "%s_%s" % (mnem.upper(), Name)
- memFlags = ["Request::PREFETCH"]
+ memFlags.append("Request::PREFETCH")
accCode = '''
uint64_t temp = Mem%s;\n
temp = temp;
''' % buildMemSuffix(sign, size)
else:
- memFlags = []
accCode = "IWDest = Mem%s;\n" % buildMemSuffix(sign, size)
if writeback:
accCode += "Base = Base %s;\n" % offset
+
+ if not prefetch:
+ memFlags.append("ArmISA::TLB::AllowUnaligned")
+
base = buildMemBase("MemoryReg", post, writeback)
emitLoad(name, Name, False, eaCode, accCode, \
accCode += "Base = Base %s;\n" % offset
base = buildMemBase("MemoryDImm", post, writeback)
+ memFlags.extend(["ArmISA::TLB::MustBeOne",
+ "ArmISA::TLB::AlignWord"])
+
emitLoad(name, Name, True, eaCode, accCode, \
memFlags, [], base, double=True)
base = buildMemBase("MemoryDReg", post, writeback)
emitLoad(name, Name, False, eaCode, accCode,
- [], [], base, double=True)
+ ["ArmISA::TLB::MustBeOne", "ArmISA::TLB::AlignWord"],
+ [], base, double=True)
def buildLoads(mnem, size=4, sign=False, user=False):
buildImmLoad(mnem, True, True, True, size, sign, user)
# This shouldn't be part of the eaCode, but until the exec templates
# are converted over it's the easiest place to put it.
eaCode += '\n unsigned memAccessFlags = '
- if memFlags:
- eaCode += (string.join(memFlags, '|') + ';')
- else:
- eaCode += '0;'
+ eaCode += (string.join(memFlags, '|') + ';')
codeBlobs["ea_code"] = eaCode
accCode += "Base = Base %s;\n" % offset
base = buildMemBase("MemoryImm", post, writeback)
- emitStore(name, Name, True, eaCode, accCode, [], [], base)
+ emitStore(name, Name, True, eaCode, accCode, \
+ ["ArmISA::TLB::MustBeOne", \
+ "ArmISA::TLB::AllowUnaligned", \
+ "%d" % (size - 1)], [], base)
def buildRegStore(mnem, post, add, writeback, \
size=4, sign=False, user=False):
accCode += "Base = Base %s;\n" % offset
base = buildMemBase("MemoryReg", post, writeback)
- emitStore(name, Name, False, eaCode, accCode, [], [], base)
+ emitStore(name, Name, False, eaCode, accCode, \
+ ["ArmISA::TLB::MustBeOne", \
+ "ArmISA::TLB::AllowUnaligned", \
+ "%d" % (size - 1)], [], base)
def buildDoubleImmStore(mnem, post, add, writeback):
name = mnem
base = buildMemBase("MemoryDImm", post, writeback)
emitStore(name, Name, True, eaCode, accCode, \
- [], [], base, double=True)
+ ["ArmISA::TLB::MustBeOne",
+ "ArmISA::TLB::AlignWord"], [], base, double=True)
def buildDoubleRegStore(mnem, post, add, writeback):
name = mnem
base = buildMemBase("MemoryDReg", post, writeback)
emitStore(name, Name, False, eaCode, accCode, \
- [], [], base, double=True)
+ ["ArmISA::TLB::MustBeOne", \
+ "ArmISA::TLB::AlignWord"], [], base, double=True)
def buildStores(mnem, size=4, sign=False, user=False):
buildImmStore(mnem, True, True, True, size, sign, user)
newDecoder,
newExec) = SwapBase("swp", "Swp", "EA = Base;",
"Mem = Op1;", "Dest = memData;",
- ["Request::MEM_SWAP"], [])
+ ["Request::MEM_SWAP",
+ "ArmISA::TLB::AlignWord",
+ "ArmISA::TLB::MustBeOne"], [])
header_output += newHeader
decoder_output += newDecoder
exec_output += newExec
newDecoder,
newExec) = SwapBase("swpb", "Swpb", "EA = Base;",
"Mem.ub = Op1.ub;", "Dest.ub = (uint8_t)memData;",
- ["Request::MEM_SWAP"], [])
+ ["Request::MEM_SWAP",
+ "ArmISA::TLB::AlignByte",
+ "ArmISA::TLB::MustBeOne"], [])
header_output += newHeader
decoder_output += newDecoder
exec_output += newExec
TLB::translateAtomic(RequestPtr req, ThreadContext *tc, Mode mode)
{
Addr vaddr = req->getVaddr() & ~PcModeMask;
+ SCTLR sctlr = tc->readMiscReg(MISCREG_SCTLR);
+ uint32_t flags = req->getFlags();
+
+ if (mode != Execute) {
+ assert(flags & MustBeOne);
+
+ if (sctlr.a || (flags & AllowUnaligned) == 0) {
+ if ((vaddr & flags & AlignmentMask) != 0) {
+ return new DataAbort;
+ }
+ }
+ }
#if !FULL_SYSTEM
Process * p = tc->getProcessPtr();
return NoFault;
#else
- SCTLR sctlr = tc->readMiscReg(MISCREG_SCTLR);
if (!sctlr.m) {
req->setPaddr(vaddr);
return NoFault;
class TLB : public BaseTLB
{
+ public:
+ enum ArmFlags {
+ AlignmentMask = 0x7,
+
+ AlignByte = 0x0,
+ AlignHalfWord = 0x1,
+ AlignWord = 0x3,
+ AlignDoubleWord = 0x7,
+
+ AllowUnaligned = 0x8,
+ // Because zero otherwise looks like a valid setting and may be used
+ // accidentally, this bit must be non-zero to show it was used on
+ // purpose.
+ MustBeOne = 0x10
+ };
protected:
typedef std::multimap<Addr, int> PageTable;
PageTable lookupTable; // Quick lookup into page table