win-pvdrivers

changeset 378:9ac05494063f

get xenvbd compiling under mingw
author Andy Grover <andy.grover@oracle.com>
date Wed Jul 09 12:31:18 2008 -0700 (2008-07-09)
parents 7f4f8d1986e5
children 8c83b0ebcb05
files xenvbd/makefile.mingw xenvbd/scsiport.c xenvbd/xenvbd.c xenvbd/xenvbd.h
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xenvbd/makefile.mingw	Wed Jul 09 12:31:18 2008 -0700
     1.3 @@ -0,0 +1,7 @@
     1.4 +W32API_PATH=/home/agrover/temp/w32api-3.11
     1.5 +
     1.6 +CFLAGS = -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas
     1.7 +
     1.8 +xenvbd.sys: xenvbd.c scsiport.c ../mingw/mingw_extras.c
     1.9 +	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s -shared -Wl,--entry,_load@8 -nostdlib $^ -lntoskrnl -lhal -lscsiport
    1.10 +
     2.1 --- a/xenvbd/scsiport.c	Wed Jul 09 11:01:11 2008 -0700
     2.2 +++ b/xenvbd/scsiport.c	Wed Jul 09 12:31:18 2008 -0700
     2.3 @@ -132,7 +132,7 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
     2.4    xvdd->event_channel = 0;
     2.5    
     2.6    ptr = xvdd->device_base;
     2.7 -  while((type = GET_XEN_INIT_RSP(&ptr, &setting, &value)) != XEN_INIT_TYPE_END)
     2.8 +  while((type = GET_XEN_INIT_RSP(&ptr, (PVOID) &setting, (PVOID) &value)) != XEN_INIT_TYPE_END)
     2.9    {
    2.10      switch(type)
    2.11      {
    2.12 @@ -238,8 +238,20 @@ XenVbd_InitFromConfig(PXENVBD_DEVICE_DAT
    2.13      return SP_RETURN_BAD_CONFIG;
    2.14    }
    2.15  
    2.16 -  /* for some reason total_sectors is measured in 512 byte sectors always, so correct this to be in bytes_per_sectors */
    2.17 -  xvdd->total_sectors /= xvdd->bytes_per_sector / 512;
    2.18 +  /* for some reason total_sectors is measured in 512 byte sectors always, so correct this to be in bytes_per_sectors */
    2.19 +#ifdef __MINGW32__
    2.20 +  /* mingw can't divide, so shift instead (assumes bps is ^2 and at least 512) */
    2.21 +  {
    2.22 +    ULONG num_512_byte_sectors = xvdd->bytes_per_sector / 512;
    2.23 +    ULONG index;
    2.24 +
    2.25 +    bit_scan_forward(&index, num_512_byte_sectors);
    2.26 +    xvdd->total_sectors <<= index-1;
    2.27 +  }
    2.28 +#else
    2.29 +  xvdd->total_sectors /= xvdd->bytes_per_sector / 512;
    2.30 +#endif
    2.31 +
    2.32  
    2.33    xvdd->shadow_free = 0;
    2.34    memset(xvdd->shadows, 0, sizeof(blkif_shadow_t) * SHADOW_ENTRIES);
    2.35 @@ -412,7 +424,7 @@ XenVbd_HwScsiTimer(PVOID DeviceExtension
    2.36    ScsiPortNotification(RequestTimerCall, DeviceExtension, XenVbd_HwScsiTimer, RESUME_CHECK_TIMER_INTERVAL);
    2.37  }
    2.38  
    2.39 -static ULONG
    2.40 +static ULONG DDKAPI
    2.41  XenVbd_HwScsiFindAdapter(PVOID DeviceExtension, PVOID HwContext, PVOID BusInformation, PCHAR ArgumentString, PPORT_CONFIGURATION_INFORMATION ConfigInfo, PBOOLEAN Again)
    2.42  {
    2.43  //  PACCESS_RANGE AccessRange;
    2.44 @@ -490,7 +502,7 @@ XenVbd_HwScsiFindAdapter(PVOID DeviceExt
    2.45    return SP_RETURN_FOUND;
    2.46  }
    2.47  
    2.48 -static BOOLEAN
    2.49 +static BOOLEAN DDKAPI
    2.50  XenVbd_HwScsiInitialize(PVOID DeviceExtension)
    2.51  {
    2.52    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
    2.53 @@ -655,7 +667,7 @@ XenVbd_MakeAutoSense(PXENVBD_DEVICE_DATA
    2.54    srb->SrbStatus |= SRB_STATUS_AUTOSENSE_VALID;
    2.55  }
    2.56  
    2.57 -static BOOLEAN
    2.58 +static BOOLEAN DDKAPI
    2.59  XenVbd_HwScsiInterrupt(PVOID DeviceExtension)
    2.60  {
    2.61    PXENVBD_DEVICE_DATA xvdd = (PXENVBD_DEVICE_DATA)DeviceExtension;
    2.62 @@ -790,7 +802,7 @@ XenVbd_HwScsiInterrupt(PVOID DeviceExten
    2.63    return FALSE; /* we just don't know... */
    2.64  }
    2.65  
    2.66 -static BOOLEAN
    2.67 +static BOOLEAN DDKAPI
    2.68  XenVbd_HwScsiStartIo(PVOID DeviceExtension, PSCSI_REQUEST_BLOCK Srb)
    2.69  {
    2.70    PUCHAR DataBuffer;
    2.71 @@ -1096,7 +1108,7 @@ XenVbd_HwScsiStartIo(PVOID DeviceExtensi
    2.72    return TRUE;
    2.73  }
    2.74  
    2.75 -static BOOLEAN
    2.76 +static BOOLEAN DDKAPI
    2.77  XenVbd_HwScsiResetBus(PVOID DeviceExtension, ULONG PathId)
    2.78  {
    2.79    UNREFERENCED_PARAMETER(DeviceExtension);
    2.80 @@ -1113,7 +1125,7 @@ XenVbd_HwScsiResetBus(PVOID DeviceExtens
    2.81    return TRUE;
    2.82  }
    2.83  
    2.84 -static BOOLEAN
    2.85 +static BOOLEAN DDKAPI
    2.86  XenVbd_HwScsiAdapterState(PVOID DeviceExtension, PVOID Context, BOOLEAN SaveState)
    2.87  {
    2.88    UNREFERENCED_PARAMETER(DeviceExtension);
    2.89 @@ -1128,7 +1140,7 @@ XenVbd_HwScsiAdapterState(PVOID DeviceEx
    2.90    return TRUE;
    2.91  }
    2.92  
    2.93 -static SCSI_ADAPTER_CONTROL_STATUS
    2.94 +static SCSI_ADAPTER_CONTROL_STATUS DDKAPI
    2.95  XenVbd_HwScsiAdapterControl(PVOID DeviceExtension, SCSI_ADAPTER_CONTROL_TYPE ControlType, PVOID Parameters)
    2.96  {
    2.97    SCSI_ADAPTER_CONTROL_STATUS Status = ScsiAdapterControlSuccess;
     3.1 --- a/xenvbd/xenvbd.c	Wed Jul 09 11:01:11 2008 -0700
     3.2 +++ b/xenvbd/xenvbd.c	Wed Jul 09 12:31:18 2008 -0700
     3.3 @@ -16,7 +16,8 @@ You should have received a copy of the G
     3.4  along with this program; if not, write to the Free Software
     3.5  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     3.6  */
     3.7 -
     3.8 +
     3.9 +#define INITGUID
    3.10  #include "xenvbd.h"
    3.11  #include <io/blkif.h>
    3.12  #include <scsi.h>
    3.13 @@ -29,9 +30,8 @@ Foundation, Inc., 51 Franklin Street, Fi
    3.14  
    3.15  #pragma warning(disable: 4127)
    3.16  
    3.17 +#ifdef ALLOC_PRAGMA
    3.18  DRIVER_INITIALIZE DriverEntry;
    3.19 -
    3.20 -#ifdef ALLOC_PRAGMA
    3.21  #pragma alloc_text (INIT, DriverEntry)
    3.22  #endif
    3.23  
     4.1 --- a/xenvbd/xenvbd.h	Wed Jul 09 11:01:11 2008 -0700
     4.2 +++ b/xenvbd/xenvbd.h	Wed Jul 09 12:31:18 2008 -0700
     4.3 @@ -19,17 +19,25 @@ Foundation, Inc., 51 Franklin Street, Fi
     4.4  
     4.5  #if !defined(_XENVBD_H_)
     4.6  #define _XENVBD_H_
     4.7 +
     4.8 +#ifdef __MINGW32__
     4.9 +#include <ntddk.h>
    4.10 +#include "../mingw/mingw_extras.h"
    4.11 +
    4.12 +#else
    4.13 +#define DDKAPI
    4.14  
    4.15  #include <ntifs.h>
    4.16  #include <ntddk.h>
    4.17  #include <wdm.h>
    4.18  #include <initguid.h>
    4.19 +#define NTSTRSAFE_LIB
    4.20 +#include <ntstrsafe.h>
    4.21 +#endif
    4.22 +
    4.23  #include <ntdddisk.h>
    4.24  #include <srb.h>
    4.25  
    4.26 -#define NTSTRSAFE_LIB
    4.27 -#include <ntstrsafe.h>
    4.28 -
    4.29  #define __DRIVER_NAME "XenVbd"
    4.30  
    4.31  #include <xen_windows.h>
    4.32 @@ -140,4 +148,5 @@ struct
    4.33  VOID
    4.34  XenVbd_FillInitCallbacks(PHW_INITIALIZATION_DATA HwInitializationData);
    4.35  
    4.36 -#endif
    4.37 \ No newline at end of file
    4.38 +#endif
    4.39 +