io_device.cc (2902:695d4683916e) io_device.cc (2914:2c524dc023d2)
1/*
2 * Copyright (c) 2006 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;

--- 22 unchanged lines hidden (view full) ---

31
32#include "base/trace.hh"
33#include "dev/io_device.hh"
34#include "sim/builder.hh"
35#include "sim/system.hh"
36
37
38PioPort::PioPort(PioDevice *dev, System *s, std::string pname)
1/*
2 * Copyright (c) 2006 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;

--- 22 unchanged lines hidden (view full) ---

31
32#include "base/trace.hh"
33#include "dev/io_device.hh"
34#include "sim/builder.hh"
35#include "sim/system.hh"
36
37
38PioPort::PioPort(PioDevice *dev, System *s, std::string pname)
39 : Port(dev->name() + pname), device(dev), sys(s),
40 outTiming(0), drainEvent(NULL)
39 : SimpleTimingPort(dev->name() + pname), device(dev), sys(s)
41{ }
42
43
44Tick
45PioPort::recvAtomic(Packet *pkt)
46{
47 return device->recvAtomic(pkt);
48}

--- 7 unchanged lines hidden (view full) ---

56void
57PioPort::getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
58{
59 snoop.clear();
60 device->addressRanges(resp);
61}
62
63
40{ }
41
42
43Tick
44PioPort::recvAtomic(Packet *pkt)
45{
46 return device->recvAtomic(pkt);
47}

--- 7 unchanged lines hidden (view full) ---

55void
56PioPort::getDeviceAddressRanges(AddrRangeList &resp, AddrRangeList &snoop)
57{
58 snoop.clear();
59 device->addressRanges(resp);
60}
61
62
64void
65PioPort::recvRetry()
66{
67 bool result = true;
68 while (result && transmitList.size()) {
69 result = Port::sendTiming(transmitList.front());
70 if (result)
71 transmitList.pop_front();
72 }
73 if (transmitList.size() == 0 && drainEvent) {
74 drainEvent->process();
75 drainEvent = NULL;
76 }
77}
78
79void
80PioPort::SendEvent::process()
81{
82 port->outTiming--;
83 assert(port->outTiming >= 0);
84 if (port->Port::sendTiming(packet))
85 if (port->transmitList.size() == 0 && port->drainEvent) {
86 port->drainEvent->process();
87 port->drainEvent = NULL;
88 }
89 return;
90
91 port->transmitList.push_back(packet);
92}
93
94void
95PioPort::resendNacked(Packet *pkt) {
96 pkt->reinitNacked();
97 if (transmitList.size()) {
98 transmitList.push_front(pkt);
99 } else {
100 if (!Port::sendTiming(pkt))
101 transmitList.push_front(pkt);
102 }
103};
104
105
106bool
107PioPort::recvTiming(Packet *pkt)
108{
109 if (pkt->result == Packet::Nacked) {
110 resendNacked(pkt);
111 } else {
112 Tick latency = device->recvAtomic(pkt);
113 // turn packet around to go back to requester
114 pkt->makeTimingResponse();
115 sendTiming(pkt, latency);
116 }
117 return true;
118}
119
63bool
64PioPort::recvTiming(Packet *pkt)
65{
66 if (pkt->result == Packet::Nacked) {
67 resendNacked(pkt);
68 } else {
69 Tick latency = device->recvAtomic(pkt);
70 // turn packet around to go back to requester
71 pkt->makeTimingResponse();
72 sendTiming(pkt, latency);
73 }
74 return true;
75}
76
120unsigned int
121PioPort::drain(Event *de)
122{
123 if (outTiming == 0 && transmitList.size() == 0)
124 return 0;
125 drainEvent = de;
126 return 1;
127}
128
129PioDevice::~PioDevice()
130{
131 if (pioPort)
132 delete pioPort;
133}
134
135void
136PioDevice::init()

--- 200 unchanged lines hidden ---
77PioDevice::~PioDevice()
78{
79 if (pioPort)
80 delete pioPort;
81}
82
83void
84PioDevice::init()

--- 200 unchanged lines hidden ---