win-pvdrivers

changeset 488:1c56a1caed9f

new config method
author James Harper <james.harper@bendigoit.com.au>
date Mon Dec 08 23:33:07 2008 +1100 (2008-12-08)
parents 8a0a695cdd97
children 30592ca314b2
files xenscsi/xenscsi.c xenscsi/xenscsi.inx
line diff
     1.1 --- a/xenscsi/xenscsi.c	Mon Dec 08 23:32:55 2008 +1100
     1.2 +++ b/xenscsi/xenscsi.c	Mon Dec 08 23:33:07 2008 +1100
     1.3 @@ -80,6 +80,8 @@ XenScsi_HwScsiInterrupt(PVOID DeviceExte
     1.4    int more_to_do = TRUE;
     1.5    vscsiif_shadow_t *shadow;
     1.6  
     1.7 +  //FUNCTION_ENTER();
     1.8 +
     1.9    if (xsdd->pause_ack != xsdd->pause_req)
    1.10    {
    1.11      xsdd->pause_ack = xsdd->pause_req;
    1.12 @@ -92,8 +94,6 @@ XenScsi_HwScsiInterrupt(PVOID DeviceExte
    1.13    if (!dump_mode && !xsdd->vectors.EvtChn_AckEvent(xsdd->vectors.context, xsdd->event_channel))
    1.14      return FALSE;
    1.15    
    1.16 -  //FUNCTION_ENTER();
    1.17 -
    1.18    while (more_to_do)
    1.19    {
    1.20      rp = xsdd->ring.sring->rsp_prod;
    1.21 @@ -109,6 +109,10 @@ XenScsi_HwScsiInterrupt(PVOID DeviceExte
    1.22          KdPrint((__DRIVER_NAME "     sense before %02x: %02x\n", j, (ULONG)((PUCHAR)Srb->SenseInfoBuffer)[j]));
    1.23  */
    1.24        memset(Srb->SenseInfoBuffer, 0, Srb->SenseInfoBufferLength);
    1.25 +      if (rep->sense_len > 0 && Srb->SenseInfoBuffer != NULL)
    1.26 +      {
    1.27 +        memcpy(Srb->SenseInfoBuffer, rep->sense_buffer, min(Srb->SenseInfoBufferLength, rep->sense_len));
    1.28 +      }
    1.29        switch(rep->rslt)
    1.30        {
    1.31        case 0:
    1.32 @@ -126,7 +130,6 @@ XenScsi_HwScsiInterrupt(PVOID DeviceExte
    1.33          {
    1.34            KdPrint((__DRIVER_NAME "     Doing autosense\n"));
    1.35            Srb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
    1.36 -          memcpy(Srb->SenseInfoBuffer, rep->sense_buffer, min(Srb->SenseInfoBufferLength, rep->sense_len));
    1.37          }
    1.38        }
    1.39  /*
    1.40 @@ -421,7 +424,7 @@ XenScsi_HwScsiFindAdapter(PVOID DeviceEx
    1.41          FRONT_RING_INIT(&xsdd->ring, sring, PAGE_SIZE);
    1.42        }
    1.43        break;
    1.44 -    case XEN_INIT_TYPE_EVENT_CHANNEL: /* frontend event channel */
    1.45 +    //case XEN_INIT_TYPE_EVENT_CHANNEL: /* frontend event channel */
    1.46      case XEN_INIT_TYPE_EVENT_CHANNEL_IRQ: /* frontend event channel */
    1.47        KdPrint((__DRIVER_NAME "     XEN_INIT_TYPE_EVENT_CHANNEL - %s = %d\n", setting, PtrToUlong(value)));
    1.48        if (strcmp(setting, "event-channel") == 0)
    1.49 @@ -588,7 +591,10 @@ XenScsi_PutSrbOnRing(PXENSCSI_DEVICE_DAT
    1.50      physical_address = MmGetPhysicalAddress(ptr);
    1.51      pfn = (ULONG)(physical_address.QuadPart >> PAGE_SHIFT);
    1.52      shadow->req.seg[shadow->req.nr_segments].gref = get_grant_from_freelist(xsdd);
    1.53 -    ASSERT(shadow->req.seg[shadow->req.nr_segments].gref);
    1.54 +    if (shadow->req.seg[shadow->req.nr_segments].gref == 0x0FFFFFFF)
    1.55 +    {
    1.56 +      return; /* better than crashing... */
    1.57 +    }
    1.58      xsdd->vectors.GntTbl_GrantAccess(xsdd->vectors.context, 0, (ULONG)pfn, 0, shadow->req.seg[shadow->req.nr_segments].gref);
    1.59      shadow->req.seg[shadow->req.nr_segments].offset = (USHORT)(physical_address.LowPart & (PAGE_SIZE - 1));
    1.60      shadow->req.seg[shadow->req.nr_segments].length = (USHORT)min(PAGE_SIZE - (ULONG)shadow->req.seg[shadow->req.nr_segments].offset, remaining);
    1.61 @@ -600,7 +606,10 @@ XenScsi_PutSrbOnRing(PXENSCSI_DEVICE_DAT
    1.62    xsdd->ring.req_prod_pvt++;
    1.63    RING_PUSH_REQUESTS_AND_CHECK_NOTIFY(&xsdd->ring, notify);
    1.64    if (notify)
    1.65 +  {
    1.66 +    //KdPrint((__DRIVER_NAME "     Notifying %d\n", xsdd->event_channel));
    1.67      xsdd->vectors.EvtChn_Notify(xsdd->vectors.context, xsdd->event_channel);
    1.68 +  }
    1.69  
    1.70    //FUNCTION_EXIT();
    1.71  }
    1.72 @@ -738,11 +747,20 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.73  {
    1.74    ULONG Status;
    1.75    HW_INITIALIZATION_DATA HwInitializationData;
    1.76 +  PVOID driver_extension;
    1.77 +  PUCHAR ptr;
    1.78  
    1.79    FUNCTION_ENTER();
    1.80  
    1.81    KdPrint((__DRIVER_NAME "     IRQL = %d\n", KeGetCurrentIrql()));
    1.82  
    1.83 +  IoAllocateDriverObjectExtension(DriverObject, UlongToPtr(XEN_INIT_DRIVER_EXTENSION_MAGIC), PAGE_SIZE, &driver_extension);
    1.84 +  ptr = driver_extension;
    1.85 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RUN, NULL, NULL);
    1.86 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_RING, "ring-ref", NULL);
    1.87 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_EVENT_CHANNEL_IRQ, "event-channel", NULL);
    1.88 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_GRANT_ENTRIES, NULL, UlongToPtr(144));
    1.89 +  ADD_XEN_INIT_REQ(&ptr, XEN_INIT_TYPE_END, NULL, NULL);       
    1.90    /* RegistryPath == NULL when we are invoked as a crash dump driver */
    1.91    if (!RegistryPath)
    1.92    {
     2.1 --- a/xenscsi/xenscsi.inx	Mon Dec 08 23:32:55 2008 +1100
     2.2 +++ b/xenscsi/xenscsi.inx	Mon Dec 08 23:33:07 2008 +1100
     2.3 @@ -26,11 +26,9 @@ CopyFiles=XenScsi.CopyFiles
     2.4  
     2.5  [XenScsi.CopyFiles]
     2.6  xenscsi.sys
     2.7 -xenconfig.sys
     2.8  
     2.9  [XenScsi_Inst.NT.Services]
    2.10  AddService=XenScsi,2,XenScsi_Service, XenScsi_EventLog
    2.11 -AddService=XenConfig,0,XenConfig_Service
    2.12  
    2.13  [XenScsi_Service]
    2.14  DisplayName    = %XenScsi.SVCDESC%                            
    2.15 @@ -39,7 +37,7 @@ StartType      = 0
    2.16  ErrorControl   = 1
    2.17  LoadOrderGroup = System Bus Extender
    2.18  ServiceBinary  = %12%\xenscsi.sys                            
    2.19 -AddReg = XenScsi_Service_AddReg,XenScsi_XenConfig_AddReg
    2.20 +AddReg = XenScsi_Service_AddReg
    2.21  
    2.22  [XenScsi_Service_AddReg]
    2.23  HKR,"Parameters\PnpInterface", "0", 0x00010001, 0x00000001
    2.24 @@ -51,34 +49,8 @@ AddReg = XenScsi_EventLog_AddReg
    2.25  HKR,,EventMessageFile,0x00020000,"%SystemRoot%\System32\IoLogMsg.dll;%SystemRoot%\System32\drivers\XenScsi.sys"
    2.26  HKR,,TypesSupported,0x00010001,7
    2.27  
    2.28 -[XenScsi_Inst.NT.HW]
    2.29 -AddReg = XenScsi_XenConfig_AddReg, XenScsi_UpperFilter_AddReg
    2.30 -
    2.31 -[XenScsi_XenConfig_AddReg]
    2.32 -HKR,"XenConfig\ring-ref", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_RING%
    2.33 -HKR,"XenConfig\event-channel", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_EVENT_CHANNEL_IRQ%
    2.34 -HKR,"XenConfig\grants", "type", %FLG_ADDREG_TYPE_DWORD%, %XEN_INIT_TYPE_GRANT_ENTRIES%
    2.35 -HKR,"XenConfig\grants", "value", %FLG_ADDREG_TYPE_DWORD%, 144
    2.36 -
    2.37 -[XenScsi_UpperFilter_AddReg]
    2.38 -HKR,,UpperFilters,0x10000,XenConfig
    2.39 -
    2.40 -[XenConfig_Service]
    2.41 -DisplayName    = %XenConfig.SVCDESC%                            
    2.42 -ServiceType    = 1
    2.43 -StartType      = 0
    2.44 -ErrorControl   = 1
    2.45 -LoadOrderGroup = System Bus Extender
    2.46 -ServiceBinary  = %12%\xenconfig.sys                            
    2.47 -AddReg = XenConfig_Service_AddReg
    2.48 -
    2.49 -[XenConfig_Service_AddReg]
    2.50 -HKR,"Parameters\PnpInterface", "0", %FLG_ADDREG_TYPE_DWORD%, 1
    2.51 -HKR,"Parameters", "BusType", %FLG_ADDREG_TYPE_DWORD%, 1
    2.52 -
    2.53  [SourceDisksFiles]
    2.54  xenscsi.sys=1
    2.55 -xenconfig.sys=1
    2.56  
    2.57  [SourceDisksNames.x86]
    2.58  1 = %DISK_NAME%,,,.\i386
    2.59 @@ -90,16 +62,5 @@ 1 = %DISK_NAME%,,,.\amd64
    2.60  XenGplPv = "Xen GPL PV Driver Developers"
    2.61  XenScsi.SVCDESC = "Xen SCSI Driver"
    2.62  XenScsi.DRVDESC = "Xen SCSI Driver"
    2.63 -XenConfig.SVCDESC = "Xen Config Resource Generator"
    2.64  DISK_NAME = "Xen SCSI Device Driver Install Disk"
    2.65  FLG_ADDREG_TYPE_DWORD = 0x00010001
    2.66 -XEN_INIT_TYPE_END = 0
    2.67 -XEN_INIT_TYPE_WRITE_STRING = 1
    2.68 -XEN_INIT_TYPE_RING = 2
    2.69 -XEN_INIT_TYPE_EVENT_CHANNEL = 3
    2.70 -XEN_INIT_TYPE_EVENT_CHANNEL_IRQ = 4
    2.71 -XEN_INIT_TYPE_READ_STRING_FRONT = 5
    2.72 -XEN_INIT_TYPE_READ_STRING_BACK = 6
    2.73 -XEN_INIT_TYPE_VECTORS = 7
    2.74 -XEN_INIT_TYPE_GRANT_ENTRIES = 8
    2.75 -XEN_INIT_TYPE_COPY_PTR = 9