diff options
Diffstat (limited to 'ext/nomali/lib/mmu.cc')
-rw-r--r-- | ext/nomali/lib/mmu.cc | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/ext/nomali/lib/mmu.cc b/ext/nomali/lib/mmu.cc index 2d166b5af..11978a26d 100644 --- a/ext/nomali/lib/mmu.cc +++ b/ext/nomali/lib/mmu.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2015 ARM Limited + * Copyright (c) 2014-2016 ARM Limited * All rights reserved * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,9 +29,11 @@ MMU::MMU(GPU &_gpu) RegAddr(MMU_IRQ_RAWSTAT), RegAddr(MMU_IRQ_CLEAR), RegAddr(MMU_IRQ_MASK), - RegAddr(MMU_IRQ_STATUS)), - regs(BLOCK_NUM_REGS) + RegAddr(MMU_IRQ_STATUS)) { + spaces.reserve(16); + for (int i = 0; i < 16; ++i) + spaces.emplace_back(_gpu, *this, i); } MMU::~MMU() @@ -39,6 +41,25 @@ MMU::~MMU() } void +MMU::reset() +{ + GPUBlockInt::reset(); + + for (auto &as : spaces) + as.reset(); +} + +uint32_t +MMU::readReg(RegAddr addr) +{ + if (isAddrSpaceReg(addr)) { + return spaces[getAddrSpaceNo(addr)].readReg(getAddrSpaceAddr(addr)); + } else { + return GPUBlockInt::readReg(addr); + } +} + +void MMU::writeReg(RegAddr addr, uint32_t value) { switch (addr.value) { @@ -50,11 +71,34 @@ MMU::writeReg(RegAddr addr, uint32_t value) break; default: - // Ignore writes by default + if (isAddrSpaceReg(addr)) { + AddrSpace &as(spaces[getAddrSpaceNo(addr)]); + as.writeReg(getAddrSpaceAddr(addr), value); + } break; }; } +uint32_t +MMU::readRegRaw(RegAddr addr) +{ + if (isAddrSpaceReg(addr)) { + return spaces[getAddrSpaceNo(addr)].readRegRaw(getAddrSpaceAddr(addr)); + } else { + return GPUBlockInt::readRegRaw(addr); + } +} + +void +MMU::writeRegRaw(RegAddr addr, uint32_t value) +{ + if (isAddrSpaceReg(addr)) { + spaces[getAddrSpaceNo(addr)].writeRegRaw(getAddrSpaceAddr(addr), value); + } else { + GPUBlockInt::writeRegRaw(addr, value); + } +} + void MMU::onInterrupt(int set) { |