2010-06-02 19:58:16 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2010 ARM Limited
|
|
|
|
* All rights reserved
|
|
|
|
*
|
|
|
|
* The license below extends only to copyright in the software and shall
|
|
|
|
* not be construed as granting a license to any other intellectual
|
|
|
|
* property including but not limited to intellectual property relating
|
|
|
|
* to a hardware implementation of the functionality of the software
|
|
|
|
* licensed hereunder. You may use the software subject to the license
|
|
|
|
* terms below provided that you ensure that this notice is replicated
|
|
|
|
* unmodified and in its entirety in all distributions of the software,
|
|
|
|
* modified or unmodified, in source code or in binary form.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met: redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer;
|
|
|
|
* redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution;
|
|
|
|
* neither the name of the copyright holders nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Authors: Ali Saidi
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "arch/arm/faults.hh"
|
|
|
|
#include "arch/arm/table_walker.hh"
|
|
|
|
#include "arch/arm/tlb.hh"
|
|
|
|
#include "dev/io_device.hh"
|
|
|
|
#include "cpu/thread_context.hh"
|
|
|
|
|
|
|
|
using namespace ArmISA;
|
|
|
|
|
|
|
|
TableWalker::TableWalker(const Params *p)
|
2010-08-23 18:18:39 +02:00
|
|
|
: MemObject(p), port(NULL), tlb(NULL),
|
2010-06-02 19:58:18 +02:00
|
|
|
currState(NULL), doL1DescEvent(this), doL2DescEvent(this)
|
|
|
|
{
|
2010-08-23 18:18:39 +02:00
|
|
|
sctlr = 0;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
TableWalker::~TableWalker()
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
drain(Event *de)
|
|
|
|
{
|
|
|
|
panic("Not implemented\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
Port*
|
|
|
|
TableWalker::getPort(const std::string &if_name, int idx)
|
|
|
|
{
|
|
|
|
if (if_name == "port") {
|
|
|
|
if (port != NULL)
|
|
|
|
fatal("%s: port already connected to %s",
|
|
|
|
name(), port->getPeer()->name());
|
|
|
|
System *sys = params()->sys;
|
|
|
|
Tick minb = params()->min_backoff;
|
|
|
|
Tick maxb = params()->max_backoff;
|
|
|
|
port = new DmaPort(this, sys, minb, maxb);
|
|
|
|
return port;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Fault
|
2010-06-02 19:58:18 +02:00
|
|
|
TableWalker::walk(RequestPtr _req, ThreadContext *_tc, uint8_t _cid, TLB::Mode _mode,
|
2010-06-02 19:58:16 +02:00
|
|
|
TLB::Translation *_trans, bool _timing)
|
|
|
|
{
|
2010-06-02 19:58:18 +02:00
|
|
|
if (!currState) {
|
|
|
|
// For atomic mode, a new WalkerState instance should be only created
|
|
|
|
// once per TLB. For timing mode, a new instance is generated for every
|
|
|
|
// TLB miss.
|
|
|
|
DPRINTF(TLBVerbose, "creating new instance of WalkerState\n");
|
|
|
|
|
|
|
|
currState = new WalkerState();
|
|
|
|
currState->tableWalker = this;
|
|
|
|
}
|
|
|
|
else if (_timing) {
|
|
|
|
panic("currState should always be empty in timing mode!\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
currState->tc = _tc;
|
|
|
|
currState->transState = _trans;
|
|
|
|
currState->req = _req;
|
|
|
|
currState->fault = NoFault;
|
|
|
|
currState->contextId = _cid;
|
|
|
|
currState->timing = _timing;
|
|
|
|
currState->mode = _mode;
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
/** @todo These should be cached or grabbed from cached copies in
|
|
|
|
the TLB, all these miscreg reads are expensive */
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->vaddr = currState->req->getVaddr() & ~PcModeMask;
|
|
|
|
currState->sctlr = currState->tc->readMiscReg(MISCREG_SCTLR);
|
|
|
|
sctlr = currState->sctlr;
|
|
|
|
currState->cpsr = currState->tc->readMiscReg(MISCREG_CPSR);
|
|
|
|
currState->N = currState->tc->readMiscReg(MISCREG_TTBCR);
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->isFetch = (currState->mode == TLB::Execute);
|
|
|
|
currState->isWrite = (currState->mode == TLB::Write);
|
|
|
|
currState->isPriv = (currState->cpsr.mode != MODE_USER);
|
|
|
|
|
|
|
|
Addr ttbr = 0;
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
// If translation isn't enabled, we shouldn't be here
|
2010-06-02 19:58:18 +02:00
|
|
|
assert(currState->sctlr.m);
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, "Begining table walk for address %#x, TTBCR: %#x, bits:%#x\n",
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->vaddr, currState->N, mbits(currState->vaddr, 31,
|
|
|
|
32-currState->N));
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->N == 0 || !mbits(currState->vaddr, 31, 32-currState->N)) {
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, " - Selecting TTBR0\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
ttbr = currState->tc->readMiscReg(MISCREG_TTBR0);
|
2010-06-02 19:58:16 +02:00
|
|
|
} else {
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, " - Selecting TTBR1\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
ttbr = currState->tc->readMiscReg(MISCREG_TTBR1);
|
|
|
|
currState->N = 0;
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
Addr l1desc_addr = mbits(ttbr, 31, 14-currState->N) |
|
|
|
|
(bits(currState->vaddr,31-currState->N,20) << 2);
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, " - Descriptor at address %#x\n", l1desc_addr);
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Trickbox address check
|
2010-06-02 19:58:18 +02:00
|
|
|
Fault f;
|
|
|
|
f = tlb->walkTrickBoxCheck(l1desc_addr, currState->vaddr, sizeof(uint32_t),
|
|
|
|
currState->isFetch, currState->isWrite, 0, true);
|
|
|
|
if (f) {
|
2010-08-23 18:18:39 +02:00
|
|
|
if (currState->timing) {
|
|
|
|
currState->transState->finish(f, currState->req,
|
|
|
|
currState->tc, currState->mode);
|
|
|
|
currState = NULL;
|
|
|
|
} else {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
|
|
|
}
|
|
|
|
return f;
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->timing) {
|
2010-06-02 19:58:16 +02:00
|
|
|
port->dmaAction(MemCmd::ReadReq, l1desc_addr, sizeof(uint32_t),
|
2010-06-02 19:58:18 +02:00
|
|
|
&doL1DescEvent, (uint8_t*)&currState->l1Desc.data, (Tick)0);
|
2010-08-23 18:18:39 +02:00
|
|
|
DPRINTF(TLBVerbose, "Adding to walker fifo: queue size before adding: %d\n",
|
|
|
|
stateQueue.size());
|
|
|
|
stateQueue.push_back(currState);
|
|
|
|
assert(stateQueue.size() < 5);
|
2010-06-02 19:58:18 +02:00
|
|
|
currState = NULL;
|
2010-06-02 19:58:16 +02:00
|
|
|
} else {
|
2010-08-23 18:18:41 +02:00
|
|
|
Request::Flags flag = 0;
|
|
|
|
if (currState->sctlr.c == 0){
|
|
|
|
flag = Request::UNCACHEABLE;
|
|
|
|
}
|
2010-06-02 19:58:16 +02:00
|
|
|
port->dmaAction(MemCmd::ReadReq, l1desc_addr, sizeof(uint32_t),
|
2010-08-23 18:18:41 +02:00
|
|
|
NULL, (uint8_t*)&currState->l1Desc.data, (Tick)0, flag);
|
2010-06-02 19:58:16 +02:00
|
|
|
doL1Descriptor();
|
2010-06-02 19:58:18 +02:00
|
|
|
f = currState->fault;
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
return f;
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2010-06-02 19:58:18 +02:00
|
|
|
TableWalker::memAttrs(ThreadContext *tc, TlbEntry &te, SCTLR sctlr,
|
|
|
|
uint8_t texcb, bool s)
|
2010-06-02 19:58:16 +02:00
|
|
|
{
|
2010-06-02 19:58:18 +02:00
|
|
|
// Note: tc and sctlr local variables are hiding tc and sctrl class
|
|
|
|
// variables
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "memAttrs texcb:%d s:%d\n", texcb, s);
|
|
|
|
te.shareable = false; // default value
|
2010-08-23 18:18:39 +02:00
|
|
|
te.nonCacheable = false;
|
2010-06-02 19:58:18 +02:00
|
|
|
bool outer_shareable = false;
|
2010-06-02 19:58:18 +02:00
|
|
|
if (sctlr.tre == 0 || ((sctlr.tre == 1) && (sctlr.m == 0))) {
|
2010-06-02 19:58:16 +02:00
|
|
|
switch(texcb) {
|
2010-06-02 19:58:18 +02:00
|
|
|
case 0: // Stongly-ordered
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.mtype = TlbEntry::StronglyOrdered;
|
|
|
|
te.shareable = true;
|
|
|
|
te.innerAttrs = 1;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
break;
|
|
|
|
case 1: // Shareable Device
|
2010-06-02 19:58:16 +02:00
|
|
|
te.nonCacheable = true;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.mtype = TlbEntry::Device;
|
|
|
|
te.shareable = true;
|
|
|
|
te.innerAttrs = 3;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
break;
|
|
|
|
case 2: // Outer and Inner Write-Through, no Write-Allocate
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
te.shareable = s;
|
|
|
|
te.innerAttrs = 6;
|
|
|
|
te.outerAttrs = bits(texcb, 1, 0);
|
|
|
|
break;
|
|
|
|
case 3: // Outer and Inner Write-Back, no Write-Allocate
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
te.shareable = s;
|
|
|
|
te.innerAttrs = 7;
|
|
|
|
te.outerAttrs = bits(texcb, 1, 0);
|
|
|
|
break;
|
|
|
|
case 4: // Outer and Inner Non-cacheable
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
te.shareable = s;
|
|
|
|
te.innerAttrs = 0;
|
|
|
|
te.outerAttrs = bits(texcb, 1, 0);
|
|
|
|
break;
|
|
|
|
case 5: // Reserved
|
2010-06-02 19:58:18 +02:00
|
|
|
panic("Reserved texcb value!\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
break;
|
|
|
|
case 6: // Implementation Defined
|
2010-06-02 19:58:18 +02:00
|
|
|
panic("Implementation-defined texcb value!\n");
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
2010-06-02 19:58:18 +02:00
|
|
|
case 7: // Outer and Inner Write-Back, Write-Allocate
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
te.shareable = s;
|
|
|
|
te.innerAttrs = 5;
|
|
|
|
te.outerAttrs = 1;
|
|
|
|
break;
|
|
|
|
case 8: // Non-shareable Device
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.mtype = TlbEntry::Device;
|
|
|
|
te.shareable = false;
|
|
|
|
te.innerAttrs = 3;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
break;
|
|
|
|
case 9 ... 15: // Reserved
|
2010-06-02 19:58:18 +02:00
|
|
|
panic("Reserved texcb value!\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
break;
|
|
|
|
case 16 ... 31: // Cacheable Memory
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
te.shareable = s;
|
2010-06-02 19:58:16 +02:00
|
|
|
if (bits(texcb, 1,0) == 0 || bits(texcb, 3,2) == 0)
|
|
|
|
te.nonCacheable = true;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.innerAttrs = bits(texcb, 1, 0);
|
|
|
|
te.outerAttrs = bits(texcb, 3, 2);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
2010-06-02 19:58:18 +02:00
|
|
|
default:
|
|
|
|
panic("More than 32 states for 5 bits?\n");
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
} else {
|
2010-06-02 19:58:18 +02:00
|
|
|
assert(tc);
|
2010-06-02 19:58:16 +02:00
|
|
|
PRRR prrr = tc->readMiscReg(MISCREG_PRRR);
|
|
|
|
NMRR nmrr = tc->readMiscReg(MISCREG_NMRR);
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "memAttrs PRRR:%08x NMRR:%08x\n", prrr, nmrr);
|
2010-08-23 18:18:39 +02:00
|
|
|
uint8_t curr_tr = 0, curr_ir = 0, curr_or = 0;
|
2010-06-02 19:58:16 +02:00
|
|
|
switch(bits(texcb, 2,0)) {
|
|
|
|
case 0:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr0;
|
|
|
|
curr_ir = nmrr.ir0;
|
|
|
|
curr_or = nmrr.or0;
|
|
|
|
outer_shareable = (prrr.nos0 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr1;
|
|
|
|
curr_ir = nmrr.ir1;
|
|
|
|
curr_or = nmrr.or1;
|
|
|
|
outer_shareable = (prrr.nos1 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 2:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr2;
|
|
|
|
curr_ir = nmrr.ir2;
|
|
|
|
curr_or = nmrr.or2;
|
|
|
|
outer_shareable = (prrr.nos2 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 3:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr3;
|
|
|
|
curr_ir = nmrr.ir3;
|
|
|
|
curr_or = nmrr.or3;
|
|
|
|
outer_shareable = (prrr.nos3 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 4:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr4;
|
|
|
|
curr_ir = nmrr.ir4;
|
|
|
|
curr_or = nmrr.or4;
|
|
|
|
outer_shareable = (prrr.nos4 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 5:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr5;
|
|
|
|
curr_ir = nmrr.ir5;
|
|
|
|
curr_or = nmrr.or5;
|
|
|
|
outer_shareable = (prrr.nos5 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
panic("Imp defined type\n");
|
|
|
|
case 7:
|
2010-06-02 19:58:18 +02:00
|
|
|
curr_tr = prrr.tr7;
|
|
|
|
curr_ir = nmrr.ir7;
|
|
|
|
curr_or = nmrr.or7;
|
|
|
|
outer_shareable = (prrr.nos7 == 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
break;
|
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
|
|
|
|
switch(curr_tr) {
|
|
|
|
case 0:
|
|
|
|
DPRINTF(TLBVerbose, "StronglyOrdered\n");
|
|
|
|
te.mtype = TlbEntry::StronglyOrdered;
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.innerAttrs = 1;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
te.shareable = true;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
DPRINTF(TLBVerbose, "Device ds1:%d ds0:%d s:%d\n",
|
|
|
|
prrr.ds1, prrr.ds0, s);
|
|
|
|
te.mtype = TlbEntry::Device;
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.innerAttrs = 3;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
if (prrr.ds1 && s)
|
|
|
|
te.shareable = true;
|
|
|
|
if (prrr.ds0 && !s)
|
|
|
|
te.shareable = true;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
DPRINTF(TLBVerbose, "Normal ns1:%d ns0:%d s:%d\n",
|
|
|
|
prrr.ns1, prrr.ns0, s);
|
|
|
|
te.mtype = TlbEntry::Normal;
|
|
|
|
if (prrr.ns1 && s)
|
|
|
|
te.shareable = true;
|
|
|
|
if (prrr.ns0 && !s)
|
|
|
|
te.shareable = true;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
panic("Reserved type");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (te.mtype == TlbEntry::Normal){
|
|
|
|
switch(curr_ir) {
|
|
|
|
case 0:
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.innerAttrs = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
te.innerAttrs = 5;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
te.innerAttrs = 6;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
te.innerAttrs = 7;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(curr_or) {
|
|
|
|
case 0:
|
|
|
|
te.nonCacheable = true;
|
|
|
|
te.outerAttrs = 0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
te.outerAttrs = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
te.outerAttrs = 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
te.outerAttrs = 3;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "memAttrs: shareable: %d, innerAttrs: %d, \
|
|
|
|
outerAttrs: %d\n",
|
|
|
|
te.shareable, te.innerAttrs, te.outerAttrs);
|
2010-06-02 19:58:18 +02:00
|
|
|
|
|
|
|
/** Formatting for Physical Address Register (PAR)
|
|
|
|
* Only including lower bits (TLB info here)
|
|
|
|
* PAR:
|
|
|
|
* PA [31:12]
|
|
|
|
* Reserved [11]
|
|
|
|
* TLB info [10:1]
|
|
|
|
* NOS [10] (Not Outer Sharable)
|
|
|
|
* NS [9] (Non-Secure)
|
|
|
|
* -- [8] (Implementation Defined)
|
|
|
|
* SH [7] (Sharable)
|
|
|
|
* Inner[6:4](Inner memory attributes)
|
|
|
|
* Outer[3:2](Outer memory attributes)
|
|
|
|
* SS [1] (SuperSection)
|
|
|
|
* F [0] (Fault, Fault Status in [6:1] if faulted)
|
|
|
|
*/
|
|
|
|
te.attributes = (
|
|
|
|
((outer_shareable ? 0:1) << 10) |
|
|
|
|
// TODO: NS Bit
|
|
|
|
((te.shareable ? 1:0) << 7) |
|
|
|
|
(te.innerAttrs << 4) |
|
|
|
|
(te.outerAttrs << 2)
|
|
|
|
// TODO: Supersection bit
|
|
|
|
// TODO: Fault bit
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TableWalker::doL1Descriptor()
|
|
|
|
{
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLB, "L1 descriptor for %#x is %#x\n",
|
|
|
|
currState->vaddr, currState->l1Desc.data);
|
2010-06-02 19:58:16 +02:00
|
|
|
TlbEntry te;
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
switch (currState->l1Desc.type()) {
|
2010-06-02 19:58:16 +02:00
|
|
|
case L1Descriptor::Ignore:
|
|
|
|
case L1Descriptor::Reserved:
|
2010-06-02 19:58:18 +02:00
|
|
|
if (!currState->delayed) {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, "L1 Descriptor Reserved/Ignore, causing fault\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->isFetch)
|
|
|
|
currState->fault =
|
|
|
|
new PrefetchAbort(currState->vaddr, ArmFault::Translation0);
|
2010-06-02 19:58:16 +02:00
|
|
|
else
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault =
|
2010-08-23 18:18:39 +02:00
|
|
|
new DataAbort(currState->vaddr, 0, currState->isWrite,
|
2010-06-02 19:58:18 +02:00
|
|
|
ArmFault::Translation0);
|
2010-06-02 19:58:16 +02:00
|
|
|
return;
|
|
|
|
case L1Descriptor::Section:
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->sctlr.afe && bits(currState->l1Desc.ap(), 0) == 0) {
|
2010-06-02 19:58:18 +02:00
|
|
|
/** @todo: check sctlr.ha (bit[17]) if Hardware Access Flag is
|
|
|
|
* enabled if set, do l1.Desc.setAp0() instead of generating
|
|
|
|
* AccessFlag0
|
|
|
|
*/
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault =
|
|
|
|
new DataAbort(currState->vaddr, NULL, currState->isWrite,
|
2010-06-02 19:58:18 +02:00
|
|
|
ArmFault::AccessFlag0);
|
|
|
|
}
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->l1Desc.supersection()) {
|
2010-06-02 19:58:16 +02:00
|
|
|
panic("Haven't implemented supersections\n");
|
|
|
|
}
|
|
|
|
te.N = 20;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.pfn = currState->l1Desc.pfn();
|
2010-06-02 19:58:16 +02:00
|
|
|
te.size = (1<<te.N) - 1;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.global = !currState->l1Desc.global();
|
2010-06-02 19:58:16 +02:00
|
|
|
te.valid = true;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.vpn = currState->vaddr >> te.N;
|
2010-06-02 19:58:16 +02:00
|
|
|
te.sNp = true;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.xn = currState->l1Desc.xn();
|
|
|
|
te.ap = currState->l1Desc.ap();
|
|
|
|
te.domain = currState->l1Desc.domain();
|
|
|
|
te.asid = currState->contextId;
|
|
|
|
memAttrs(currState->tc, te, currState->sctlr,
|
|
|
|
currState->l1Desc.texcb(), currState->l1Desc.shareable());
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
DPRINTF(TLB, "Inserting Section Descriptor into TLB\n");
|
2010-08-23 18:18:39 +02:00
|
|
|
DPRINTF(TLB, " - N:%d pfn:%#x size: %#x global:%d valid: %d\n",
|
2010-06-02 19:58:16 +02:00
|
|
|
te.N, te.pfn, te.size, te.global, te.valid);
|
2010-08-23 18:18:39 +02:00
|
|
|
DPRINTF(TLB, " - vpn:%#x sNp: %d xn:%d ap:%d domain: %d asid:%d nc:%d\n",
|
|
|
|
te.vpn, te.sNp, te.xn, te.ap, te.domain, te.asid,
|
|
|
|
te.nonCacheable);
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, " - domain from l1 desc: %d data: %#x bits:%d\n",
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->l1Desc.domain(), currState->l1Desc.data,
|
|
|
|
(currState->l1Desc.data >> 5) & 0xF );
|
2010-06-02 19:58:16 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (!currState->timing) {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
tlb->insert(currState->vaddr, te);
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
return;
|
|
|
|
case L1Descriptor::PageTable:
|
|
|
|
Addr l2desc_addr;
|
2010-06-02 19:58:18 +02:00
|
|
|
l2desc_addr = currState->l1Desc.l2Addr() |
|
|
|
|
(bits(currState->vaddr, 19,12) << 2);
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLB, "L1 descriptor points to page table at: %#x\n",
|
|
|
|
l2desc_addr);
|
2010-06-02 19:58:16 +02:00
|
|
|
|
|
|
|
// Trickbox address check
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault = tlb->walkTrickBoxCheck(l2desc_addr, currState->vaddr,
|
|
|
|
sizeof(uint32_t), currState->isFetch, currState->isWrite,
|
|
|
|
currState->l1Desc.domain(), false);
|
|
|
|
|
|
|
|
if (currState->fault) {
|
|
|
|
if (!currState->timing) {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
return;
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->timing) {
|
|
|
|
currState->delayed = true;
|
2010-06-02 19:58:16 +02:00
|
|
|
port->dmaAction(MemCmd::ReadReq, l2desc_addr, sizeof(uint32_t),
|
2010-06-02 19:58:18 +02:00
|
|
|
&doL2DescEvent, (uint8_t*)&currState->l2Desc.data, 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
} else {
|
|
|
|
port->dmaAction(MemCmd::ReadReq, l2desc_addr, sizeof(uint32_t),
|
2010-06-02 19:58:18 +02:00
|
|
|
NULL, (uint8_t*)&currState->l2Desc.data, 0);
|
2010-06-02 19:58:16 +02:00
|
|
|
doL2Descriptor();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
default:
|
|
|
|
panic("A new type in a 2 bit field?\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TableWalker::doL2Descriptor()
|
|
|
|
{
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLB, "L2 descriptor for %#x is %#x\n",
|
|
|
|
currState->vaddr, currState->l2Desc.data);
|
2010-06-02 19:58:16 +02:00
|
|
|
TlbEntry te;
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->l2Desc.invalid()) {
|
2010-06-02 19:58:16 +02:00
|
|
|
DPRINTF(TLB, "L2 descriptor invalid, causing fault\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
if (!currState->delayed) {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->isFetch)
|
|
|
|
currState->fault =
|
|
|
|
new PrefetchAbort(currState->vaddr, ArmFault::Translation1);
|
2010-06-02 19:58:16 +02:00
|
|
|
else
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault =
|
|
|
|
new DataAbort(currState->vaddr, currState->l1Desc.domain(),
|
|
|
|
currState->isWrite, ArmFault::Translation1);
|
2010-06-02 19:58:16 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->sctlr.afe && bits(currState->l2Desc.ap(), 0) == 0) {
|
2010-06-02 19:58:18 +02:00
|
|
|
/** @todo: check sctlr.ha (bit[17]) if Hardware Access Flag is enabled
|
|
|
|
* if set, do l2.Desc.setAp0() instead of generating AccessFlag0
|
|
|
|
*/
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault =
|
2010-08-23 18:18:39 +02:00
|
|
|
new DataAbort(currState->vaddr, 0, currState->isWrite,
|
2010-06-02 19:58:18 +02:00
|
|
|
ArmFault::AccessFlag1);
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->l2Desc.large()) {
|
2010-06-02 19:58:16 +02:00
|
|
|
te.N = 16;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.pfn = currState->l2Desc.pfn();
|
2010-06-02 19:58:16 +02:00
|
|
|
} else {
|
|
|
|
te.N = 12;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.pfn = currState->l2Desc.pfn();
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
te.valid = true;
|
|
|
|
te.size = (1 << te.N) - 1;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.asid = currState->contextId;
|
2010-06-02 19:58:16 +02:00
|
|
|
te.sNp = false;
|
2010-06-02 19:58:18 +02:00
|
|
|
te.vpn = currState->vaddr >> te.N;
|
|
|
|
te.global = currState->l2Desc.global();
|
|
|
|
te.xn = currState->l2Desc.xn();
|
|
|
|
te.ap = currState->l2Desc.ap();
|
|
|
|
te.domain = currState->l1Desc.domain();
|
|
|
|
memAttrs(currState->tc, te, currState->sctlr, currState->l2Desc.texcb(),
|
|
|
|
currState->l2Desc.shareable());
|
|
|
|
|
|
|
|
if (!currState->delayed) {
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->req = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
tlb->insert(currState->vaddr, te);
|
2010-06-02 19:58:16 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
void
|
|
|
|
TableWalker::doL1DescriptorWrapper()
|
|
|
|
{
|
2010-08-23 18:18:39 +02:00
|
|
|
currState = stateQueue.front();
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->delayed = false;
|
2010-06-02 19:58:18 +02:00
|
|
|
|
2010-08-23 18:18:39 +02:00
|
|
|
DPRINTF(TLBVerbose, "L1 Desc object host addr: %p\n",&currState->l1Desc.data);
|
|
|
|
DPRINTF(TLBVerbose, "L1 Desc object data: %08x\n",currState->l1Desc.data);
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "calling doL1Descriptor for vaddr:%#x\n", currState->vaddr);
|
2010-06-02 19:58:18 +02:00
|
|
|
doL1Descriptor();
|
|
|
|
|
|
|
|
// Check if fault was generated
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->fault != NoFault) {
|
|
|
|
currState->transState->finish(currState->fault, currState->req,
|
|
|
|
currState->tc, currState->mode);
|
2010-06-02 19:58:18 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->req = NULL;
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->delayed = false;
|
|
|
|
|
2010-08-23 18:18:39 +02:00
|
|
|
stateQueue.pop_front();
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
else if (!currState->delayed) {
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "calling translateTiming again\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault = tlb->translateTiming(currState->req, currState->tc,
|
|
|
|
currState->transState, currState->mode);
|
|
|
|
|
|
|
|
currState->req = NULL;
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->delayed = false;
|
2010-06-02 19:58:18 +02:00
|
|
|
|
2010-08-23 18:18:39 +02:00
|
|
|
stateQueue.pop_front();
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
2010-06-02 19:58:18 +02:00
|
|
|
currState = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
TableWalker::doL2DescriptorWrapper()
|
|
|
|
{
|
2010-08-23 18:18:39 +02:00
|
|
|
currState = stateQueue.front();
|
2010-06-02 19:58:18 +02:00
|
|
|
assert(currState->delayed);
|
2010-06-02 19:58:18 +02:00
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
DPRINTF(TLBVerbose, "calling doL2Descriptor for vaddr:%#x\n",
|
|
|
|
currState->vaddr);
|
2010-06-02 19:58:18 +02:00
|
|
|
doL2Descriptor();
|
|
|
|
|
|
|
|
// Check if fault was generated
|
2010-06-02 19:58:18 +02:00
|
|
|
if (currState->fault != NoFault) {
|
|
|
|
currState->transState->finish(currState->fault, currState->req,
|
|
|
|
currState->tc, currState->mode);
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
DPRINTF(TLBVerbose, "calling translateTiming again\n");
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->fault = tlb->translateTiming(currState->req, currState->tc,
|
|
|
|
currState->transState, currState->mode);
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:18 +02:00
|
|
|
currState->req = NULL;
|
|
|
|
currState->tc = NULL;
|
|
|
|
currState->delayed = false;
|
|
|
|
|
2010-08-23 18:18:39 +02:00
|
|
|
stateQueue.pop_front();
|
2010-06-02 19:58:18 +02:00
|
|
|
currState = NULL;
|
2010-06-02 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
2010-06-02 19:58:16 +02:00
|
|
|
ArmISA::TableWalker *
|
|
|
|
ArmTableWalkerParams::create()
|
|
|
|
{
|
|
|
|
return new ArmISA::TableWalker(this);
|
|
|
|
}
|
|
|
|
|