io_device.hh (2982:0ecdb0879b14) | io_device.hh (3090:3cced9156352) |
---|---|
1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Ali Saidi 29 * Nathan Binkert 30 */ 31 32#ifndef __DEV_IO_DEVICE_HH__ 33#define __DEV_IO_DEVICE_HH__ 34 | 1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 18 unchanged lines hidden (view full) --- 27 * 28 * Authors: Ali Saidi 29 * Nathan Binkert 30 */ 31 32#ifndef __DEV_IO_DEVICE_HH__ 33#define __DEV_IO_DEVICE_HH__ 34 |
35#include "base/chunk_generator.hh" | |
36#include "mem/mem_object.hh" 37#include "mem/packet_impl.hh" | 35#include "mem/mem_object.hh" 36#include "mem/packet_impl.hh" |
38#include "sim/eventq.hh" | |
39#include "sim/sim_object.hh" 40#include "mem/tport.hh" 41 | 37#include "sim/sim_object.hh" 38#include "mem/tport.hh" 39 |
40class Event; |
|
42class Platform; 43class PioDevice; 44class DmaDevice; 45class System; 46 47/** 48 * The PioPort class is a programmed i/o port that all devices that are 49 * sensitive to an address range use. The port takes all the memory 50 * access types and roles them into one read() and write() call that the device 51 * must respond to. The device must also provide the addressRanges() function | 41class Platform; 42class PioDevice; 43class DmaDevice; 44class System; 45 46/** 47 * The PioPort class is a programmed i/o port that all devices that are 48 * sensitive to an address range use. The port takes all the memory 49 * access types and roles them into one read() and write() call that the device 50 * must respond to. The device must also provide the addressRanges() function |
52 * with which it returns the address ranges it is interested in. */ 53 | 51 * with which it returns the address ranges it is interested in. 52 */ |
54class PioPort : public SimpleTimingPort 55{ 56 protected: 57 /** The device that this port serves. */ 58 PioDevice *device; 59 60 /** The system that device/port are in. This is used to select which mode 61 * we are currently operating in. */ --- 6 unchanged lines hidden (view full) --- 68 69 virtual Tick recvAtomic(Packet *pkt); 70 71 virtual void recvFunctional(Packet *pkt) ; 72 73 virtual void recvStatusChange(Status status) 74 { peerStatus = status; } 75 | 53class PioPort : public SimpleTimingPort 54{ 55 protected: 56 /** The device that this port serves. */ 57 PioDevice *device; 58 59 /** The system that device/port are in. This is used to select which mode 60 * we are currently operating in. */ --- 6 unchanged lines hidden (view full) --- 67 68 virtual Tick recvAtomic(Packet *pkt); 69 70 virtual void recvFunctional(Packet *pkt) ; 71 72 virtual void recvStatusChange(Status status) 73 { peerStatus = status; } 74 |
76 virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop); | 75 virtual void getDeviceAddressRanges(AddrRangeList &resp, 76 AddrRangeList &snoop); |
77 78 public: 79 PioPort(PioDevice *dev, System *s, std::string pname = "-pioport"); 80 81}; 82 83 84class DmaPort : public Port --- 42 unchanged lines hidden (view full) --- 127 virtual void recvFunctional(Packet *pkt) 128 { panic("dma port shouldn't be used for pio access."); } 129 130 virtual void recvStatusChange(Status status) 131 { ; } 132 133 virtual void recvRetry() ; 134 | 77 78 public: 79 PioPort(PioDevice *dev, System *s, std::string pname = "-pioport"); 80 81}; 82 83 84class DmaPort : public Port --- 42 unchanged lines hidden (view full) --- 127 virtual void recvFunctional(Packet *pkt) 128 { panic("dma port shouldn't be used for pio access."); } 129 130 virtual void recvStatusChange(Status status) 131 { ; } 132 133 virtual void recvRetry() ; 134 |
135 virtual void getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop) | 135 virtual void getDeviceAddressRanges(AddrRangeList &resp, 136 AddrRangeList &snoop) |
136 { resp.clear(); snoop.clear(); } 137 138 void sendDma(Packet *pkt, bool front = false); 139 140 public: 141 DmaPort(DmaDevice *dev, System *s); 142 143 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, --- 6 unchanged lines hidden (view full) --- 150 151/** 152 * This device is the base class which all devices senstive to an address range 153 * inherit from. There are three pure virtual functions which all devices must 154 * implement addressRanges(), read(), and write(). The magic do choose which 155 * mode we are in, etc is handled by the PioPort so the device doesn't have to 156 * bother. 157 */ | 137 { resp.clear(); snoop.clear(); } 138 139 void sendDma(Packet *pkt, bool front = false); 140 141 public: 142 DmaPort(DmaDevice *dev, System *s); 143 144 void dmaAction(Packet::Command cmd, Addr addr, int size, Event *event, --- 6 unchanged lines hidden (view full) --- 151 152/** 153 * This device is the base class which all devices senstive to an address range 154 * inherit from. There are three pure virtual functions which all devices must 155 * implement addressRanges(), read(), and write(). The magic do choose which 156 * mode we are in, etc is handled by the PioPort so the device doesn't have to 157 * bother. 158 */ |
158 | |
159class PioDevice : public MemObject 160{ 161 protected: 162 163 /** The platform we are in. This is used to decide what type of memory 164 * transaction we should perform. */ 165 Platform *platform; 166 167 System *sys; 168 169 /** The pioPort that handles the requests for us and provides us requests 170 * that it sees. */ 171 PioPort *pioPort; 172 173 virtual void addressRanges(AddrRangeList &range_list) = 0; 174 | 159class PioDevice : public MemObject 160{ 161 protected: 162 163 /** The platform we are in. This is used to decide what type of memory 164 * transaction we should perform. */ 165 Platform *platform; 166 167 System *sys; 168 169 /** The pioPort that handles the requests for us and provides us requests 170 * that it sees. */ 171 PioPort *pioPort; 172 173 virtual void addressRanges(AddrRangeList &range_list) = 0; 174 |
175 /** As far as the devices are concerned they only accept atomic transactions 176 * which are converted to either a write or a read. */ | 175 /** As far as the devices are concerned they only accept atomic 176 * transactions which are converted to either a write or a 177 * read. */ |
177 Tick recvAtomic(Packet *pkt) 178 { return pkt->isRead() ? this->read(pkt) : this->write(pkt); } 179 | 178 Tick recvAtomic(Packet *pkt) 179 { return pkt->isRead() ? this->read(pkt) : this->write(pkt); } 180 |
180 /** Pure virtual function that the device must implement. Called when a read 181 * command is recieved by the port. | 181 /** Pure virtual function that the device must implement. Called 182 * when a read command is recieved by the port. |
182 * @param pkt Packet describing this request 183 * @return number of ticks it took to complete 184 */ 185 virtual Tick read(Packet *pkt) = 0; 186 187 /** Pure virtual function that the device must implement. Called when a 188 * write command is recieved by the port. 189 * @param pkt Packet describing this request 190 * @return number of ticks it took to complete 191 */ 192 virtual Tick write(Packet *pkt) = 0; 193 194 public: | 183 * @param pkt Packet describing this request 184 * @return number of ticks it took to complete 185 */ 186 virtual Tick read(Packet *pkt) = 0; 187 188 /** Pure virtual function that the device must implement. Called when a 189 * write command is recieved by the port. 190 * @param pkt Packet describing this request 191 * @return number of ticks it took to complete 192 */ 193 virtual Tick write(Packet *pkt) = 0; 194 195 public: |
195 /** Params struct which is extended through each device based on the 196 * parameters it needs. Since we are re-writing everything, we might as well 197 * start from the bottom this time. */ 198 | 196 /** Params struct which is extended through each device based on 197 * the parameters it needs. Since we are re-writing everything, we 198 * might as well start from the bottom this time. */ |
199 struct Params 200 { 201 std::string name; 202 Platform *platform; 203 System *system; 204 }; 205 206 protected: --- 43 unchanged lines hidden (view full) --- 250 /** Size that the device's address range. */ 251 Addr pioSize; 252 253 /** Delay that the device experinces on an access. */ 254 Tick pioDelay; 255 256 public: 257 BasicPioDevice(Params *p) | 199 struct Params 200 { 201 std::string name; 202 Platform *platform; 203 System *system; 204 }; 205 206 protected: --- 43 unchanged lines hidden (view full) --- 250 /** Size that the device's address range. */ 251 Addr pioSize; 252 253 /** Delay that the device experinces on an access. */ 254 Tick pioDelay; 255 256 public: 257 BasicPioDevice(Params *p) |
258 : PioDevice(p), pioAddr(p->pio_addr), pioSize(0), pioDelay(p->pio_delay) | 258 : PioDevice(p), pioAddr(p->pio_addr), pioSize(0), 259 pioDelay(p->pio_delay) |
259 {} 260 261 /** return the address ranges that this device responds to. 262 * @param range_list range list to populate with ranges 263 */ 264 void addressRanges(AddrRangeList &range_list); 265 266}; --- 41 unchanged lines hidden --- | 260 {} 261 262 /** return the address ranges that this device responds to. 263 * @param range_list range list to populate with ranges 264 */ 265 void addressRanges(AddrRangeList &range_list); 266 267}; --- 41 unchanged lines hidden --- |