*/
#include <freeldr.h>
+
#include <debug.h>
-#include <rtl.h>
-#include <comm.h>
-#include <portio.h>
-#include <machine.h>
#ifdef DEBUG
VOID DebugInit(VOID)
{
- if (DebugPort == RS232)
+ if (DebugPort & RS232)
{
Rs232PortInitialize(ComPort, BaudRate);
}
}
}
-static VOID DebugPrintV(char *format, int *dataptr)
-{
- char c, *ptr, str[16];
- int ll;
-
- ll = 0;
- while ((c = *(format++)))
- {
- if (c != '%')
- {
- DebugPrintChar(c);
- }
- else
- {
- if (*format == 'I' && *(format+1) == '6' && *(format+2) == '4')
- {
- ll = 1;
- format += 3;
- }
- else
- {
- ll = 0;
- }
- switch (c = *(format++))
- {
- case 'd': case 'u': case 'x':
-
- if (ll)
- {
- *convert_i64_to_ascii(str, c, *((unsigned long long*) dataptr)) = 0;
- dataptr += 2;
- }
- else
- {
- *convert_to_ascii(str, c, *((unsigned long *) dataptr++)) = 0;
- }
-
- ptr = str;
-
- while (*ptr)
- {
- DebugPrintChar(*(ptr++));
- }
- break;
-
- case 'c':
-
- DebugPrintChar((*(dataptr++))&0xff);
- break;
-
- case 's':
-
- ptr = (char *)(*(dataptr++));
-
- while ((c = *(ptr++)))
- {
- DebugPrintChar(c);
- }
- break;
- case '%':
- DebugPrintChar(c);
- break;
- default:
- DebugPrint(DPRINT_WARNING, "\nDebugPrint() invalid format specifier - %%%c\n", c);
- break;
- }
- }
- }
-
-
- if (DebugPort == SCREEN)
- {
- //getch();
- }
-
-}
-
VOID DebugPrint(ULONG Mask, char *format, ...)
{
- int *dataptr = (int *) &format;
+ va_list ap;
+ char Buffer[4096];
+ char *ptr = Buffer;
// Mask out unwanted debug messages
if (!(Mask & DebugPrintMask))
DebugStartOfLine = FALSE;
}
- DebugPrintV(format, ++dataptr);
+ va_start(ap, format);
+ vsprintf(Buffer, format, ap);
+ va_end(ap);
+ while (*ptr)
+ {
+ DebugPrintChar(*ptr++);
+ }
}
VOID DebugPrint1(char *format, ...)
{
- int *dataptr = (int *) &format;
-
- DebugPrintV(format, ++dataptr);
+ va_list ap;
+ char Buffer[4096];
+ char *ptr = Buffer;
+
+ va_start(ap, format);
+ vsprintf(Buffer, format, ap);
+ va_end(ap);
+ while (*ptr)
+ {
+ DebugPrintChar(*ptr++);
+ }
}
VOID DebugDumpBuffer(ULONG Mask, PVOID Buffer, ULONG Length)