From df76b24fed5ac3b5af406aad3df277d7f4c347e5 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Mon, 31 Aug 2009 21:44:26 +0200 Subject: Now we can read frop floppy drives !!! Next : FAT driver. --- Source/Kernel/VTManager/VirtualTerminal.class.cpp | 28 +++++++++++++++++++++++ Source/Kernel/VTManager/VirtualTerminal.class.h | 2 ++ 2 files changed, 30 insertions(+) (limited to 'Source/Kernel/VTManager') 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; } -- cgit v1.2.3