Sean Wilson has uploaded this change for review. (
https://gem5-review.googlesource.com/3928
Change subject: dev: Refactor some Event subclasses to lambdas
......................................................................
dev: Refactor some Event subclasses to lambdas
Change-Id: I965d31ff8ad1658b03a902bf4244d7d0977b0466
Signed-off-by: Sean Wilson <spwils...@wisc.edu>
---
M src/dev/dma_device.hh
M src/dev/uart8250.cc
M src/dev/uart8250.hh
3 files changed, 21 insertions(+), 59 deletions(-)
diff --git a/src/dev/dma_device.hh b/src/dev/dma_device.hh
index f354d38..0dc79df 100644
--- a/src/dev/dma_device.hh
+++ b/src/dev/dma_device.hh
@@ -240,22 +240,6 @@
}
}
- /**
- * Event invoked by DmaDevice on completion of each chunk.
- */
- class DmaChunkEvent : public Event
- {
- private:
- DmaCallback *callback;
-
- public:
- DmaChunkEvent(DmaCallback *cb)
- : Event(Default_Pri, AutoDelete), callback(cb)
- { }
-
- void process() { callback->chunkComplete(); }
- };
-
public:
/**
@@ -265,7 +249,8 @@
Event *getChunkEvent()
{
++count;
- return new DmaChunkEvent(this);
+ return new EventFunctionWrapper([this]{ chunkComplete(); }, name(),
+ true);
}
};
diff --git a/src/dev/uart8250.cc b/src/dev/uart8250.cc
index 3c97604..8ee763f 100644
--- a/src/dev/uart8250.cc
+++ b/src/dev/uart8250.cc
@@ -49,27 +49,14 @@
using namespace std;
using namespace TheISA;
-Uart8250::IntrEvent::IntrEvent(Uart8250 *u, int bit)
- : uart(u)
-{
- DPRINTF(Uart, "UART Interrupt Event Initilizing\n");
- intrBit = bit;
-}
-
-const char *
-Uart8250::IntrEvent::description() const
-{
- return "uart interrupt delay";
-}
-
void
-Uart8250::IntrEvent::process()
+Uart8250::processIntrEvent(int intrBit)
{
- if (intrBit & uart->IER) {
+ if (intrBit & IER) {
DPRINTF(Uart, "UART InterEvent, interrupting\n");
- uart->platform->postConsoleInt();
- uart->status |= intrBit;
- uart->lastTxInt = curTick();
+ platform->postConsoleInt();
+ status |= intrBit;
+ lastTxInt = curTick();
}
else
DPRINTF(Uart, "UART InterEvent, not interrupting\n");
@@ -89,21 +76,20 @@
* character to send to alleviate this problem. --Ali
*/
void
-Uart8250::IntrEvent::scheduleIntr()
+Uart8250::scheduleIntr(Event *event)
{
static const Tick interval = 225 * SimClock::Int::ns;
- DPRINTF(Uart, "Scheduling IER interrupt for %#x, at cycle %lld\n",
intrBit,
- curTick() + interval);
- if (!scheduled())
- uart->schedule(this, curTick() + interval);
+ if (!event->scheduled())
+ schedule(event, curTick() + interval);
else
- uart->reschedule(this, curTick() + interval);
+ reschedule(event, curTick() + interval);
}
Uart8250::Uart8250(const Params *p)
: Uart(p, 8), IER(0), DLAB(0), LCR(0), MCR(0), lastTxInt(0),
- txIntrEvent(this, TX_INT), rxIntrEvent(this, RX_INT)
+ txIntrEvent([this]{ processIntrEvent(TX_INT); }, "uart interrupt
delay"),
+ rxIntrEvent([this]{ processIntrEvent(RX_INT); }, "uart interrupt
delay")
{
}
@@ -131,7 +117,7 @@
platform->clearConsoleInt();
if (term->dataAvailable() && (IER & UART_IER_RDI))
- rxIntrEvent.scheduleIntr();
+ scheduleIntr(&rxIntrEvent);
} else { // dll divisor latch
;
}
@@ -206,7 +192,7 @@
platform->clearConsoleInt();
status &= ~TX_INT;
if (UART_IER_THRI & IER)
- txIntrEvent.scheduleIntr();
+ scheduleIntr(&txIntrEvent);
} else { // dll divisor latch
;
}
@@ -224,7 +210,7 @@
} else {
DPRINTF(Uart, "-- Delaying interrupt... %d,%d\n",
curTick(), lastTxInt);
- txIntrEvent.scheduleIntr();
+ scheduleIntr(&txIntrEvent);
}
}
else
@@ -239,7 +225,7 @@
if ((UART_IER_RDI & IER) && term->dataAvailable()) {
DPRINTF(Uart, "IER: IER_RDI set, scheduling RX
intrrupt\n");
- rxIntrEvent.scheduleIntr();
+ scheduleIntr(&rxIntrEvent);
} else {
DPRINTF(Uart, "IER: IER_RDI cleared, descheduling RX
intrrupt\n");
if (rxIntrEvent.scheduled())
diff --git a/src/dev/uart8250.hh b/src/dev/uart8250.hh
index ccccac1..b7fefc5 100644
--- a/src/dev/uart8250.hh
+++ b/src/dev/uart8250.hh
@@ -73,20 +73,11 @@
uint8_t IER, DLAB, LCR, MCR;
Tick lastTxInt;
- class IntrEvent : public Event
- {
- protected:
- Uart8250 *uart;
- int intrBit;
- public:
- IntrEvent(Uart8250 *u, int bit);
- virtual void process();
- virtual const char *description() const;
- void scheduleIntr();
- };
+ void processIntrEvent(int intrBit);
+ void scheduleIntr(Event *event);
- IntrEvent txIntrEvent;
- IntrEvent rxIntrEvent;
+ EventFunctionWrapper txIntrEvent;
+ EventFunctionWrapper rxIntrEvent;
public:
typedef Uart8250Params Params;
--
To view, visit https://gem5-review.googlesource.com/3928
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I965d31ff8ad1658b03a902bf4244d7d0977b0466
Gerrit-Change-Number: 3928
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Wilson <spwils...@wisc.edu>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev