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_NONE (ULL(2) << 62)
|
||||||
#define RECEIVE_ERROR (ULL(3) << 62)
|
#define RECEIVE_ERROR (ULL(3) << 62)
|
||||||
|
|
||||||
bool
|
uint8_t
|
||||||
SimConsole::in(uint8_t &c)
|
SimConsole::in()
|
||||||
{
|
{
|
||||||
bool empty, ret;
|
bool empty;
|
||||||
|
uint8_t c;
|
||||||
|
|
||||||
empty = rxbuf.empty();
|
empty = rxbuf.empty();
|
||||||
ret = !empty;
|
assert(!empty);
|
||||||
if (!empty) {
|
rxbuf.read((char *)&c, 1);
|
||||||
rxbuf.read((char *)&c, 1);
|
empty = rxbuf.empty();
|
||||||
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
|
uint64_t
|
||||||
SimConsole::console_in()
|
SimConsole::console_in()
|
||||||
{
|
{
|
||||||
uint8_t c;
|
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
|
|
||||||
if (in(c)) {
|
if (dataAvailable()) {
|
||||||
value = RECEIVE_SUCCESS | c;
|
value = RECEIVE_SUCCESS | in();
|
||||||
if (!rxbuf.empty())
|
if (!rxbuf.empty())
|
||||||
value |= MORE_PENDING;
|
value |= MORE_PENDING;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -102,7 +102,7 @@ class SimConsole : public SimObject
|
||||||
// OS interface
|
// OS interface
|
||||||
|
|
||||||
// Get a character from the console.
|
// 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
|
// get a character from the console in the console specific format
|
||||||
// corresponds to GETC:
|
// corresponds to GETC:
|
||||||
|
|
|
@ -118,25 +118,27 @@ TsunamiIO::RTC::writeData(const uint8_t data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
uint8_t
|
||||||
TsunamiIO::RTC::readData(uint8_t *data)
|
TsunamiIO::RTC::readData()
|
||||||
{
|
{
|
||||||
if (addr < RTC_STAT_REGA)
|
if (addr < RTC_STAT_REGA)
|
||||||
*data = clock_data[addr];
|
return clock_data[addr];
|
||||||
else {
|
else {
|
||||||
switch (addr) {
|
switch (addr) {
|
||||||
case RTC_STAT_REGA:
|
case RTC_STAT_REGA:
|
||||||
// toggle UIP bit for linux
|
// toggle UIP bit for linux
|
||||||
stat_regA ^= RTCA_UIP;
|
stat_regA ^= RTCA_UIP;
|
||||||
*data = stat_regA;
|
return stat_regA;
|
||||||
break;
|
break;
|
||||||
case RTC_STAT_REGB:
|
case RTC_STAT_REGB:
|
||||||
*data = stat_regB;
|
return stat_regB;
|
||||||
break;
|
break;
|
||||||
case RTC_STAT_REGC:
|
case RTC_STAT_REGC:
|
||||||
case RTC_STAT_REGD:
|
case RTC_STAT_REGD:
|
||||||
*data = 0x00;
|
return 0x00;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
panic("Shouldn't be here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -263,31 +265,35 @@ TsunamiIO::PITimer::Counter::latchCount()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
uint8_t
|
||||||
TsunamiIO::PITimer::Counter::read(uint8_t *data)
|
TsunamiIO::PITimer::Counter::read()
|
||||||
{
|
{
|
||||||
if (latch_on) {
|
if (latch_on) {
|
||||||
switch (read_byte) {
|
switch (read_byte) {
|
||||||
case LSB:
|
case LSB:
|
||||||
read_byte = MSB;
|
read_byte = MSB;
|
||||||
*data = (uint8_t)latched_count;
|
return (uint8_t)latched_count;
|
||||||
break;
|
break;
|
||||||
case MSB:
|
case MSB:
|
||||||
read_byte = LSB;
|
read_byte = LSB;
|
||||||
latch_on = false;
|
latch_on = false;
|
||||||
*data = latched_count >> 8;
|
return latched_count >> 8;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
panic("Shouldn't be here");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (read_byte) {
|
switch (read_byte) {
|
||||||
case LSB:
|
case LSB:
|
||||||
read_byte = MSB;
|
read_byte = MSB;
|
||||||
*data = (uint8_t)count;
|
return (uint8_t)count;
|
||||||
break;
|
break;
|
||||||
case MSB:
|
case MSB:
|
||||||
read_byte = LSB;
|
read_byte = LSB;
|
||||||
*data = count >> 8;
|
return count >> 8;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
panic("Shouldn't be here");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -469,16 +475,16 @@ TsunamiIO::read(Packet *pkt)
|
||||||
pkt->set(0x00);
|
pkt->set(0x00);
|
||||||
break;
|
break;
|
||||||
case TSDEV_TMR0_DATA:
|
case TSDEV_TMR0_DATA:
|
||||||
pitimer.counter0.read(pkt->getPtr<uint8_t>());
|
pkt->set(pitimer.counter0.read());
|
||||||
break;
|
break;
|
||||||
case TSDEV_TMR1_DATA:
|
case TSDEV_TMR1_DATA:
|
||||||
pitimer.counter1.read(pkt->getPtr<uint8_t>());
|
pkt->set(pitimer.counter1.read());
|
||||||
break;
|
break;
|
||||||
case TSDEV_TMR2_DATA:
|
case TSDEV_TMR2_DATA:
|
||||||
pitimer.counter2.read(pkt->getPtr<uint8_t>());
|
pkt->set(pitimer.counter2.read());
|
||||||
break;
|
break;
|
||||||
case TSDEV_RTC_DATA:
|
case TSDEV_RTC_DATA:
|
||||||
rtc.readData(pkt->getPtr<uint8_t>());
|
pkt->set(rtc.readData());
|
||||||
break;
|
break;
|
||||||
case TSDEV_CTRL_PORTB:
|
case TSDEV_CTRL_PORTB:
|
||||||
if (pitimer.counter2.outputHigh())
|
if (pitimer.counter2.outputHigh())
|
||||||
|
|
|
@ -118,7 +118,7 @@ class TsunamiIO : public BasicPioDevice
|
||||||
void writeData(const uint8_t data);
|
void writeData(const uint8_t data);
|
||||||
|
|
||||||
/** RTC read data */
|
/** RTC read data */
|
||||||
void readData(uint8_t *data);
|
uint8_t readData();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serialize this object to the given output stream.
|
* Serialize this object to the given output stream.
|
||||||
|
@ -207,7 +207,7 @@ class TsunamiIO : public BasicPioDevice
|
||||||
void setBCD(int bcd_val);
|
void setBCD(int bcd_val);
|
||||||
|
|
||||||
/** Read a count byte */
|
/** Read a count byte */
|
||||||
void read(uint8_t *data);
|
uint8_t read();
|
||||||
|
|
||||||
/** Write a count byte */
|
/** Write a count byte */
|
||||||
void write(const uint8_t data);
|
void write(const uint8_t data);
|
||||||
|
|
|
@ -124,7 +124,7 @@ Uart8250::read(Packet *pkt)
|
||||||
case 0x0:
|
case 0x0:
|
||||||
if (!(LCR & 0x80)) { // read byte
|
if (!(LCR & 0x80)) { // read byte
|
||||||
if (cons->dataAvailable())
|
if (cons->dataAvailable())
|
||||||
cons->in(*pkt->getPtr<uint8_t>());
|
pkt->set(cons->in());
|
||||||
else {
|
else {
|
||||||
pkt->set((uint8_t)0);
|
pkt->set((uint8_t)0);
|
||||||
// A limited amount of these are ok.
|
// A limited amount of these are ok.
|
||||||
|
|
Loading…
Reference in a new issue