#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 {
// 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:
}
}
-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");
}
}
}
}
}
-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");
}
}
}
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())
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.
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);
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.