|
|
1.1 ! root 1: /* ! 2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Governed by the TrueCrypt License 2.4 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #include "Platform.h" ! 10: #include "Bios.h" ! 11: #include "BootConsoleIo.h" ! 12: #include "BootDiskIo.h" ! 13: #include "BootDebug.h" ! 14: ! 15: ! 16: void InitDebugPort () ! 17: { ! 18: __asm ! 19: { ! 20: mov dx, TC_DEBUG_PORT ! 21: mov ah, 1 ! 22: int 0x17 ! 23: mov dx, TC_DEBUG_PORT ! 24: mov ah, 0xe2 ! 25: int 0x17 ! 26: } ! 27: } ! 28: ! 29: ! 30: void WriteDebugPort (byte dataByte) ! 31: { ! 32: __asm ! 33: { ! 34: mov al, dataByte ! 35: mov dx, TC_DEBUG_PORT ! 36: mov ah, 0 ! 37: int 0x17 ! 38: } ! 39: } ! 40: ! 41: ! 42: extern "C" void PrintDebug (uint32 debugVal) ! 43: { ! 44: Print (debugVal); ! 45: PrintEndl(); ! 46: } ! 47: ! 48: ! 49: void PrintAddress (void *addr) ! 50: { ! 51: uint16 segment = uint16 (uint32 (addr) >> 16); ! 52: uint16 offset = uint16 (addr); ! 53: ! 54: PrintHex (segment); ! 55: PrintChar (':'); ! 56: PrintHex (offset); ! 57: Print (" ("); ! 58: PrintHex (GetLinearAddress (segment, offset)); ! 59: Print (")"); ! 60: } ! 61: ! 62: ! 63: void PrintVal (const char *message, const uint32 value, bool newLine, bool hex) ! 64: { ! 65: Print (message); ! 66: Print (": "); ! 67: ! 68: if (hex) ! 69: PrintHex (value); ! 70: else ! 71: Print (value); ! 72: ! 73: if (newLine) ! 74: PrintEndl(); ! 75: } ! 76: ! 77: ! 78: void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex) ! 79: { ! 80: Print (message); ! 81: Print (": "); ! 82: PrintHex (value); ! 83: if (newLine) ! 84: PrintEndl(); ! 85: } ! 86: ! 87: ! 88: void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) ! 89: { ! 90: const size_t width = 16; ! 91: for (size_t pos = 0; pos < size; ) ! 92: { ! 93: for (int pass = 1; pass <= 2; ++pass) ! 94: { ! 95: size_t i; ! 96: for (i = 0; i < width && pos < size; ++i) ! 97: { ! 98: byte dataByte; ! 99: if (memSegment) ! 100: { ! 101: __asm ! 102: { ! 103: push es ! 104: mov si, ss:memSegment ! 105: mov es, ss:[si] ! 106: mov si, ss:mem ! 107: add si, pos ! 108: mov al, es:[si] ! 109: mov dataByte, al ! 110: pop es ! 111: } ! 112: pos++; ! 113: } ! 114: else ! 115: dataByte = mem[pos++]; ! 116: ! 117: if (pass == 1) ! 118: { ! 119: PrintHex (dataByte); ! 120: PrintChar (' '); ! 121: } ! 122: else ! 123: PrintChar (IsPrintable (dataByte) ? dataByte : '.'); ! 124: } ! 125: ! 126: if (pass == 1) ! 127: { ! 128: pos -= i; ! 129: PrintChar (' '); ! 130: } ! 131: } ! 132: ! 133: PrintEndl (); ! 134: } ! 135: } ! 136: ! 137: ! 138: void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size) ! 139: { ! 140: PrintHexDump ((byte *) memOffset, size, &memSegment); ! 141: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.