2004-02-11 22:07:55 +01:00
|
|
|
/*
|
MEM: Separate snoops and normal memory requests/responses
This patch introduces port access methods that separates snoop
request/responses from normal memory request/responses. The
differentiation is made for functional, atomic and timing accesses and
builds on the introduction of master and slave ports.
Before the introduction of this patch, the packets belonging to the
different phases of the protocol (request -> [forwarded snoop request
-> snoop response]* -> response) all use the same port access
functions, even though the snoop packets flow in the opposite
direction to the normal packet. That is, a coherent master sends
normal request and receives responses, but receives snoop requests and
sends snoop responses (vice versa for the slave). These two distinct
phases now use different access functions, as described below.
Starting with the functional access, a master sends a request to a
slave through sendFunctional, and the request packet is turned into a
response before the call returns. In a system without cache coherence,
this is all that is needed from the functional interface. For the
cache-coherent scenario, a slave also sends snoop requests to coherent
masters through sendFunctionalSnoop, with responses returned within
the same packet pointer. This is currently used by the bus and caches,
and the LSQ of the O3 CPU. The send/recvFunctional and
send/recvFunctionalSnoop are moved from the Port super class to the
appropriate subclass.
Atomic accesses follow the same flow as functional accesses, with
request being sent from master to slave through sendAtomic. In the
case of cache-coherent ports, a slave can send snoop requests to a
master through sendAtomicSnoop. Just as for the functional access
methods, the atomic send and receive member functions are moved to the
appropriate subclasses.
The timing access methods are different from the functional and atomic
in that requests and responses are separated in time and
send/recvTiming are used for both directions. Hence, a master uses
sendTiming to send a request to a slave, and a slave uses sendTiming
to send a response back to a master, at a later point in time. Snoop
requests and responses travel in the opposite direction, similar to
what happens in functional and atomic accesses. With the introduction
of this patch, it is possible to determine the direction of packets in
the bus, and no longer necessary to look for both a master and a slave
port with the requested port id.
In contrast to the normal recvFunctional, recvAtomic and recvTiming
that are pure virtual functions, the recvFunctionalSnoop,
recvAtomicSnoop and recvTimingSnoop have a default implementation that
calls panic. This is to allow non-coherent master and slave ports to
not implement these functions.
2012-04-14 11:45:07 +02: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.
|
|
|
|
*
|
2005-06-05 11:16:00 +02:00
|
|
|
* Copyright (c) 2004-2005 The Regents of The University of Michigan
|
2004-02-11 22:07:55 +01:00
|
|
|
* 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.
|
2006-06-01 01:26:56 +02:00
|
|
|
*
|
|
|
|
* Authors: Ali Saidi
|
|
|
|
* Nathan Binkert
|
2004-02-11 22:07:55 +01:00
|
|
|
*/
|
|
|
|
|
2005-01-15 10:12:25 +01:00
|
|
|
#ifndef __DEV_IO_DEVICE_HH__
|
|
|
|
#define __DEV_IO_DEVICE_HH__
|
2004-02-11 22:07:55 +01:00
|
|
|
|
2006-04-11 19:42:47 +02:00
|
|
|
#include "mem/mem_object.hh"
|
2006-07-21 01:03:47 +02:00
|
|
|
#include "mem/tport.hh"
|
2007-07-24 06:51:38 +02:00
|
|
|
#include "params/BasicPioDevice.hh"
|
|
|
|
#include "params/PioDevice.hh"
|
2004-02-11 22:07:55 +01:00
|
|
|
|
2006-01-31 20:20:39 +01:00
|
|
|
class PioDevice;
|
2006-04-06 20:57:51 +02:00
|
|
|
class System;
|
2006-03-21 21:45:31 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The PioPort class is a programmed i/o port that all devices that are
|
|
|
|
* sensitive to an address range use. The port takes all the memory
|
|
|
|
* access types and roles them into one read() and write() call that the device
|
2012-01-17 19:55:09 +01:00
|
|
|
* must respond to. The device must also provide getAddrRanges() function
|
2006-08-30 18:57:46 +02:00
|
|
|
* with which it returns the address ranges it is interested in.
|
|
|
|
*/
|
2006-07-21 01:03:47 +02:00
|
|
|
class PioPort : public SimpleTimingPort
|
2004-02-11 22:07:55 +01:00
|
|
|
{
|
|
|
|
protected:
|
2006-03-21 21:45:31 +01:00
|
|
|
/** The device that this port serves. */
|
2006-01-31 20:20:39 +01:00
|
|
|
PioDevice *device;
|
|
|
|
|
2006-10-20 09:10:12 +02:00
|
|
|
virtual Tick recvAtomic(PacketPtr pkt);
|
2006-01-31 20:20:39 +01:00
|
|
|
|
2012-07-09 18:35:34 +02:00
|
|
|
virtual AddrRangeList getAddrRanges() const;
|
2006-01-31 20:20:39 +01:00
|
|
|
|
|
|
|
public:
|
2006-07-13 02:22:07 +02:00
|
|
|
|
2012-03-22 11:36:27 +01:00
|
|
|
PioPort(PioDevice *dev);
|
2006-01-31 20:20:39 +01:00
|
|
|
};
|
|
|
|
|
2006-03-21 21:45:31 +01:00
|
|
|
/**
|
|
|
|
* This device is the base class which all devices senstive to an address range
|
|
|
|
* inherit from. There are three pure virtual functions which all devices must
|
2012-01-17 19:55:09 +01:00
|
|
|
* implement getAddrRanges(), read(), and write(). The magic do choose which
|
2006-03-21 21:45:31 +01:00
|
|
|
* mode we are in, etc is handled by the PioPort so the device doesn't have to
|
|
|
|
* bother.
|
|
|
|
*/
|
2006-04-11 19:42:47 +02:00
|
|
|
class PioDevice : public MemObject
|
2006-01-31 20:20:39 +01:00
|
|
|
{
|
|
|
|
protected:
|
2006-07-13 02:22:07 +02:00
|
|
|
System *sys;
|
|
|
|
|
2006-03-21 21:45:31 +01:00
|
|
|
/** The pioPort that handles the requests for us and provides us requests
|
|
|
|
* that it sees. */
|
2012-02-24 17:43:53 +01:00
|
|
|
PioPort pioPort;
|
2006-01-31 20:20:39 +01:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
/**
|
|
|
|
* Every PIO device is obliged to provide an implementation that
|
|
|
|
* returns the address ranges the device responds to.
|
|
|
|
*
|
|
|
|
* @return a list of non-overlapping address ranges
|
|
|
|
*/
|
2012-07-09 18:35:34 +02:00
|
|
|
virtual AddrRangeList getAddrRanges() const = 0;
|
2006-01-31 20:20:39 +01:00
|
|
|
|
2006-08-30 18:57:46 +02:00
|
|
|
/** Pure virtual function that the device must implement. Called
|
|
|
|
* when a read command is recieved by the port.
|
2006-04-07 00:04:49 +02:00
|
|
|
* @param pkt Packet describing this request
|
|
|
|
* @return number of ticks it took to complete
|
|
|
|
*/
|
2006-10-20 09:10:12 +02:00
|
|
|
virtual Tick read(PacketPtr pkt) = 0;
|
2006-01-31 20:20:39 +01:00
|
|
|
|
2006-03-21 21:45:31 +01:00
|
|
|
/** Pure virtual function that the device must implement. Called when a
|
2006-04-07 00:04:49 +02:00
|
|
|
* write command is recieved by the port.
|
|
|
|
* @param pkt Packet describing this request
|
|
|
|
* @return number of ticks it took to complete
|
|
|
|
*/
|
2006-10-20 09:10:12 +02:00
|
|
|
virtual Tick write(PacketPtr pkt) = 0;
|
2004-02-11 22:07:55 +01:00
|
|
|
|
|
|
|
public:
|
2007-07-24 06:51:38 +02:00
|
|
|
typedef PioDeviceParams Params;
|
|
|
|
PioDevice(const Params *p);
|
2004-02-11 22:07:55 +01:00
|
|
|
virtual ~PioDevice();
|
2006-01-31 20:20:39 +01:00
|
|
|
|
2007-07-24 06:51:38 +02:00
|
|
|
const Params *
|
|
|
|
params() const
|
|
|
|
{
|
|
|
|
return dynamic_cast<const Params *>(_params);
|
|
|
|
}
|
|
|
|
|
2006-04-10 20:40:22 +02:00
|
|
|
virtual void init();
|
|
|
|
|
2012-10-15 14:12:35 +02:00
|
|
|
virtual BaseSlavePort &getSlavePort(const std::string &if_name,
|
|
|
|
PortID idx = InvalidPortID);
|
2011-10-20 22:11:56 +02:00
|
|
|
|
2006-03-21 21:45:31 +01:00
|
|
|
friend class PioPort;
|
|
|
|
|
2004-02-11 22:07:55 +01:00
|
|
|
};
|
|
|
|
|
2006-03-30 00:37:25 +02:00
|
|
|
class BasicPioDevice : public PioDevice
|
|
|
|
{
|
|
|
|
protected:
|
|
|
|
/** Address that the device listens to. */
|
|
|
|
Addr pioAddr;
|
|
|
|
|
|
|
|
/** Size that the device's address range. */
|
2006-04-06 06:51:46 +02:00
|
|
|
Addr pioSize;
|
2006-03-30 00:37:25 +02:00
|
|
|
|
|
|
|
/** Delay that the device experinces on an access. */
|
|
|
|
Tick pioDelay;
|
|
|
|
|
|
|
|
public:
|
2007-07-24 06:51:38 +02:00
|
|
|
typedef BasicPioDeviceParams Params;
|
2013-07-12 04:57:04 +02:00
|
|
|
BasicPioDevice(const Params *p, Addr size);
|
2007-07-24 06:51:38 +02:00
|
|
|
|
|
|
|
const Params *
|
|
|
|
params() const
|
|
|
|
{
|
|
|
|
return dynamic_cast<const Params *>(_params);
|
|
|
|
}
|
2006-03-30 00:37:25 +02:00
|
|
|
|
2012-01-17 19:55:09 +01:00
|
|
|
/**
|
|
|
|
* Determine the address ranges that this device responds to.
|
|
|
|
*
|
|
|
|
* @return a list of non-overlapping address ranges
|
2006-04-10 20:14:06 +02:00
|
|
|
*/
|
2012-07-09 18:35:34 +02:00
|
|
|
virtual AddrRangeList getAddrRanges() const;
|
2006-04-10 20:14:06 +02:00
|
|
|
|
2006-03-30 00:37:25 +02:00
|
|
|
};
|
|
|
|
|
2005-01-15 10:12:25 +01:00
|
|
|
#endif // __DEV_IO_DEVICE_HH__
|