win-pvdrivers

changeset 448:b90f59eb12f9

Added additional debugging via port writes to 0x10+cpu
author James Harper <james.harper@bendigoit.com.au>
date Thu Nov 13 17:09:08 2008 +1100 (2008-11-13)
parents 5a8502167007
children 6159eac26b1a
files common/include/xen_windows.h
line diff
     1.1 --- a/common/include/xen_windows.h	Fri Nov 07 20:07:35 2008 +1100
     1.2 +++ b/common/include/xen_windows.h	Thu Nov 13 17:09:08 2008 +1100
     1.3 @@ -60,19 +60,16 @@ typedef unsigned long xenbus_transaction
     1.4  
     1.5  #define wmb() KeMemoryBarrier()
     1.6  #define mb() KeMemoryBarrier()
     1.7 -#define FUNCTION_ENTER()       KdPrint((__DRIVER_NAME " --> %s\n", __FUNCTION__))
     1.8 -#define FUNCTION_EXIT()        KdPrint((__DRIVER_NAME " <-- %s\n", __FUNCTION__))
     1.9 -#define FUNCTION_EXIT_STATUS(_status) KdPrint((__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status))
    1.10 -#define FUNCTION_ERROR_EXIT()  KdPrint((__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__))
    1.11 -#define FUNCTION_CALLED()      KdPrint((__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__))
    1.12 +#define FUNCTION_ENTER()       XenDbgPrint(__DRIVER_NAME " --> %s\n", __FUNCTION__)
    1.13 +#define FUNCTION_EXIT()        XenDbgPrint(__DRIVER_NAME " <-- %s\n", __FUNCTION__)
    1.14 +#define FUNCTION_EXIT_STATUS(_status) XenDbgPrint(__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status)
    1.15 +#define FUNCTION_ERROR_EXIT()  XenDbgPrint(__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__)
    1.16 +#define FUNCTION_CALLED()      XenDbgPrint(__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__)
    1.17  #ifdef __MINGW32__
    1.18  #define FUNCTION_MSG(_x) _FUNCTION_MSG _x
    1.19 -#define _FUNCTION_MSG(format, args...) KdPrint((__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args))
    1.20 -#else
    1.21 -#define FUNCTION_MSG(_x)     {  \
    1.22 -    KdPrint((__DRIVER_NAME " %s called: ", __FUNCTION__));          \
    1.23 -    KdPrint(_x);                \
    1.24 -  }
    1.25 +#define _FUNCTION_MSG(format, args...) XenDbgPrint(__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args)
    1.26 +#else
    1.27 +#define FUNCTION_MSG(format, ...)     XenDbgPrint(__DRIVER_NAME "     " format, __VA_ARGS__);
    1.28  #endif
    1.29  
    1.30  static __inline char **
    1.31 @@ -194,4 +191,42 @@ FreePages(PMDL Mdl)
    1.32    ExFreePoolWithTag(Buf, ALLOCATE_PAGES_POOL_TAG);
    1.33  }
    1.34  
    1.35 +//#define XEN_IOPORT_DEBUG_PORT_BASE 0x10
    1.36 +
    1.37 +static XenDbgPrint(PCHAR format, ...)
    1.38 +{
    1.39 +  CHAR buf[512];
    1.40 +  va_list ap;
    1.41 +  ULONG i;
    1.42 +  BOOLEAN flag;
    1.43 +  int cpu;
    1.44 +  KIRQL old_irql = 0;
    1.45 +  
    1.46 +  va_start(ap, format);
    1.47 +  RtlStringCbVPrintfA(buf, ARRAY_SIZE(buf), format, ap);
    1.48 +  va_end(ap);
    1.49 +  DbgPrint(buf);
    1.50 +#ifdef XEN_IOPORT_DEBUG_PORT_BASE
    1.51 +  flag = (KeGetCurrentIrql() < HIGH_LEVEL);
    1.52 +  if (flag)
    1.53 +  {
    1.54 +    KeRaiseIrql(HIGH_LEVEL, &old_irql);
    1.55 +  }
    1.56 +  cpu = KeGetCurrentProcessorNumber() & 0x0F;
    1.57 +  for (i = 0; i < strlen(buf); i++)
    1.58 +  {
    1.59 +    WRITE_PORT_UCHAR((PUCHAR)XEN_IOPORT_DEBUG_PORT_BASE + cpu, buf[i]);
    1.60 +  }
    1.61 +  if (flag)
    1.62 +  {
    1.63 +    KeLowerIrql(old_irql);
    1.64 +  }
    1.65  #endif
    1.66 +}
    1.67 +
    1.68 +#ifdef KdPrint
    1.69 +  #undef KdPrint
    1.70 +#endif
    1.71 +#define KdPrint(_x_) XenDbgPrint _x_
    1.72 +
    1.73 +#endif