win-pvdrivers

changeset 74:06b4321b7068

Created a common AllocagePages routine in xen_windows.h
Updated xennet and xenvbd to use it.
Updated xennet's method of getting the virtual address from the Mdl
author James Harper <james.harper@bendigoit.com.au>
date Thu Dec 20 21:37:20 2007 +1100 (2007-12-20)
parents f74723639713
children b7863ede7a37
files TODO.txt common/include/xen_windows.h xennet/xennet.c xennet/xennet.h xenpci/xenpci.h xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- a/TODO.txt	Thu Dec 20 13:07:44 2007 +1100
     1.2 +++ b/TODO.txt	Thu Dec 20 21:37:20 2007 +1100
     1.3 @@ -3,20 +3,15 @@ get to that as soon as I figure out what
     1.4  
     1.5  Known problems or things that need doing to make it properly useful:
     1.6  . Test under envirnments other than 32-bit PAE Windows 2003. Almost certainly won't work under 64 bit
     1.7 -. Doesn't unload properly
     1.8  . No power management
     1.9  . Almost certainly won't support migration or suspend/resume.
    1.10 -. Probably really poor performance - no optimisation done at all yet.
    1.11  . Reports of problems on Intel systems
    1.12 -. No CDROM Support
    1.13  . Lockups under SMP
    1.14  . Probably lots of other things too.
    1.15  
    1.16  TODO:
    1.17  . Do some performance testing
    1.18 -. Implement a nice shutdown so that 'xm shutdown domain' works (need a user space driver to do this)
    1.19  . network adapters (vif) (Andy Grover is looking at this)
    1.20  . virtual scsi (eg a front end for the scsi passthrough stuff)
    1.21  . balloon drivers (this should actually be pretty easy)
    1.22  . Write an installer for the above binaries to automate everything
    1.23 -. Put up a binary release so it can get some further testing
     2.1 --- a/common/include/xen_windows.h	Thu Dec 20 13:07:44 2007 +1100
     2.2 +++ b/common/include/xen_windows.h	Thu Dec 20 21:37:20 2007 +1100
     2.3 @@ -84,4 +84,43 @@ FreeSplitString(char **Bits, int Count)
     2.4    ExFreePoolWithTag(Bits, SPLITSTRING_POOL_TAG);
     2.5  }
     2.6  
     2.7 +#define ALLOCATE_PAGES_POOL_TAG (ULONG) 'APPT'
     2.8 +
     2.9 +static PMDL
    2.10 +AllocatePages(int Pages)
    2.11 +{
    2.12 +  PMDL Mdl;
    2.13 +  PVOID Buf;
    2.14 +
    2.15 +  //KdPrint((__DRIVER_NAME " --- AllocatePages IRQL = %d\n", KeGetCurrentIrql()));
    2.16 +  Buf = ExAllocatePoolWithTag(NonPagedPool, Pages * PAGE_SIZE, ALLOCATE_PAGES_POOL_TAG);
    2.17 +  if (Buf == NULL)
    2.18 +  {
    2.19 +    KdPrint((__DRIVER_NAME "     AllocatePages Failed at ExAllocatePoolWithTag\n"));
    2.20 +  }
    2.21 +  Mdl = IoAllocateMdl(Buf, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
    2.22 +  if (Mdl == NULL)
    2.23 +  {
    2.24 +    KdPrint((__DRIVER_NAME "     AllocatePages Failed at IoAllocateMdl\n"));
    2.25 +  }
    2.26 +  MmBuildMdlForNonPagedPool(Mdl);
    2.27 +  
    2.28 +  return Mdl;
    2.29 +}
    2.30 +
    2.31 +static PMDL
    2.32 +AllocatePage()
    2.33 +{
    2.34 +  return AllocatePages(1);
    2.35 +}
    2.36 +
    2.37 +static VOID
    2.38 +FreePages(PMDL Mdl)
    2.39 +{
    2.40 +  PVOID Buf = MmGetMdlVirtualAddress(Mdl);
    2.41 +  //KdPrint((__DRIVER_NAME " --- FreePages IRQL = %d\n", KeGetCurrentIrql()));
    2.42 +  IoFreeMdl(Mdl);
    2.43 +  ExFreePoolWithTag(Buf, ALLOCATE_PAGES_POOL_TAG);
    2.44 +}
    2.45 +
    2.46  #endif
     3.1 --- a/xennet/xennet.c	Thu Dec 20 13:07:44 2007 +1100
     3.2 +++ b/xennet/xennet.c	Thu Dec 20 21:37:20 2007 +1100
     3.3 @@ -156,33 +156,6 @@ get_id_from_freelist(NDIS_PACKET **list)
     3.4    return id;
     3.5  }
     3.6  
     3.7 -static PMDL
     3.8 -AllocatePages(int Pages)
     3.9 -{
    3.10 -  PHYSICAL_ADDRESS Min;
    3.11 -  PHYSICAL_ADDRESS Max;
    3.12 -  PHYSICAL_ADDRESS Align;
    3.13 -  PMDL Mdl;
    3.14 -
    3.15 -  // KdPrint((__DRIVER_NAME " --> Allocate Pages\n"));
    3.16 -
    3.17 -  Min.QuadPart = 0;
    3.18 -  Max.QuadPart = 0xFFFFFFFF;
    3.19 -  Align.QuadPart = PAGE_SIZE;
    3.20 -
    3.21 -  Mdl = MmAllocatePagesForMdl(Min, Max, Align, Pages * PAGE_SIZE);
    3.22 -
    3.23 -  // KdPrint((__DRIVER_NAME " <-- Allocate Pages (mdl = %08x)\n", Mdl));
    3.24 -
    3.25 -  return Mdl;
    3.26 -}
    3.27 -  
    3.28 -static PMDL
    3.29 -AllocatePage()
    3.30 -{
    3.31 -  return AllocatePages(1);
    3.32 -}
    3.33 -
    3.34  static NDIS_STATUS
    3.35  XenNet_TxBufferGC(struct xennet_info *xi)
    3.36  {
     4.1 --- a/xennet/xennet.h	Thu Dec 20 13:07:44 2007 +1100
     4.2 +++ b/xennet/xennet.h	Thu Dec 20 21:37:20 2007 +1100
     4.3 @@ -34,6 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  #define NTSTRSAFE_LIB
     4.5  #include <ntstrsafe.h>
     4.6  
     4.7 +#define __DRIVER_NAME "XenNet"
     4.8 +
     4.9  #include <xen_windows.h>
    4.10  #include <memory.h>
    4.11  #include <grant_table.h>
    4.12 @@ -46,7 +48,6 @@ Foundation, Inc., 51 Franklin Street, Fi
    4.13  #include <gnttbl_public.h>
    4.14  #include <io/ring.h>
    4.15  #include <io/netif.h>
    4.16 -#define __DRIVER_NAME "XenNet"
    4.17  #define XENNET_POOL_TAG (ULONG) 'XenN'
    4.18  
    4.19  #define NAME_SIZE 64
     5.1 --- a/xenpci/xenpci.h	Thu Dec 20 13:07:44 2007 +1100
     5.2 +++ b/xenpci/xenpci.h	Thu Dec 20 21:37:20 2007 +1100
     5.3 @@ -33,6 +33,8 @@ Foundation, Inc., 51 Franklin Street, Fi
     5.4  #define NTSTRSAFE_LIB
     5.5  #include <ntstrsafe.h>
     5.6  
     5.7 +#define __DRIVER_NAME "XenPCI"
     5.8 +
     5.9  #include <xen_windows.h>
    5.10  #include <memory.h>
    5.11  #include <grant_table.h>
    5.12 @@ -48,7 +50,6 @@ Foundation, Inc., 51 Franklin Street, Fi
    5.13  //{C828ABE9-14CA-4445-BAA6-82C2376C6518}
    5.14  DEFINE_GUID( GUID_XENPCI_DEVCLASS, 0xC828ABE9, 0x14CA, 0x4445, 0xBA, 0xA6, 0x82, 0xC2, 0x37, 0x6C, 0x65, 0x18);
    5.15  
    5.16 -#define __DRIVER_NAME "XenPCI"
    5.17  #define XENPCI_POOL_TAG (ULONG) 'XenP'
    5.18  //#define XENPCI_FDO_INSTANCE_SIGNATURE (ULONG) 'XENP'
    5.19  
     6.1 --- a/xenvbd/xenvbd.c	Thu Dec 20 13:07:44 2007 +1100
     6.2 +++ b/xenvbd/xenvbd.c	Thu Dec 20 21:37:20 2007 +1100
     6.3 @@ -87,45 +87,6 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
     6.4    return Status;
     6.5  }
     6.6  
     6.7 -static PMDL
     6.8 -AllocatePages(int Pages)
     6.9 -{
    6.10 -  PMDL Mdl;
    6.11 -  PVOID Buf;
    6.12 -
    6.13 -  //KdPrint((__DRIVER_NAME " --- AllocatePages IRQL = %d\n", KeGetCurrentIrql()));
    6.14 -  Buf = ExAllocatePoolWithTag(NonPagedPool, Pages * PAGE_SIZE, XENVBD_POOL_TAG);
    6.15 -  if (Buf == NULL)
    6.16 -  {
    6.17 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at ExAllocatePoolWithTag\n"));
    6.18 -  }
    6.19 -  Mdl = IoAllocateMdl(Buf, Pages * PAGE_SIZE, FALSE, FALSE, NULL);
    6.20 -  if (Mdl == NULL)
    6.21 -  {
    6.22 -    KdPrint((__DRIVER_NAME "     AllocatePages Failed at IoAllocateMdl\n"));
    6.23 -  }
    6.24 -  MmBuildMdlForNonPagedPool(Mdl);
    6.25 -  
    6.26 -  return Mdl;
    6.27 -}
    6.28 -
    6.29 -static PMDL
    6.30 -AllocatePage()
    6.31 -{
    6.32 -  return AllocatePages(1);
    6.33 -}
    6.34 -
    6.35 -static VOID
    6.36 -FreePages(PMDL Mdl)
    6.37 -{
    6.38 -  PVOID Buf = MmGetMdlVirtualAddress(Mdl);
    6.39 -  //KdPrint((__DRIVER_NAME " --- FreePages IRQL = %d\n", KeGetCurrentIrql()));
    6.40 -  //KdPrint((__DRIVER_NAME "     FreePages Failed at IoAllocateMdl\n"));
    6.41 -  //KdPrint((__DRIVER_NAME "     FreePages Buf = %08x\n", Buf));
    6.42 -  IoFreeMdl(Mdl);
    6.43 -  ExFreePoolWithTag(Buf, XENVBD_POOL_TAG);
    6.44 -}
    6.45 -
    6.46  static ULONG
    6.47  XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
    6.48  {
     7.1 --- a/xenvbd/xenvbd.h	Thu Dec 20 13:07:44 2007 +1100
     7.2 +++ b/xenvbd/xenvbd.h	Thu Dec 20 21:37:20 2007 +1100
     7.3 @@ -12,6 +12,8 @@
     7.4  #define NTSTRSAFE_LIB
     7.5  #include <ntstrsafe.h>
     7.6  
     7.7 +#define __DRIVER_NAME "XenVbd"
     7.8 +
     7.9  #include <xen_windows.h>
    7.10  #include <memory.h>
    7.11  #include <grant_table.h>
    7.12 @@ -24,7 +26,7 @@
    7.13  #include <gnttbl_public.h>
    7.14  #include <io/ring.h>
    7.15  #include <io/blkif.h>
    7.16 -#define __DRIVER_NAME "XenVbd"
    7.17 +
    7.18  #define XENVBD_POOL_TAG (ULONG) 'XVBD'
    7.19  
    7.20  #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))