win-pvdrivers

changeset 116:ff8c14904e96

Updated shutdownmon to use the 'force' option .
Added a sysrq handler to xenpci, with 'B' to cause a deliberate BSOD to test memory dumps under xenvbd
author James Harper <james.harper@bendigoit.com.au>
date Mon Jan 14 21:26:55 2008 +1100 (2008-01-14)
parents 0d9e5303a8d2
children 92aea8738afb
files ShutdownMon/Program.cs Xen.sln xenpci/sources xenpci/xenpci.c xenvbd/xenvbd.c
line diff
     1.1 --- a/ShutdownMon/Program.cs	Sat Jan 12 22:14:04 2008 +1100
     1.2 +++ b/ShutdownMon/Program.cs	Mon Jan 14 21:26:55 2008 +1100
     1.3 @@ -298,13 +298,13 @@ namespace ShutdownMon
     1.4                          break;
     1.5                      case "reboot":
     1.6                          //DoExitWin(EWX_REBOOT | EWX_FORCE);
     1.7 -                        DoExitWin(ExitWindows.Reboot | ExitWindows.ForceIfHung);
     1.8 +                        DoExitWin(ExitWindows.Reboot | ExitWindows.Force);
     1.9                          break;
    1.10                      case "poweroff":
    1.11                      case "halt":
    1.12                      default:
    1.13                          //DoExitWin(EWX_POWEROFF | EWX_FORCE);
    1.14 -                        DoExitWin(ExitWindows.PowerOff | ExitWindows.ForceIfHung);
    1.15 +                        DoExitWin(ExitWindows.PowerOff | ExitWindows.Force);
    1.16                          break;
    1.17                  }
    1.18              }
     2.1 --- a/Xen.sln	Sat Jan 12 22:14:04 2008 +1100
     2.2 +++ b/Xen.sln	Mon Jan 14 21:26:55 2008 +1100
     2.3 @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, F
     2.4  # Visual Studio 2005
     2.5  Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShutdownMon", "ShutdownMon\ShutdownMon.csproj", "{26FF5B06-2383-454E-821F-306186171677}"
     2.6  EndProject
     2.7 +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "XenPvInstaller", "XenPvInstaller\XenPvInstaller.vdproj", "{086AB089-7132-4D35-8BBE-D5211FBBD915}"
     2.8 +EndProject
     2.9  Global
    2.10  	GlobalSection(SolutionConfigurationPlatforms) = preSolution
    2.11  		Debug|Any CPU = Debug|Any CPU
    2.12 @@ -13,6 +15,8 @@ Global
    2.13  		{26FF5B06-2383-454E-821F-306186171677}.Debug|Any CPU.Build.0 = Debug|Any CPU
    2.14  		{26FF5B06-2383-454E-821F-306186171677}.Release|Any CPU.ActiveCfg = Release|Any CPU
    2.15  		{26FF5B06-2383-454E-821F-306186171677}.Release|Any CPU.Build.0 = Release|Any CPU
    2.16 +		{086AB089-7132-4D35-8BBE-D5211FBBD915}.Debug|Any CPU.ActiveCfg = Debug
    2.17 +		{086AB089-7132-4D35-8BBE-D5211FBBD915}.Release|Any CPU.ActiveCfg = Release
    2.18  	EndGlobalSection
    2.19  	GlobalSection(SolutionProperties) = preSolution
    2.20  		HideSolutionNode = FALSE
     3.1 --- a/xenpci/sources	Sat Jan 12 22:14:04 2008 +1100
     3.2 +++ b/xenpci/sources	Mon Jan 14 21:26:55 2008 +1100
     3.3 @@ -1,7 +1,7 @@
     3.4  TARGETNAME=XENPCI
     3.5  TARGETTYPE=DRIVER
     3.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     3.7 -VERSION=0.5.0.23
     3.8 +VERSION=0.5.0.24
     3.9  KMDF_VERSION=1
    3.10  MSC_WARNING_LEVEL=/W4
    3.11  INF_NAME=xenpci
     4.1 --- a/xenpci/xenpci.c	Sat Jan 12 22:14:04 2008 +1100
     4.2 +++ b/xenpci/xenpci.c	Mon Jan 14 21:26:55 2008 +1100
     4.3 @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  #include "hypercall.h"
     4.5  #include <stdlib.h>
     4.6  
     4.7 +#define SYSRQ_PATH "control/sysrq"
     4.8  #define SHUTDOWN_PATH "control/shutdown"
     4.9  #define BALLOON_PATH "memory/target"
    4.10  
    4.11 @@ -59,6 +60,8 @@ static NTSTATUS
    4.12  XenPCI_RemoveAddedResources(WDFDEVICE Device, WDFCMRESLIST ResourcesRaw, WDFCMRESLIST ResourcesTranslated);
    4.13  
    4.14  static VOID
    4.15 +XenBus_SysrqHandler(char *Path, PVOID Data);
    4.16 +static VOID
    4.17  XenBus_ShutdownHandler(char *Path, PVOID Data);
    4.18  static VOID
    4.19  XenBus_BalloonHandler(char *Path, PVOID Data);
    4.20 @@ -600,6 +603,9 @@ XenPCI_D0EntryPostInterruptsEnabled(WDFD
    4.21    XenBus_Start(Device);
    4.22  
    4.23    KdPrint((__DRIVER_NAME "     A\n"));
    4.24 +
    4.25 +  response = XenBus_AddWatch(Device, XBT_NIL, SYSRQ_PATH, XenBus_SysrqHandler, Device);
    4.26 +  KdPrint((__DRIVER_NAME "     sysrqwatch response = '%s'\n", response)); 
    4.27    
    4.28    response = XenBus_AddWatch(Device, XBT_NIL, SHUTDOWN_PATH, XenBus_ShutdownHandler, Device);
    4.29    KdPrint((__DRIVER_NAME "     shutdown watch response = '%s'\n", response)); 
    4.30 @@ -1041,6 +1047,63 @@ XenBus_BalloonHandler(char *Path, PVOID 
    4.31    KdPrint((__DRIVER_NAME " <-- XenBus_BalloonHandler\n"));
    4.32  }
    4.33  
    4.34 +static VOID
    4.35 +XenBus_SysrqHandler(char *Path, PVOID Data)
    4.36 +{
    4.37 +  WDFDEVICE Device = Data;
    4.38 +  char *Value;
    4.39 +  xenbus_transaction_t xbt;
    4.40 +  int retry;
    4.41 +  char letter;
    4.42 +  char *res;
    4.43 +
    4.44 +  UNREFERENCED_PARAMETER(Path);
    4.45 +
    4.46 +  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    4.47 +
    4.48 +  XenBus_StartTransaction(Device, &xbt);
    4.49 +
    4.50 +  XenBus_Read(Device, XBT_NIL, SYSRQ_PATH, &Value);
    4.51 +
    4.52 +  KdPrint((__DRIVER_NAME "     SysRq Value = %s\n", Value));
    4.53 +
    4.54 +  if (Value != NULL && strlen(Value) != 0)
    4.55 +  {
    4.56 +    letter = *Value;
    4.57 +    res = XenBus_Write(Device, XBT_NIL, SYSRQ_PATH, "");
    4.58 +    if (res)
    4.59 +    {
    4.60 +      KdPrint(("Error writing sysrq path\n"));
    4.61 +      XenPCI_FreeMem(res);
    4.62 +      XenBus_EndTransaction(Device, xbt, 0, &retry);
    4.63 +      return;
    4.64 +    }
    4.65 +  }
    4.66 +  else
    4.67 +  {
    4.68 +    letter = 0;
    4.69 +  }
    4.70 +
    4.71 +  XenBus_EndTransaction(Device, xbt, 0, &retry);
    4.72 +
    4.73 +  if (Value != NULL)
    4.74 +  {
    4.75 +    XenPCI_FreeMem(Value);
    4.76 +  }
    4.77 +
    4.78 +  switch (letter)
    4.79 +  {
    4.80 +  case 'B':
    4.81 +    KeBugCheckEx(('X' << 16)|('E' << 8)|('N'), 0x00000001, 0x00000000, 0x00000000, 0x00000000);
    4.82 +    break;
    4.83 +  default:
    4.84 +    KdPrint(("     Unhandled sysrq letter %c\n", letter));
    4.85 +    break;
    4.86 +  }
    4.87 +
    4.88 +  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    4.89 +}
    4.90 +
    4.91  /*
    4.92  IO_RESOURCE_DESCRIPTOR MemoryDescriptor;
    4.93  
     5.1 --- a/xenvbd/xenvbd.c	Sat Jan 12 22:14:04 2008 +1100
     5.2 +++ b/xenvbd/xenvbd.c	Mon Jan 14 21:26:55 2008 +1100
     5.3 @@ -42,6 +42,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     5.4    HW_INITIALIZATION_DATA HwInitializationData;
     5.5  
     5.6    KdPrint((__DRIVER_NAME " --> DriverEntry\n"));
     5.7 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
     5.8  
     5.9    RtlZeroMemory(&HwInitializationData, sizeof(HW_INITIALIZATION_DATA));
    5.10  
    5.11 @@ -418,6 +419,7 @@ XenVbd_WatchHandler(char *Path, PVOID De
    5.12    int i, j;
    5.13  
    5.14    KdPrint((__DRIVER_NAME " --> WatchHandler (DeviceData = %08x)\n", DeviceData));
    5.15 +  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    5.16  
    5.17    KdPrint((__DRIVER_NAME "     Path = %s\n", Path));
    5.18