win-pvdrivers

changeset 561:d56ecda9e61f

Interrupt delivery updates.
SG updates
Removed XenHide and made XenPci also function as a filter device
author James Harper <james.harper@bendigoit.com.au>
date Sun May 10 20:17:05 2009 +1000 (2009-05-10)
parents 369502736dfd
children 8ab116a713f4
files xenpci/evtchn.c xenpci/xenpci.c xenpci/xenpci.h xenpci/xenpci.inx xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/evtchn.c	Sun Apr 12 19:15:28 2009 +1000
     1.2 +++ b/xenpci/evtchn.c	Sun May 10 20:17:05 2009 +1000
     1.3 @@ -57,18 +57,27 @@ EvtChn_DpcBounce(PRKDPC Dpc, PVOID Conte
     1.4  
     1.5  /* Called at DIRQL */
     1.6  BOOLEAN
     1.7 -EvtChn_AckEvent(PVOID context, evtchn_port_t port)
     1.8 +EvtChn_AckEvent(PVOID context, evtchn_port_t port, BOOLEAN *last_interrupt)
     1.9  {
    1.10    PXENPCI_DEVICE_DATA xpdd = context;
    1.11    ULONG evt_word;
    1.12    ULONG evt_bit;
    1.13    xen_ulong_t val;
    1.14 +  int i;
    1.15    
    1.16    evt_bit = port & (BITS_PER_LONG - 1);
    1.17    evt_word = port >> BITS_PER_LONG_SHIFT;
    1.18  
    1.19    val = synch_clear_bit(evt_bit, (volatile xen_long_t *)&xpdd->evtchn_pending_pvt[evt_word]);
    1.20 -  //KdPrint((__DRIVER_NAME "     EvtChn_AckEvent work[0] = %08x, port %d = %d\n", xpdd->evtchn_pending_pvt[0], port, val));
    1.21 +  *last_interrupt = FALSE;
    1.22 +  for (i = 0; i < sizeof(xen_ulong_t) * 8; i++)
    1.23 +  {
    1.24 +    if (xpdd->evtchn_pending_pvt[i])
    1.25 +    {
    1.26 +      *last_interrupt = TRUE;
    1.27 +      break;
    1.28 +    }
    1.29 +  }
    1.30    
    1.31    return (BOOLEAN)!!val;
    1.32  }
     2.1 --- a/xenpci/xenpci.c	Sun Apr 12 19:15:28 2009 +1000
     2.2 +++ b/xenpci/xenpci.c	Sun May 10 20:17:05 2009 +1000
     2.3 @@ -54,7 +54,7 @@ XenPci_EvtDeviceUsageNotification(WDFDEV
     2.4  }
     2.5  
     2.6  static NTSTATUS
     2.7 -XenPci_EvtDeviceAdd(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
     2.8 +XenPci_EvtDeviceAdd_XenPci(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
     2.9  {
    2.10    NTSTATUS status;
    2.11  //  PDEVICE_OBJECT fdo = NULL;
    2.12 @@ -79,7 +79,7 @@ XenPci_EvtDeviceAdd(WDFDRIVER driver, PW
    2.13    UNREFERENCED_PARAMETER(driver);
    2.14  
    2.15    FUNCTION_ENTER();
    2.16 -  
    2.17 +
    2.18    WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnp_power_callbacks);
    2.19    pnp_power_callbacks.EvtDeviceD0Entry = XenPci_EvtDeviceD0Entry;
    2.20    pnp_power_callbacks.EvtDeviceD0EntryPostInterruptsEnabled = XenPci_EvtDeviceD0EntryPostInterruptsEnabled;
    2.21 @@ -187,8 +187,207 @@ XenPci_EvtDeviceAdd(WDFDRIVER driver, PW
    2.22    return status;
    2.23  }
    2.24  
    2.25 +NTSTATUS
    2.26 +XenHide_EvtDevicePrepareHardware (WDFDEVICE device, WDFCMRESLIST resources_raw, WDFCMRESLIST resources_translated)
    2.27 +{
    2.28 +  UNREFERENCED_PARAMETER(device);
    2.29 +  UNREFERENCED_PARAMETER(resources_raw);
    2.30 +  UNREFERENCED_PARAMETER(resources_translated);
    2.31 +  FUNCTION_ENTER();
    2.32 +  FUNCTION_EXIT();
    2.33 +  return STATUS_UNSUCCESSFUL;
    2.34 +}
    2.35 +
    2.36 +static BOOLEAN
    2.37 +XenPci_IdSuffixMatches(PWDFDEVICE_INIT device_init, PWCHAR matching_id)
    2.38 +{
    2.39 +  NTSTATUS status;
    2.40 +  WDFMEMORY memory;
    2.41 +  ULONG remaining;
    2.42 +  size_t string_length;
    2.43 +  PWCHAR ids;
    2.44 +  PWCHAR ptr;
    2.45 +  size_t ids_length;
    2.46 +  ULONG properties[] = {DevicePropertyCompatibleIDs, DevicePropertyHardwareID};
    2.47 +  int i;
    2.48 +  
    2.49 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    2.50 +  for (i = 0; i < ARRAY_SIZE(properties); i++)
    2.51 +  {
    2.52 +
    2.53 +    status = WdfFdoInitAllocAndQueryProperty(device_init, properties[i], NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, &memory);
    2.54 +    if (!NT_SUCCESS(status))
    2.55 +      continue;
    2.56 +    ids = WdfMemoryGetBuffer(memory, &ids_length);
    2.57 +
    2.58 +    if (!NT_SUCCESS(status))
    2.59 +    {
    2.60 +//      KdPrint((__DRIVER_NAME "     i = %d, status = %x, ids_length = %d\n", i, status, ids_length));
    2.61 +      continue;
    2.62 +    }
    2.63 +    
    2.64 +    remaining = (ULONG)ids_length / 2;
    2.65 +    for (ptr = ids; *ptr != 0; ptr += string_length + 1)
    2.66 +    {
    2.67 +      RtlStringCchLengthW(ptr, remaining, &string_length);
    2.68 +      remaining -= (ULONG)string_length + 1;
    2.69 +      if (string_length >= wcslen(matching_id))
    2.70 +      {
    2.71 +        ptr += string_length - wcslen(matching_id);
    2.72 +        string_length = wcslen(matching_id);
    2.73 +      }
    2.74 +//      KdPrint((__DRIVER_NAME "     Comparing '%S' and '%S'\n", ptr, matching_id));
    2.75 +      if (wcscmp(ptr, matching_id) == 0)
    2.76 +      {
    2.77 +        //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (Match)\n"));
    2.78 +        WdfObjectDelete(memory);
    2.79 +        return TRUE;
    2.80 +      }
    2.81 +    }
    2.82 +    WdfObjectDelete(memory);
    2.83 +  }
    2.84 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (No match)\n"));
    2.85 +  return FALSE;
    2.86 +}
    2.87 +
    2.88  ULONG qemu_filtered;
    2.89  ULONG qemu_filtered_by_qemu;
    2.90 +
    2.91 +static NTSTATUS
    2.92 +XenPci_EvtDeviceAdd_XenHide(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
    2.93 +{
    2.94 +  NTSTATUS status;
    2.95 +  WDFMEMORY memory;
    2.96 +  PWCHAR device_description;
    2.97 +  WDF_PNPPOWER_EVENT_CALLBACKS pnp_power_callbacks;
    2.98 +  WDF_OBJECT_ATTRIBUTES device_attributes;
    2.99 +  BOOLEAN hide_required = FALSE;
   2.100 +  WDFDEVICE device;
   2.101 +  WDFKEY param_key;
   2.102 +  DECLARE_CONST_UNICODE_STRING(hide_devices_name, L"hide_devices");
   2.103 +  WDFCOLLECTION hide_devices;
   2.104 +  ULONG i;
   2.105 +  
   2.106 +  UNREFERENCED_PARAMETER(driver);
   2.107 +
   2.108 +  FUNCTION_ENTER();
   2.109 +
   2.110 +  WdfCollectionCreate(WDF_NO_OBJECT_ATTRIBUTES, &hide_devices);
   2.111 +  status = WdfDriverOpenParametersRegistryKey(driver, KEY_QUERY_VALUE, WDF_NO_OBJECT_ATTRIBUTES, &param_key);
   2.112 +  if (NT_SUCCESS(status))
   2.113 +  {
   2.114 +    status = WdfRegistryQueryMultiString(param_key, &hide_devices_name, WDF_NO_OBJECT_ATTRIBUTES, hide_devices);
   2.115 +    if (!NT_SUCCESS(status))
   2.116 +    {
   2.117 +      KdPrint(("Error reading parameters/hide_devices value %08x\n", status));
   2.118 +    }
   2.119 +    WdfRegistryClose(param_key);
   2.120 +  }
   2.121 +  else
   2.122 +  {
   2.123 +    KdPrint(("Error opening parameters key %08x\n", status));
   2.124 +  }
   2.125 +  if (!WdfCollectionGetCount(hide_devices))
   2.126 +  {
   2.127 +    WDFSTRING wdf_string;
   2.128 +    UNICODE_STRING unicode_string;
   2.129 +    
   2.130 +    RtlInitUnicodeString(&unicode_string, L"VEN_8086&DEV_7010"); // Qemu IDE
   2.131 +    WdfStringCreate(&unicode_string, WDF_NO_OBJECT_ATTRIBUTES, &wdf_string);
   2.132 +    WdfCollectionAdd(hide_devices, wdf_string);
   2.133 +    RtlInitUnicodeString(&unicode_string, L"VEN_1000&DEV_0012"); // Qemu SCSI
   2.134 +    WdfStringCreate(&unicode_string, WDF_NO_OBJECT_ATTRIBUTES, &wdf_string);
   2.135 +    WdfCollectionAdd(hide_devices, wdf_string);
   2.136 +    RtlInitUnicodeString(&unicode_string, L"VEN_10EC&DEV_8139"); // Qemu Network
   2.137 +    WdfStringCreate(&unicode_string, WDF_NO_OBJECT_ATTRIBUTES, &wdf_string);
   2.138 +    WdfCollectionAdd(hide_devices, wdf_string);
   2.139 +  }
   2.140 +  status = WdfFdoInitAllocAndQueryProperty(device_init, DevicePropertyDeviceDescription, NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, &memory);
   2.141 +  if (NT_SUCCESS(status))
   2.142 +  {
   2.143 +    device_description = WdfMemoryGetBuffer(memory, NULL);
   2.144 +  }
   2.145 +  else
   2.146 +  {
   2.147 +    device_description = L"<unknown device>";
   2.148 +  }
   2.149 +
   2.150 +  for (i = 0; i < WdfCollectionGetCount(hide_devices); i++)
   2.151 +  {
   2.152 +    WDFSTRING wdf_string = WdfCollectionGetItem(hide_devices, i);
   2.153 +    UNICODE_STRING unicode_string;
   2.154 +    WdfStringGetUnicodeString(wdf_string, &unicode_string);
   2.155 +    if (XenPci_IdSuffixMatches(device_init, unicode_string.Buffer))
   2.156 +    {
   2.157 +      hide_required = TRUE;
   2.158 +      break;
   2.159 +    }
   2.160 +  }
   2.161 +#if 0
   2.162 +  /* hide only specific devices */
   2.163 +  if (XenPci_IdSuffixMatches(device_init, L"VEN_8086&DEV_7010")) // Qemu IDE
   2.164 +  {
   2.165 +    hide_required = TRUE;
   2.166 +  }
   2.167 +  else if (XenPci_IdSuffixMatches(device_init, L"VEN_1000&DEV_0012"))// Qemu SCSI
   2.168 +  {
   2.169 +    hide_required = TRUE;
   2.170 +  }
   2.171 +  else if (XenPci_IdSuffixMatches(device_init, L"VEN_10EC&DEV_8139")) // Qemu Network
   2.172 +  {
   2.173 +    hide_required = TRUE;
   2.174 +  }
   2.175 +#endif
   2.176 +  if (!hide_required)
   2.177 +  {
   2.178 +    WdfObjectDelete(memory);
   2.179 +    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (filter not required for %S)\n", device_description));
   2.180 +    return STATUS_SUCCESS;
   2.181 +  }
   2.182 +  
   2.183 +  KdPrint((__DRIVER_NAME "     Installing Filter for %S\n", device_description));
   2.184 +
   2.185 +  WdfFdoInitSetFilter(device_init);
   2.186 +  WdfDeviceInitSetDeviceType(device_init, FILE_DEVICE_UNKNOWN);
   2.187 +  WdfDeviceInitSetExclusive(device_init, FALSE);
   2.188 +
   2.189 +  WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnp_power_callbacks);
   2.190 +  pnp_power_callbacks.EvtDevicePrepareHardware = XenHide_EvtDevicePrepareHardware;
   2.191 +  WdfDeviceInitSetPnpPowerEventCallbacks(device_init, &pnp_power_callbacks);
   2.192 +  
   2.193 +  WDF_OBJECT_ATTRIBUTES_INIT(&device_attributes);
   2.194 +  status = WdfDeviceCreate(&device_init, &device_attributes, &device);
   2.195 +  if (!NT_SUCCESS(status))
   2.196 +  {
   2.197 +    KdPrint(("Error creating device %08x\n", status));
   2.198 +    WdfObjectDelete(memory);
   2.199 +    FUNCTION_EXIT();
   2.200 +    return status;
   2.201 +  }
   2.202 +
   2.203 +  WdfObjectDelete(memory);
   2.204 +  FUNCTION_EXIT();
   2.205 +
   2.206 +  return status;
   2.207 +}
   2.208 +
   2.209 +static NTSTATUS
   2.210 +XenPci_EvtDeviceAdd(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
   2.211 +{
   2.212 +  if (XenPci_IdSuffixMatches(device_init, L"VEN_5853&DEV_0001"))
   2.213 +  {
   2.214 +    KdPrint((__DRIVER_NAME "     Xen PCI device found - must be fdo\n"));
   2.215 +    return XenPci_EvtDeviceAdd_XenPci(driver, device_init);
   2.216 +  }
   2.217 +  else if (qemu_filtered && !qemu_filtered_by_qemu)
   2.218 +  {
   2.219 +    KdPrint((__DRIVER_NAME "     Xen PCI device not found - must be filter\n"));
   2.220 +    return XenPci_EvtDeviceAdd_XenHide(driver, device_init);  
   2.221 +  }
   2.222 +  else
   2.223 +    return STATUS_SUCCESS;
   2.224 +}
   2.225 +
   2.226  ULONG qemu_protocol_version;
   2.227  ULONG tpr_patch_requested;
   2.228  extern PULONG InitSafeBootMode;
   2.229 @@ -213,7 +412,6 @@ XenPci_HideQemuDevices()
   2.230        }
   2.231        /* fall through */
   2.232      case 0:
   2.233 -      qemu_filtered = TRUE;
   2.234        qemu_filtered_by_qemu = TRUE;
   2.235        WRITE_PORT_USHORT(XEN_IOPORT_DEVICE_MASK, QEMU_UNPLUG_ALL_IDE_DISKS|QEMU_UNPLUG_ALL_NICS);
   2.236        KdPrint((__DRIVER_NAME "     Disabled qemu devices\n"));
   2.237 @@ -226,7 +424,7 @@ XenPci_HideQemuDevices()
   2.238  }
   2.239  
   2.240  /*
   2.241 -make sure the load order is System Reserved, Dummy Group, WdfLoadGroup, Boot Bus Extender
   2.242 +make sure the load order is System Reserved, Dummy Group, WdfLoadGroup, XenPCI, Boot Bus Extender
   2.243  */
   2.244  
   2.245  static VOID
   2.246 @@ -240,9 +438,11 @@ XenPci_FixLoadOrder()
   2.247    ULONG i;
   2.248    LONG dummy_group_index = -1;
   2.249    LONG boot_bus_extender_index = -1;
   2.250 +  LONG xenpci_group_index = -1;
   2.251    LONG wdf_load_group_index = -1;
   2.252    DECLARE_CONST_UNICODE_STRING(dummy_group_name, L"Dummy Group");
   2.253    DECLARE_CONST_UNICODE_STRING(wdf_load_group_name, L"WdfLoadGroup");
   2.254 +  DECLARE_CONST_UNICODE_STRING(xenpci_group_name, L"XenPCI Group");
   2.255    DECLARE_CONST_UNICODE_STRING(boot_bus_extender_name, L"Boot Bus Extender");
   2.256  
   2.257    FUNCTION_ENTER();
   2.258 @@ -273,12 +473,15 @@ XenPci_FixLoadOrder()
   2.259        dummy_group_index = (ULONG)i;
   2.260      if (!RtlCompareUnicodeString(&val, &wdf_load_group_name, TRUE))
   2.261        wdf_load_group_index = (ULONG)i;         
   2.262 +    if (!RtlCompareUnicodeString(&val, &xenpci_group_name, TRUE))
   2.263 +      xenpci_group_index = (ULONG)i;         
   2.264      if (!RtlCompareUnicodeString(&val, &boot_bus_extender_name, TRUE))
   2.265        boot_bus_extender_index = (ULONG)i;         
   2.266      KdPrint((__DRIVER_NAME "       %wZ\n", &val));        
   2.267    }
   2.268    KdPrint((__DRIVER_NAME "     dummy_group_index = %d\n", dummy_group_index));
   2.269    KdPrint((__DRIVER_NAME "     wdf_load_group_index = %d\n", wdf_load_group_index));
   2.270 +  KdPrint((__DRIVER_NAME "     xenpci_group_index = %d\n", xenpci_group_index));
   2.271    KdPrint((__DRIVER_NAME "     boot_bus_extender_index = %d\n", boot_bus_extender_index));
   2.272    if (boot_bus_extender_index == -1)
   2.273    {
   2.274 @@ -287,7 +490,10 @@ XenPci_FixLoadOrder()
   2.275      WdfRegistryClose(sgo_key);
   2.276      return; /* something is very wrong */
   2.277    }
   2.278 -  if (dummy_group_index == 1 && (wdf_load_group_index == -1 || (wdf_load_group_index > dummy_group_index && wdf_load_group_index < boot_bus_extender_index)))
   2.279 +  if (dummy_group_index == 1 && (wdf_load_group_index == -1 || 
   2.280 +    (dummy_group_index < wdf_load_group_index
   2.281 +    && wdf_load_group_index < xenpci_group_index
   2.282 +    && xenpci_group_index < boot_bus_extender_index)))
   2.283    {
   2.284      return; /* our work here is done */
   2.285    }
   2.286 @@ -308,7 +514,14 @@ XenPci_FixLoadOrder()
   2.287        WdfCollectionAdd(new_load_order, tmp_wdf_string);
   2.288        WdfObjectDelete(tmp_wdf_string);
   2.289      }
   2.290 -    if (i == (ULONG)dummy_group_index || i == (ULONG)wdf_load_group_index)
   2.291 +    if (i == 1)
   2.292 +    {
   2.293 +      WDFSTRING tmp_wdf_string;
   2.294 +      WdfStringCreate(&xenpci_group_name, WDF_NO_OBJECT_ATTRIBUTES, &tmp_wdf_string);
   2.295 +      WdfCollectionAdd(new_load_order, tmp_wdf_string);
   2.296 +      WdfObjectDelete(tmp_wdf_string);
   2.297 +    }
   2.298 +    if (i == (ULONG)dummy_group_index || i == (ULONG)wdf_load_group_index || i == (ULONG)xenpci_group_index)
   2.299        continue;
   2.300      ws = WdfCollectionGetItem(old_load_order, i);
   2.301      WdfCollectionAdd(new_load_order, ws);
   2.302 @@ -391,27 +604,9 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   2.303        && !wcsstr(SystemStartOptions, L"NOGPLPV")
   2.304        && !*InitSafeBootMode)
   2.305    {
   2.306 +    qemu_filtered = TRUE;
   2.307      /* see if the qemu method of disabling the PCI devices exists */
   2.308      XenPci_HideQemuDevices();
   2.309 -    /* if not, tell the filter to deny the pci devices their resources */
   2.310 -    if (!qemu_filtered)
   2.311 -    {
   2.312 -      OBJECT_ATTRIBUTES oa;
   2.313 -      UNICODE_STRING dir_name;
   2.314 -      NTSTATUS status;
   2.315 -      HANDLE handle;
   2.316 -      
   2.317 -      KdPrint((__DRIVER_NAME "     Adding DirectoryObject\n"));
   2.318 -      RtlInitUnicodeString(&dir_name, L"\\NEED_GPLPV_FILTER");
   2.319 -      InitializeObjectAttributes(&oa, &dir_name, OBJ_KERNEL_HANDLE, NULL, NULL);
   2.320 -      status = ZwCreateDirectoryObject(&handle, DIRECTORY_CREATE_OBJECT, &oa);
   2.321 -      KdPrint((__DRIVER_NAME "     ZwCreateDirectoryObject = %08x\n", status));
   2.322 -      if (!NT_SUCCESS(status))
   2.323 -      {
   2.324 -        return status;
   2.325 -      }
   2.326 -      qemu_filtered = TRUE;
   2.327 -    }
   2.328    }
   2.329    
   2.330    if (qemu_filtered)
     3.1 --- a/xenpci/xenpci.h	Sun Apr 12 19:15:28 2009 +1000
     3.2 +++ b/xenpci/xenpci.h	Sun May 10 20:17:05 2009 +1000
     3.3 @@ -511,7 +511,7 @@ EvtChn_Close(PVOID Context, evtchn_port_
     3.4  evtchn_port_t
     3.5  EvtChn_AllocUnbound(PVOID Context, domid_t Domain);
     3.6  BOOLEAN
     3.7 -EvtChn_AckEvent(PVOID context, evtchn_port_t port);
     3.8 +EvtChn_AckEvent(PVOID context, evtchn_port_t port, BOOLEAN *last_interrupt);
     3.9  
    3.10  VOID
    3.11  GntTbl_Init(PXENPCI_DEVICE_DATA xpdd);
     4.1 --- a/xenpci/xenpci.inx	Sun Apr 12 19:15:28 2009 +1000
     4.2 +++ b/xenpci/xenpci.inx	Sun May 10 20:17:05 2009 +1000
     4.3 @@ -27,44 +27,51 @@ CopyFiles=XenPCI.CopyFiles
     4.4  
     4.5  [XenPCI.CopyFiles]
     4.6  xenpci.sys
     4.7 -xenhide.sys
     4.8  
     4.9  [SourceDisksFiles]
    4.10  xenpci.sys=1
    4.11 -xenhide.sys=1
    4.12  
    4.13  [SourceDisksNames]
    4.14  1 = %DISK_NAME%
    4.15  
    4.16  [XenPCI_Device.NT.Services]
    4.17  AddService=XenPCI,3,XenPCI_Service
    4.18 -AddService=XenHide,0,XenHide_Service
    4.19  
    4.20  [XenPCI_Service]
    4.21  DisplayName    = %XenPCI.SVCDESC%                            
    4.22  ServiceType    = 1
    4.23  StartType      = 0
    4.24  ErrorControl   = 1
    4.25 -LoadOrderGroup = Boot Bus Extender
    4.26 +LoadOrderGroup = XenPCI Group
    4.27  ServiceBinary  = %12%\xenpci.sys
    4.28  AddReg         = XenPci_Service_AddReg
    4.29 -
    4.30 -[XenHide_Service]
    4.31 -DisplayName    = %XenHide.SVCDESC%
    4.32 -ServiceType    = 1
    4.33 -StartType      = 0
    4.34 -ErrorControl   = 1
    4.35 -LoadOrderGroup = System Bus Extender
    4.36 -ServiceBinary  = %12%\xenhide.sys
    4.37 -DelReg         = XenHide_Service_DelReg
    4.38 +DelReg         = XenPci_Service_DelReg
    4.39  
    4.40  [XenPci_Service_AddReg]
    4.41  HKR,"Parameters", "veto_devices", 0x00010008, "console"
    4.42  HKR,"Parameters", "veto_devices", 0x00010008, "vfb"
    4.43  HKR,"Parameters", "veto_devices", 0x00010008, "vkbd"
    4.44 +; Qemu IDE
    4.45 +HKR,"Parameters", "hide_devices", 0x00010008, "VEN_8086&DEV_7010"
    4.46 +; Qemu SCSI
    4.47 +HKR,"Parameters", "hide_devices", 0x00010008, "VEN_1000&DEV_0012"
    4.48 +; Qemu Network
    4.49 +HKR,"Parameters", "hide_devices", 0x00010008, "VEN_10EC&DEV_8139"
    4.50 +; Add XenHide as a filter to IDE Controllers
    4.51 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenPci
    4.52 +; Add XenHide as a filter to SCSI Controllers
    4.53 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97B-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenPci
    4.54 +; Add XenPci as a filter to Network Adapters
    4.55 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002bE10318},UpperFilters,0x00010008,XenPci
    4.56  
    4.57 -[XenHide_Service_DelReg]
    4.58 -HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},UpperFilters
    4.59 +[XenPci_Service_DelReg]
    4.60 +; Clear out some old keys
    4.61 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97D-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenHide
    4.62 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenHide
    4.63 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E96A-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenHide
    4.64 +HKLM,SYSTEM\CurrentControlSet\Control\Class\{4D36E97B-E325-11CE-BFC1-08002BE10318},UpperFilters,0x00010008,XenHide
    4.65 +
    4.66 +
    4.67  
    4.68  [DestinationDirs]
    4.69  XenPCI_Device_CoInstaller_CopyFiles = 11
    4.70 @@ -92,5 +99,4 @@ KmdfLibraryVersion = $KMDFVERSION$
    4.71  XenGplPv = "Xen GPL PV Driver Developers"
    4.72  XenPCI.SVCDESC = "Xen PCI Device Driver"
    4.73  XenPCI.DRVDESC = "Xen PCI Device Driver"
    4.74 -XenHide.SVCDESC = "Xen PCI Device Hider Driver"
    4.75  DISK_NAME = "Xen PCI Device Driver Install Disk"
     5.1 --- a/xenpci/xenpci_pdo.c	Sun Apr 12 19:15:28 2009 +1000
     5.2 +++ b/xenpci/xenpci_pdo.c	Sun May 10 20:17:05 2009 +1000
     5.3 @@ -499,18 +499,28 @@ XenPci_DOP_CalculateScatterGatherList(
     5.4    ULONG elements;
     5.5    PMDL curr_mdl;
     5.6      
     5.7 -  FUNCTION_ENTER();
     5.8 +  //FUNCTION_ENTER();
     5.9    
    5.10 -  KdPrint((__DRIVER_NAME "     Mdl = %p\n", Mdl));
    5.11 -  KdPrint((__DRIVER_NAME "     CurrentVa = %p\n", CurrentVa));
    5.12 -  KdPrint((__DRIVER_NAME "     Length = %d\n", Length));
    5.13 +  //KdPrint((__DRIVER_NAME "     Mdl = %p\n", Mdl));
    5.14 +  //KdPrint((__DRIVER_NAME "     CurrentVa = %p\n", CurrentVa));
    5.15 +  //KdPrint((__DRIVER_NAME "     Length = %d\n", Length));
    5.16  
    5.17    xen_dma_adapter = (xen_dma_adapter_t *)DmaAdapter;
    5.18  
    5.19    if (Mdl)
    5.20    {
    5.21 +    //if (CurrentVa != MmGetMdlVirtualAddress(Mdl))
    5.22 +    //{
    5.23 +    //  KdPrint((__DRIVER_NAME "     CurrentVa (%p) != MdlVa (%p)\n", CurrentVa, MmGetMdlVirtualAddress(Mdl)));
    5.24 +    //
    5.25 +
    5.26 +    KdPrint((__DRIVER_NAME "     CurrentVa = %p, MdlVa = %p\n", CurrentVa, MmGetMdlVirtualAddress(Mdl)));
    5.27 +
    5.28      for (curr_mdl = Mdl, elements = 0; curr_mdl; curr_mdl = curr_mdl->Next)
    5.29 -      elements += ADDRESS_AND_SIZE_TO_SPAN_PAGES(CurrentVa, Length);
    5.30 +    {
    5.31 +      KdPrint((__DRIVER_NAME "     curr_mdlVa = %p, curr_mdl size = %d\n", MmGetMdlVirtualAddress(curr_mdl), MmGetMdlByteCount(curr_mdl)));
    5.32 +      elements += ADDRESS_AND_SIZE_TO_SPAN_PAGES(MmGetMdlVirtualAddress(curr_mdl), MmGetMdlByteCount(curr_mdl));
    5.33 +    }
    5.34    }
    5.35    else
    5.36    {
    5.37 @@ -535,7 +545,7 @@ XenPci_DOP_CalculateScatterGatherList(
    5.38  
    5.39    KdPrint((__DRIVER_NAME "     ScatterGatherListSize = %d, NumberOfMapRegisters = %d\n", *ScatterGatherListSize, elements));
    5.40  
    5.41 -  FUNCTION_EXIT();
    5.42 +  //FUNCTION_EXIT();
    5.43    return STATUS_SUCCESS;
    5.44  }
    5.45  
    5.46 @@ -624,8 +634,8 @@ XenPci_DOP_BuildScatterGatherListButDont
    5.47    if (ScatterGatherBufferLength < FIELD_OFFSET(SCATTER_GATHER_LIST, Elements) +
    5.48      sizeof(SCATTER_GATHER_ELEMENT) * sglist->NumberOfElements + sizeof(sg_extra_t))
    5.49    {
    5.50 -    KdPrint((__DRIVER_NAME "     STATUS_BUFFER_TOO_SMALL (%d < %d)\n", ScatterGatherBufferLength, FIELD_OFFSET(SCATTER_GATHER_LIST, Elements) +
    5.51 -      sizeof(SCATTER_GATHER_ELEMENT) * sglist->NumberOfElements + sizeof(sg_extra_t)));
    5.52 +    //KdPrint((__DRIVER_NAME "     STATUS_BUFFER_TOO_SMALL (%d < %d)\n", ScatterGatherBufferLength, FIELD_OFFSET(SCATTER_GATHER_LIST, Elements) +
    5.53 +    //  sizeof(SCATTER_GATHER_ELEMENT) * sglist->NumberOfElements + sizeof(sg_extra_t)));
    5.54      return STATUS_BUFFER_TOO_SMALL;
    5.55    }
    5.56    
    5.57 @@ -745,12 +755,12 @@ XenPci_DOP_GetScatterGatherList(
    5.58    ULONG map_registers;
    5.59    PSCATTER_GATHER_LIST sg_list;
    5.60    
    5.61 -  FUNCTION_ENTER();
    5.62 +  //FUNCTION_ENTER();
    5.63  
    5.64    status = XenPci_DOP_CalculateScatterGatherList(DmaAdapter, Mdl, CurrentVa, Length, &list_size, &map_registers);
    5.65    if (!NT_SUCCESS(status))
    5.66    {
    5.67 -    FUNCTION_EXIT();
    5.68 +    //FUNCTION_EXIT();
    5.69      return status;
    5.70    }
    5.71  
    5.72 @@ -758,7 +768,7 @@ XenPci_DOP_GetScatterGatherList(
    5.73    if (!sg_list)
    5.74    {
    5.75      KdPrint((__DRIVER_NAME "     Cannot allocate memory for sg_list\n"));
    5.76 -    FUNCTION_EXIT();
    5.77 +    //FUNCTION_EXIT();
    5.78      return STATUS_INSUFFICIENT_RESOURCES;
    5.79    }
    5.80      
    5.81 @@ -767,7 +777,7 @@ XenPci_DOP_GetScatterGatherList(
    5.82    if (NT_SUCCESS(status))
    5.83      ExecutionRoutine(DeviceObject, DeviceObject->CurrentIrp, sg_list, Context);
    5.84    
    5.85 -  FUNCTION_EXIT();
    5.86 +  //FUNCTION_EXIT();
    5.87    
    5.88    return status;
    5.89  }
    5.90 @@ -779,14 +789,27 @@ XenPci_DOP_BuildMdlFromScatterGatherList
    5.91    PMDL OriginalMdl,
    5.92    PMDL *TargetMdl)
    5.93  {
    5.94 +  NTSTATUS status = STATUS_SUCCESS;
    5.95    UNREFERENCED_PARAMETER(DmaAdapter);
    5.96    UNREFERENCED_PARAMETER(ScatterGather);
    5.97    UNREFERENCED_PARAMETER(OriginalMdl);
    5.98    UNREFERENCED_PARAMETER(TargetMdl);
    5.99  
   5.100    FUNCTION_ENTER();
   5.101 +  
   5.102 +  if (OriginalMdl)
   5.103 +  {
   5.104 +    *TargetMdl = OriginalMdl;
   5.105 +  }
   5.106 +  else
   5.107 +  {
   5.108 +    *TargetMdl = NULL;
   5.109 +    status = STATUS_INVALID_PARAMETER;
   5.110 +  }
   5.111 +  
   5.112    FUNCTION_EXIT();
   5.113 -  return STATUS_UNSUCCESSFUL;
   5.114 +  
   5.115 +  return status;
   5.116  }
   5.117  
   5.118  static PDMA_ADAPTER
   5.119 @@ -1216,13 +1239,13 @@ XenPci_EvtChn_Notify(PVOID context, evtc
   5.120  }
   5.121  
   5.122  static BOOLEAN
   5.123 -XenPci_EvtChn_AckEvent(PVOID context, evtchn_port_t port)
   5.124 +XenPci_EvtChn_AckEvent(PVOID context, evtchn_port_t port, BOOLEAN *last_interrupt)
   5.125  {
   5.126    WDFDEVICE device = context;
   5.127    PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
   5.128    PXENPCI_DEVICE_DATA xpdd = GetXpdd(xppdd->wdf_device_bus_fdo);
   5.129    
   5.130 -  return EvtChn_AckEvent(xpdd, port);
   5.131 +  return EvtChn_AckEvent(xpdd, port, last_interrupt);
   5.132  }
   5.133  
   5.134  typedef struct {