remove some getPtr() calls by changing having function return values
instead of taking a pointer --HG-- extra : convert_revision : fd9092eaa726e91b501334d35d28dda28aaa01bd
This commit is contained in:
parent
5df77b865d
commit
de20b819f1
5 changed files with 39 additions and 34 deletions
|
@ -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 {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue