inorder: register ports for FS mode

handle "snoop" port registration as well as functional
port setup for FS mode
This commit is contained in:
Korey Sewell 2011-06-19 21:43:40 -04:00
parent f1c3691356
commit c4deabfb97
3 changed files with 45 additions and 10 deletions

View file

@ -70,21 +70,27 @@ printMemData(uint8_t *data, unsigned size)
Tick Tick
CacheUnit::CachePort::recvAtomic(PacketPtr pkt) CacheUnit::CachePort::recvAtomic(PacketPtr pkt)
{ {
panic("CacheUnit::CachePort doesn't expect recvAtomic callback!"); panic("%s doesn't expect recvAtomic callback!", cachePortUnit->name());
return curTick(); return curTick();
} }
void void
CacheUnit::CachePort::recvFunctional(PacketPtr pkt) CacheUnit::CachePort::recvFunctional(PacketPtr pkt)
{ {
panic("CacheUnit::CachePort doesn't expect recvFunctional callback!"); DPRINTF(InOrderCachePort, "Doesn't update state on a recvFunctional."
"Ignoring packet for %x.\n", pkt->getAddr());
} }
void void
CacheUnit::CachePort::recvStatusChange(Status status) CacheUnit::CachePort::recvStatusChange(Status status)
{ {
if (status == RangeChange) if (status == RangeChange) {
if (!snoopRangeSent) {
snoopRangeSent = true;
sendStatusChange(Port::RangeChange);
}
return; return;
}
panic("CacheUnit::CachePort doesn't expect recvStatusChange callback!"); panic("CacheUnit::CachePort doesn't expect recvStatusChange callback!");
} }
@ -92,7 +98,16 @@ CacheUnit::CachePort::recvStatusChange(Status status)
bool bool
CacheUnit::CachePort::recvTiming(Packet *pkt) CacheUnit::CachePort::recvTiming(Packet *pkt)
{ {
cachePortUnit->processCacheCompletion(pkt); DPRINTF(Cache, "RecvTiming: Pkt %x,\n", pkt->getAddr());
if (pkt->isError())
DPRINTF(InOrderCachePort, "Got error packet back for address: %x\n",
pkt->getAddr());
else if (pkt->isResponse())
cachePortUnit->processCacheCompletion(pkt);
else
DPRINTF(Cache, "Received snoop pkt %x,Ignoring\n", pkt->getAddr());
return true; return true;
} }
@ -130,6 +145,21 @@ CacheUnit::tlb()
} }
void
CacheUnit::CachePort::setPeer(Port *port)
{
Port::setPeer(port);
#if FULL_SYSTEM
// Update the ThreadContext's memory ports (Functional/Virtual
// Ports)
if (cachePortUnit->resName == "dcache_port") {
cachePortUnit->cpu->updateMemPorts();
}
#endif
}
Port * Port *
CacheUnit::getPort(const string &if_name, int idx) CacheUnit::getPort(const string &if_name, int idx)
{ {
@ -1022,6 +1052,8 @@ CacheUnit::processSquash(CacheReqPacket *cache_pkt)
void void
CacheUnit::processCacheCompletion(PacketPtr pkt) CacheUnit::processCacheCompletion(PacketPtr pkt)
{ {
//@todo: use packet sender state instead of deriving from packet class to
// get special state
CacheReqPacket* cache_pkt = dynamic_cast<CacheReqPacket*>(pkt); CacheReqPacket* cache_pkt = dynamic_cast<CacheReqPacket*>(pkt);
assert(cache_pkt); assert(cache_pkt);

View file

@ -89,16 +89,18 @@ class CacheUnit : public Resource
CachePort(CacheUnit *_cachePortUnit) CachePort(CacheUnit *_cachePortUnit)
: Port(_cachePortUnit->name() + "-cache-port", : Port(_cachePortUnit->name() + "-cache-port",
(MemObject*)_cachePortUnit->cpu), (MemObject*)_cachePortUnit->cpu),
cachePortUnit(_cachePortUnit) cachePortUnit(_cachePortUnit), snoopRangeSent(false)
{ } { }
bool snoopRangeSent; bool snoopRangeSent;
void setPeer(Port *port);
protected: protected:
/** Atomic version of receive. Panics. */ /** Atomic version of receive. Panics. */
Tick recvAtomic(PacketPtr pkt); Tick recvAtomic(PacketPtr pkt);
/** Functional version of receive. Panics. */ /** Functional version of receive.*/
void recvFunctional(PacketPtr pkt); void recvFunctional(PacketPtr pkt);
/** Receives status change. Other than range changing, panics. */ /** Receives status change. Other than range changing, panics. */
@ -106,11 +108,10 @@ class CacheUnit : public Resource
/** Returns the address ranges of this device. */ /** Returns the address ranges of this device. */
void getDeviceAddressRanges(AddrRangeList &resp, void getDeviceAddressRanges(AddrRangeList &resp,
AddrRangeList &snoop) bool &snoop)
{ resp.clear(); snoop.clear(); } { resp.clear(); snoop = true; }
/** Timing version of receive. Handles setting fetch to the /** Timing version of receive */
* proper status to start fetching. */
bool recvTiming(PacketPtr pkt); bool recvTiming(PacketPtr pkt);
/** Handles doing a retry of a failed fetch. */ /** Handles doing a retry of a failed fetch. */

View file

@ -423,6 +423,8 @@ void
FetchUnit::processCacheCompletion(PacketPtr pkt) FetchUnit::processCacheCompletion(PacketPtr pkt)
{ {
// Cast to correct packet type // Cast to correct packet type
// @todo: use pkt Sender state here to be consistent with other
// cpu models
CacheReqPacket* cache_pkt = dynamic_cast<CacheReqPacket*>(pkt); CacheReqPacket* cache_pkt = dynamic_cast<CacheReqPacket*>(pkt);
assert(cache_pkt); assert(cache_pkt);