win-pvdrivers

changeset 818:4e6f162a054c

Fixes for build under Window 2000
author James Harper <james.harper@bendigoit.com.au>
date Sun Oct 10 10:34:26 2010 +1100 (2010-10-10)
parents 678c7d92321c
children d538e0141114
files xenpci/evtchn.c xenpci/sources xenpci/xenpci.c xenpci/xenpci_dbgprint.c xenpci/xenpci_fdo.c xenpci/xenpci_highsync.c xenpci/xenpci_patch_kernel.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/xenpci/evtchn.c	Sun Oct 10 10:33:11 2010 +1100
     1.2 +++ b/xenpci/evtchn.c	Sun Oct 10 10:34:26 2010 +1100
     1.3 @@ -20,7 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     1.4  #include "xenpci.h"
     1.5  
     1.6  /* Not really necessary but keeps PREfast happy */
     1.7 +#if (NTDDI_VERSION >= NTDDI_WINXP)
     1.8  static KDEFERRED_ROUTINE EvtChn_DpcBounce;
     1.9 +#endif
    1.10  
    1.11  #if defined(_X86_)
    1.12    #define xchg(p1, p2) InterlockedExchange(p1, p2)
    1.13 @@ -314,7 +316,9 @@ EvtChn_Unbind(PVOID Context, evtchn_port
    1.14    if (old_type == EVT_ACTION_TYPE_DPC || old_type == EVT_ACTION_TYPE_SUSPEND)
    1.15    {
    1.16      KeRemoveQueueDpc(&xpdd->ev_actions[Port].Dpc);
    1.17 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    1.18      KeFlushQueuedDpcs();
    1.19 +#endif
    1.20    }
    1.21    
    1.22    KeMemoryBarrier(); // make sure we don't call the old Service Routine with the new data...
    1.23 @@ -471,8 +475,9 @@ EvtChn_Suspend(PXENPCI_DEVICE_DATA xpdd)
    1.24        KeRemoveQueueDpc(&xpdd->ev_actions[i].Dpc);
    1.25      }
    1.26    }
    1.27 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    1.28    KeFlushQueuedDpcs();
    1.29 -
    1.30 +#endif
    1.31    return STATUS_SUCCESS;
    1.32  }
    1.33  
     2.1 --- a/xenpci/sources	Sun Oct 10 10:33:11 2010 +1100
     2.2 +++ b/xenpci/sources	Sun Oct 10 10:34:26 2010 +1100
     2.3 @@ -6,6 +6,7 @@ KMDF_VERSION_MAJOR=1
     2.4  NTTARGETFILES=$(NTTARGETFILES) $(OBJ_PATH)\$(O)\$(INF_NAME).inf
     2.5  TARGETLIBS=$(TARGETLIBS) $(DDK_LIB_PATH)\wdmsec.lib $(DDK_LIB_PATH)\Rtlver.lib \
     2.6             $(DDK_LIB_PATH)\..\..\wlh\*\aux_klib.lib
     2.7 +
     2.8  !IF $(386)
     2.9  TARGETLIBS=$(TARGETLIBS) $(LIBLFDS_DIR)\bin\i386\liblfds.lib
    2.10  !ELSE
     3.1 --- a/xenpci/xenpci.c	Sun Oct 10 10:33:11 2010 +1100
     3.2 +++ b/xenpci/xenpci.c	Sun Oct 10 10:34:26 2010 +1100
     3.3 @@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     3.4  
     3.5  /* Not really necessary but keeps PREfast happy */
     3.6  DRIVER_INITIALIZE DriverEntry;
     3.7 +static EVT_WDF_DRIVER_UNLOAD XenPci_EvtDriverUnload;
     3.8  static EVT_WDF_DRIVER_DEVICE_ADD XenPci_EvtDeviceAdd;
     3.9  static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenPci_EvtDeviceUsageNotification;
    3.10  static EVT_WDF_DEVICE_PREPARE_HARDWARE XenHide_EvtDevicePrepareHardware;
    3.11 @@ -541,8 +542,6 @@ XenPci_FixLoadOrder()
    3.12    return;
    3.13  }
    3.14  
    3.15 -EVT_WDF_DRIVER_UNLOAD EvtDriverUnload;
    3.16 -
    3.17  VOID
    3.18  XenPci_EvtDriverUnload(WDFDRIVER driver)
    3.19  {
    3.20 @@ -582,6 +581,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    3.21    #if DBG
    3.22    XenPci_HookDbgPrint();
    3.23    #endif
    3.24 +
    3.25    /* again after enabling DbgPrint hooking */
    3.26    KdPrint((__DRIVER_NAME " " VER_FILEVERSION_STR "\n"));
    3.27  
     4.1 --- a/xenpci/xenpci_dbgprint.c	Sun Oct 10 10:33:11 2010 +1100
     4.2 +++ b/xenpci/xenpci_dbgprint.c	Sun Oct 10 10:34:26 2010 +1100
     4.3 @@ -54,8 +54,9 @@ typedef struct _IDT
     4.4  #pragma pack()
     4.5  
     4.6  /* Not really necessary but keeps PREfast happy */
     4.7 +#if (NTDDI_VERSION >= NTDDI_WINXP)
     4.8  static KBUGCHECK_CALLBACK_ROUTINE XenPci_BugcheckCallback;
     4.9 -
    4.10 +#endif
    4.11  KBUGCHECK_CALLBACK_RECORD callback_record;
    4.12  
    4.13  extern VOID Int2dHandlerNew(VOID);
    4.14 @@ -210,7 +211,7 @@ XenPci_HookDbgPrint()
    4.15    {
    4.16      status = STATUS_UNSUCCESSFUL;
    4.17    }
    4.18 -  
    4.19 +
    4.20    KeInitializeCallbackRecord(&callback_record);
    4.21    if (!KeRegisterBugCheckCallback(&callback_record, XenPci_BugcheckCallback, NULL, 0, (PUCHAR)"XenPci"))
    4.22    {
    4.23 @@ -260,4 +261,3 @@ XenPci_UnHookDbgPrint()
    4.24  
    4.25    return status;
    4.26  }
    4.27 -
     5.1 --- a/xenpci/xenpci_fdo.c	Sun Oct 10 10:33:11 2010 +1100
     5.2 +++ b/xenpci/xenpci_fdo.c	Sun Oct 10 10:34:26 2010 +1100
     5.3 @@ -27,7 +27,9 @@ Foundation, Inc., 51 Franklin Street, Fi
     5.4  
     5.5  /* Not really necessary but keeps PREfast happy */
     5.6  static EVT_WDF_WORKITEM XenPci_SuspendResume;
     5.7 +#if (NTDDI_VERSION >= NTDDI_WINXP)
     5.8  static KSTART_ROUTINE XenPci_BalloonThreadProc;
     5.9 +#endif
    5.10  
    5.11  static VOID
    5.12  XenPci_MapHalThenPatchKernel(PXENPCI_DEVICE_DATA xpdd)
     6.1 --- a/xenpci/xenpci_highsync.c	Sun Oct 10 10:33:11 2010 +1100
     6.2 +++ b/xenpci/xenpci_highsync.c	Sun Oct 10 10:34:26 2010 +1100
     6.3 @@ -20,8 +20,10 @@ Foundation, Inc., 51 Franklin Street, Fi
     6.4  #include "xenpci.h"
     6.5  
     6.6  /* Not really necessary but keeps PREfast happy */
     6.7 +#if (NTDDI_VERSION >= NTDDI_WINXP)
     6.8  static KDEFERRED_ROUTINE XenPci_HighSyncCallFunction0;
     6.9  static KDEFERRED_ROUTINE XenPci_HighSyncCallFunctionN;
    6.10 +#endif
    6.11  
    6.12  /*
    6.13  we need these intrinsics as even going to HIGH_LEVEL doesn't ensure that interrupts are completely disabled
    6.14 @@ -57,7 +59,11 @@ XenPci_HighSyncCallFunction0(
    6.15    UNREFERENCED_PARAMETER(SystemArgument2);
    6.16  
    6.17    FUNCTION_ENTER();
    6.18 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    6.19    ActiveProcessorCount = (ULONG)KeNumberProcessors;
    6.20 +#else
    6.21 +  ActiveProcessorCount = (ULONG)*KeNumberProcessors;
    6.22 +#endif
    6.23    InterlockedIncrement(&highsync_info->nr_procs_at_dispatch_level);
    6.24    if (highsync_info->sync_level > DISPATCH_LEVEL)
    6.25    {
    6.26 @@ -113,7 +119,11 @@ XenPci_HighSyncCallFunctionN(
    6.27    InterlockedIncrement(&highsync_info->nr_procs_at_dispatch_level);
    6.28    if (highsync_info->sync_level > DISPATCH_LEVEL)
    6.29    {
    6.30 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    6.31      ActiveProcessorCount = (ULONG)KeNumberProcessors;
    6.32 +#else
    6.33 +    ActiveProcessorCount = (ULONG)*KeNumberProcessors;
    6.34 +#endif
    6.35      while (highsync_info->nr_procs_at_dispatch_level < (LONG)ActiveProcessorCount)
    6.36      {
    6.37        KeStallExecutionProcessor(1);
    6.38 @@ -156,7 +166,11 @@ XenPci_HighSync(PXENPCI_HIGHSYNC_FUNCTIO
    6.39    highsync_info->context = context;
    6.40    highsync_info->sync_level = HIGH_LEVEL;
    6.41  
    6.42 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    6.43    ActiveProcessorCount = (ULONG)KeNumberProcessors;
    6.44 +#else
    6.45 +  ActiveProcessorCount = (ULONG)*KeNumberProcessors;
    6.46 +#endif
    6.47  
    6.48    /* Go to HIGH_LEVEL to prevent any races with Dpc's on the current processor */
    6.49    KeRaiseIrql(highsync_info->sync_level, &old_irql);
     7.1 --- a/xenpci/xenpci_patch_kernel.c	Sun Oct 10 10:33:11 2010 +1100
     7.2 +++ b/xenpci/xenpci_patch_kernel.c	Sun Oct 10 10:34:26 2010 +1100
     7.3 @@ -306,11 +306,18 @@ MapVlapic(PXENPCI_DEVICE_DATA xpdd)
     7.4  {
     7.5    struct xen_add_to_physmap xatp;
     7.6    ULONG rc = EINVAL;
     7.7 +  ULONG ActiveProcessorCount;
     7.8    int i;
     7.9  
    7.10    FUNCTION_ENTER();
    7.11    
    7.12 -  for (i = 0; i < KeNumberProcessors; i++)
    7.13 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    7.14 +  ActiveProcessorCount = (ULONG)KeNumberProcessors;
    7.15 +#else
    7.16 +  ActiveProcessorCount = (ULONG)*KeNumberProcessors;
    7.17 +#endif
    7.18 +
    7.19 +  for (i = 0; i < (int)ActiveProcessorCount; i++)
    7.20    {
    7.21      KdPrint((__DRIVER_NAME "     mapping lapic for cpu = %d\n", i));
    7.22  
    7.23 @@ -340,11 +347,16 @@ XenPci_PatchKernel(PXENPCI_DEVICE_DATA x
    7.24  {
    7.25    patch_info_t patch_info;
    7.26    ULONG rc;
    7.27 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    7.28    RTL_OSVERSIONINFOEXW version_info;
    7.29 +#endif
    7.30  
    7.31    FUNCTION_ENTER();
    7.32  
    7.33 +/* if we're compiled for 2000 then assume we need patching */
    7.34 +#if (NTDDI_VERSION >= NTDDI_WINXP)
    7.35    version_info.dwOSVersionInfoSize = sizeof(RTL_OSVERSIONINFOEXW);
    7.36 +
    7.37    RtlGetVersion((PRTL_OSVERSIONINFOW)&version_info);
    7.38    if (version_info.dwMajorVersion >= 6)
    7.39    {
    7.40 @@ -364,7 +376,7 @@ XenPci_PatchKernel(PXENPCI_DEVICE_DATA x
    7.41      KdPrint((__DRIVER_NAME "     Windows 2003 sp2 or newer - no need for patch\n"));
    7.42      return;
    7.43    }
    7.44 -
    7.45 +#endif
    7.46    if (IsMoveCr8Supported())
    7.47    {
    7.48      KdPrint((__DRIVER_NAME "     Using LOCK MOVE CR0 TPR patch\n"));
     8.1 --- a/xenpci/xenpci_pdo.c	Sun Oct 10 10:33:11 2010 +1100
     8.2 +++ b/xenpci/xenpci_pdo.c	Sun Oct 10 10:34:26 2010 +1100
     8.3 @@ -33,7 +33,7 @@ static EVT_WDF_DEVICE_RELEASE_HARDWARE X
     8.4  static EVT_WDF_DEVICE_USAGE_NOTIFICATION XenPciPdo_EvtDeviceUsageNotification;
     8.5  static EVT_WDFDEVICE_WDM_IRP_PREPROCESS XenPciPdo_EvtDeviceWdmIrpPreprocess_START_DEVICE;
     8.6  static EVT_WDF_DEVICE_RESOURCE_REQUIREMENTS_QUERY XenPciPdo_EvtDeviceResourceRequirementsQuery;
     8.7 -static EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION  EvtDevicePnpStateChange;
     8.8 +static EVT_WDF_DEVICE_PNP_STATE_CHANGE_NOTIFICATION XenPci_EvtDevicePnpStateChange;
     8.9  
    8.10  /*
    8.11  Called at PASSIVE_LEVEL(?)
    8.12 @@ -1252,7 +1252,7 @@ XenPciPdo_EvtDeviceUsageNotification(WDF
    8.13    FUNCTION_EXIT();
    8.14  }
    8.15  
    8.16 -static NTSTATUS
    8.17 +static VOID
    8.18  XenPci_EvtDevicePnpStateChange(WDFDEVICE device, PCWDF_DEVICE_PNP_NOTIFICATION_DATA notification_data)
    8.19  {
    8.20    PXENPCI_PDO_DEVICE_DATA xppdd = GetXppdd(device);
    8.21 @@ -1273,7 +1273,7 @@ XenPci_EvtDevicePnpStateChange(WDFDEVICE
    8.22    
    8.23    //FUNCTION_EXIT();
    8.24    
    8.25 -  return STATUS_SUCCESS;
    8.26 +  //return STATUS_SUCCESS;
    8.27  }
    8.28  
    8.29  NTSTATUS