win-pvdrivers

changeset 88:3a9c28d5a006

xenpci: clean up warnings and add comments for FreeMem and AllocMMIO
author Andy Grover <andy.grover@oracle.com>
date Wed Jan 02 11:27:47 2008 -0800 (2008-01-02)
parents 70258b4c8380
children 5f69bcb9090c
files common/include/xen_public.h xenpci/xenpci.c
line diff
     1.1 --- a/common/include/xen_public.h	Wed Jan 02 10:43:25 2008 -0800
     1.2 +++ b/common/include/xen_public.h	Wed Jan 02 11:27:47 2008 -0800
     1.3 @@ -28,9 +28,9 @@ DEFINE_GUID( GUID_XEN_IFACE, 0x5C568AC5,
     1.4  //{5C568AC5-9DDF-4FA5-A94A-39D67077819C}
     1.5  
     1.6  typedef PHYSICAL_ADDRESS
     1.7 -(*PXEN_ALLOCMMIO)(ULONG Length);
     1.8 +(*PXEN_ALLOCMMIO)(PVOID Context, ULONG Length);
     1.9  
    1.10 -typedef PHYSICAL_ADDRESS
    1.11 +typedef void
    1.12  (*PXEN_FREEMEM)(PVOID Ptr);
    1.13  
    1.14  typedef NTSTATUS
     2.1 --- a/xenpci/xenpci.c	Wed Jan 02 10:43:25 2008 -0800
     2.2 +++ b/xenpci/xenpci.c	Wed Jan 02 11:27:47 2008 -0800
     2.3 @@ -74,6 +74,8 @@ XenPCI_XenBusWatchHandler(char *Path, PV
     2.4  static BOOLEAN AutoEnumerate;
     2.5  static LIST_ENTRY ShutdownMsgList;
     2.6  
     2.7 +#pragma warning(disable : 4200) // zero-sized array
     2.8 +
     2.9  typedef struct {
    2.10    LIST_ENTRY ListEntry;
    2.11    ULONG Ptr;
    2.12 @@ -203,7 +205,12 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
    2.13    return status;
    2.14  }
    2.15  
    2.16 -static XenPCI_FreeMem(PVOID Ptr)
    2.17 +/*
    2.18 + * Many XEN_IFACE functions allocate memory. Clients must use this to free it.
    2.19 + * (Xenbus_Read, XenBus_List, XenBus_AddWatch, XenBus_RemWatch)
    2.20 + */
    2.21 +static void
    2.22 +XenPCI_FreeMem(PVOID Ptr)
    2.23  {
    2.24    ExFreePoolWithTag(Ptr, XENPCI_POOL_TAG);
    2.25  }
    2.26 @@ -245,6 +252,9 @@ get_hypercall_stubs(WDFDEVICE Device)
    2.27    return STATUS_SUCCESS;
    2.28  }
    2.29  
    2.30 +/*
    2.31 + * Alloc MMIO from the device's MMIO region. There is no corresponding free() fn
    2.32 + */
    2.33  PHYSICAL_ADDRESS
    2.34  XenPCI_AllocMMIO(WDFDEVICE Device, ULONG len)
    2.35  {
    2.36 @@ -256,6 +266,8 @@ XenPCI_AllocMMIO(WDFDEVICE Device, ULONG
    2.37    addr.QuadPart += xpdd->platform_mmio_alloc;
    2.38    xpdd->platform_mmio_alloc += len;
    2.39  
    2.40 +  ASSERT(xpdd->platform_mmio_alloc <= xpdd->platform_mmio_len);
    2.41 +
    2.42    return addr;
    2.43  }
    2.44