win-pvdrivers

changeset 857:f6ba3ce0bd81

Log bugcheck directly to Xen instead of using KdPrint, which doesn't work.
author James Harper <james.harper@bendigoit.com.au>
date Tue Feb 22 23:21:15 2011 +1100 (2011-02-22)
parents c730857f9831
children fc54b0c09c08
files xenpci/xenpci_dbgprint.c
line diff
     1.1 --- a/xenpci/xenpci_dbgprint.c	Tue Feb 22 23:08:08 2011 +1100
     1.2 +++ b/xenpci/xenpci_dbgprint.c	Tue Feb 22 23:21:15 2011 +1100
     1.3 @@ -62,26 +62,6 @@ KBUGCHECK_CALLBACK_RECORD callback_recor
     1.4  extern VOID Int2dHandlerNew(VOID);
     1.5  extern PVOID Int2dHandlerOld;
     1.6  
     1.7 -static VOID
     1.8 -XenPci_BugcheckCallback(PVOID buffer, ULONG length)
     1.9 -{
    1.10 -  NTSTATUS status;
    1.11 -  KBUGCHECK_DATA bugcheck_data;
    1.12 -  
    1.13 -  UNREFERENCED_PARAMETER(buffer);
    1.14 -  UNREFERENCED_PARAMETER(length);
    1.15 -  
    1.16 -  bugcheck_data.BugCheckDataSize  = sizeof(bugcheck_data);
    1.17 -  status = AuxKlibGetBugCheckData(&bugcheck_data);
    1.18 -  if(!NT_SUCCESS(status))
    1.19 -  {
    1.20 -    KdPrint((__DRIVER_NAME "     AuxKlibGetBugCheckData returned %08x\n", status));
    1.21 -    return;
    1.22 -  }
    1.23 -  KdPrint((__DRIVER_NAME "     Bug check 0x%08X (0x%p, 0x%p, 0x%p, 0x%p)\n",
    1.24 -    bugcheck_data.BugCheckCode, bugcheck_data.Parameter1, bugcheck_data.Parameter2, bugcheck_data.Parameter3, bugcheck_data.Parameter4));
    1.25 -}
    1.26 -
    1.27  static BOOLEAN debug_port_enabled = FALSE;
    1.28  static volatile LONG debug_print_lock = 0;
    1.29  
    1.30 @@ -99,6 +79,77 @@ static void XenDbgPrint(PCHAR string, UL
    1.31    InterlockedExchange(&debug_print_lock, 0);
    1.32  }
    1.33  
    1.34 +static VOID
    1.35 +XenPci_DbgWriteChar(CHAR c)
    1.36 +{
    1.37 +  WRITE_PORT_UCHAR(XEN_IOPORT_LOG, c);
    1.38 +}
    1.39 +
    1.40 +static VOID
    1.41 +XenPci_DbgWriteString(PCHAR string)
    1.42 +{
    1.43 +  while (*string)
    1.44 +  {
    1.45 +    WRITE_PORT_UCHAR(XEN_IOPORT_LOG, *string);
    1.46 +    string++;
    1.47 +  }
    1.48 +}
    1.49 +
    1.50 +static VOID
    1.51 +XenPci_DbgWriteHexByte(UCHAR byte)
    1.52 +{
    1.53 +  char *digits = "0123456789ABCDEF";
    1.54 +  XenPci_DbgWriteChar(digits[byte >> 4]);
    1.55 +  XenPci_DbgWriteChar(digits[byte & 0x0F]);
    1.56 +}
    1.57 +
    1.58 +static VOID
    1.59 +XenPci_DbgWriteULONG(ULONG data)
    1.60 +{
    1.61 +  int i;
    1.62 +  for (i = 0; i < sizeof(data); i++)
    1.63 +    XenPci_DbgWriteHexByte((UCHAR)(data >> ((sizeof(data) - 1 - i) << 3)));
    1.64 +}
    1.65 +
    1.66 +static VOID
    1.67 +XenPci_DbgWriteULONG_PTR(ULONG_PTR data)
    1.68 +{
    1.69 +  int i;
    1.70 +  for (i = 0; i < sizeof(data); i++)
    1.71 +    XenPci_DbgWriteHexByte((UCHAR)(data >> ((sizeof(data) - 1 - i) << 3)));
    1.72 +}
    1.73 +
    1.74 +static VOID
    1.75 +XenPci_BugcheckCallback(PVOID buffer, ULONG length)
    1.76 +{
    1.77 +  NTSTATUS status;
    1.78 +  KBUGCHECK_DATA bugcheck_data;
    1.79 +  
    1.80 +  UNREFERENCED_PARAMETER(buffer);
    1.81 +  UNREFERENCED_PARAMETER(length);
    1.82 +  
    1.83 +  bugcheck_data.BugCheckDataSize  = sizeof(bugcheck_data);
    1.84 +  status = AuxKlibGetBugCheckData(&bugcheck_data);
    1.85 +  if(!NT_SUCCESS(status))
    1.86 +  {
    1.87 +    XenPci_DbgWriteString(__DRIVER_NAME "     AuxKlibGetBugCheckData returned ");
    1.88 +    XenPci_DbgWriteULONG(status);
    1.89 +    XenPci_DbgWriteString("\n");
    1.90 +    return;
    1.91 +  }
    1.92 +  XenPci_DbgWriteString(__DRIVER_NAME "     Bug check 0x");
    1.93 +  XenPci_DbgWriteULONG(bugcheck_data.BugCheckCode);
    1.94 +  XenPci_DbgWriteString(" (0x");
    1.95 +  XenPci_DbgWriteULONG_PTR(bugcheck_data.Parameter1);
    1.96 +  XenPci_DbgWriteString(", 0x");
    1.97 +  XenPci_DbgWriteULONG_PTR(bugcheck_data.Parameter2);
    1.98 +  XenPci_DbgWriteString(", 0x");
    1.99 +  XenPci_DbgWriteULONG_PTR(bugcheck_data.Parameter3);
   1.100 +  XenPci_DbgWriteString(", 0x");
   1.101 +  XenPci_DbgWriteULONG_PTR(bugcheck_data.Parameter4);
   1.102 +  XenPci_DbgWriteString(")\n");
   1.103 +}
   1.104 +
   1.105  VOID
   1.106  Int2dHandlerProc(ULONG_PTR dbg_type, PVOID arg2, PVOID arg3, PVOID arg4, PVOID arg5)
   1.107  {