win-pvdrivers

changeset 1006:9fb8690938b3

tidyup
author James Harper <james.harper@bendigoit.com.au>
date Sun Feb 10 23:12:03 2013 +1100 (2013-02-10)
parents 4f7d5a8636bd
children 4cda50fe71d5
files xenpci/xenpci.c xenpci/xenpci.h xenpci/xenpci_export.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/xenpci.c	Sat Feb 02 18:51:07 2013 +1100
     1.2 +++ b/xenpci/xenpci.c	Sun Feb 10 23:12:03 2013 +1100
     1.3 @@ -330,35 +330,29 @@ XenPci_EvtDeviceAdd_XenHide(WDFDRIVER dr
     1.4    FUNCTION_ENTER();
     1.5  
     1.6    status = WdfFdoInitAllocAndQueryProperty(device_init, DevicePropertyDeviceDescription, NonPagedPool, WDF_NO_OBJECT_ATTRIBUTES, &memory);
     1.7 -  if (NT_SUCCESS(status))
     1.8 -  {
     1.9 +  if (NT_SUCCESS(status)) {
    1.10      device_description = WdfMemoryGetBuffer(memory, NULL);
    1.11 -  }
    1.12 -  else
    1.13 -  {
    1.14 +  } else {
    1.15      device_description = L"<unknown device>";
    1.16    }
    1.17 -
    1.18 -  for (i = 0; i < WdfCollectionGetCount(qemu_hide_devices); i++)
    1.19 -  {
    1.20 +  
    1.21 +  for (i = 0; i < WdfCollectionGetCount(qemu_hide_devices); i++) {
    1.22      WDFSTRING wdf_string = WdfCollectionGetItem(qemu_hide_devices, i);
    1.23      UNICODE_STRING unicode_string;
    1.24      WdfStringGetUnicodeString(wdf_string, &unicode_string);
    1.25 -    if (XenPci_IdSuffixMatches(device_init, unicode_string.Buffer))
    1.26 -    {
    1.27 +    if (XenPci_IdSuffixMatches(device_init, unicode_string.Buffer)) {
    1.28        hide_required = TRUE;
    1.29        break;
    1.30      }
    1.31    }
    1.32 -  if (!hide_required)
    1.33 -  {
    1.34 +  if (!hide_required) {
    1.35 +    FUNCTION_MSG("(filter not required for %S)\n", device_description);
    1.36      WdfObjectDelete(memory);
    1.37 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (filter not required for %S)\n", device_description));
    1.38      return STATUS_SUCCESS;
    1.39    }
    1.40    
    1.41 -  KdPrint((__DRIVER_NAME "     Installing Filter for %S\n", device_description));
    1.42 -
    1.43 +  FUNCTION_MSG("Installing Filter for %S\n", device_description);
    1.44 +  
    1.45    WdfFdoInitSetFilter(device_init);
    1.46    WdfDeviceInitSetDeviceType(device_init, FILE_DEVICE_UNKNOWN);
    1.47    WdfDeviceInitSetExclusive(device_init, FALSE);
    1.48 @@ -369,9 +363,8 @@ XenPci_EvtDeviceAdd_XenHide(WDFDRIVER dr
    1.49    
    1.50    WDF_OBJECT_ATTRIBUTES_INIT(&device_attributes);
    1.51    status = WdfDeviceCreate(&device_init, &device_attributes, &device);
    1.52 -  if (!NT_SUCCESS(status))
    1.53 -  {
    1.54 -    KdPrint(("Error creating device %08x\n", status));
    1.55 +  if (!NT_SUCCESS(status)) {
    1.56 +    FUNCTION_MSG("Error creating device %08x\n", status);
    1.57      WdfObjectDelete(memory);
    1.58      FUNCTION_EXIT();
    1.59      return status;
    1.60 @@ -386,18 +379,15 @@ XenPci_EvtDeviceAdd_XenHide(WDFDRIVER dr
    1.61  static NTSTATUS
    1.62  XenPci_EvtDeviceAdd(WDFDRIVER driver, PWDFDEVICE_INIT device_init)
    1.63  {
    1.64 -  if (XenPci_IdSuffixMatches(device_init, L"VEN_5853&DEV_0001"))
    1.65 -  {
    1.66 -    KdPrint((__DRIVER_NAME "     Xen PCI device found - must be fdo\n"));
    1.67 +  if (XenPci_IdSuffixMatches(device_init, L"VEN_5853&DEV_0001")) {
    1.68 +    FUNCTION_MSG("Xen PCI device found - must be fdo\n");
    1.69      return XenPci_EvtDeviceAdd_XenPci(driver, device_init);
    1.70 +  } else if (WdfCollectionGetCount(qemu_hide_devices) > 0) {
    1.71 +    FUNCTION_MSG("Xen PCI device not found - must be filter\n");
    1.72 +    return XenPci_EvtDeviceAdd_XenHide(driver, device_init);  
    1.73 +  } else {
    1.74 +    return STATUS_SUCCESS;
    1.75    }
    1.76 -  else if (WdfCollectionGetCount(qemu_hide_devices) > 0)
    1.77 -  {
    1.78 -    KdPrint((__DRIVER_NAME "     Xen PCI device not found - must be filter\n"));
    1.79 -    return XenPci_EvtDeviceAdd_XenHide(driver, device_init);  
    1.80 -  }
    1.81 -  else
    1.82 -    return STATUS_SUCCESS;
    1.83  }
    1.84  
    1.85  ULONG qemu_protocol_version;
    1.86 @@ -860,10 +850,8 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    1.87    conf_info = IoGetConfigurationInformation();      
    1.88    if (always_hide || ((conf_info == NULL || conf_info->DiskCount == 0)
    1.89        && !(system_start_options.Buffer && wcsstr(system_start_options.Buffer, L"NOGPLPV"))
    1.90 -      && !*InitSafeBootMode))
    1.91 -  {
    1.92 -    if (!(system_start_options.Buffer && wcsstr(system_start_options.Buffer, L"GPLPVUSEFILTERHIDE")) && XenPci_CheckHideQemuDevices())
    1.93 -    {
    1.94 +      && !*InitSafeBootMode)) {
    1.95 +    if (!(system_start_options.Buffer && wcsstr(system_start_options.Buffer, L"GPLPVUSEFILTERHIDE")) && XenPci_CheckHideQemuDevices()) {
    1.96        DECLARE_CONST_UNICODE_STRING(qemu_hide_flags_name, L"qemu_hide_flags");
    1.97        DECLARE_CONST_UNICODE_STRING(txt_qemu_hide_flags_name, L"txt_qemu_hide_flags");
    1.98        WDFCOLLECTION qemu_hide_flags;
    1.99 @@ -872,8 +860,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   1.100        WdfCollectionCreate(&parent_attributes, &qemu_hide_flags);
   1.101        WdfRegistryQueryMultiString(param_key, &qemu_hide_flags_name, &parent_attributes, qemu_hide_flags);
   1.102        WdfRegistryQueryMultiString(param_key, &txt_qemu_hide_flags_name, &parent_attributes, qemu_hide_flags);
   1.103 -      for (i = 0; i < WdfCollectionGetCount(qemu_hide_flags); i++)
   1.104 -      {
   1.105 +      for (i = 0; i < WdfCollectionGetCount(qemu_hide_flags); i++) {
   1.106          ULONG value;
   1.107          WDFSTRING wdf_string = WdfCollectionGetItem(qemu_hide_flags, i);
   1.108          UNICODE_STRING unicode_string;
   1.109 @@ -883,9 +870,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   1.110        }
   1.111        WdfObjectDelete(qemu_hide_flags);
   1.112        XenPci_HideQemuDevices();
   1.113 -    }
   1.114 -    else
   1.115 -    {
   1.116 +    } else {
   1.117        WdfRegistryQueryMultiString(param_key, &hide_devices_name, &parent_attributes, qemu_hide_devices);      
   1.118      }
   1.119    }
     2.1 --- a/xenpci/xenpci.h	Sat Feb 02 18:51:07 2013 +1100
     2.2 +++ b/xenpci/xenpci.h	Sun Feb 10 23:12:03 2013 +1100
     2.3 @@ -25,11 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fi
     2.4  
     2.5  #include <ntddk.h>
     2.6  
     2.7 -/* including ntifs.h (only needed for this function) causes PREFast to trip up on lots of bogus errors */
     2.8 -PDEVICE_OBJECT IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject); 
     2.9 -//#include <ntifs.h>
    2.10 -
    2.11 -//#include <wdm.h>
    2.12  #include <wdf.h>
    2.13  #include <initguid.h>
    2.14  #include <wdmguid.h>
    2.15 @@ -262,14 +257,6 @@ typedef struct {
    2.16    PVOID device_callback_context;
    2.17    FAST_MUTEX backend_state_mutex;
    2.18    ULONG frontend_state;
    2.19 -  PMDL config_page_mdl;
    2.20 -  PHYSICAL_ADDRESS config_page_phys;
    2.21 -  ULONG config_page_length;
    2.22 -  PUCHAR requested_resources_start;
    2.23 -  PUCHAR requested_resources_ptr;
    2.24 -  PUCHAR assigned_resources_start;
    2.25 -  PUCHAR assigned_resources_ptr;
    2.26 -  //XENPCI_DEVICE_STATE device_state;
    2.27    BOOLEAN restart_on_resume;
    2.28    BOOLEAN backend_initiated_remove;
    2.29    BOOLEAN do_not_enumerate;
    2.30 @@ -377,9 +364,6 @@ VOID XenPci_HideQemuDevices();
    2.31  extern WDFCOLLECTION qemu_hide_devices;
    2.32  extern USHORT qemu_hide_flags_value;
    2.33  
    2.34 -//NTSTATUS XenPci_Pdo_Suspend(WDFDEVICE device);
    2.35 -//NTSTATUS XenPci_Pdo_Resume(WDFDEVICE device);
    2.36 -
    2.37  VOID XenPci_BackendStateCallback(char *path, PVOID context);
    2.38  NTSTATUS XenPci_SuspendPdo(WDFDEVICE device);
    2.39  NTSTATUS XenPci_ResumePdo(WDFDEVICE device);
    2.40 @@ -426,12 +410,10 @@ NTSTATUS EvtChn_Mask(PVOID context, evtc
    2.41  NTSTATUS EvtChn_Unmask(PVOID context, evtchn_port_t port);
    2.42  NTSTATUS EvtChn_Bind(PVOID context, evtchn_port_t port, PXN_EVENT_CALLBACK ServiceRoutine, PVOID ServiceContext, ULONG flags);
    2.43  NTSTATUS EvtChn_BindDpc(PVOID context, evtchn_port_t port, PXN_EVENT_CALLBACK ServiceRoutine, PVOID ServiceContext, ULONG flags);
    2.44 -//ULONG EvtChn_AllocIpi(PVOID context, ULONG vcpu);
    2.45  NTSTATUS EvtChn_Unbind(PVOID context, evtchn_port_t port);
    2.46  NTSTATUS EvtChn_Notify(PVOID context, evtchn_port_t port);
    2.47  VOID EvtChn_Close(PVOID context, evtchn_port_t port);
    2.48  evtchn_port_t EvtChn_AllocUnbound(PVOID context, domid_t domain);
    2.49 -//BOOLEAN EvtChn_AckEvent(PVOID context, evtchn_port_t port, BOOLEAN *last_interrupt);
    2.50  evtchn_port_t EvtChn_GetEventPort(PVOID context, evtchn_port_t port);
    2.51  
    2.52  VOID GntTbl_Init(PXENPCI_DEVICE_DATA xpdd);
     3.1 --- a/xenpci/xenpci_export.c	Sat Feb 02 18:51:07 2013 +1100
     3.2 +++ b/xenpci/xenpci_export.c	Sun Feb 10 23:12:03 2013 +1100
     3.3 @@ -199,7 +199,7 @@ XnWriteString(XN_HANDLE handle, ULONG ba
     3.4    RtlStringCbCatA(full_path, ARRAY_SIZE(full_path), "/");
     3.5    RtlStringCbCatA(full_path, ARRAY_SIZE(full_path), path);
     3.6  
     3.7 -  FUNCTION_MSG("XnWriteString(%s, %s)\n", full_path, value);
     3.8 +  //FUNCTION_MSG("XnWriteString(%s, %s)\n", full_path, value);
     3.9    response = XenBus_Write(xpdd, XBT_NIL, full_path, value);
    3.10    if (response) {
    3.11      FUNCTION_MSG("XnWriteString - %s = %s\n", full_path, response);
    3.12 @@ -262,7 +262,7 @@ XnWriteInt32(XN_HANDLE handle, ULONG bas
    3.13    RtlStringCbCatA(full_path, ARRAY_SIZE(full_path), "/");
    3.14    RtlStringCbCatA(full_path, ARRAY_SIZE(full_path), path);
    3.15    
    3.16 -  FUNCTION_MSG("XnWriteInt32(%s, %d)\n", full_path, value);
    3.17 +  //FUNCTION_MSG("XnWriteInt32(%s, %d)\n", full_path, value);
    3.18    response = XenBus_Printf(xpdd, XBT_NIL, full_path, "%d", value);
    3.19    if (response) {
    3.20      FUNCTION_MSG("XnWriteInt - %s = %s\n", full_path, response);
     4.1 --- a/xenpci/xenpci_pdo.c	Sat Feb 02 18:51:07 2013 +1100
     4.2 +++ b/xenpci/xenpci_pdo.c	Sun Feb 10 23:12:03 2013 +1100
     4.3 @@ -575,8 +575,6 @@ XenPci_EvtChildListCreateDevice(WDFCHILD
     4.4    xppdd->wdf_device_bus_fdo = WdfChildListGetDevice(child_list);
     4.5    xppdd->xpdd = xpdd;
     4.6  
     4.7 -  xppdd->config_page_mdl = AllocateUncachedPage();
     4.8 -
     4.9    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFilePaging, TRUE);
    4.10    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFileHibernation, TRUE);
    4.11    WdfDeviceSetSpecialFileSupport(child_device, WdfSpecialFileDump, TRUE);