summaryrefslogtreecommitdiff
path: root/src/dev/terminal.cc
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-08-07 09:59:19 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-08-07 09:59:19 +0100
commit9b2426ecfc4f004fe77badb4cc64f93af3a2d0d3 (patch)
tree1371894c4c8b50a4bffdea877a9cbe15225df821 /src/dev/terminal.cc
parent39d8034475f09187bee91f90391db26bde287506 (diff)
downloadgem5-9b2426ecfc4f004fe77badb4cc64f93af3a2d0d3.tar.xz
base: Rewrite the CircleBuf to fix bugs and add serialization
The CircleBuf class has at least one bug causing it to overwrite the wrong elements when wrapping. The current code has a lot of unused functionality and duplicated code. This changeset replaces the old implementation with a new version that supports serialization and arbitrary types in the buffer (not just char).
Diffstat (limited to 'src/dev/terminal.cc')
-rw-r--r--src/dev/terminal.cc12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/dev/terminal.cc b/src/dev/terminal.cc
index b4fb50f6e..e653ee115 100644
--- a/src/dev/terminal.cc
+++ b/src/dev/terminal.cc
@@ -205,8 +205,12 @@ Terminal::accept()
write((const uint8_t *)stream.str().c_str(), stream.str().size());
DPRINTFN("attach terminal %d\n", number);
-
- txbuf.readall(data_fd);
+ char buf[1024];
+ for (size_t i = 0; i < txbuf.size(); i += sizeof(buf)) {
+ const size_t chunk_len(std::min(txbuf.size() - i, sizeof(buf)));
+ txbuf.peek(buf, chunk_len);
+ write((const uint8_t *)buf, chunk_len);
+ }
}
void
@@ -329,7 +333,7 @@ Terminal::out(char c)
DPRINTF(Terminal, "%s\n", buffer);
delete [] buffer;
} else {
- linebuf.write(c);
+ linebuf.write(&c, 1);
}
}
@@ -337,7 +341,7 @@ Terminal::out(char c)
}
#endif
- txbuf.write(c);
+ txbuf.write(&c, 1);
if (data_fd >= 0)
write(c);