2010-01-30 05:29:17 +01:00
|
|
|
/*
|
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
|
|
|
* 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.
|
|
|
|
*
|
2010-01-30 05:29:17 +01:00
|
|
|
* Copyright (c) 2009 Advanced Micro Devices, Inc.
|
2012-01-23 18:07:14 +01:00
|
|
|
* Copyright (c) 2011 Mark D. Hill and David A. Wood
|
2010-01-30 05:29:17 +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.
|
|
|
|
*/
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#ifndef __MEM_RUBY_SYSTEM_RUBYPORT_HH__
|
|
|
|
#define __MEM_RUBY_SYSTEM_RUBYPORT_HH__
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#include <cassert>
|
2009-07-07 00:49:47 +02:00
|
|
|
#include <string>
|
|
|
|
|
2010-01-30 05:29:33 +01:00
|
|
|
#include "mem/protocol/RequestStatus.hh"
|
2011-02-07 07:14:18 +01:00
|
|
|
#include "mem/ruby/system/System.hh"
|
2011-04-15 19:44:06 +02:00
|
|
|
#include "mem/mem_object.hh"
|
|
|
|
#include "mem/physical.hh"
|
2010-03-23 02:43:53 +01:00
|
|
|
#include "mem/tport.hh"
|
2010-01-30 05:29:17 +01:00
|
|
|
#include "params/RubyPort.hh"
|
|
|
|
|
|
|
|
class MessageBuffer;
|
|
|
|
class AbstractController;
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
class RubyPort : public MemObject
|
|
|
|
{
|
|
|
|
public:
|
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
|
|
|
class M5Port : public QueuedSlavePort
|
2010-01-30 05:29:19 +01:00
|
|
|
{
|
2010-03-23 02:43:53 +01:00
|
|
|
private:
|
2012-03-22 11:36:27 +01:00
|
|
|
|
|
|
|
PacketQueue queue;
|
2010-01-30 05:29:19 +01:00
|
|
|
RubyPort *ruby_port;
|
2011-07-01 02:49:26 +02:00
|
|
|
RubySystem* ruby_system;
|
2011-02-07 07:14:18 +01:00
|
|
|
bool _onRetryList;
|
2011-02-07 07:14:19 +01:00
|
|
|
bool access_phys_mem;
|
2010-01-30 05:29:19 +01:00
|
|
|
|
|
|
|
public:
|
2011-02-07 07:14:19 +01:00
|
|
|
M5Port(const std::string &_name, RubyPort *_port,
|
2011-07-01 02:49:26 +02:00
|
|
|
RubySystem*_system, bool _access_phys_mem);
|
2012-03-02 15:16:50 +01:00
|
|
|
bool sendNextCycle(PacketPtr pkt);
|
2010-01-30 05:29:19 +01:00
|
|
|
void hitCallback(PacketPtr pkt);
|
2012-01-23 18:07:14 +01:00
|
|
|
void evictionCallback(const Address& address);
|
2011-02-07 07:14:18 +01:00
|
|
|
unsigned deviceBlockSize() const;
|
2011-02-07 07:14:18 +01:00
|
|
|
|
|
|
|
bool onRetryList()
|
|
|
|
{ return _onRetryList; }
|
|
|
|
|
|
|
|
void onRetryList(bool newVal)
|
|
|
|
{ _onRetryList = newVal; }
|
2010-01-30 05:29:19 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool recvTiming(PacketPtr pkt);
|
|
|
|
virtual Tick recvAtomic(PacketPtr pkt);
|
2011-07-01 02:49:26 +02:00
|
|
|
virtual void recvFunctional(PacketPtr pkt);
|
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
|
|
|
virtual AddrRangeList getAddrRanges();
|
2010-01-30 05:29:19 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool isPhysMemAddress(Addr addr);
|
2011-07-01 02:49:26 +02:00
|
|
|
bool doFunctionalRead(PacketPtr pkt);
|
|
|
|
bool doFunctionalWrite(PacketPtr pkt);
|
2010-01-30 05:29:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
friend class M5Port;
|
|
|
|
|
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
|
|
|
class PioPort : public QueuedMasterPort
|
2010-01-30 05:29:19 +01:00
|
|
|
{
|
2010-03-23 02:43:53 +01:00
|
|
|
private:
|
2012-03-22 11:36:27 +01:00
|
|
|
|
|
|
|
PacketQueue queue;
|
|
|
|
|
2010-01-30 05:29:19 +01:00
|
|
|
RubyPort *ruby_port;
|
|
|
|
|
|
|
|
public:
|
2010-03-23 02:43:53 +01:00
|
|
|
PioPort(const std::string &_name, RubyPort *_port);
|
2012-03-02 15:16:50 +01:00
|
|
|
bool sendNextCycle(PacketPtr pkt);
|
2010-01-30 05:29:19 +01:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool recvTiming(PacketPtr pkt);
|
|
|
|
virtual Tick recvAtomic(PacketPtr pkt);
|
2012-03-22 11:36:27 +01:00
|
|
|
virtual void recvFunctional(PacketPtr pkt) { }
|
2010-01-30 05:29:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
friend class PioPort;
|
|
|
|
|
|
|
|
struct SenderState : public Packet::SenderState
|
|
|
|
{
|
|
|
|
M5Port* port;
|
|
|
|
Packet::SenderState *saved;
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
SenderState(M5Port* _port, Packet::SenderState *sender_state = NULL)
|
2010-01-30 05:29:19 +01:00
|
|
|
: port(_port), saved(sender_state)
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2010-01-30 05:29:17 +01:00
|
|
|
typedef RubyPortParams Params;
|
|
|
|
RubyPort(const Params *p);
|
2010-01-30 05:29:19 +01:00
|
|
|
virtual ~RubyPort() {}
|
|
|
|
|
|
|
|
void init();
|
2009-07-07 00:49:47 +02:00
|
|
|
|
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
|
|
|
MasterPort &getMasterPort(const std::string &if_name, int idx);
|
|
|
|
SlavePort &getSlavePort(const std::string &if_name, int idx);
|
2010-01-30 05:29:17 +01:00
|
|
|
|
2011-11-15 00:44:35 +01:00
|
|
|
virtual RequestStatus makeRequest(PacketPtr pkt) = 0;
|
2012-01-11 20:48:48 +01:00
|
|
|
virtual int outstandingCount() const = 0;
|
|
|
|
virtual bool isDeadlockEventScheduled() const = 0;
|
|
|
|
virtual void descheduleDeadlockEvent() = 0;
|
2010-01-30 05:29:19 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Called by the controller to give the sequencer a pointer.
|
|
|
|
// A pointer to the controller is needed for atomic support.
|
|
|
|
//
|
|
|
|
void setController(AbstractController* _cntrl) { m_controller = _cntrl; }
|
2012-01-11 20:48:48 +01:00
|
|
|
int getId() { return m_version; }
|
|
|
|
unsigned int drain(Event *de);
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
protected:
|
2010-04-02 20:20:32 +02:00
|
|
|
const std::string m_name;
|
2010-03-23 02:43:53 +01:00
|
|
|
void ruby_hit_callback(PacketPtr pkt);
|
2012-01-11 20:48:48 +01:00
|
|
|
void testDrainComplete();
|
2012-01-23 18:07:14 +01:00
|
|
|
void ruby_eviction_callback(const Address& address);
|
2009-07-07 00:49:47 +02:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
int m_version;
|
|
|
|
AbstractController* m_controller;
|
|
|
|
MessageBuffer* m_mandatory_q_ptr;
|
2012-02-24 17:43:53 +01:00
|
|
|
PioPort pio_port;
|
2011-02-07 07:14:18 +01:00
|
|
|
bool m_usingRubyTester;
|
2010-01-30 05:29:17 +01:00
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
private:
|
2011-02-07 07:14:18 +01:00
|
|
|
void addToRetryList(M5Port * port)
|
|
|
|
{
|
|
|
|
if (!port->onRetryList()) {
|
|
|
|
port->onRetryList(true);
|
|
|
|
retryList.push_back(port);
|
|
|
|
waitingOnSequencer = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-11 20:48:48 +01:00
|
|
|
unsigned int getDrainCount(Event *de);
|
|
|
|
|
2010-01-30 05:29:33 +01:00
|
|
|
uint16_t m_port_id;
|
|
|
|
uint64_t m_request_cnt;
|
2010-01-30 05:29:19 +01:00
|
|
|
|
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
|
|
|
/** Vector of M5 Ports attached to this Ruby port. */
|
2012-01-11 20:39:58 +01:00
|
|
|
typedef std::vector<M5Port*>::iterator CpuPortIter;
|
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
|
|
|
std::vector<M5Port*> slave_ports;
|
|
|
|
std::vector<PioPort*> master_ports;
|
2012-01-11 20:39:58 +01:00
|
|
|
|
2012-01-11 20:48:48 +01:00
|
|
|
Event *drainEvent;
|
|
|
|
|
2011-07-01 02:49:26 +02:00
|
|
|
RubySystem* ruby_system;
|
2012-03-30 15:42:36 +02:00
|
|
|
System* system;
|
2011-02-07 07:14:18 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Based on similar code in the M5 bus. Stores pointers to those ports
|
|
|
|
// that should be called when the Sequencer becomes available after a stall.
|
|
|
|
//
|
|
|
|
std::list<M5Port*> retryList;
|
|
|
|
|
|
|
|
bool waitingOnSequencer;
|
2011-02-07 07:14:19 +01:00
|
|
|
bool access_phys_mem;
|
2009-07-07 00:49:47 +02:00
|
|
|
};
|
|
|
|
|
2010-03-23 02:43:53 +01:00
|
|
|
#endif // __MEM_RUBY_SYSTEM_RUBYPORT_HH__
|