2006-07-21 01:03:47 +02:00
|
|
|
/*
|
2012-02-24 17:52:49 +01:00
|
|
|
* Copyright (c) 2012 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.
|
|
|
|
*
|
2006-07-21 01:03:47 +02:00
|
|
|
* Copyright (c) 2006 The Regents of The University of Michigan
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* 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
|
2012-02-24 17:52:49 +01:00
|
|
|
* Andreas Hansson
|
2006-07-21 01:03:47 +02:00
|
|
|
*/
|
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
#include "mem/mem_object.hh"
|
2006-07-21 01:03:47 +02:00
|
|
|
#include "mem/tport.hh"
|
|
|
|
|
2012-03-22 11:36:27 +01:00
|
|
|
SimpleTimingPort::SimpleTimingPort(const std::string& _name,
|
|
|
|
MemObject* _owner) :
|
MEM: Introduce the master/slave port sub-classes in C++
This patch introduces the notion of a master and slave port in the C++
code, thus bringing the previous classification from the Python
classes into the corresponding simulation objects and memory objects.
The patch enables us to classify behaviours into the two bins and add
assumptions and enfore compliance, also simplifying the two
interfaces. As a starting point, isSnooping is confined to a master
port, and getAddrRanges to slave ports. More of these specilisations
are to come in later patches.
The getPort function is not getMasterPort and getSlavePort, and
returns a port reference rather than a pointer as NULL would never be
a valid return value. The default implementation of these two
functions is placed in MemObject, and calls fatal.
The one drawback with this specific patch is that it requires some
code duplication, e.g. QueuedPort becomes QueuedMasterPort and
QueuedSlavePort, and BusPort becomes BusMasterPort and BusSlavePort
(avoiding multiple inheritance). With the later introduction of the
port interfaces, moving the functionality outside the port itself, a
lot of the duplicated code will disappear again.
2012-03-30 15:40:11 +02:00
|
|
|
QueuedSlavePort(_name, _owner, queue), queue(*_owner, *this)
|
2006-08-31 01:24:26 +02:00
|
|
|
{
|
2007-05-28 17:11:43 +02:00
|
|
|
}
|
2006-10-20 19:01:21 +02:00
|
|
|
|
2007-05-28 17:11:43 +02:00
|
|
|
void
|
|
|
|
SimpleTimingPort::recvFunctional(PacketPtr pkt)
|
|
|
|
{
|
2012-03-22 11:36:27 +01:00
|
|
|
if (!queue.checkFunctional(pkt)) {
|
|
|
|
// do an atomic access and throw away the returned latency
|
2006-10-12 21:30:30 +02:00
|
|
|
recvAtomic(pkt);
|
2007-07-30 05:17:03 +02:00
|
|
|
}
|
2006-08-31 01:24:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
MEM: Separate requests and responses for timing accesses
This patch moves send/recvTiming and send/recvTimingSnoop from the
Port base class to the MasterPort and SlavePort, and also splits them
into separate member functions for requests and responses:
send/recvTimingReq, send/recvTimingResp, and send/recvTimingSnoopReq,
send/recvTimingSnoopResp. A master port sends requests and receives
responses, and also receives snoop requests and sends snoop
responses. A slave port has the reciprocal behaviour as it receives
requests and sends responses, and sends snoop requests and receives
snoop responses.
For all MemObjects that have only master ports or slave ports (but not
both), e.g. a CPU, or a PIO device, this patch merely adds more
clarity to what kind of access is taking place. For example, a CPU
port used to call sendTiming, and will now call
sendTimingReq. Similarly, a response previously came back through
recvTiming, which is now recvTimingResp. For the modules that have
both master and slave ports, e.g. the bus, the behaviour was
previously relying on branches based on pkt->isRequest(), and this is
now replaced with a direct call to the apprioriate member function
depending on the type of access. Please note that send/recvRetry is
still shared by all the timing accessors and remains in the Port base
class for now (to maintain the current bus functionality and avoid
changing the statistics of all regressions).
The packet queue is split into a MasterPort and SlavePort version to
facilitate the use of the new timing accessors. All uses of the
PacketQueue are updated accordingly.
With this patch, the type of packet (request or response) is now well
defined for each type of access, and asserts on pkt->isRequest() and
pkt->isResponse() are now moved to the appropriate send member
functions. It is also worth noting that sendTimingSnoopReq no longer
returns a boolean, as the semantics do not alow snoop requests to be
rejected or stalled. All these assumptions are now excplicitly part of
the port interface itself.
2012-05-01 19:40:42 +02:00
|
|
|
SimpleTimingPort::recvTimingReq(PacketPtr pkt)
|
2006-08-31 01:24:26 +02:00
|
|
|
{
|
2012-06-07 16:59:03 +02:00
|
|
|
/// @todo temporary hack to deal with memory corruption issue until
|
|
|
|
/// 4-phase transactions are complete. Remove me later
|
|
|
|
for (int x = 0; x < pendingDelete.size(); x++)
|
|
|
|
delete pendingDelete[x];
|
|
|
|
pendingDelete.clear();
|
|
|
|
|
2007-06-27 07:23:10 +02:00
|
|
|
if (pkt->memInhibitAsserted()) {
|
|
|
|
// snooper will supply based on copy of packet
|
|
|
|
// still target's responsibility to delete packet
|
|
|
|
delete pkt;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-06-18 02:27:53 +02:00
|
|
|
bool needsResponse = pkt->needsResponse();
|
2006-08-31 01:24:26 +02:00
|
|
|
Tick latency = recvAtomic(pkt);
|
2006-10-09 01:05:48 +02:00
|
|
|
// turn packet around to go back to requester if response expected
|
2007-06-18 02:27:53 +02:00
|
|
|
if (needsResponse) {
|
2007-06-27 07:23:10 +02:00
|
|
|
// recvAtomic() should already have turned packet into
|
|
|
|
// atomic response
|
2007-06-18 02:27:53 +02:00
|
|
|
assert(pkt->isResponse());
|
2012-03-22 11:36:27 +01:00
|
|
|
queue.schedSendTiming(pkt, curTick() + latency);
|
2007-06-18 02:27:53 +02:00
|
|
|
} else {
|
2012-06-07 16:59:03 +02:00
|
|
|
/// @todo nominally we should just delete the packet here.
|
|
|
|
/// Until 4-phase stuff we can't because the sending
|
|
|
|
/// cache is still relying on it
|
|
|
|
pendingDelete.push_back(pkt);
|
2006-10-17 22:47:22 +02:00
|
|
|
}
|
2007-06-27 07:23:10 +02:00
|
|
|
|
2006-08-31 01:24:26 +02:00
|
|
|
return true;
|
|
|
|
}
|