external_slave.cc (12128:75e1a5bed42e) | external_slave.cc (13784:1941dc118243) |
---|---|
1/* 2 * Copyright (c) 2012-2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 35 unchanged lines hidden (view full) --- 44 45#include "base/trace.hh" 46#include "debug/ExternalPort.hh" 47 48/** Implement a `stub' port which just responds to requests by printing 49 * a message. The stub port can be used to configure and test a system 50 * where the external port is used for a peripheral before connecting 51 * the external port */ | 1/* 2 * Copyright (c) 2012-2014 ARM Limited 3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 35 unchanged lines hidden (view full) --- 44 45#include "base/trace.hh" 46#include "debug/ExternalPort.hh" 47 48/** Implement a `stub' port which just responds to requests by printing 49 * a message. The stub port can be used to configure and test a system 50 * where the external port is used for a peripheral before connecting 51 * the external port */ |
52class StubSlavePort : public ExternalSlave::Port | 52class StubSlavePort : public ExternalSlave::ExternalPort |
53{ 54 public: 55 void processResponseEvent(); 56 57 EventFunctionWrapper responseEvent; 58 59 /** Stub can handle a single request at a time. This will be 60 * NULL when no packet is in flight */ 61 PacketPtr responsePacket; 62 63 /** Received a new request while processing a first. Need to ask for 64 * a retry after completing this packet */ 65 bool mustRetry; 66 67 StubSlavePort(const std::string &name_, 68 ExternalSlave &owner_) : | 53{ 54 public: 55 void processResponseEvent(); 56 57 EventFunctionWrapper responseEvent; 58 59 /** Stub can handle a single request at a time. This will be 60 * NULL when no packet is in flight */ 61 PacketPtr responsePacket; 62 63 /** Received a new request while processing a first. Need to ask for 64 * a retry after completing this packet */ 65 bool mustRetry; 66 67 StubSlavePort(const std::string &name_, 68 ExternalSlave &owner_) : |
69 ExternalSlave::Port(name_, owner_), | 69 ExternalSlave::ExternalPort(name_, owner_), |
70 responseEvent([this]{ processResponseEvent(); }, name()), 71 responsePacket(NULL), mustRetry(false) 72 { } 73 74 Tick recvAtomic(PacketPtr packet); 75 void recvFunctional(PacketPtr packet); 76 bool recvTimingReq(PacketPtr packet); 77 bool recvTimingSnoopResp(PacketPtr packet); 78 void recvRespRetry(); 79 void recvFunctionalSnoop(PacketPtr packet); 80}; 81 82class StubSlavePortHandler : public 83 ExternalSlave::Handler 84{ 85 public: | 70 responseEvent([this]{ processResponseEvent(); }, name()), 71 responsePacket(NULL), mustRetry(false) 72 { } 73 74 Tick recvAtomic(PacketPtr packet); 75 void recvFunctional(PacketPtr packet); 76 bool recvTimingReq(PacketPtr packet); 77 bool recvTimingSnoopResp(PacketPtr packet); 78 void recvRespRetry(); 79 void recvFunctionalSnoop(PacketPtr packet); 80}; 81 82class StubSlavePortHandler : public 83 ExternalSlave::Handler 84{ 85 public: |
86 ExternalSlave::Port *getExternalPort( | 86 ExternalSlave::ExternalPort *getExternalPort( |
87 const std::string &name_, 88 ExternalSlave &owner, 89 const std::string &port_data) 90 { 91 StringWrap name(name_); 92 93 DPRINTF(ExternalPort, "finding stub port '%s'\n", port_data); 94 return new StubSlavePort(name_, owner); --- 75 unchanged lines hidden (view full) --- 170{ 171 fatal("StubSlavePort: unimplemented function: %s\n", __func__); 172} 173 174std::map<std::string, ExternalSlave::Handler *> 175 ExternalSlave::portHandlers; 176 177AddrRangeList | 87 const std::string &name_, 88 ExternalSlave &owner, 89 const std::string &port_data) 90 { 91 StringWrap name(name_); 92 93 DPRINTF(ExternalPort, "finding stub port '%s'\n", port_data); 94 return new StubSlavePort(name_, owner); --- 75 unchanged lines hidden (view full) --- 170{ 171 fatal("StubSlavePort: unimplemented function: %s\n", __func__); 172} 173 174std::map<std::string, ExternalSlave::Handler *> 175 ExternalSlave::portHandlers; 176 177AddrRangeList |
178ExternalSlave::Port::getAddrRanges() const | 178ExternalSlave::ExternalPort::getAddrRanges() const |
179{ 180 return owner.addrRanges; 181} 182 183ExternalSlave::ExternalSlave(ExternalSlaveParams *params) : 184 MemObject(params), 185 externalPort(NULL), 186 portName(params->name + ".port"), 187 portType(params->port_type), 188 portData(params->port_data), 189 addrRanges(params->addr_ranges.begin(), params->addr_ranges.end()) 190{ 191 /* Register the stub handler if it hasn't already been registered */ 192 if (portHandlers.find("stub") == portHandlers.end()) 193 registerHandler("stub", new StubSlavePortHandler); 194} 195 | 179{ 180 return owner.addrRanges; 181} 182 183ExternalSlave::ExternalSlave(ExternalSlaveParams *params) : 184 MemObject(params), 185 externalPort(NULL), 186 portName(params->name + ".port"), 187 portType(params->port_type), 188 portData(params->port_data), 189 addrRanges(params->addr_ranges.begin(), params->addr_ranges.end()) 190{ 191 /* Register the stub handler if it hasn't already been registered */ 192 if (portHandlers.find("stub") == portHandlers.end()) 193 registerHandler("stub", new StubSlavePortHandler); 194} 195 |
196BaseSlavePort & 197ExternalSlave::getSlavePort(const std::string &if_name, 198 PortID idx) | 196Port & 197ExternalSlave::getPort(const std::string &if_name, PortID idx) |
199{ 200 if (if_name == "port") { 201 DPRINTF(ExternalPort, "Trying to bind external port: %s %s\n", 202 portType, portName); 203 204 if (!externalPort) { 205 auto handlerIter = portHandlers.find(portType); 206 --- 5 unchanged lines hidden (view full) --- 212 213 if (!externalPort) { 214 fatal("%s: Can't find external port type: %s" 215 " port_data: '%s'\n", portName, portType, portData); 216 } 217 } 218 return *externalPort; 219 } else { | 198{ 199 if (if_name == "port") { 200 DPRINTF(ExternalPort, "Trying to bind external port: %s %s\n", 201 portType, portName); 202 203 if (!externalPort) { 204 auto handlerIter = portHandlers.find(portType); 205 --- 5 unchanged lines hidden (view full) --- 211 212 if (!externalPort) { 213 fatal("%s: Can't find external port type: %s" 214 " port_data: '%s'\n", portName, portType, portData); 215 } 216 } 217 return *externalPort; 218 } else { |
220 return MemObject::getSlavePort(if_name, idx); | 219 return MemObject::getPort(if_name, idx); |
221 } 222} 223 224void 225ExternalSlave::init() 226{ 227 if (!externalPort) { 228 fatal("ExternalSlave %s: externalPort not set!\n", name()); --- 19 unchanged lines hidden --- | 220 } 221} 222 223void 224ExternalSlave::init() 225{ 226 if (!externalPort) { 227 fatal("ExternalSlave %s: externalPort not set!\n", name()); --- 19 unchanged lines hidden --- |