win-pvdrivers

changeset 982:e9011a1ba5bb testing

started rewriting xenpci<->child interface
author James Harper <james.harper@bendigoit.com.au>
date Mon Aug 13 17:10:03 2012 +1000 (2012-08-13)
parents b96f14f62b50
children
files common/include/xen_windows.h dirs xenpci/xenpci.h xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c xenvbd/xenvbd_scsiport.c xenvbd/xenvbd_storport.c xenvbd/xenvbd_storport.h
line diff
     1.1 --- a/common/include/xen_windows.h	Sun Jun 17 14:57:35 2012 +1000
     1.2 +++ b/common/include/xen_windows.h	Mon Aug 13 17:10:03 2012 +1000
     1.3 @@ -305,6 +305,8 @@ XenPci_FreeMem(PVOID Ptr)
     1.4    ExFreePoolWithTag(Ptr, XENPCI_POOL_TAG);
     1.5  }
     1.6  
     1.7 +#if 0
     1.8 +
     1.9  #define XEN_DATA_MAGIC (ULONG)'XV02'
    1.10  
    1.11  typedef struct {
    1.12 @@ -688,5 +690,6 @@ typedef struct {
    1.13    PXEN_DMA_GET_ALIGNMENT get_alignment;
    1.14    ULONG max_sg_elements;
    1.15  } dma_driver_extension_t;
    1.16 +#endif
    1.17  
    1.18  #endif
     2.1 --- a/dirs	Sun Jun 17 14:57:35 2012 +1000
     2.2 +++ b/dirs	Mon Aug 13 17:10:03 2012 +1000
     2.3 @@ -1,2 +1,4 @@
     2.4 +#
     2.5 +DIRS=liblfds.6 xenpci xenvbd xennet xenscsi xenusb copyconfig shutdownmon waitnopendinginstallevents
     2.6  
     2.7 -DIRS=liblfds.6 xenpci xenvbd xennet xenscsi xenusb copyconfig shutdownmon waitnopendinginstallevents
     2.8 +DIRS=liblfds.6 xenpci xenvbd copyconfig shutdownmon waitnopendinginstallevents
     3.1 --- a/xenpci/xenpci.h	Sun Jun 17 14:57:35 2012 +1000
     3.2 +++ b/xenpci/xenpci.h	Mon Aug 13 17:10:03 2012 +1000
     3.3 @@ -185,7 +185,6 @@ typedef struct {
     3.4    ULONG grant_frames;
     3.5  
     3.6    ev_action_t ev_actions[NR_EVENTS];
     3.7 -//  unsigned long bound_ports[NR_EVENTS/(8*sizeof(unsigned long))];
     3.8  
     3.9    BOOLEAN xb_state;
    3.10    
    3.11 @@ -224,24 +223,19 @@ typedef struct {
    3.12    
    3.13    WDFQUEUE io_queue;
    3.14  
    3.15 -  //WDFCOLLECTION veto_devices;
    3.16    LIST_ENTRY veto_list;
    3.17  
    3.18 -#if 0
    3.19 -  KSPIN_LOCK mmio_freelist_lock;
    3.20 -  PPFN_NUMBER mmio_freelist_base;
    3.21 -  ULONG mmio_freelist_free;
    3.22 -#endif
    3.23 -
    3.24  } XENPCI_DEVICE_DATA, *PXENPCI_DEVICE_DATA;
    3.25  
    3.26  WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_DEVICE_DATA, GetXpdd)
    3.27  
    3.28 +#if 0
    3.29  typedef struct {
    3.30    UCHAR front_target;
    3.31    UCHAR back_expected;
    3.32    UCHAR wait; /* units = 100ms */
    3.33  } XENPCI_STATE_MAP_ELEMENT, *PXENPCI_STATE_MAP_ELEMENT;
    3.34 +#endif
    3.35  
    3.36  typedef struct {  
    3.37    WDFDEVICE wdf_device;
    3.38 @@ -255,8 +249,10 @@ typedef struct {
    3.39    KIRQL irq_level;
    3.40    char backend_path[128];
    3.41    domid_t backend_id;
    3.42 +  ULONG backend_state;
    3.43 +  BOOLEAN backend_initiated_remove;
    3.44 +#if 0
    3.45    KEVENT backend_state_event;
    3.46 -  ULONG backend_state;
    3.47    FAST_MUTEX backend_state_mutex;
    3.48    ULONG frontend_state;
    3.49    PMDL config_page_mdl;
    3.50 @@ -268,14 +264,14 @@ typedef struct {
    3.51    PUCHAR assigned_resources_ptr;
    3.52    XENPCI_DEVICE_STATE device_state;
    3.53    BOOLEAN restart_on_resume;
    3.54 -  BOOLEAN backend_initiated_remove;
    3.55 -  BOOLEAN do_not_enumerate;
    3.56    
    3.57    XENPCI_STATE_MAP_ELEMENT xb_pre_connect_map[5];
    3.58    XENPCI_STATE_MAP_ELEMENT xb_post_connect_map[5];
    3.59    XENPCI_STATE_MAP_ELEMENT xb_shutdown_map[5];
    3.60    
    3.61 +#endif
    3.62    BOOLEAN hiber_usage_kludge;
    3.63 +  BOOLEAN do_not_enumerate;
    3.64  } XENPCI_PDO_DEVICE_DATA, *PXENPCI_PDO_DEVICE_DATA;
    3.65  
    3.66  WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(XENPCI_PDO_DEVICE_DATA, GetXppdd)
     4.1 --- a/xenpci/xenpci_fdo.c	Sun Jun 17 14:57:35 2012 +1000
     4.2 +++ b/xenpci/xenpci_fdo.c	Mon Aug 13 17:10:03 2012 +1000
     4.3 @@ -554,7 +554,7 @@ XenPci_SuspendResume(WDFWORKITEM workite
     4.4      while ((status = WdfChildListRetrieveNextDevice(child_list, &child_iterator, &child_device, NULL)) == STATUS_SUCCESS)
     4.5      {
     4.6        KdPrint((__DRIVER_NAME "     Suspending child\n"));
     4.7 -      XenPci_Pdo_Suspend(child_device);
     4.8 +//      XenPci_Pdo_Suspend(child_device);
     4.9      }
    4.10      WdfChildListEndIteration(child_list, &child_iterator);
    4.11  
    4.12 @@ -571,7 +571,7 @@ XenPci_SuspendResume(WDFWORKITEM workite
    4.13      while ((status = WdfChildListRetrieveNextDevice(child_list, &child_iterator, &child_device, NULL)) == STATUS_SUCCESS)
    4.14      {
    4.15        KdPrint((__DRIVER_NAME "     Resuming child\n"));
    4.16 -      XenPci_Pdo_Resume(child_device);
    4.17 +//      XenPci_Pdo_Resume(child_device);
    4.18      }
    4.19      WdfChildListEndIteration(child_list, &child_iterator);
    4.20  
     5.1 --- a/xenpci/xenpci_pdo.c	Sun Jun 17 14:57:35 2012 +1000
     5.2 +++ b/xenpci/xenpci_pdo.c	Mon Aug 13 17:10:03 2012 +1000
     5.3 @@ -31,10 +31,11 @@ static EVT_WDF_DEVICE_D0_EXIT XenPciPdo_
     5.4  static EVT_WDF_DEVICE_PREPARE_HARDWARE XenPciPdo_EvtDevicePrepareHardware;
     5.5  static EVT_WDF_DEVICE_RELEASE_HARDWARE XenPciPdo_EvtDeviceReleaseHardware;
     5.6  static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenPciPdo_EvtDeviceUsageNotification;
     5.7 -static EVT_WDFDEVICE_WDM_IRP_PREPROCESS XenPciPdo_EvtDeviceWdmIrpPreprocess_START_DEVICE;
     5.8 +//static EVT_WDFDEVICE_WDM_IRP_PREPROCESS XenPciPdo_EvtDeviceWdmIrpPreprocess_START_DEVICE;
     5.9  static EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY XenPciPdo_EvtDeviceResourceRequirementsQuery;
    5.10  static EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION XenPci_EvtDevicePnpStateChange;
    5.11  
    5.12 +#if 0
    5.13  /*
    5.14  Called at PASSIVE_LEVEL(?)
    5.15  Called during restore
    5.16 @@ -482,11 +483,11 @@ XenPci_XenBus_RemWatch(PVOID context, xe
    5.17    return XenBus_RemWatch(xpdd, xbt, path, ServiceRoutine, ServiceContext);
    5.18  }
    5.19  
    5.20 +
    5.21  /*
    5.22  Called at PASSIVE_LEVEL
    5.23  Called during restore
    5.24  */
    5.25 -
    5.26  static NTSTATUS
    5.27  XenPci_ChangeFrontendState(WDFDEVICE device, ULONG frontend_state_set, ULONG backend_state_response, ULONG maximum_wait_ms)
    5.28  {
    5.29 @@ -573,7 +574,6 @@ XenPci_XenShutdownDevice(PVOID context)
    5.30    {
    5.31        XenPci_ChangeFrontendState(device, XenbusStateClosed, XenbusStateClosed, 30000);
    5.32    }
    5.33 -
    5.34    if (xppdd->assigned_resources_start != NULL)
    5.35    {
    5.36      ADD_XEN_INIT_RSP(&xppdd->assigned_resources_ptr, XEN_INIT_TYPE_END, NULL, NULL, NULL);
    5.37 @@ -1035,6 +1035,8 @@ XenPciPdo_EvtDeviceResourcesQuery(WDFDEV
    5.38  }
    5.39  #endif
    5.40  
    5.41 +#endif
    5.42 +
    5.43  static NTSTATUS
    5.44  XenPciPdo_EvtDeviceResourceRequirementsQuery(WDFDEVICE device, WDFIORESREQLIST requirements_list)
    5.45  {
    5.46 @@ -1116,6 +1118,7 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    5.47      break;  
    5.48    }
    5.49  
    5.50 +#if 0
    5.51    status = XenPci_GetBackendAndAddWatch(device);
    5.52    if (!NT_SUCCESS(status))
    5.53    {
    5.54 @@ -1123,7 +1126,6 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    5.55      FUNCTION_EXIT_STATUS(status);
    5.56      return status;
    5.57    }
    5.58 -
    5.59    if (previous_state == WdfPowerDeviceD3 || previous_state == WdfPowerDeviceD3Final)
    5.60    {
    5.61      xppdd->requested_resources_ptr = xppdd->requested_resources_start;
    5.62 @@ -1156,6 +1158,7 @@ XenPciPdo_EvtDeviceD0Entry(WDFDEVICE dev
    5.63      FUNCTION_EXIT_STATUS(status);
    5.64      return status;
    5.65    }
    5.66 +#endif
    5.67  
    5.68    FUNCTION_EXIT();
    5.69    
    5.70 @@ -1205,7 +1208,8 @@ XenPciPdo_EvtDeviceD0Exit(WDFDEVICE devi
    5.71      KdPrint((__DRIVER_NAME "     Unknown WdfPowerDevice state %d\n", target_state));
    5.72      break;  
    5.73    }
    5.74 -  
    5.75 +
    5.76 +#if 0  
    5.77    if (target_state == WdfPowerDevicePrepareForHibernation)
    5.78    {
    5.79      KdPrint((__DRIVER_NAME "     not powering down as we are hibernating\n"));
    5.80 @@ -1215,10 +1219,10 @@ XenPciPdo_EvtDeviceD0Exit(WDFDEVICE devi
    5.81    {
    5.82      status = XenPci_XenShutdownDevice(device);
    5.83    }
    5.84 -  
    5.85    /* Remove watch on backend state */
    5.86    RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
    5.87    XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackendStateHandler, device);
    5.88 +#endif
    5.89    
    5.90    FUNCTION_EXIT();
    5.91    
    5.92 @@ -1341,13 +1345,14 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
    5.93  
    5.94    KdPrint((__DRIVER_NAME "     device = '%s', index = '%d', path = '%s'\n",
    5.95      identification->device, identification->index, identification->path));
    5.96 -  
    5.97 +
    5.98 +#if 0
    5.99    status = WdfDeviceInitAssignWdmIrpPreprocessCallback(child_init, XenPciPdo_EvtDeviceWdmIrpPreprocess_START_DEVICE,
   5.100      IRP_MJ_PNP, pnp_minor_functions, ARRAY_SIZE(pnp_minor_functions));
   5.101 -  if (!NT_SUCCESS(status))
   5.102 -  {
   5.103 +  if (!NT_SUCCESS(status)) {
   5.104      return status;
   5.105    }
   5.106 +#endif
   5.107    
   5.108    WDF_PDO_EVENT_CALLBACKS_INIT(&pdo_callbacks);
   5.109    //pdo_callbacks.EvtDeviceResourcesQuery = XenPciPdo_EvtDeviceResourcesQuery;
   5.110 @@ -1404,6 +1409,7 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   5.111    xppdd->wdf_device = child_device;
   5.112    xppdd->wdf_device_bus_fdo = WdfChildListGetDevice(child_list);
   5.113  
   5.114 +#if 0
   5.115    xppdd->config_page_mdl = AllocateUncachedPage();
   5.116  
   5.117    xppdd->device_state.magic = XEN_DEVICE_STATE_MAGIC;
   5.118 @@ -1411,6 +1417,7 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   5.119    xppdd->device_state.suspend_resume_state_pdo = SR_STATE_RUNNING;
   5.120    xppdd->device_state.suspend_resume_state_fdo = SR_STATE_RUNNING;
   5.121    xppdd->device_state.pdo_event_channel = xpdd->pdo_event_channel;
   5.122 +#endif
   5.123    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFilePaging, TRUE);
   5.124    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFileHibernation, TRUE);
   5.125    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFileDump, TRUE);
   5.126 @@ -1441,10 +1448,12 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   5.127    RtlStringCbCopyA(xppdd->path, ARRAY_SIZE(xppdd->path), identification->path);
   5.128    RtlStringCbCopyA(xppdd->device, ARRAY_SIZE(xppdd->device), identification->device);
   5.129    xppdd->index = identification->index;
   5.130 +#if 0
   5.131    KeInitializeEvent(&xppdd->backend_state_event, SynchronizationEvent, FALSE);
   5.132    ExInitializeFastMutex(&xppdd->backend_state_mutex);
   5.133    xppdd->backend_state = XenbusStateUnknown;
   5.134 -  xppdd->frontend_state = XenbusStateUnknown;
   5.135 +#endif
   5.136 +  //xppdd->frontend_state = XenbusStateUnknown;
   5.137    xppdd->backend_path[0] = '\0';
   5.138    xppdd->backend_id = 0;
   5.139      
   5.140 @@ -1453,6 +1462,7 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
   5.141    return status;
   5.142  }
   5.143  
   5.144 +#if 0
   5.145  static __forceinline VOID
   5.146  XenPci_Pdo_ChangeSuspendState(WDFDEVICE device, ULONG new_state)
   5.147  {
   5.148 @@ -1595,3 +1605,4 @@ XenPci_Pdo_Resume(WDFDEVICE device)
   5.149  
   5.150    return STATUS_SUCCESS;
   5.151  }
   5.152 +#endif
   5.153 \ No newline at end of file
     6.1 --- a/xenvbd/xenvbd_scsiport.c	Sun Jun 17 14:57:35 2012 +1000
     6.2 +++ b/xenvbd/xenvbd_scsiport.c	Mon Aug 13 17:10:03 2012 +1000
     6.3 @@ -467,7 +467,6 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
     6.4        ptr = srb->DataBuffer;
     6.5        shadow->aligned_buffer_in_use = FALSE;
     6.6      }
     6.7 -
     6.8      //KdPrint((__DRIVER_NAME "     sector_number = %d, block_count = %d\n", (ULONG)shadow->req.sector_number, block_count));
     6.9      //KdPrint((__DRIVER_NAME "     SrbExtension = %p\n", srb->SrbExtension));
    6.10      //KdPrint((__DRIVER_NAME "     DataBuffer   = %p\n", srb->DataBuffer));
     7.1 --- a/xenvbd/xenvbd_storport.c	Sun Jun 17 14:57:35 2012 +1000
     7.2 +++ b/xenvbd/xenvbd_storport.c	Mon Aug 13 17:10:03 2012 +1000
     7.3 @@ -36,9 +36,9 @@ static BOOLEAN dump_mode = FALSE;
     7.4  #define DUMP_MODE_ERROR_LIMIT 64
     7.5  static ULONG dump_mode_errors = 0;
     7.6  
     7.7 -CHAR scsi_device_manufacturer[8];
     7.8 -CHAR scsi_disk_model[16];
     7.9 -CHAR scsi_cdrom_model[16];
    7.10 +#define scsi_device_manufacturer "XEN     "
    7.11 +#define scsi_disk_model  "PV DISK         "
    7.12 +#define scsi_cdrom_model "PV CDROM        "
    7.13  
    7.14  ULONGLONG parse_numeric_string(PCHAR string)
    7.15  {
    7.16 @@ -74,41 +74,7 @@ put_shadow_on_freelist(PXENVBD_DEVICE_DA
    7.17    xvdd->shadow_free++;
    7.18  }
    7.19  
    7.20 -static blkif_response_t *
    7.21 -XenVbd_GetResponse(PXENVBD_DEVICE_DATA xvdd, int i)
    7.22 -{
    7.23 -  blkif_other_response_t *rep;
    7.24 -  if (!xvdd->use_other)
    7.25 -    return RING_GET_RESPONSE(&xvdd->ring, i);
    7.26 -  rep = RING_GET_RESPONSE(&xvdd->other_ring, i);
    7.27 -  xvdd->tmp_rep.id = rep->id;
    7.28 -  xvdd->tmp_rep.operation = rep->operation;
    7.29 -  xvdd->tmp_rep.status = rep->status;
    7.30 -  return &xvdd->tmp_rep;
    7.31 -}
    7.32 -
    7.33 -static VOID
    7.34 -XenVbd_PutRequest(PXENVBD_DEVICE_DATA xvdd, blkif_request_t *req)
    7.35 -{
    7.36 -  blkif_other_request_t *other_req;
    7.37 -
    7.38 -  if (!xvdd->use_other)
    7.39 -  {
    7.40 -    *RING_GET_REQUEST(&xvdd->ring, xvdd->ring.req_prod_pvt) = *req;
    7.41 -  }
    7.42 -  else
    7.43 -  {  
    7.44 -    other_req = RING_GET_REQUEST(&xvdd->other_ring, xvdd->ring.req_prod_pvt);
    7.45 -    other_req->operation = req->operation;
    7.46 -    other_req->nr_segments = req->nr_segments;
    7.47 -    other_req->handle = req->handle;
    7.48 -    other_req->id = req->id;
    7.49 -    other_req->sector_number = req->sector_number;
    7.50 -    memcpy(other_req->seg, req->seg, sizeof(struct blkif_request_segment) * req->nr_segments);
    7.51 -  }
    7.52 -  xvdd->ring.req_prod_pvt++;
    7.53 -}
    7.54 -
    7.55 +#if 0
    7.56  static ULONG
    7.57  XenVbd_InitConfig(PXENVBD_DEVICE_DATA xvdd)
    7.58  {
    7.59 @@ -187,6 +153,7 @@ XenVbd_InitConfig(PXENVBD_DEVICE_DATA xv
    7.60    FUNCTION_EXIT();
    7.61    return SP_RETURN_FOUND;
    7.62  }
    7.63 +#endif
    7.64  
    7.65  static ULONG
    7.66  XenVbd_InitFromConfig(PXENVBD_DEVICE_DATA xvdd)
    7.67 @@ -200,6 +167,28 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
    7.68    ULONG qemu_hide_flags_value = 0;
    7.69  
    7.70    FUNCTION_ENTER();
    7.71 +
    7.72 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RING, "ring-ref", NULL, NULL);
    7.73 +  #pragma warning(suppress:4054)
    7.74 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_EVENT_CHANNEL_DPC, "event-channel", (PVOID)XenVbd_HandleEvent, xvdd);
    7.75 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_READ_STRING_FRONT, "device-type", NULL, NULL);
    7.76 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_READ_STRING_BACK, "mode", NULL, NULL);
    7.77 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_READ_STRING_BACK, "sectors", NULL, NULL);
    7.78 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_READ_STRING_BACK, "sector-size", NULL, NULL);
    7.79 +  
    7.80 +  // allocate page(s?) of memory
    7.81 +  // grant page
    7.82 +  // write to backend as ring-ref
    7.83 +  // allocate event channel
    7.84 +  // write to backend as event-channel
    7.85 +  // write protocol = "x86_64-abi"
    7.86 +  // set watch on backend state
    7.87 +  // change state to 2
    7.88 +  // wait for backend state change
    7.89 +  // read device-type
    7.90 +  // read mode
    7.91 +  // read sectors
    7.92 +  // read sector-size
    7.93    
    7.94    xvdd->device_type = XENVBD_DEVICETYPE_UNKNOWN;
    7.95    xvdd->sring = NULL;
    7.96 @@ -245,12 +234,7 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
    7.97        {
    7.98          /* cheat here - save the state of the ring in the topmost bits of the event-channel */
    7.99          xvdd->event_channel_ptr = (ULONG *)(((PCHAR)ptr) - sizeof(ULONG));
   7.100 -        xvdd->event_channel = PtrToUlong(value) & 0x3FFFFFFF;
   7.101 -        if (PtrToUlong(value) & 0x80000000)
   7.102 -        {
   7.103 -          xvdd->cached_use_other = (BOOLEAN)!!(PtrToUlong(value) & 0x40000000);
   7.104 -          KdPrint((__DRIVER_NAME "     cached_use_other = %d\n", xvdd->cached_use_other));
   7.105 -        }
   7.106 +        xvdd->event_channel = PtrToUlong(value);
   7.107        }
   7.108        break;
   7.109      case XEN_INIT_TYPE_READ_STRING_BACK:
   7.110 @@ -656,7 +640,7 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
   7.111        InsertHeadList(&xvdd->srb_list, (PLIST_ENTRY)srb_entry);
   7.112      }
   7.113  
   7.114 -    XenVbd_PutRequest(xvdd, &shadow->req);
   7.115 +    *RING_GET_REQUEST(&xvdd->ring, xvdd->ring.req_prod_pvt) = shadow->req;
   7.116    }
   7.117    RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&xvdd->ring, notify);
   7.118    if (notify)
   7.119 @@ -668,6 +652,7 @@ XenVbd_PutQueuedSrbsOnRing(PXENVBD_DEVIC
   7.120    //if (dump_mode) FUNCTION_EXIT();
   7.121  }
   7.122  
   7.123 +/* called at PASSIVE_LEVEL except in dump mode */
   7.124  static ULONG
   7.125  XenVbd_VirtualHwStorFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PVOID LowerDevice, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
   7.126  {
   7.127 @@ -675,7 +660,6 @@ XenVbd_VirtualHwStorFindAdapter(PVOID De
   7.128    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
   7.129    ULONG status;
   7.130  //  PXENPCI_XEN_DEVICE_DATA XenDeviceData;
   7.131 -  PACCESS_RANGE access_range;
   7.132  
   7.133    UNREFERENCED_PARAMETER(HwContext);
   7.134    UNREFERENCED_PARAMETER(BusInformation);
   7.135 @@ -689,9 +673,6 @@ XenVbd_VirtualHwStorFindAdapter(PVOID De
   7.136    RtlZeroMemory(xvdd, sizeof(XENVBD_DEVICE_DATA));
   7.137    *Again = FALSE;
   7.138  
   7.139 -  KdPrint((__DRIVER_NAME "     BusInterruptLevel = %d\n", ConfigInfo->BusInterruptLevel));
   7.140 -  KdPrint((__DRIVER_NAME "     BusInterruptVector = %03x\n", ConfigInfo->BusInterruptVector));
   7.141 -
   7.142    if (!dump_mode)
   7.143    {
   7.144      KdPrint((__DRIVER_NAME "     NumberOfAccessRanges = %d\n", ConfigInfo->NumberOfAccessRanges));    
   7.145 @@ -699,40 +680,14 @@ XenVbd_VirtualHwStorFindAdapter(PVOID De
   7.146      {
   7.147        return SP_RETURN_BAD_CONFIG;
   7.148      }
   7.149 -
   7.150 -    access_range = &((*(ConfigInfo->AccessRanges))[0]);
   7.151 -    KdPrint((__DRIVER_NAME "     RangeStart = %08x, RangeLength = %08x\n",
   7.152 -      access_range->RangeStart.LowPart, access_range->RangeLength));
   7.153 -    xvdd->device_base = StorPortGetDeviceBase(
   7.154 -      DeviceExtension,
   7.155 -      PNPBus, //AdapterInterfaceType,
   7.156 -      ConfigInfo->SystemIoBusNumber,
   7.157 -      access_range->RangeStart,
   7.158 -      access_range->RangeLength,
   7.159 -      !access_range->RangeInMemory);
   7.160 -    if (!xvdd->device_base)
   7.161 -    {
   7.162 -      KdPrint((__DRIVER_NAME "     StorPortGetDeviceBase failed\n"));
   7.163 -      FUNCTION_EXIT(); 
   7.164 -      return SP_RETURN_BAD_CONFIG;
   7.165 -    }
   7.166 -    status = XenVbd_InitConfig(xvdd);
   7.167 -    if (status != SP_RETURN_FOUND)
   7.168 -    {
   7.169 -      /* set inactive here so StartIo is harmless - we still get called with a PNP remove (or similar) */
   7.170 -      xvdd->inactive = TRUE;
   7.171 -      FUNCTION_EXIT();
   7.172 -      return status;
   7.173 -    }
   7.174      xvdd->grant_tag = (ULONG)'VBD0';
   7.175    }
   7.176    else
   7.177    {
   7.178 -    xvdd->device_base = ConfigInfo->Reserved;
   7.179 +    // do something with the ConfigInfo->Reserved... it's the dump pointers xvdd->device_base = ConfigInfo->Reserved;
   7.180      xvdd->grant_tag = (ULONG)'DUMP';
   7.181    }
   7.182    
   7.183 -  xvdd->ring_detect_state = RING_DETECT_STATE_NOT_STARTED;
   7.184    status = XenVbd_InitFromConfig(xvdd);
   7.185    if (status != SP_RETURN_FOUND)
   7.186    {
   7.187 @@ -804,27 +759,6 @@ XenVbd_HwStorFindAdapter(PVOID DeviceExt
   7.188    return status;
   7.189  }
   7.190  
   7.191 -//do this in StartIo instead to prevent races with the driver initialisation
   7.192 -static VOID
   7.193 -XenVbd_StartRingDetection(PXENVBD_DEVICE_DATA xvdd)
   7.194 -{
   7.195 -  blkif_request_t *req;
   7.196 -  int notify;
   7.197 -
   7.198 -  xvdd->ring_detect_state = RING_DETECT_STATE_DETECT1;
   7.199 -  RtlZeroMemory(xvdd->sring->ring, PAGE_SIZE - FIELD_OFFSET(blkif_sring_t, ring));
   7.200 -  req = RING_GET_REQUEST(&xvdd->ring, xvdd->ring.req_prod_pvt);
   7.201 -  req->operation = 0xff;
   7.202 -  xvdd->ring.req_prod_pvt++;
   7.203 -  req = RING_GET_REQUEST(&xvdd->ring, xvdd->ring.req_prod_pvt);
   7.204 -  req->operation = 0xff;
   7.205 -  xvdd->ring.req_prod_pvt++;
   7.206 -
   7.207 -  RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&xvdd->ring, notify);
   7.208 -  if (notify)
   7.209 -    xvdd->vectors.EvtChn_Notify(xvdd->vectors.context, xvdd->event_channel);
   7.210 -}
   7.211 -
   7.212  static BOOLEAN
   7.213  XenVbd_HwStorInitialize(PVOID DeviceExtension)
   7.214  {
   7.215 @@ -834,17 +768,7 @@ XenVbd_HwStorInitialize(PVOID DeviceExte
   7.216    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   7.217    KdPrint((__DRIVER_NAME "     dump_mode = %d\n", dump_mode));
   7.218  
   7.219 -  if (!xvdd->inactive)
   7.220 -  {
   7.221 -    if (dump_mode)
   7.222 -    {
   7.223 -      if (xvdd->cached_use_other)
   7.224 -      {
   7.225 -        xvdd->ring.nr_ents = BLK_OTHER_RING_SIZE;
   7.226 -        xvdd->use_other = TRUE;
   7.227 -      }
   7.228 -      xvdd->ring_detect_state = RING_DETECT_STATE_COMPLETE;
   7.229 -    }
   7.230 +  if (!xvdd->inactive) {
   7.231      InitializeListHead(&xvdd->srb_list);
   7.232    }
   7.233    FUNCTION_EXIT();
   7.234 @@ -1085,7 +1009,6 @@ XenVbd_HandleEventSynchronised(PVOID Dev
   7.235        case SR_STATE_RUNNING:
   7.236          KdPrint((__DRIVER_NAME "     New pdo state %d\n", suspend_resume_state_pdo));
   7.237          xvdd->device_state->suspend_resume_state_fdo = suspend_resume_state_pdo;
   7.238 -        xvdd->ring_detect_state = RING_DETECT_STATE_NOT_STARTED; /* could be running on different hardware */
   7.239          xvdd->vectors.EvtChn_Notify(xvdd->vectors.context, xvdd->device_state->pdo_event_channel);
   7.240        default:
   7.241          KdPrint((__DRIVER_NAME "     New pdo state %d\n", suspend_resume_state_pdo));
   7.242 @@ -1107,108 +1030,70 @@ XenVbd_HandleEventSynchronised(PVOID Dev
   7.243      KeMemoryBarrier();
   7.244      for (i = xvdd->ring.rsp_cons; i != rp; i++)
   7.245      {
   7.246 -      rep = XenVbd_GetResponse(xvdd, i);
   7.247 -/*
   7.248 -* This code is to automatically detect if the backend is using the same
   7.249 -* bit width or a different bit width to us. Later versions of Xen do this
   7.250 -* via a xenstore value, but not all. That 0x0fffffff (notice
   7.251 -* that the msb is not actually set, so we don't have any problems with
   7.252 -* sign extending) is to signify the last entry on the right, which is
   7.253 -* different under 32 and 64 bits, and that is why we set it up there.
   7.254 -
   7.255 -* To do the detection, we put two initial entries on the ring, with an op
   7.256 -* of 0xff (which is invalid). The first entry is mostly okay, but the
   7.257 -* second will be grossly misaligned if the backend bit width is different,
   7.258 -* and we detect this and switch frontend structures.
   7.259 -*/
   7.260 -      switch (xvdd->ring_detect_state)
   7.261 +      rep = RING_GET_RESPONSE(&xvdd->ring, i);
   7.262 +      shadow = &xvdd->shadows[rep->id & SHADOW_ID_ID_MASK];
   7.263 +      if (shadow->reset)
   7.264        {
   7.265 -      case RING_DETECT_STATE_NOT_STARTED:
   7.266 -        KdPrint((__DRIVER_NAME "     premature IRQ\n"));
   7.267 -        break;
   7.268 -      case RING_DETECT_STATE_DETECT1:
   7.269 -        KdPrint((__DRIVER_NAME "     ring_detect_state = %d, index = %d, operation = %x, id = %lx, status = %d\n", xvdd->ring_detect_state, i, rep->operation, rep->id, rep->status));
   7.270 -        KdPrint((__DRIVER_NAME "     req_prod = %d, rsp_prod = %d, rsp_cons = %d\n", xvdd->sring->req_prod, xvdd->sring->rsp_prod, xvdd->ring.rsp_cons));
   7.271 -        xvdd->ring_detect_state = RING_DETECT_STATE_DETECT2;
   7.272 -        break;
   7.273 -      case RING_DETECT_STATE_DETECT2:
   7.274 -        KdPrint((__DRIVER_NAME "     ring_detect_state = %d, index = %d, operation = %x, id = %lx, status = %d\n", xvdd->ring_detect_state, i, rep->operation, rep->id, rep->status));
   7.275 -        KdPrint((__DRIVER_NAME "     req_prod = %d, rsp_prod = %d, rsp_cons = %d\n", xvdd->sring->req_prod, xvdd->sring->rsp_prod, xvdd->ring.rsp_cons));
   7.276 -        *xvdd->event_channel_ptr |= 0x80000000;
   7.277 -        if (rep->operation != 0xff)
   7.278 +        KdPrint((__DRIVER_NAME "     discarding reset shadow\n"));
   7.279 +        for (j = 0; j < shadow->req.nr_segments; j++)
   7.280          {
   7.281 -          KdPrint((__DRIVER_NAME "     switching to 'other' ring size\n"));
   7.282 -          xvdd->ring.nr_ents = BLK_OTHER_RING_SIZE;
   7.283 -          xvdd->use_other = TRUE;
   7.284 -          *xvdd->event_channel_ptr |= 0x40000000;
   7.285 +          xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
   7.286 +            shadow->req.seg[j].gref, FALSE, xvdd->grant_tag);
   7.287          }
   7.288 -        xvdd->ring_detect_state = RING_DETECT_STATE_COMPLETE;
   7.289 -        break;
   7.290 -      case RING_DETECT_STATE_COMPLETE:
   7.291 -        shadow = &xvdd->shadows[rep->id & SHADOW_ID_ID_MASK];
   7.292 -        if (shadow->reset)
   7.293 -        {
   7.294 -          KdPrint((__DRIVER_NAME "     discarding reset shadow\n"));
   7.295 -          for (j = 0; j < shadow->req.nr_segments; j++)
   7.296 -          {
   7.297 -            xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
   7.298 -              shadow->req.seg[j].gref, FALSE, xvdd->grant_tag);
   7.299 -          }
   7.300 -        }
   7.301 -        else if (dump_mode && !(rep->id & SHADOW_ID_DUMP_FLAG))
   7.302 -        {
   7.303 -          KdPrint((__DRIVER_NAME "     discarding stale (non-dump-mode) shadow\n"));
   7.304 -        }
   7.305 +      }
   7.306 +      else if (dump_mode && !(rep->id & SHADOW_ID_DUMP_FLAG))
   7.307 +      {
   7.308 +        KdPrint((__DRIVER_NAME "     discarding stale (non-dump-mode) shadow\n"));
   7.309 +      }
   7.310 +      else
   7.311 +      {
   7.312 +        srb = shadow->srb;
   7.313 +        ASSERT(srb);
   7.314 +        srb_entry = srb->SrbExtension;
   7.315 +        ASSERT(srb_entry);
   7.316 +        /* a few errors occur in dump mode because Xen refuses to allow us to map pages we are using for other stuff. Just ignore them */
   7.317 +        if (rep->status == BLKIF_RSP_OKAY || (dump_mode &&  dump_mode_errors++ < DUMP_MODE_ERROR_LIMIT))
   7.318 +          srb->SrbStatus = SRB_STATUS_SUCCESS;
   7.319          else
   7.320          {
   7.321 -          srb = shadow->srb;
   7.322 -          ASSERT(srb);
   7.323 -          srb_entry = srb->SrbExtension;
   7.324 -          ASSERT(srb_entry);
   7.325 -          /* a few errors occur in dump mode because Xen refuses to allow us to map pages we are using for other stuff. Just ignore them */
   7.326 -          if (rep->status == BLKIF_RSP_OKAY || (dump_mode &&  dump_mode_errors++ < DUMP_MODE_ERROR_LIMIT))
   7.327 -            srb->SrbStatus = SRB_STATUS_SUCCESS;
   7.328 +          KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
   7.329 +          if (decode_cdb_is_read(srb))
   7.330 +            KdPrint((__DRIVER_NAME "     Operation = Read\n"));
   7.331            else
   7.332 -          {
   7.333 -            KdPrint((__DRIVER_NAME "     Xen Operation returned error\n"));
   7.334 -            if (decode_cdb_is_read(srb))
   7.335 -              KdPrint((__DRIVER_NAME "     Operation = Read\n"));
   7.336 -            else
   7.337 -              KdPrint((__DRIVER_NAME "     Operation = Write\n"));
   7.338 -            srb_entry->error = TRUE;
   7.339 -          }
   7.340 -          if (shadow->aligned_buffer_in_use)
   7.341 +            KdPrint((__DRIVER_NAME "     Operation = Write\n"));
   7.342 +          srb_entry->error = TRUE;
   7.343 +        }
   7.344 +        if (shadow->aligned_buffer_in_use)
   7.345 +        {
   7.346 +          ASSERT(xvdd->aligned_buffer_in_use);
   7.347 +          xvdd->aligned_buffer_in_use = FALSE;
   7.348 +          if (srb->SrbStatus == SRB_STATUS_SUCCESS && decode_cdb_is_read(srb))
   7.349 +            memcpy((PUCHAR)shadow->system_address, xvdd->aligned_buffer, shadow->length);
   7.350 +        }
   7.351 +        for (j = 0; j < shadow->req.nr_segments; j++)
   7.352 +        {
   7.353 +          xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
   7.354 +            shadow->req.seg[j].gref, FALSE, xvdd->grant_tag);
   7.355 +        }
   7.356 +        srb_entry->outstanding_requests--;
   7.357 +        if (!srb_entry->outstanding_requests && srb_entry->offset == srb_entry->length)
   7.358 +        {
   7.359 +          if (srb_entry->error)
   7.360            {
   7.361 -            ASSERT(xvdd->aligned_buffer_in_use);
   7.362 -            xvdd->aligned_buffer_in_use = FALSE;
   7.363 -            if (srb->SrbStatus == SRB_STATUS_SUCCESS && decode_cdb_is_read(srb))
   7.364 -              memcpy((PUCHAR)shadow->system_address, xvdd->aligned_buffer, shadow->length);
   7.365 -          }
   7.366 -          for (j = 0; j < shadow->req.nr_segments; j++)
   7.367 -          {
   7.368 -            xvdd->vectors.GntTbl_EndAccess(xvdd->vectors.context,
   7.369 -              shadow->req.seg[j].gref, FALSE, xvdd->grant_tag);
   7.370 -          }
   7.371 -          srb_entry->outstanding_requests--;
   7.372 -          if (!srb_entry->outstanding_requests && srb_entry->offset == srb_entry->length)
   7.373 -          {
   7.374 -            if (srb_entry->error)
   7.375 -            {
   7.376 -              srb->SrbStatus = SRB_STATUS_ERROR;
   7.377 -              srb->ScsiStatus = 0x02;
   7.378 -              xvdd->last_sense_key = SCSI_SENSE_MEDIUM_ERROR;
   7.379 -              xvdd->last_additional_sense_code = SCSI_ADSENSE_NO_SENSE;
   7.380 -              XenVbd_MakeAutoSense(xvdd, srb);
   7.381 -            }        
   7.382 -            StorPortNotification(RequestComplete, xvdd, srb);
   7.383 -          }
   7.384 +            srb->SrbStatus = SRB_STATUS_ERROR;
   7.385 +            srb->ScsiStatus = 0x02;
   7.386 +            xvdd->last_sense_key = SCSI_SENSE_MEDIUM_ERROR;
   7.387 +            xvdd->last_additional_sense_code = SCSI_ADSENSE_NO_SENSE;
   7.388 +            XenVbd_MakeAutoSense(xvdd, srb);
   7.389 +          }        
   7.390 +          StorPortNotification(RequestComplete, xvdd, srb);
   7.391          }
   7.392 -        shadow->aligned_buffer_in_use = FALSE;
   7.393 -        shadow->srb = NULL;
   7.394 -        shadow->reset = FALSE;
   7.395 -        put_shadow_on_freelist(xvdd, shadow);
   7.396 -        break;
   7.397        }
   7.398 +      shadow->aligned_buffer_in_use = FALSE;
   7.399 +      shadow->srb = NULL;
   7.400 +      shadow->reset = FALSE;
   7.401 +      put_shadow_on_freelist(xvdd, shadow);
   7.402 +      break;
   7.403      }
   7.404  
   7.405      xvdd->ring.rsp_cons = i;
   7.406 @@ -1223,7 +1108,6 @@ XenVbd_HandleEventSynchronised(PVOID Dev
   7.407      }
   7.408    }
   7.409  
   7.410 -  //if (start_ring_detect_state == RING_DETECT_STATE_COMPLETE)
   7.411    XenVbd_PutQueuedSrbsOnRing(xvdd);
   7.412  
   7.413    if (suspend_resume_state_pdo == SR_STATE_SUSPENDING)
   7.414 @@ -1288,7 +1172,7 @@ XenVbd_HwStorResetBus(PVOID DeviceExtens
   7.415  
   7.416    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   7.417  
   7.418 -  if (xvdd->ring_detect_state == RING_DETECT_STATE_COMPLETE && xvdd->device_state->suspend_resume_state_pdo == SR_STATE_RUNNING)
   7.419 +  if (xvdd->device_state->suspend_resume_state_pdo == SR_STATE_RUNNING)
   7.420    {
   7.421      xvdd->aligned_buffer_in_use = FALSE;
   7.422      
   7.423 @@ -1375,21 +1259,6 @@ XenVbd_HwStorStartIo(PVOID DeviceExtensi
   7.424      return TRUE;
   7.425    }
   7.426  
   7.427 -  if (xvdd->ring_detect_state == RING_DETECT_STATE_NOT_STARTED)
   7.428 -  {
   7.429 -    XenVbd_StartRingDetection(DeviceExtension);
   7.430 -  }
   7.431 -
   7.432 -  // If we haven't enumerated all the devices yet then just defer the request
   7.433 -  if (xvdd->ring_detect_state < RING_DETECT_STATE_COMPLETE)
   7.434 -  {
   7.435 -    srb->SrbStatus = SRB_STATUS_BUSY;
   7.436 -    StorPortNotification(RequestComplete, DeviceExtension, srb);
   7.437 -    KdPrint((__DRIVER_NAME " --- HwStorStartIo (Still figuring out ring)\n"));
   7.438 -    StorPortReleaseSpinLock (DeviceExtension, &lock_handle);
   7.439 -    return TRUE;
   7.440 -  }
   7.441 -
   7.442    if (!dump_mode && xvdd->device_state->suspend_resume_state_pdo != SR_STATE_RUNNING)
   7.443    {
   7.444      //KdPrint((__DRIVER_NAME " --> HwStorStartIo (Suspending/Resuming)\n"));
   7.445 @@ -1942,8 +1811,7 @@ XenVbd_HwStorAdapterControl(PVOID Device
   7.446      break;
   7.447    case ScsiRestartAdapter:
   7.448      KdPrint((__DRIVER_NAME "     ScsiRestartAdapter\n"));
   7.449 -    if (xvdd->inactive)
   7.450 -    {
   7.451 +    if (xvdd->inactive) {
   7.452        KdPrint((__DRIVER_NAME "     inactive - nothing to do\n"));
   7.453        break;
   7.454      }
   7.455 @@ -1953,9 +1821,6 @@ XenVbd_HwStorAdapterControl(PVOID Device
   7.456        #pragma warning(suppress:28159)
   7.457        KeBugCheckEx(DATA_COHERENCY_EXCEPTION, 0, (ULONG_PTR)xvdd, 0, 0);
   7.458      }
   7.459 -    xvdd->ring_detect_state = RING_DETECT_STATE_NOT_STARTED;
   7.460 -    
   7.461 -    //XenVbd_StartRingDetection(xvdd);
   7.462      break;
   7.463    case ScsiSetBootConfig:
   7.464      KdPrint((__DRIVER_NAME "     ScsiSetBootConfig\n"));
   7.465 @@ -1977,78 +1842,18 @@ NTSTATUS
   7.466  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   7.467  {
   7.468    ULONG status;
   7.469 -  VIRTUAL_HW_INITIALIZATION_DATA VHwInitializationData;
   7.470 -  HW_INITIALIZATION_DATA HwInitializationData;
   7.471 -  OBJECT_ATTRIBUTES oa;
   7.472 -  HANDLE service_handle;
   7.473 -  UNICODE_STRING param_name;
   7.474 -  HANDLE param_handle;
   7.475 -  UNICODE_STRING value_name;
   7.476 -  CHAR buf[256];
   7.477 -  ULONG buf_len;
   7.478 -  PKEY_VALUE_PARTIAL_INFORMATION kpv;
   7.479    
   7.480    FUNCTION_ENTER();
   7.481    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
   7.482    KdPrint((__DRIVER_NAME "     DriverObject = %p, RegistryPath = %p\n", DriverObject, RegistryPath));
   7.483  
   7.484    /* RegistryPath == NULL when we are invoked as a crash dump driver */
   7.485 -  if (!RegistryPath)
   7.486 -  {
   7.487 +  if (!RegistryPath) {
   7.488      dump_mode = TRUE;
   7.489    }
   7.490    
   7.491 -  if (!dump_mode)
   7.492 -  {
   7.493 -    InitializeObjectAttributes(&oa, RegistryPath, OBJ_CASE_INSENSITIVE, NULL, NULL);
   7.494 -    status = ZwOpenKey(&service_handle, KEY_READ, &oa);
   7.495 -    if(!NT_SUCCESS(status))
   7.496 -    {
   7.497 -      KdPrint((__DRIVER_NAME "     ZwOpenKey(Service) returned %08x\n", status));
   7.498 -    }
   7.499 -    else
   7.500 -    {
   7.501 -      RtlInitUnicodeString(&param_name, L"Parameters");
   7.502 -      InitializeObjectAttributes(&oa, &param_name, OBJ_CASE_INSENSITIVE, service_handle, NULL);
   7.503 -      status = ZwOpenKey(&param_handle, KEY_READ, &oa);
   7.504 -      if(!NT_SUCCESS(status))
   7.505 -      {
   7.506 -        KdPrint((__DRIVER_NAME "     ZwOpenKey(Parameters) returned %08x\n", status));
   7.507 -      }
   7.508 -      else
   7.509 -      {
   7.510 -        kpv = (PKEY_VALUE_PARTIAL_INFORMATION)buf;
   7.511 -        RtlFillMemory(scsi_device_manufacturer, 8, ' ');
   7.512 -        RtlFillMemory(scsi_disk_model, 16, ' ');
   7.513 -        RtlFillMemory(scsi_cdrom_model, 16, ' ');
   7.514 -
   7.515 -        RtlInitUnicodeString(&value_name, L"Manufacturer");
   7.516 -        buf_len = 256;
   7.517 -        status = ZwQueryValueKey(param_handle, &value_name, KeyValuePartialInformation, buf, buf_len, &buf_len);
   7.518 -        if(NT_SUCCESS(status))
   7.519 -          wcstombs(scsi_device_manufacturer, (PWCHAR)kpv->Data, min(kpv->DataLength, 8));
   7.520 -        else
   7.521 -          RtlStringCbCopyA(scsi_device_manufacturer, 8, "XEN     ");
   7.522 -
   7.523 -        RtlInitUnicodeString(&value_name, L"Disk_Model");
   7.524 -        buf_len = 256;
   7.525 -        status = ZwQueryValueKey(param_handle, &value_name, KeyValuePartialInformation, buf, buf_len, &buf_len);
   7.526 -        if(NT_SUCCESS(status))
   7.527 -          wcstombs(scsi_disk_model, (PWCHAR)kpv->Data, min(kpv->DataLength, 16));
   7.528 -        else
   7.529 -          RtlStringCbCopyA(scsi_disk_model, 16, "PV DISK          ");
   7.530 -
   7.531 -        RtlInitUnicodeString(&value_name, L"CDROM_Model");
   7.532 -        buf_len = 256;
   7.533 -        status = ZwQueryValueKey(param_handle, &value_name, KeyValuePartialInformation, buf, buf_len, &buf_len);
   7.534 -        if(NT_SUCCESS(status))
   7.535 -          wcstombs(scsi_cdrom_model, (PWCHAR)kpv->Data, min(kpv->DataLength, 16));
   7.536 -        else
   7.537 -          RtlStringCbCopyA(scsi_cdrom_model, 16, "PV CDROM        ");
   7.538 -        ZwClose(param_handle);
   7.539 -      }
   7.540 -      ZwClose(service_handle);
   7.541 -    }  
   7.542 +  if (!dump_mode) {
   7.543 +    VIRTUAL_HW_INITIALIZATION_DATA VHwInitializationData;
   7.544      RtlZeroMemory(&VHwInitializationData, sizeof(VIRTUAL_HW_INITIALIZATION_DATA));
   7.545      VHwInitializationData.HwInitializationDataSize = sizeof(VIRTUAL_HW_INITIALIZATION_DATA);
   7.546      VHwInitializationData.AdapterInterfaceType = Internal; //PNPBus; /* maybe should be internal? */
   7.547 @@ -2069,9 +1874,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   7.548      VHwInitializationData.HwResetBus = XenVbd_HwStorResetBus;
   7.549      VHwInitializationData.HwAdapterControl = XenVbd_HwStorAdapterControl;
   7.550      status = StorPortInitialize(DriverObject, RegistryPath, (PHW_INITIALIZATION_DATA)&VHwInitializationData, NULL);
   7.551 -  }
   7.552 -  else
   7.553 -  {
   7.554 +  } else {
   7.555 +    HW_INITIALIZATION_DATA HwInitializationData;
   7.556      RtlZeroMemory(&HwInitializationData, sizeof(HW_INITIALIZATION_DATA));
   7.557      HwInitializationData.HwInitializationDataSize = sizeof(HW_INITIALIZATION_DATA);
   7.558      HwInitializationData.AdapterInterfaceType = Internal; //PNPBus; /* not Internal */
   7.559 @@ -2093,8 +1897,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   7.560      status = StorPortInitialize(DriverObject, RegistryPath, &HwInitializationData, NULL);
   7.561    }
   7.562    
   7.563 -  if(!NT_SUCCESS(status))
   7.564 -  {
   7.565 +  if(!NT_SUCCESS(status)) {
   7.566      KdPrint((__DRIVER_NAME " ScsiPortInitialize failed with status 0x%08x\n", status));
   7.567    }
   7.568  
     8.1 --- a/xenvbd/xenvbd_storport.h	Sun Jun 17 14:57:35 2012 +1000
     8.2 +++ b/xenvbd/xenvbd_storport.h	Mon Aug 13 17:10:03 2012 +1000
     8.3 @@ -47,31 +47,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     8.4  
     8.5  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
     8.6  #define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
     8.7 -#define BLK_OTHER_RING_SIZE __RING_SIZE((blkif_other_sring_t *)0, PAGE_SIZE)
     8.8 -
     8.9 -#if defined(__x86_64__)
    8.10 -#pragma pack(push, 4)
    8.11 -#endif
    8.12 -struct blkif_other_request {
    8.13 -  uint8_t operation;
    8.14 -  uint8_t nr_segments;
    8.15 -  blkif_vdev_t handle;
    8.16 -  uint64_t id;
    8.17 -  blkif_sector_t sector_number;
    8.18 -  struct blkif_request_segment seg[BLKIF_MAX_SEGMENTS_PER_REQUEST];
    8.19 -};
    8.20 -struct blkif_other_response {
    8.21 -  uint64_t id;
    8.22 -  uint8_t operation;
    8.23 -  int16_t status;
    8.24 -};
    8.25 -#if defined(__x86_64__)
    8.26 -#pragma pack(pop)
    8.27 -#endif
    8.28 -
    8.29 -typedef struct blkif_other_request blkif_other_request_t;
    8.30 -typedef struct blkif_other_response blkif_other_response_t;
    8.31 -DEFINE_RING_TYPES(blkif_other, struct blkif_other_request, struct blkif_other_response);
    8.32  
    8.33  typedef struct {
    8.34    LIST_ENTRY list_entry;
    8.35 @@ -90,7 +65,7 @@ typedef struct {
    8.36    ULONG length;
    8.37    BOOLEAN aligned_buffer_in_use;
    8.38    BOOLEAN reset;
    8.39 -  #if DBG && NTDDI_VERSION >= NTDDI_WINXP
    8.40 +  #if DBG
    8.41    LARGE_INTEGER ring_submit_time;
    8.42    #endif
    8.43  } blkif_shadow_t;
    8.44 @@ -99,7 +74,7 @@ typedef struct {
    8.45  #define SHADOW_ID_ID_MASK   0x03FF /* maximum of 1024 requests - currently use a maximum of 64 though */
    8.46  #define SHADOW_ID_DUMP_FLAG 0x8000 /* indicates the request was generated by dump mode */
    8.47  
    8.48 -#define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, min(BLK_RING_SIZE, BLK_OTHER_RING_SIZE))
    8.49 +#define SHADOW_ENTRIES min(MAX_SHADOW_ENTRIES, BLK_RING_SIZE)
    8.50  
    8.51  typedef enum {
    8.52    XENVBD_DEVICETYPE_UNKNOWN,
    8.53 @@ -114,11 +89,6 @@ typedef enum {
    8.54    XENVBD_DEVICEMODE_WRITE
    8.55  } XENVBD_DEVICEMODE;
    8.56  
    8.57 -#define RING_DETECT_STATE_NOT_STARTED  0
    8.58 -#define RING_DETECT_STATE_DETECT1      1
    8.59 -#define RING_DETECT_STATE_DETECT2      2
    8.60 -#define RING_DETECT_STATE_COMPLETE     3
    8.61 -
    8.62  /* if this is ever increased to more than 1 then we need a way of tracking it properly */
    8.63  #define DUMP_MODE_UNALIGNED_PAGES 1 /* only for unaligned buffer use */
    8.64  
    8.65 @@ -132,18 +102,10 @@ struct
    8.66    USHORT shadow_min_free;
    8.67    ULONG grant_tag;
    8.68  
    8.69 -  PUCHAR device_base;
    8.70 -
    8.71    blkif_sring_t *sring;
    8.72    evtchn_port_t event_channel;
    8.73    ULONG *event_channel_ptr;
    8.74 -  union {
    8.75 -    blkif_front_ring_t ring;
    8.76 -    blkif_other_front_ring_t other_ring;
    8.77 -  };
    8.78 -  int ring_detect_state;
    8.79 -  BOOLEAN use_other;
    8.80 -  BOOLEAN cached_use_other;
    8.81 +  blkif_front_ring_t ring;
    8.82    UCHAR last_sense_key;
    8.83    UCHAR last_additional_sense_code;
    8.84    blkif_response_t tmp_rep;