diff options
author | Nathan Binkert <binkertn@umich.edu> | 2004-01-30 16:01:26 -0500 |
---|---|---|
committer | Nathan Binkert <binkertn@umich.edu> | 2004-01-30 16:01:26 -0500 |
commit | 4ae64216c3c27e9f1e35ce93114f932f3d2c3361 (patch) | |
tree | fe3ca24667628af7c2e5a94a3bcae585fb492855 /dev | |
parent | a0c3e61d320e72bbdddf4cea1413f6638e0faf45 (diff) | |
parent | 2f4f7aacf77dea16795a4052613da6092f6efc31 (diff) | |
download | gem5-4ae64216c3c27e9f1e35ce93114f932f3d2c3361.tar.xz |
Merge
--HG--
extra : convert_revision : 8690e31b64235874d74ea4a1123a408610fb115b
Diffstat (limited to 'dev')
-rw-r--r-- | dev/alpha_console.cc | 2 | ||||
-rw-r--r-- | dev/console.cc | 59 | ||||
-rw-r--r-- | dev/console.hh | 8 | ||||
-rw-r--r-- | dev/etherdump.cc | 18 |
4 files changed, 65 insertions, 22 deletions
diff --git a/dev/alpha_console.cc b/dev/alpha_console.cc index 359995693..89e121ed3 100644 --- a/dev/alpha_console.cc +++ b/dev/alpha_console.cc @@ -82,7 +82,7 @@ AlphaConsole::read(MemReqPtr req, uint8_t *data) Addr daddr = req->paddr & addr_mask; switch (daddr) { case offsetof(AlphaAccess, inputChar): - val = console->in(); + val = console->console_in(); break; default: diff --git a/dev/console.cc b/dev/console.cc index 08b169bc4..fb74c388a 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 @@ -383,8 +400,16 @@ END_INIT_SIM_OBJECT_PARAMS(SimConsole) CREATE_SIM_OBJECT(SimConsole) { string filename = output; - if (!filename.empty() && append_name) - filename += "." + getInstanceName(); + if (filename.empty()) { + if (!outputDirectory.empty()) + filename = outputDirectory + getInstanceName(); + } else { + if (append_name) + filename += "." + getInstanceName(); + if (!outputDirectory.empty()) + filename = outputDirectory + filename; + } + SimConsole *console = new SimConsole(getInstanceName(), filename, number); ((ConsoleListener *)listener)->add(console); ((SimConsole *)console)->initInt(intr_control); diff --git a/dev/console.hh b/dev/console.hh index 9913fe379..d2bba4612 100644 --- a/dev/console.hh +++ b/dev/console.hh @@ -109,7 +109,10 @@ class SimConsole : public SimObject // 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 @@ -118,8 +121,9 @@ class SimConsole : public SimObject // 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); diff --git a/dev/etherdump.cc b/dev/etherdump.cc index 60dc1559d..89f1ce382 100644 --- a/dev/etherdump.cc +++ b/dev/etherdump.cc @@ -126,13 +126,27 @@ END_DECLARE_SIM_OBJECT_PARAMS(EtherDump) BEGIN_INIT_SIM_OBJECT_PARAMS(EtherDump) - INIT_PARAM_DFLT(file, "file to dump packets to", "") + INIT_PARAM(file, "file to dump packets to") END_INIT_SIM_OBJECT_PARAMS(EtherDump) CREATE_SIM_OBJECT(EtherDump) { - return new EtherDump(getInstanceName(), file); + string filename; + if (file.isValid()) { + filename = file; + + if (filename[0] != '/' && !outputDirectory.empty()) + filename = outputDirectory + filename; + } else { + if (outputDirectory.empty()) { + filename = "etherdump"; + } else { + filename = outputDirectory + "etherdump"; + } + } + + return new EtherDump(getInstanceName(), filename); } REGISTER_SIM_OBJECT("EtherDump", EtherDump) |