Addr daddr = req->paddr & addr_mask;
switch (daddr) {
case offsetof(AlphaAccess, inputChar):
- val = console->in();
+ val = console->console_in();
break;
default:
#define RECEIVE_NONE (ULL(2) << 62)
#define RECEIVE_ERROR (ULL(3) << 62)
-uint64_t
-SimConsole::in()
+bool
+SimConsole::in(uint8_t &c)
{
- char c = 0;
- uint64_t val = 0;
- if (rxbuf.empty()) {
+ bool empty, ret;
+
+ empty = rxbuf.empty();
+ ret = !empty;
+ if (!empty) {
+ rxbuf.read((char *)&c, 1);
+ empty = rxbuf.empty();
+ }
+
+ if (empty)
clearInt(ReceiveInterrupt);
- val |= RECEIVE_NONE;
- return 0x8;
- } else {
- uint64_t val;
- rxbuf.read(&c, 1);
- val |= RECEIVE_SUCCESS | c;
+
+ DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x more: %d, return: %d\n",
+ isprint(c) ? c : ' ', c, !empty, ret);
+
+ return ret;
+}
+
+uint64_t
+SimConsole::console_in()
+{
+ uint8_t c;
+ uint64_t value;
+
+ if (in(c)) {
+ value = RECEIVE_SUCCESS | c;
if (!rxbuf.empty())
- val |= MORE_PENDING;
+ value |= MORE_PENDING;
+ } else {
+ value = RECEIVE_NONE;
}
- DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x retval: %#x\n",
- isprint(c) ? c : ' ', c, val);
+ DPRINTF(ConsoleVerbose, "console_in: return: %#x\n", value);
- return val;
+ return value;
}
void
// OS interface
// Get a character from the console.
- // the return value corresponds to the console GETC return value:
+ bool in(uint8_t &value);
+
+ // get a character from the console in the console specific format
+ // corresponds to GETC:
// retval<63:61>
// 000: success: character received
// 001: success: character received, more pending
// 111: failure: character received with error, more pending
// retval<31:0>
// character read from console
+ //
// Interrupts are cleared when the buffer is empty.
- uint64_t in();
+ uint64_t console_in();
// Send a character to the console
void out(char c, bool raise_int = true);