summaryrefslogtreecommitdiff
path: root/Source/Kernel/VTManager
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Kernel/VTManager')
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.cpp28
-rw-r--r--Source/Kernel/VTManager/VirtualTerminal.class.h2
2 files changed, 30 insertions, 0 deletions
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.cpp b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
index 7864afd..4c0df95 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.cpp
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.cpp
@@ -158,6 +158,7 @@ void VirtualTerminal::writeDec(s32int i, bool updatecsr) {
}
void VirtualTerminal::writeHex(u32int i, bool updatecsr) {
+ if (m_cols < 60) return;
write("0x", false);
char hexdigits[] = "0123456789ABCDEF";
for (u32int j = 0; j < 8; j++) {
@@ -166,3 +167,30 @@ void VirtualTerminal::writeHex(u32int i, bool updatecsr) {
}
if (updatecsr) updateCursor();
}
+
+void VirtualTerminal::hexDump(u8int *ptr, u32int sz) {
+ if (m_cols < 76) return; //Not enough space
+ write("HEX Dump, from "); writeHex((u32int)ptr); write("\n");
+ char hexdigits[] = "0123456789ABCDEF";
+ for (u32int i = 0; i < sz; i += 16) {
+ writeHex(i);
+ write(" ");
+ for (u32int j = 0; j < 16; j++) {
+ u8int b = ptr[i + j];
+ if (j > 7) put(" ");
+ put(hexdigits[b >> 4]);
+ put(hexdigits[b & 0xF]);
+ if (j < 8) put(" ");
+ }
+ write(" ");
+ for (u32int j = 0; j < 16; j++) {
+ u8int b = ptr[i + j];
+ if (b >= 0x20 && b < 128) {
+ put(wchar(b));
+ } else {
+ put(".");
+ }
+ }
+ if (m_cols > 76) write("\n");
+ }
+}
diff --git a/Source/Kernel/VTManager/VirtualTerminal.class.h b/Source/Kernel/VTManager/VirtualTerminal.class.h
index 6a14080..4e5fe86 100644
--- a/Source/Kernel/VTManager/VirtualTerminal.class.h
+++ b/Source/Kernel/VTManager/VirtualTerminal.class.h
@@ -49,6 +49,8 @@ class VirtualTerminal {
void write(String s, bool updatecsr = true);
void writeDec(s32int i, bool updatecsr = true);
void writeHex(u32int i, bool updatecsr = true);
+
+ void hexDump(u8int* ptr, u32int sz);
inline VirtualTerminal& operator<<(String s) { write(s); return *this; }
//inline VirtualTerminal& operator<<(wchar c) { put(c); return *this; }