io_device.hh (9015:7f4d25789dc4) | io_device.hh (9016:18093957a102) |
---|---|
1/* 2 * Copyright (c) 2012 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 --- 30 unchanged lines hidden (view full) --- 39 * 40 * Authors: Ali Saidi 41 * Nathan Binkert 42 */ 43 44#ifndef __DEV_IO_DEVICE_HH__ 45#define __DEV_IO_DEVICE_HH__ 46 | 1/* 2 * Copyright (c) 2012 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 --- 30 unchanged lines hidden (view full) --- 39 * 40 * Authors: Ali Saidi 41 * Nathan Binkert 42 */ 43 44#ifndef __DEV_IO_DEVICE_HH__ 45#define __DEV_IO_DEVICE_HH__ 46 |
47#include "base/fast_alloc.hh" | |
48#include "mem/mem_object.hh" | 47#include "mem/mem_object.hh" |
49#include "mem/packet.hh" | |
50#include "mem/tport.hh" 51#include "params/BasicPioDevice.hh" | 48#include "mem/tport.hh" 49#include "params/BasicPioDevice.hh" |
52#include "params/DmaDevice.hh" | |
53#include "params/PioDevice.hh" | 50#include "params/PioDevice.hh" |
54#include "sim/sim_object.hh" | |
55 | 51 |
56class Event; | |
57class PioDevice; | 52class PioDevice; |
58class DmaDevice; | |
59class System; 60 61/** 62 * The PioPort class is a programmed i/o port that all devices that are 63 * sensitive to an address range use. The port takes all the memory 64 * access types and roles them into one read() and write() call that the device 65 * must respond to. The device must also provide getAddrRanges() function 66 * with which it returns the address ranges it is interested in. --- 8 unchanged lines hidden (view full) --- 75 76 virtual AddrRangeList getAddrRanges(); 77 78 public: 79 80 PioPort(PioDevice *dev); 81}; 82 | 53class System; 54 55/** 56 * The PioPort class is a programmed i/o port that all devices that are 57 * sensitive to an address range use. The port takes all the memory 58 * access types and roles them into one read() and write() call that the device 59 * must respond to. The device must also provide getAddrRanges() function 60 * with which it returns the address ranges it is interested in. --- 8 unchanged lines hidden (view full) --- 69 70 virtual AddrRangeList getAddrRanges(); 71 72 public: 73 74 PioPort(PioDevice *dev); 75}; 76 |
83 84class DmaPort : public MasterPort 85{ 86 protected: 87 struct DmaReqState : public Packet::SenderState, public FastAlloc 88 { 89 /** Event to call on the device when this transaction (all packets) 90 * complete. */ 91 Event *completionEvent; 92 93 /** Where we came from for some sanity checking. */ 94 Port *outPort; 95 96 /** Total number of bytes that this transaction involves. */ 97 Addr totBytes; 98 99 /** Number of bytes that have been acked for this transaction. */ 100 Addr numBytes; 101 102 /** Amount to delay completion of dma by */ 103 Tick delay; 104 105 106 DmaReqState(Event *ce, Port *p, Addr tb, Tick _delay) 107 : completionEvent(ce), outPort(p), totBytes(tb), numBytes(0), 108 delay(_delay) 109 {} 110 }; 111 112 MemObject *device; 113 std::list<PacketPtr> transmitList; 114 115 /** The system that device/port are in. This is used to select which mode 116 * we are currently operating in. */ 117 System *sys; 118 119 /** Id for all requests */ 120 MasterID masterId; 121 122 /** Number of outstanding packets the dma port has. */ 123 int pendingCount; 124 125 /** If a dmaAction is in progress. */ 126 int actionInProgress; 127 128 /** If we need to drain, keep the drain event around until we're done 129 * here.*/ 130 Event *drainEvent; 131 132 /** time to wait between sending another packet, increases as NACKs are 133 * recived, decreases as responses are recived. */ 134 Tick backoffTime; 135 136 /** Minimum time that device should back off for after failed sendTiming */ 137 Tick minBackoffDelay; 138 139 /** Maximum time that device should back off for after failed sendTiming */ 140 Tick maxBackoffDelay; 141 142 /** If the port is currently waiting for a retry before it can send whatever 143 * it is that it's sending. */ 144 bool inRetry; 145 146 virtual bool recvTimingResp(PacketPtr pkt); 147 148 virtual void recvRetry() ; 149 150 void queueDma(PacketPtr pkt, bool front = false); 151 void sendDma(); 152 153 /** event to give us a kick every time we backoff time is reached. */ 154 EventWrapper<DmaPort, &DmaPort::sendDma> backoffEvent; 155 156 public: 157 DmaPort(MemObject *dev, System *s, Tick min_backoff, Tick max_backoff); 158 159 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, 160 uint8_t *data, Tick delay, Request::Flags flag = 0); 161 162 bool dmaPending() { return pendingCount > 0; } 163 164 unsigned cacheBlockSize() const { return peerBlockSize(); } 165 unsigned int drain(Event *de); 166}; 167 | |
168/** 169 * This device is the base class which all devices senstive to an address range 170 * inherit from. There are three pure virtual functions which all devices must 171 * implement getAddrRanges(), read(), and write(). The magic do choose which 172 * mode we are in, etc is handled by the PioPort so the device doesn't have to 173 * bother. 174 */ 175class PioDevice : public MemObject --- 74 unchanged lines hidden (view full) --- 250 * Determine the address ranges that this device responds to. 251 * 252 * @return a list of non-overlapping address ranges 253 */ 254 virtual AddrRangeList getAddrRanges(); 255 256}; 257 | 77/** 78 * This device is the base class which all devices senstive to an address range 79 * inherit from. There are three pure virtual functions which all devices must 80 * implement getAddrRanges(), read(), and write(). The magic do choose which 81 * mode we are in, etc is handled by the PioPort so the device doesn't have to 82 * bother. 83 */ 84class PioDevice : public MemObject --- 74 unchanged lines hidden (view full) --- 159 * Determine the address ranges that this device responds to. 160 * 161 * @return a list of non-overlapping address ranges 162 */ 163 virtual AddrRangeList getAddrRanges(); 164 165}; 166 |
258class DmaDevice : public PioDevice 259{ 260 protected: 261 DmaPort dmaPort; 262 263 public: 264 typedef DmaDeviceParams Params; 265 DmaDevice(const Params *p); 266 virtual ~DmaDevice(); 267 268 const Params * 269 params() const 270 { 271 return dynamic_cast<const Params *>(_params); 272 } 273 274 void dmaWrite(Addr addr, int size, Event *event, uint8_t *data, 275 Tick delay = 0) 276 { 277 dmaPort.dmaAction(MemCmd::WriteReq, addr, size, event, data, delay); 278 } 279 280 void dmaRead(Addr addr, int size, Event *event, uint8_t *data, 281 Tick delay = 0) 282 { 283 dmaPort.dmaAction(MemCmd::ReadReq, addr, size, event, data, delay); 284 } 285 286 bool dmaPending() { return dmaPort.dmaPending(); } 287 288 virtual void init(); 289 290 virtual unsigned int drain(Event *de); 291 292 unsigned cacheBlockSize() const { return dmaPort.cacheBlockSize(); } 293 294 virtual MasterPort &getMasterPort(const std::string &if_name, 295 int idx = -1); 296 297 friend class DmaPort; 298}; 299 300 | |
301#endif // __DEV_IO_DEVICE_HH__ | 167#endif // __DEV_IO_DEVICE_HH__ |