win-pvdrivers

changeset 403:abdcb860cfdf

More suspend/resume updates.
author James Harper <james.harper@bendigoit.com.au>
date Mon Jul 21 11:47:29 2008 +1000 (2008-07-21)
parents 04883e1dc65c
children 1a1ddc1beba6
files common.inc installer.nsi xenhide/xenhide.c xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c xenvbd/scsiport.c
line diff
     1.1 --- a/common.inc	Sat Jul 19 11:35:24 2008 +1000
     1.2 +++ b/common.inc	Mon Jul 21 11:47:29 2008 +1000
     1.3 @@ -1,4 +1,4 @@
     1.4 -VERSION=0.9.10.8
     1.5 +VERSION=0.9.10.10
     1.6  TARGETPATH=..\Target\$(DDK_TARGET_OS)
     1.7  MSC_WARNING_LEVEL=/W4
     1.8  INCLUDES = ..\common\include;..\common\include\public
     2.1 --- a/installer.nsi	Sat Jul 19 11:35:24 2008 +1000
     2.2 +++ b/installer.nsi	Mon Jul 21 11:47:29 2008 +1000
     2.3 @@ -3,7 +3,7 @@
     2.4  
     2.5  !define AppName "Xen PV Drivers"
     2.6  !define StartMenu "$SMPROGRAMS\${AppName}"
     2.7 -!define Version "0.9.11-pre7"
     2.8 +!define Version "0.9.11-pre9"
     2.9  #!define Version "$%VERSION%"
    2.10  Name "${AppName}"
    2.11  InstallDir "$PROGRAMFILES\${AppName}"
     3.1 --- a/xenhide/xenhide.c	Sat Jul 19 11:35:24 2008 +1000
     3.2 +++ b/xenhide/xenhide.c	Mon Jul 21 11:47:29 2008 +1000
     3.3 @@ -38,6 +38,9 @@ XenHide_AddDevice();
     3.4  #endif
     3.5  
     3.6  static BOOLEAN gplpv;
     3.7 +static BOOLEAN qemu_ide_device_filter_installed;
     3.8 +static BOOLEAN qemu_scsi_device_filter_installed;
     3.9 +static KEVENT add_device_event;
    3.10  static XENHIDE_DRIVER_DATA xenhide_global_data;
    3.11  
    3.12  static NTSTATUS
    3.13 @@ -92,6 +95,10 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    3.14    KeyPartialValue = (PKEY_VALUE_PARTIAL_INFORMATION)Buf;
    3.15    SystemStartOptions = (WCHAR *)KeyPartialValue->Data;
    3.16  
    3.17 +  qemu_ide_device_filter_installed = FALSE;
    3.18 +  qemu_scsi_device_filter_installed = FALSE;
    3.19 +  KeInitializeEvent(&add_device_event, SynchronizationEvent, FALSE);
    3.20 +
    3.21    gplpv = FALSE;
    3.22  
    3.23    RtlStringCbLengthW(SystemStartOptions, KeyPartialValue->DataLength, &SystemStartOptionsLen);
    3.24 @@ -253,9 +260,19 @@ XenHide_AddDevice(
    3.25    if (gplpv)
    3.26    {
    3.27      /* hide only specific devices */
    3.28 -    if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_8086&DEV_7010") // Qemu IDE
    3.29 -      || XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_10EC&DEV_8139") // Qemu Network
    3.30 -      || XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_1000&DEV_0012"))// Qemu SCSI
    3.31 +    if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_8086&DEV_7010")) // Qemu IDE
    3.32 +    {
    3.33 +      hide_type = XENHIDE_TYPE_DEVICE;
    3.34 +      qemu_ide_device_filter_installed = TRUE;
    3.35 +      KeSetEvent(&add_device_event, IO_NO_INCREMENT, FALSE);
    3.36 +    }
    3.37 +    else if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_1000&DEV_0012"))// Qemu SCSI
    3.38 +    {
    3.39 +      hide_type = XENHIDE_TYPE_DEVICE;
    3.40 +      qemu_scsi_device_filter_installed = TRUE;
    3.41 +      KeSetEvent(&add_device_event, IO_NO_INCREMENT, FALSE);
    3.42 +    }
    3.43 +    else if (XenHide_IdSuffixMatches(PhysicalDeviceObject, L"VEN_10EC&DEV_8139")) // Qemu Network
    3.44      {
    3.45        hide_type = XENHIDE_TYPE_DEVICE;
    3.46      }
     4.1 --- a/xenpci/xenpci_fdo.c	Sat Jul 19 11:35:24 2008 +1000
     4.2 +++ b/xenpci/xenpci_fdo.c	Mon Jul 21 11:47:29 2008 +1000
     4.3 @@ -547,10 +547,57 @@ XenPci_ShutdownHandler(char *path, PVOID
     4.4    FUNCTION_EXIT();
     4.5  }
     4.6  
     4.7 +static DDKAPI void
     4.8 +XenBus_DummyXenbusThreadProc(PVOID StartContext)
     4.9 +{
    4.10 +  PXENPCI_DEVICE_DATA xpdd = StartContext;
    4.11 +  char *value;
    4.12 +  char *err;
    4.13 +  LARGE_INTEGER wait_time;
    4.14 +  int thread_id;
    4.15 +  
    4.16 +  thread_id = (int)PsGetCurrentThreadId();
    4.17 +  for(;;)
    4.18 +  {
    4.19 +    KdPrint((__DRIVER_NAME "     %08X: writing 666\n", thread_id));
    4.20 +    XenBus_Write(xpdd, XBT_NIL, "james", "666");
    4.21 +    err = XenBus_Read(xpdd, XBT_NIL, "james", &value);
    4.22 +    if (err)
    4.23 +    {
    4.24 +      KdPrint((__DRIVER_NAME "     %08X: error on read - %s\n", thread_id, err));
    4.25 +      XenPci_FreeMem(err);
    4.26 +    }
    4.27 +    else
    4.28 +    {
    4.29 +      KdPrint((__DRIVER_NAME "     %08X: read %s\n", thread_id, value));
    4.30 +      XenPci_FreeMem(value);
    4.31 +    }
    4.32 +    KdPrint((__DRIVER_NAME "     %08X: writing 362436\n", thread_id));
    4.33 +    XenBus_Write(xpdd, XBT_NIL, "james", "362436");
    4.34 +    err = XenBus_Read(xpdd, XBT_NIL, "james", &value);
    4.35 +    if (err)
    4.36 +    {
    4.37 +      KdPrint((__DRIVER_NAME "     %08X: error on read - %s\n", thread_id, err));
    4.38 +      XenPci_FreeMem(err);
    4.39 +    }
    4.40 +    else
    4.41 +    {
    4.42 +      KdPrint((__DRIVER_NAME "     %08X: read %s\n", thread_id, value));
    4.43 +      XenPci_FreeMem(value);
    4.44 +    }
    4.45 +/*
    4.46 +    wait_time.QuadPart = 1000 * (-1 * 10 * 1000);
    4.47 +    KeDelayExecutionThread(KernelMode, FALSE, &wait_time);
    4.48 +*/
    4.49 +  }
    4.50 +}
    4.51 +
    4.52  static VOID
    4.53  XenPci_SysrqHandler(char *path, PVOID context)
    4.54  {
    4.55    PXENPCI_DEVICE_DATA xpdd = context;
    4.56 +  NTSTATUS status;
    4.57 +  HANDLE thread_handle;
    4.58    char *value;
    4.59    char letter;
    4.60    char *res;
    4.61 @@ -589,6 +636,9 @@ XenPci_SysrqHandler(char *path, PVOID co
    4.62    case 'B':
    4.63      KeBugCheckEx(('X' << 16)|('E' << 8)|('N'), 0x00000001, 0x00000000, 0x00000000, 0x00000000);
    4.64      break;
    4.65 +  case 'X':
    4.66 +    status = PsCreateSystemThread(&thread_handle, THREAD_ALL_ACCESS, NULL, NULL, NULL, XenBus_DummyXenbusThreadProc, xpdd);
    4.67 +    break;
    4.68    default:
    4.69      KdPrint(("     Unhandled sysrq letter %c\n", letter));
    4.70      break;
     5.1 --- a/xenpci/xenpci_pdo.c	Sat Jul 19 11:35:24 2008 +1000
     5.2 +++ b/xenpci/xenpci_pdo.c	Mon Jul 21 11:47:29 2008 +1000
     5.3 @@ -93,33 +93,49 @@ XenPci_Power_Pdo(PDEVICE_OBJECT device_o
     5.4  Called at PASSIVE_LEVEL(?)
     5.5  Called during restore
     5.6  */
     5.7 -static VOID
     5.8 -XenPci_BackEndStateHandler(char *Path, PVOID Context)
     5.9 +
    5.10 +static ULONG
    5.11 +XenPci_ReadBackendState(PXENPCI_PDO_DEVICE_DATA xppdd)
    5.12  {
    5.13 -  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)Context;
    5.14    PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    5.15 +  char path[128];
    5.16    char *value;
    5.17    char *err;
    5.18 +  ULONG backend_state;
    5.19 +  
    5.20 +  RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    5.21 +  err = XenBus_Read(xpdd, XBT_NIL, path, &value);
    5.22 +  if (err)
    5.23 +  {
    5.24 +    XenPci_FreeMem(err);
    5.25 +    return XenbusStateUnknown;
    5.26 +  }
    5.27 +  else
    5.28 +  {
    5.29 +    backend_state = atoi(value);
    5.30 +    XenPci_FreeMem(value);
    5.31 +    return backend_state;
    5.32 +  }
    5.33 +}
    5.34 +
    5.35 +static VOID
    5.36 +XenPci_BackEndStateHandler(char *path, PVOID context)
    5.37 +{
    5.38 +  PXENPCI_PDO_DEVICE_DATA xppdd = (PXENPCI_PDO_DEVICE_DATA)context;
    5.39 +  PXENPCI_DEVICE_DATA xpdd = xppdd->bus_fdo->DeviceExtension;
    5.40    ULONG new_backend_state;
    5.41 -  char path[128];
    5.42  
    5.43  //  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    5.44  
    5.45    /* check that path == device/id/state */
    5.46 -  RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->path);
    5.47 -  err = XenBus_Read(xpdd, XBT_NIL, Path, &value);
    5.48 -  if (err)
    5.49 +  //RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->path);
    5.50 +  new_backend_state = XenPci_ReadBackendState(xppdd);
    5.51 +  if (new_backend_state == XenbusStateUnknown)
    5.52    {
    5.53      if (xpdd->suspend_state != SUSPEND_STATE_NONE)
    5.54        return;
    5.55 -    KdPrint(("Failed to read %s, assuming closed\n", path, err));
    5.56 +    KdPrint(("Failed to read %s, assuming closed\n", path));
    5.57      new_backend_state = XenbusStateClosed;
    5.58 -    XenPci_FreeMem(err);
    5.59 -  }
    5.60 -  else
    5.61 -  {
    5.62 -    new_backend_state = atoi(value);
    5.63 -    XenPci_FreeMem(value);
    5.64    }
    5.65  
    5.66    if (xppdd->backend_state == new_backend_state)
    5.67 @@ -224,7 +240,8 @@ XenPci_ChangeFrontendState(PXENPCI_PDO_D
    5.68    XenBus_Printf(xpdd, XBT_NIL, path, "%d", frontend_state_set);
    5.69  
    5.70    remaining = maximum_wait_ms;
    5.71 -  while (xppdd->backend_state != backend_state_response)
    5.72 +  /* we can't rely on xppdd->backend_state here - events can occasionally be missed on startup or resume! */
    5.73 +  while (XenPci_ReadBackendState(xppdd) != backend_state_response)
    5.74    {
    5.75      thiswait = min((LONG)remaining, 1000); // 1 second or remaining time, whichever is less
    5.76      timeout.QuadPart = (LONGLONG)-1 * thiswait * 1000 * 10;
    5.77 @@ -668,7 +685,7 @@ XenPci_GetBackendAndAddWatch(PDEVICE_OBJ
    5.78    /* Add watch on backend state */
    5.79    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    5.80    XenBus_AddWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
    5.81 -
    5.82 +  
    5.83    return STATUS_SUCCESS;
    5.84  }
    5.85  
    5.86 @@ -755,7 +772,7 @@ XenPci_Pdo_Suspend(PDEVICE_OBJECT device
    5.87      while(xppdd->device_state.resume_state_ack != RESUME_STATE_SUSPENDING)
    5.88      {
    5.89        KdPrint((__DRIVER_NAME "     Starting delay - resume_state = %d, resume_state_ack = %d\n", xppdd->device_state.resume_state, xppdd->device_state.resume_state_ack));
    5.90 -      wait_time.QuadPart = 5000 * (-1 * 10 * 1000);
    5.91 +      wait_time.QuadPart = 100 * (-1 * 10 * 1000);
    5.92        KeDelayExecutionThread(KernelMode, FALSE, &wait_time);
    5.93        KdPrint((__DRIVER_NAME "     Done with delay\n"));
    5.94      }
    5.95 @@ -873,7 +890,7 @@ XenPci_QueryResourceRequirements(PDEVICE
    5.96    PIO_RESOURCE_REQUIREMENTS_LIST irrl;
    5.97    PIO_RESOURCE_DESCRIPTOR ird;
    5.98    ULONG length;
    5.99 -  ULONG available_interrupts[] = {2, 3, 4, 5, 7, 10, 11, 14, 15};
   5.100 +  ULONG available_interrupts[] = {3, 4, 5, 10, 11, 14};
   5.101    int i;
   5.102  
   5.103    UNREFERENCED_PARAMETER(device_object);
     6.1 --- a/xenvbd/scsiport.c	Sat Jul 19 11:35:24 2008 +1000
     6.2 +++ b/xenvbd/scsiport.c	Mon Jul 21 11:47:29 2008 +1000
     6.3 @@ -1122,12 +1122,12 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
     6.4    UNREFERENCED_PARAMETER(DeviceExtension);
     6.5    UNREFERENCED_PARAMETER(PathId);
     6.6  
     6.7 -  KdPrint((__DRIVER_NAME " --> HwScsiResetBus\n"));
     6.8 +//  KdPrint((__DRIVER_NAME " --> HwScsiResetBus\n"));
     6.9  
    6.10 -  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    6.11 +//  KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    6.12    ScsiPortNotification(NextRequest, DeviceExtension);
    6.13  
    6.14 -  KdPrint((__DRIVER_NAME " <-- HwScsiResetBus\n"));
    6.15 +//  KdPrint((__DRIVER_NAME " <-- HwScsiResetBus\n"));
    6.16  
    6.17  
    6.18    return TRUE;