Merge ehallnor@zizzer:/bk/m5 into zazzer.eecs.umich.edu:/z/ehallnor/m5

--HG--
extra : convert_revision : a74364b249fc6164ef2752ff1e3d6e414b5ab79d
This commit is contained in:
Erik Hallnor 2004-01-29 20:15:54 -05:00
commit ca11c9d3e7
5 changed files with 58 additions and 30 deletions

View file

@ -37,9 +37,20 @@ using namespace std;
namespace cp { namespace cp {
ArgList::~ArgList()
{
while (!objects.empty()) {
delete objects.front();
objects.pop_front();
}
}
void void
ArgList::dump(const string &format) ArgList::dump(const string &format)
{ {
list_t::iterator iter = objects.begin();
list_t::iterator end = objects.end();
const char *p = format.c_str(); const char *p = format.c_str();
stream->fill(' '); stream->fill(' ');
@ -198,22 +209,19 @@ ArgList::dump(const string &format)
} }
} }
if (!objects.empty()) if (iter != end)
{ {
Base *data = objects.front();
objects.pop_front();
ios::fmtflags saved_flags = stream->flags(); ios::fmtflags saved_flags = stream->flags();
char old_fill = stream->fill(); char old_fill = stream->fill();
int old_precision = stream->precision(); int old_precision = stream->precision();
data->process(*stream, fmt); (*iter)->process(*stream, fmt);
stream->flags(saved_flags); stream->flags(saved_flags);
stream->fill(old_fill); stream->fill(old_fill);
stream->precision(old_precision); stream->precision(old_precision);
delete data; ++iter;
} else { } else {
*stream << "<missing arg for format>"; *stream << "<missing arg for format>";
} }
@ -241,11 +249,9 @@ ArgList::dump(const string &format)
} }
} }
while (!objects.empty()) { while (iter != end) {
*stream << "<extra arg>"; *stream << "<extra arg>";
Base *data = objects.front(); ++iter;
objects.pop_front();
delete data;
} }
} }

View file

@ -89,6 +89,7 @@ class ArgList
public: public:
ArgList() : stream(&std::cout) {} ArgList() : stream(&std::cout) {}
~ArgList();
template<class T> template<class T>
void append(const T &data) { void append(const T &data) {

View file

@ -81,7 +81,7 @@ AlphaConsole::read(MemReqPtr req, uint8_t *data)
Addr daddr = req->paddr & addr_mask; Addr daddr = req->paddr & addr_mask;
switch (daddr) { switch (daddr) {
case offsetof(AlphaAccess, inputChar): case offsetof(AlphaAccess, inputChar):
val = console->in(); val = console->console_in();
break; break;
default: default:

View file

@ -228,27 +228,44 @@ SimConsole::configTerm()
#define RECEIVE_NONE (ULL(2) << 62) #define RECEIVE_NONE (ULL(2) << 62)
#define RECEIVE_ERROR (ULL(3) << 62) #define RECEIVE_ERROR (ULL(3) << 62)
uint64_t bool
SimConsole::in() SimConsole::in(uint8_t &c)
{ {
char c = 0; bool empty, ret;
uint64_t val = 0;
if (rxbuf.empty()) { empty = rxbuf.empty();
clearInt(ReceiveInterrupt); ret = !empty;
val |= RECEIVE_NONE; if (!empty) {
return 0x8; rxbuf.read((char *)&c, 1);
} else { empty = rxbuf.empty();
uint64_t val;
rxbuf.read(&c, 1);
val |= RECEIVE_SUCCESS | c;
if (!rxbuf.empty())
val |= MORE_PENDING;
} }
DPRINTF(ConsoleVerbose, "in: \'%c\' %#02x retval: %#x\n", if (empty)
isprint(c) ? c : ' ', c, val); clearInt(ReceiveInterrupt);
return val; 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())
value |= MORE_PENDING;
} else {
value = RECEIVE_NONE;
}
DPRINTF(ConsoleVerbose, "console_in: return: %#x\n", value);
return value;
} }
void void

View file

@ -109,7 +109,10 @@ class SimConsole : public SimObject
// OS interface // OS interface
// Get a character from the console. // 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> // retval<63:61>
// 000: success: character received // 000: success: character received
// 001: success: character received, more pending // 001: success: character received, more pending
@ -118,8 +121,9 @@ class SimConsole : public SimObject
// 111: failure: character received with error, more pending // 111: failure: character received with error, more pending
// retval<31:0> // retval<31:0>
// character read from console // character read from console
//
// Interrupts are cleared when the buffer is empty. // Interrupts are cleared when the buffer is empty.
uint64_t in(); uint64_t console_in();
// Send a character to the console // Send a character to the console
void out(char c, bool raise_int = true); void out(char c, bool raise_int = true);