summaryrefslogtreecommitdiff
path: root/src/dev
diff options
context:
space:
mode:
Diffstat (limited to 'src/dev')
-rw-r--r--src/dev/simconsole.cc27
-rw-r--r--src/dev/simconsole.hh2
-rw-r--r--src/dev/tsunami_io.cc38
-rw-r--r--src/dev/tsunami_io.hh4
-rw-r--r--src/dev/uart8250.cc2
5 files changed, 39 insertions, 34 deletions
diff --git a/src/dev/simconsole.cc b/src/dev/simconsole.cc
index c3e4f554a..e33fa18b5 100644
--- a/src/dev/simconsole.cc
+++ b/src/dev/simconsole.cc
@@ -202,32 +202,31 @@ SimConsole::write(const uint8_t *buf, size_t len)
#define RECEIVE_NONE (ULL(2) << 62)
#define RECEIVE_ERROR (ULL(3) << 62)
-bool
-SimConsole::in(uint8_t &c)
+uint8_t
+SimConsole::in()
{
- bool empty, ret;
+ bool empty;
+ uint8_t c;
empty = rxbuf.empty();
- ret = !empty;
- if (!empty) {
- rxbuf.read((char *)&c, 1);
- empty = rxbuf.empty();
- }
+ assert(!empty);
+ rxbuf.read((char *)&c, 1);
+ empty = rxbuf.empty();
- DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d, return: %d\n",
- isprint(c) ? c : ' ', c, !empty, ret);
- return ret;
+ DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d\n",
+ isprint(c) ? c : ' ', c, !empty);
+
+ return c;
}
uint64_t
SimConsole::console_in()
{
- uint8_t c;
uint64_t value;
- if (in(c)) {
- value = RECEIVE_SUCCESS | c;
+ if (dataAvailable()) {
+ value = RECEIVE_SUCCESS | in();
if (!rxbuf.empty())
value |= MORE_PENDING;
} else {
diff --git a/src/dev/simconsole.hh b/src/dev/simconsole.hh
index cf0641f9e..64d1f6717 100644
--- a/src/dev/simconsole.hh
+++ b/src/dev/simconsole.hh
@@ -102,7 +102,7 @@ class SimConsole : public SimObject
// OS interface
// Get a character from the console.
- bool in(uint8_t &value);
+ uint8_t in();
// get a character from the console in the console specific format
// corresponds to GETC:
diff --git a/src/dev/tsunami_io.cc b/src/dev/tsunami_io.cc
index 7c649a84a..729a61cf7 100644
--- a/src/dev/tsunami_io.cc
+++ b/src/dev/tsunami_io.cc
@@ -118,25 +118,27 @@ TsunamiIO::RTC::writeData(const uint8_t data)
}
}
-void
-TsunamiIO::RTC::readData(uint8_t *data)
+uint8_t
+TsunamiIO::RTC::readData()
{
if (addr < RTC_STAT_REGA)
- *data = clock_data[addr];
+ return clock_data[addr];
else {
switch (addr) {
case RTC_STAT_REGA:
// toggle UIP bit for linux
stat_regA ^= RTCA_UIP;
- *data = stat_regA;
+ return stat_regA;
break;
case RTC_STAT_REGB:
- *data = stat_regB;
+ return stat_regB;
break;
case RTC_STAT_REGC:
case RTC_STAT_REGD:
- *data = 0x00;
+ return 0x00;
break;
+ default:
+ panic("Shouldn't be here");
}
}
}
@@ -263,31 +265,35 @@ TsunamiIO::PITimer::Counter::latchCount()
}
}
-void
-TsunamiIO::PITimer::Counter::read(uint8_t *data)
+uint8_t
+TsunamiIO::PITimer::Counter::read()
{
if (latch_on) {
switch (read_byte) {
case LSB:
read_byte = MSB;
- *data = (uint8_t)latched_count;
+ return (uint8_t)latched_count;
break;
case MSB:
read_byte = LSB;
latch_on = false;
- *data = latched_count >> 8;
+ return latched_count >> 8;
break;
+ default:
+ panic("Shouldn't be here");
}
} else {
switch (read_byte) {
case LSB:
read_byte = MSB;
- *data = (uint8_t)count;
+ return (uint8_t)count;
break;
case MSB:
read_byte = LSB;
- *data = count >> 8;
+ return count >> 8;
break;
+ default:
+ panic("Shouldn't be here");
}
}
}
@@ -469,16 +475,16 @@ TsunamiIO::read(Packet *pkt)
pkt->set(0x00);
break;
case TSDEV_TMR0_DATA:
- pitimer.counter0.read(pkt->getPtr<uint8_t>());
+ pkt->set(pitimer.counter0.read());
break;
case TSDEV_TMR1_DATA:
- pitimer.counter1.read(pkt->getPtr<uint8_t>());
+ pkt->set(pitimer.counter1.read());
break;
case TSDEV_TMR2_DATA:
- pitimer.counter2.read(pkt->getPtr<uint8_t>());
+ pkt->set(pitimer.counter2.read());
break;
case TSDEV_RTC_DATA:
- rtc.readData(pkt->getPtr<uint8_t>());
+ pkt->set(rtc.readData());
break;
case TSDEV_CTRL_PORTB:
if (pitimer.counter2.outputHigh())
diff --git a/src/dev/tsunami_io.hh b/src/dev/tsunami_io.hh
index 4e4fb2036..71ca0d98f 100644
--- a/src/dev/tsunami_io.hh
+++ b/src/dev/tsunami_io.hh
@@ -118,7 +118,7 @@ class TsunamiIO : public BasicPioDevice
void writeData(const uint8_t data);
/** RTC read data */
- void readData(uint8_t *data);
+ uint8_t readData();
/**
* Serialize this object to the given output stream.
@@ -207,7 +207,7 @@ class TsunamiIO : public BasicPioDevice
void setBCD(int bcd_val);
/** Read a count byte */
- void read(uint8_t *data);
+ uint8_t read();
/** Write a count byte */
void write(const uint8_t data);
diff --git a/src/dev/uart8250.cc b/src/dev/uart8250.cc
index 8e6843841..8a5a1f1cd 100644
--- a/src/dev/uart8250.cc
+++ b/src/dev/uart8250.cc
@@ -124,7 +124,7 @@ Uart8250::read(Packet *pkt)
case 0x0:
if (!(LCR & 0x80)) { // read byte
if (cons->dataAvailable())
- cons->in(*pkt->getPtr<uint8_t>());
+ pkt->set(cons->in());
else {
pkt->set((uint8_t)0);
// A limited amount of these are ok.