win-pvdrivers

changeset 787:e723cc352a15

add a spinlock to dbgprint to avoid mixing up messages
author James Harper <james.harper@bendigoit.com.au>
date Sat Feb 20 16:31:45 2010 +1100 (2010-02-20)
parents 8ab029b609c8
children 3058ea7a6f59
files xenpci/xenpci_dbgprint.c
line diff
     1.1 --- a/xenpci/xenpci_dbgprint.c	Tue Feb 16 16:49:14 2010 +1100
     1.2 +++ b/xenpci/xenpci_dbgprint.c	Sat Feb 20 16:31:45 2010 +1100
     1.3 @@ -82,6 +82,7 @@ XenPci_BugcheckCallback(PVOID buffer, UL
     1.4  }
     1.5  
     1.6  static BOOLEAN debug_port_enabled = FALSE;
     1.7 +static volatile LONG debug_print_lock = 0;
     1.8  
     1.9  /* This appears to be called with interrupts disabled already, so no need to go to HIGH_LEVEL or anything like that */
    1.10  static void XenDbgPrint(PCHAR string, ULONG length)
    1.11 @@ -89,10 +90,12 @@ static void XenDbgPrint(PCHAR string, UL
    1.12    ULONG i;
    1.13    //KIRQL old_irql = 0;
    1.14  
    1.15 -  //KeRaiseIrql(HIGH_LEVEL, &old_irql);
    1.16 +  while(InterlockedCompareExchange(&debug_print_lock, 1, 0) == 1)
    1.17 +    KeStallExecutionProcessor(1);
    1.18    for (i = 0; i < length; i++)
    1.19      WRITE_PORT_UCHAR(XEN_IOPORT_LOG, string[i]);
    1.20 -  //KeLowerIrql(old_irql);
    1.21 +  /* release the lock */
    1.22 +  InterlockedExchange(&debug_print_lock, 0);
    1.23  }
    1.24  
    1.25  VOID