summaryrefslogtreecommitdiff
path: root/dev/console.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2004-01-29 16:32:03 -0500
committerNathan Binkert <binkertn@umich.edu>2004-01-29 16:32:03 -0500
commitee4263f72e547d551e26b058ee16a48a5f47e3c4 (patch)
tree0430dfb5febc3e431581fa752d51141efef703f7 /dev/console.cc
parent639037d127586bb363ed314b2f00f1d371555ae1 (diff)
downloadgem5-ee4263f72e547d551e26b058ee16a48a5f47e3c4.tar.xz
Fix character input by handling the character and the
special console values separately. dev/alpha_console.cc: use new console specific input function --HG-- extra : convert_revision : 08997d6115d2aac3a26cac2774b3c3fc0cd76ab0
Diffstat (limited to 'dev/console.cc')
-rw-r--r--dev/console.cc47
1 files changed, 32 insertions, 15 deletions
diff --git a/dev/console.cc b/dev/console.cc
index 3fa51a414..5e7b0abf6 100644
--- a/dev/console.cc
+++ b/dev/console.cc
@@ -228,27 +228,44 @@ SimConsole::configTerm()
#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