win-pvdrivers

changeset 402:04883e1dc65c

merged with head
author James Harper <james.harper@bendigoit.com.au>
date Sat Jul 19 11:35:24 2008 +1000 (2008-07-19)
parents fdb7f8853695 8f94eeae17f9
children abdcb860cfdf
files xennet/xennet.c xenpci/xenbus.c xenpci/xenpci_fdo.c xenpci/xenpci_pdo.c
line diff
     1.1 --- a/common/include/xen_windows.h	Fri Jul 18 23:22:01 2008 +1000
     1.2 +++ b/common/include/xen_windows.h	Sat Jul 19 11:35:24 2008 +1000
     1.3 @@ -61,10 +61,11 @@ typedef unsigned long xenbus_transaction
     1.4  #define wmb() KeMemoryBarrier()
     1.5  #define mb() KeMemoryBarrier()
     1.6  
     1.7 -#define FUNCTION_ENTER()      KdPrint((__DRIVER_NAME " --> %s\n", __FUNCTION__))
     1.8 -#define FUNCTION_EXIT()       KdPrint((__DRIVER_NAME " <-- %s\n", __FUNCTION__))
     1.9 -#define FUNCTION_ERROR_EXIT() KdPrint((__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__))
    1.10 -#define FUNCTION_CALLED()     KdPrint((__DRIVER_NAME " %s called\n", __FUNCTION__))
    1.11 +#define FUNCTION_ENTER()       KdPrint((__DRIVER_NAME " --> %s\n", __FUNCTION__))
    1.12 +#define FUNCTION_EXIT()        KdPrint((__DRIVER_NAME " <-- %s\n", __FUNCTION__))
    1.13 +#define FUNCTION_EXIT_STATUS(_status) KdPrint((__DRIVER_NAME " <-- %s, status = %08x\n", __FUNCTION__, _status))
    1.14 +#define FUNCTION_ERROR_EXIT()  KdPrint((__DRIVER_NAME " <-- %s (error path)\n", __FUNCTION__))
    1.15 +#define FUNCTION_CALLED()      KdPrint((__DRIVER_NAME " %s called (line %d)\n", __FUNCTION__, __LINE__))
    1.16  #ifdef __MINGW32__
    1.17  #define FUNCTION_MSG(_x) _FUNCTION_MSG _x
    1.18  #define _FUNCTION_MSG(format, args...) KdPrint((__DRIVER_NAME " %s called: " format, __FUNCTION__, ##args))
     2.1 --- a/doc/BUILDING_mingw.txt	Fri Jul 18 23:22:01 2008 +1000
     2.2 +++ b/doc/BUILDING_mingw.txt	Sat Jul 19 11:35:24 2008 +1000
     2.3 @@ -4,7 +4,7 @@ reasons to using the Microsoft WDK/DDK.
     2.4  These instructions are for building the driver on a Linux Ubuntu system, using
     2.5  the mingw32msvc cross-compiler.
     2.6  
     2.7 -1. sudo apt-get install mingw mingw-binutils mingw-runtime
     2.8 +1. sudo apt-get install mingw32 mingw32-binutils mingw32-runtime
     2.9  
    2.10  2. mingw-runtime headers need to be modified. Download the latest w32api-src.tar.gz
    2.11     package from mingw.sf.net.
    2.12 @@ -17,7 +17,7 @@ 4. Use Mercurial and type:
    2.13  5. Apply the patch "w32api.diff" in the mingw directory to the untarred w32api
    2.14     source: "cd w32api-<version>;patch -p1 < ~/hg/win-pvdrivers.hg/mingw/w32api.diff"
    2.15  
    2.16 -6. Type: "./configure i586-mingw32-msvc;make"
    2.17 +6. Type: "./configure i586-mingw32msvc;make"
    2.18  
    2.19  7. Change to the win-pvdrivers.hg/xenpci dir.
    2.20  
     3.1 --- a/mingw/w32api.diff	Fri Jul 18 23:22:01 2008 +1000
     3.2 +++ b/mingw/w32api.diff	Sat Jul 19 11:35:24 2008 +1000
     3.3 @@ -1,7 +1,7 @@
     3.4 -diff -r 8a2d0356d23d include/ddk/ndis.h
     3.5 ---- a/include/ddk/ndis.h	Wed Jul 09 12:54:30 2008 -0700
     3.6 -+++ b/include/ddk/ndis.h	Wed Jul 09 12:54:42 2008 -0700
     3.7 -@@ -52,12 +52,16 @@ extern "C" {
     3.8 +diff -r 0717ca718d88 include/ddk/ndis.h
     3.9 +--- a/include/ddk/ndis.h	Tue Jul 08 21:35:58 2008 -0700
    3.10 ++++ b/include/ddk/ndis.h	Thu Jul 17 23:09:31 2008 -0700
    3.11 +@@ -52,12 +52,16 @@
    3.12   #if defined(NDIS50_MINIPORT)
    3.13   #ifndef NDIS50
    3.14   #define NDIS50
    3.15 @@ -18,7 +18,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.16   #endif
    3.17   #endif /* NDIS51_MINIPORT */
    3.18   
    3.19 -@@ -399,19 +403,19 @@ typedef struct _NDIS_PACKET_PRIVATE {
    3.20 +@@ -399,19 +403,19 @@
    3.21   
    3.22   typedef struct _NDIS_PACKET {
    3.23     NDIS_PACKET_PRIVATE  Private;
    3.24 @@ -46,21 +46,19 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.25     ULONG_PTR  Reserved[2];
    3.26     UCHAR  ProtocolReserved[1];
    3.27   } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
    3.28 -@@ -642,6 +646,13 @@ typedef enum _NDIS_PNP_DEVICE_STATE {
    3.29 +@@ -642,6 +646,11 @@
    3.30   #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET  0x00000080
    3.31   #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100
    3.32   
    3.33 ++/* _NDIS_DEVICE_PNP_EVENT */
    3.34  +typedef enum _NDIS_DEVICE_PNP_EVENT
    3.35  +{
    3.36 -+  /* couldn't find public docs on other values */
    3.37 -+  NdisDevicePnpEventSurpriseRemoved=2,
    3.38 -+  NdisDevicePnpEventPowerProfileChanged=5
    3.39 ++  Unused
    3.40  +} NDIS_DEVICE_PNP_EVENT;
    3.41 -+
    3.42   
    3.43   /* OID_GEN_NETWORK_LAYER_ADDRESSES */
    3.44   typedef struct _NETWORK_ADDRESS {
    3.45 -@@ -915,6 +926,33 @@ typedef struct _NDIS_TASK_IPSEC {
    3.46 +@@ -915,6 +924,33 @@
    3.47     } V4ESP;
    3.48   } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
    3.49   
    3.50 @@ -94,7 +92,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.51   typedef struct _NDIS_TASK_OFFLOAD {
    3.52     ULONG  Version;
    3.53     ULONG  Size;
    3.54 -@@ -926,24 +964,6 @@ typedef struct _NDIS_TASK_OFFLOAD {
    3.55 +@@ -926,24 +962,6 @@
    3.56   
    3.57   /* NDIS_TASK_OFFLOAD_HEADER.Version constants */
    3.58   #define NDIS_TASK_OFFLOAD_VERSION 1
    3.59 @@ -119,7 +117,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.60   
    3.61   typedef struct _NDIS_TASK_TCP_IP_CHECKSUM {
    3.62     struct {
    3.63 -@@ -1542,6 +1562,8 @@ NdisAllocatePacketPool(
    3.64 +@@ -1542,6 +1560,8 @@
    3.65     /*OUT*/ PNDIS_HANDLE  PoolHandle,
    3.66     /*IN*/ UINT  NumberOfDescriptors,
    3.67     /*IN*/ UINT  ProtocolReservedLength);
    3.68 @@ -128,7 +126,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.69   
    3.70   NDISAPI
    3.71   VOID
    3.72 -@@ -1756,6 +1778,46 @@ NdisFreeBuffer(
    3.73 +@@ -1756,6 +1776,46 @@
    3.74   
    3.75   /*
    3.76    * VOID
    3.77 @@ -175,7 +173,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.78    * NdisQueryBuffer(
    3.79    * IN PNDIS_BUFFER  Buffer,
    3.80    * OUT PVOID  *VirtualAddress OPTIONAL,
    3.81 -@@ -2092,7 +2154,7 @@ NdisFreeBuffer(
    3.82 +@@ -2092,7 +2152,7 @@
    3.83    * NdisReinitializePacket(
    3.84    * IN OUT  PNDIS_PACKET  Packet);
    3.85    */
    3.86 @@ -184,7 +182,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.87   {                                               \
    3.88   	(Packet)->Private.Head = (PNDIS_BUFFER)NULL;  \
    3.89   	(Packet)->Private.ValidCounts = FALSE;        \
    3.90 -@@ -2967,6 +3029,11 @@ NdisMWanIndicateReceive(
    3.91 +@@ -2967,6 +3027,11 @@
    3.92     /*IN*/ PUCHAR  PacketBuffer,
    3.93     /*IN*/ UINT  PacketSize);
    3.94   
    3.95 @@ -196,7 +194,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
    3.96   NDISAPI
    3.97   VOID
    3.98   DDKAPI
    3.99 -@@ -3155,6 +3222,13 @@ DDKAPI
   3.100 +@@ -3155,6 +3220,13 @@
   3.101   DDKAPI
   3.102   NdisPacketPoolUsage(
   3.103     /*IN*/ NDIS_HANDLE  PoolHandle);
   3.104 @@ -210,7 +208,7 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
   3.105   
   3.106   NDISAPI
   3.107   NDIS_STATUS
   3.108 -@@ -4517,6 +4591,29 @@ struct _NDIS_OPEN_BLOCK
   3.109 +@@ -4517,6 +4589,29 @@
   3.110   
   3.111   /* Routines for NDIS miniport drivers */
   3.112   
   3.113 @@ -240,27 +238,22 @@ diff -r 8a2d0356d23d include/ddk/ndis.h
   3.114   NDISAPI
   3.115   VOID
   3.116   DDKAPI
   3.117 -diff -r 8a2d0356d23d include/ddk/ntddndis.h
   3.118 ---- a/include/ddk/ntddndis.h	Wed Jul 09 12:54:30 2008 -0700
   3.119 -+++ b/include/ddk/ntddndis.h	Wed Jul 09 12:54:42 2008 -0700
   3.120 -@@ -179,6 +179,13 @@ typedef struct _NDIS_PNP_CAPABILITIES {
   3.121 - #define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS    0x00800000
   3.122 - #define NDIS_MINIPORT_64BITS_DMA                      0x01000000
   3.123 +diff -r 0717ca718d88 include/ddk/ntddndis.h
   3.124 +--- a/include/ddk/ntddndis.h	Tue Jul 08 21:35:58 2008 -0700
   3.125 ++++ b/include/ddk/ntddndis.h	Thu Jul 17 23:09:31 2008 -0700
   3.126 +@@ -152,6 +152,8 @@
   3.127 + #define OID_802_3_XMIT_TIMES_CRS_LOST     0x01020206
   3.128 + #define OID_802_3_XMIT_LATE_COLLISIONS    0x01020207
   3.129   
   3.130 -+/* TCP offload OIDs */
   3.131 -+#define OID_TCP_TASK_OFFLOAD                0xFC010201
   3.132 -+#define OID_TCP_TASK_IPSEC_ADD_SA           0xFC010202
   3.133 -+#define OID_TCP_TASK_IPSEC_ADD_UDPESP_SA    0xFC010203
   3.134 -+#define OID_TCP_TASK_IPSEC_DELETE_SA        0xFC010204
   3.135 -+#define OID_TCP_TASK_IPSEC_DELETE_UDPESP_SA 0xFC010205
   3.136 ++#define OID_TCP_TASK_OFFLOAD              0xFC010201
   3.137  +
   3.138 - #pragma pack(pop)
   3.139 - 
   3.140 - #ifdef __cplusplus
   3.141 -diff -r 8a2d0356d23d include/ddk/scsi.h
   3.142 ---- a/include/ddk/scsi.h	Wed Jul 09 12:54:30 2008 -0700
   3.143 -+++ b/include/ddk/scsi.h	Wed Jul 09 12:54:42 2008 -0700
   3.144 -@@ -1272,6 +1272,13 @@ typedef struct _SENSE_DATA {
   3.145 + /* OID_GEN_MINIPORT_INFO constants */
   3.146 + #define NDIS_MINIPORT_BUS_MASTER                      0x00000001
   3.147 + #define NDIS_MINIPORT_WDM_DRIVER                      0x00000002
   3.148 +diff -r 0717ca718d88 include/ddk/scsi.h
   3.149 +--- a/include/ddk/scsi.h	Tue Jul 08 21:35:58 2008 -0700
   3.150 ++++ b/include/ddk/scsi.h	Thu Jul 17 23:09:31 2008 -0700
   3.151 +@@ -1272,6 +1272,13 @@
   3.152   #define IOCTL_SCSI_MINIPORT_NOT_QUORUM_CAPABLE  ((FILE_DEVICE_SCSI << 16) + 0x0520)
   3.153   #define IOCTL_SCSI_MINIPORT_NOT_CLUSTER_CAPABLE ((FILE_DEVICE_SCSI << 16) + 0x0521)
   3.154   
   3.155 @@ -274,21 +267,67 @@ diff -r 8a2d0356d23d include/ddk/scsi.h
   3.156   /* Read Capacity Data. Returned in Big Endian format */
   3.157   typedef struct _READ_CAPACITY_DATA {
   3.158     ULONG  LogicalBlockAddress;
   3.159 -diff -r 8a2d0356d23d include/ddk/winddk.h
   3.160 ---- a/include/ddk/winddk.h	Wed Jul 09 12:54:30 2008 -0700
   3.161 -+++ b/include/ddk/winddk.h	Wed Jul 09 12:54:42 2008 -0700
   3.162 -@@ -4896,6 +4896,10 @@ RtlStringFromGUID(
   3.163 +diff -r 0717ca718d88 include/ddk/winddk.h
   3.164 +--- a/include/ddk/winddk.h	Tue Jul 08 21:35:58 2008 -0700
   3.165 ++++ b/include/ddk/winddk.h	Thu Jul 17 23:09:31 2008 -0700
   3.166 +@@ -3828,7 +3828,7 @@
   3.167 +  *   VOID)
   3.168 +  */
   3.169 + #define KeGetCurrentProcessorNumber() \
   3.170 +-  ((ULONG)KeGetCurrentKPCR()->ProcessorNumber)
   3.171 ++  ((ULONG)KeGetCurrentKPCR()->Number)
   3.172 + 
   3.173 + 
   3.174 + #if  __USE_NTOSKRNL__
   3.175 +@@ -3842,13 +3842,13 @@
   3.176 + LONG
   3.177 + DDKFASTAPI
   3.178 + InterlockedIncrement(
   3.179 +-  /*IN*/ PLONG  VOLATILE  Addend);
   3.180 ++  /*IN*/ LONG VOLATILE *Addend);
   3.181 + 
   3.182 + NTOSAPI
   3.183 + LONG
   3.184 + DDKFASTAPI
   3.185 + InterlockedDecrement(
   3.186 +-  /*IN*/ PLONG  VOLATILE  Addend);
   3.187 ++  /*IN*/ LONG VOLATILE *Addend);
   3.188 + 
   3.189 + NTOSAPI
   3.190 + LONG
   3.191 +@@ -4895,6 +4895,10 @@
   3.192 + RtlStringFromGUID( 
   3.193     /*IN*/ REFGUID  Guid, 
   3.194     /*OUT*/ PUNICODE_STRING  GuidString);
   3.195 - 
   3.196 ++
   3.197  +#define RtlStringCbCopyA(dst, dst_len, src) strncpy(dst, src, dst_len)
   3.198  +#define RtlStringCbPrintfA(args...) snprintf(args)
   3.199  +#define RtlStringCbVPrintfA(args...) vsnprintf(args)
   3.200 -+
   3.201 + 
   3.202   NTOSAPI
   3.203   BOOLEAN
   3.204 +@@ -7350,6 +7354,11 @@
   3.205 + #define KeFlushIoBuffers(_Mdl, _ReadOperation, _DmaOperation)
   3.206 + 
   3.207 + NTOSAPI
   3.208 ++VOID
   3.209 ++DDKAPI
   3.210 ++KeFlushQueuedDpcs(VOID);
   3.211 ++
   3.212 ++NTOSAPI
   3.213 + PRKTHREAD
   3.214   DDKAPI
   3.215 -@@ -7726,38 +7730,18 @@ KeWaitForSingleObject(
   3.216 + KeGetCurrentThread(
   3.217 +@@ -7448,6 +7457,8 @@
   3.218 + DDKAPI
   3.219 + KeLeaveCriticalRegion(
   3.220 +   VOID);
   3.221 ++
   3.222 ++#define KeMemoryBarrier() asm("mfence;")
   3.223 + 
   3.224 + NTOSAPI
   3.225 + NTSTATUS
   3.226 +@@ -7719,38 +7730,18 @@
   3.227     /*IN*/ BOOLEAN  Alertable,
   3.228     /*IN*/ PLARGE_INTEGER  Timeout  /*OPTIONAL*/);
   3.229   
   3.230 @@ -334,10 +373,10 @@ diff -r 8a2d0356d23d include/ddk/winddk.
   3.231   
   3.232   NTOSAPI
   3.233   KIRQL
   3.234 -diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.235 ---- a/lib/ddk/ndis.def	Wed Jul 09 12:54:30 2008 -0700
   3.236 -+++ b/lib/ddk/ndis.def	Wed Jul 09 12:54:42 2008 -0700
   3.237 -@@ -130,8 +130,8 @@ NdisImmediateReadSharedMemory@16
   3.238 +diff -r 0717ca718d88 lib/ddk/ndis.def
   3.239 +--- a/lib/ddk/ndis.def	Tue Jul 08 21:35:58 2008 -0700
   3.240 ++++ b/lib/ddk/ndis.def	Thu Jul 17 23:09:31 2008 -0700
   3.241 +@@ -130,8 +130,8 @@
   3.242   ;NdisImmediateWritePortUlong
   3.243   ;NdisImmediateWritePortUshort
   3.244   NdisImmediateWriteSharedMemory@16
   3.245 @@ -348,7 +387,7 @@ diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.246   ;NdisInitializeEvent
   3.247   NdisInitializeReadWriteLock@4
   3.248   ;NdisInitializeString
   3.249 -@@ -149,7 +149,7 @@ NdisMAllocateMapRegisters@20
   3.250 +@@ -149,7 +149,7 @@
   3.251   NdisMAllocateMapRegisters@20
   3.252   NdisMAllocateSharedMemory@20
   3.253   NdisMAllocateSharedMemoryAsync@16
   3.254 @@ -357,7 +396,7 @@ diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.255   NdisMCloseLog@4
   3.256   NdisMCmActivateVc@8
   3.257   NdisMCmCreateVc@16
   3.258 -@@ -179,7 +179,7 @@ NdisMGetDeviceProperty@24
   3.259 +@@ -179,7 +179,7 @@
   3.260   ;NdisMIndicateStatus
   3.261   ;NdisMIndicateStatusComplete
   3.262   NdisMInitializeScatterGatherDma@12
   3.263 @@ -366,7 +405,7 @@ diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.264   NdisMMapIoSpace@20
   3.265   ;NdisMPciAssignResources
   3.266   NdisMPromoteMiniport@4
   3.267 -@@ -202,7 +202,7 @@ NdisMSetAttributesEx@20
   3.268 +@@ -202,7 +202,7 @@
   3.269   NdisMSetAttributesEx@20
   3.270   ;NdisMSetInformationComplete
   3.271   NdisMSetMiniportSecondary@8
   3.272 @@ -375,7 +414,7 @@ diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.273   ;NdisMSetTimer
   3.274   NdisMSleep@4
   3.275   ;NdisMStartBufferPhysicalMapping
   3.276 -@@ -252,7 +252,7 @@ NdisSendPackets@12
   3.277 +@@ -252,7 +252,7 @@
   3.278   NdisSendPackets@12
   3.279   ;NdisSetEvent
   3.280   ;NdisSetPacketCancelId
   3.281 @@ -384,10 +423,30 @@ diff -r 8a2d0356d23d lib/ddk/ndis.def
   3.282   ;NdisSetPacketStatus
   3.283   ;NdisSetProtocolFilter
   3.284   ;NdisSetTimer
   3.285 -diff -r 8a2d0356d23d lib/ddk/scsiport.def
   3.286 ---- a/lib/ddk/scsiport.def	Wed Jul 09 12:54:30 2008 -0700
   3.287 -+++ b/lib/ddk/scsiport.def	Wed Jul 09 12:54:42 2008 -0700
   3.288 -@@ -8,7 +8,7 @@ ScsiPortFlushDma@4
   3.289 +diff -r 0717ca718d88 lib/ddk/ntoskrnl.def
   3.290 +--- a/lib/ddk/ntoskrnl.def	Tue Jul 08 21:35:58 2008 -0700
   3.291 ++++ b/lib/ddk/ntoskrnl.def	Thu Jul 17 23:09:31 2008 -0700
   3.292 +@@ -506,6 +506,7 @@
   3.293 + ;KeFindConfigurationEntry
   3.294 + ;KeFindConfigurationNextEntry
   3.295 + ;KeFlushEntireTb
   3.296 ++KeFlushQueuedDpcs@0
   3.297 + KeGetCurrentThread@0
   3.298 + KeGetPreviousMode@0
   3.299 + KeGetRecommendedSharedDataAlignment@0
   3.300 +@@ -542,7 +543,7 @@
   3.301 + ;KeIsExecutingDpc
   3.302 + KeLeaveCriticalRegion@0
   3.303 + ;KeLoaderBlock DATA
   3.304 +-;KeNumberProcessors DATA
   3.305 ++KeNumberProcessors DATA
   3.306 + ;KeProfileInterrupt
   3.307 + ;KeProfileInterruptWithSource
   3.308 + KePulseEvent@12
   3.309 +diff -r 0717ca718d88 lib/ddk/scsiport.def
   3.310 +--- a/lib/ddk/scsiport.def	Tue Jul 08 21:35:58 2008 -0700
   3.311 ++++ b/lib/ddk/scsiport.def	Thu Jul 17 23:09:31 2008 -0700
   3.312 +@@ -8,7 +8,7 @@
   3.313   ScsiPortFlushDma@4
   3.314   ScsiPortFreeDeviceBase@8
   3.315   ScsiPortGetBusData@24
     4.1 --- a/xennet/makefile.mingw	Fri Jul 18 23:22:01 2008 +1000
     4.2 +++ b/xennet/makefile.mingw	Sat Jul 19 11:35:24 2008 +1000
     4.3 @@ -1,6 +1,6 @@
     4.4  W32API_PATH=/home/agrover/temp/w32api-3.11
     4.5  
     4.6 -CFLAGS = -g -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas -DDBG
     4.7 +CFLAGS = -O2 -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas -DDBG
     4.8  
     4.9  xennet.sys: xennet.c xennet_oid.c xennet_tx.c xennet_rx.c xennet_common.c ../mingw/mingw_extras.c
    4.10  	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -shared -Wl,--entry,_DriverEntry@8 -nostartfiles -nostdlib $^ -lntoskrnl -lhal -lndis
     5.1 --- a/xennet/xennet.c	Fri Jul 18 23:22:01 2008 +1000
     5.2 +++ b/xennet/xennet.c	Sat Jul 19 11:35:24 2008 +1000
     5.3 @@ -289,7 +289,7 @@ XenNet_Init(
     5.4    NDIS_STATUS status;
     5.5    BOOLEAN medium_found = FALSE;
     5.6    struct xennet_info *xi = NULL;
     5.7 -  ULONG nrl_length;
     5.8 +  UINT nrl_length;
     5.9    PNDIS_RESOURCE_LIST nrl;
    5.10    PCM_PARTIAL_RESOURCE_DESCRIPTOR prd;
    5.11    KIRQL irq_level = 0;
     6.1 --- a/xennet/xennet_common.c	Fri Jul 18 23:22:01 2008 +1000
     6.2 +++ b/xennet/xennet_common.c	Sat Jul 19 11:35:24 2008 +1000
     6.3 @@ -125,11 +125,11 @@ XenNet_GetData(
     6.4    PNDIS_BUFFER mdl = pi->mdls[pi->curr_mdl];
     6.5    PUCHAR buffer = (PUCHAR)MmGetMdlVirtualAddress(mdl) + pi->curr_mdl_offset;
     6.6  
     6.7 -//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     6.8 +  //FUNCTION_ENTER();
     6.9  
    6.10    *length = (USHORT)min(req_length, MmGetMdlByteCount(mdl) - pi->curr_mdl_offset);
    6.11  
    6.12 -//  KdPrint((__DRIVER_NAME "     req_length = %d, length = %d\n", req_length, *length));
    6.13 +  //FUNCTION_MSG(("req_length = %d, length = %d\n", req_length, *length));
    6.14  
    6.15    pi->curr_mdl_offset = pi->curr_mdl_offset + *length;
    6.16    if (pi->curr_mdl_offset == MmGetMdlByteCount(mdl))
    6.17 @@ -138,7 +138,7 @@ XenNet_GetData(
    6.18      pi->curr_mdl_offset = 0;
    6.19    }
    6.20  
    6.21 -//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    6.22 +  //FUNCTION_EXIT();
    6.23  
    6.24    return buffer;
    6.25  }
    6.26 @@ -162,11 +162,10 @@ XenFreelist_Timer(
    6.27  
    6.28    if (fl->xi->device_state->resume_state != RESUME_STATE_RUNNING && !fl->grants_resumed)
    6.29      return;
    6.30 -    
    6.31 +
    6.32    KeAcquireSpinLockAtDpcLevel(fl->lock);
    6.33  
    6.34 -  //KdPrint((__DRIVER_NAME " --- timer - page_free_lowest = %d\n", fl->page_free_lowest));
    6.35 -//  KdPrint((__DRIVER_NAME " --- rx_outstanding = %d, rx_id_free = %d\n", xi->rx_outstanding, xi->rx_id_free));
    6.36 +  //FUNCTION_MSG((" --- timer - page_free_lowest = %d\n", fl->page_free_lowest));
    6.37  
    6.38    if (fl->page_free_lowest > fl->page_free_target) // lots of potential for tuning here
    6.39    {
    6.40 @@ -177,14 +176,12 @@ XenFreelist_Timer(
    6.41          *(grant_ref_t *)(((UCHAR *)mdl) + MmSizeOfMdl(0, PAGE_SIZE)), 0);
    6.42        FreePages(mdl);
    6.43      }
    6.44 -    //KdPrint((__DRIVER_NAME " --- timer - freed %d pages\n", i));
    6.45 +    //FUNCTION_MSG((__DRIVER_NAME " --- timer - freed %d pages\n", i));
    6.46    }
    6.47  
    6.48    fl->page_free_lowest = fl->page_free;
    6.49  
    6.50    KeReleaseSpinLockFromDpcLevel(fl->lock);
    6.51 -
    6.52 -  return;
    6.53  }
    6.54  
    6.55  VOID
     7.1 --- a/xenpci/evtchn.c	Fri Jul 18 23:22:01 2008 +1000
     7.2 +++ b/xenpci/evtchn.c	Sat Jul 19 11:35:24 2008 +1000
     7.3 @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fi
     7.4  
     7.5  #if defined(__MINGW32__)
     7.6    #define xchg(p1, p2) InterlockedExchange((xen_long_t * volatile)p1, p2)
     7.7 -  /* rest implemented in mingw_extras.c */
     7.8 +  /* rest implemented in mingw_extras.c */
     7.9  #elif defined(_X86_)
    7.10    #define xchg(p1, p2) _InterlockedExchange(p1, p2)
    7.11    #define synch_clear_bit(p1, p2) _interlockedbittestandreset(p2, p1)
    7.12 @@ -116,7 +116,7 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    7.13  {
    7.14    PXENPCI_DEVICE_DATA xpdd = Context;
    7.15  
    7.16 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    7.17 +  FUNCTION_ENTER();
    7.18    
    7.19    if (xpdd->ev_actions[Port].type != EVT_ACTION_TYPE_EMPTY)
    7.20    {
    7.21 @@ -133,7 +133,7 @@ EvtChn_Bind(PVOID Context, evtchn_port_t
    7.22  
    7.23    EvtChn_Unmask(Context, Port);
    7.24  
    7.25 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    7.26 +  FUNCTION_EXIT();
    7.27  
    7.28    return STATUS_SUCCESS;
    7.29  }
    7.30 @@ -143,7 +143,7 @@ EvtChn_BindDpc(PVOID Context, evtchn_por
    7.31  {
    7.32    PXENPCI_DEVICE_DATA xpdd = Context;
    7.33  
    7.34 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    7.35 +  FUNCTION_ENTER();
    7.36  
    7.37    if (xpdd->ev_actions[Port].type != EVT_ACTION_TYPE_EMPTY)
    7.38    {
    7.39 @@ -161,7 +161,7 @@ EvtChn_BindDpc(PVOID Context, evtchn_por
    7.40  
    7.41    EvtChn_Unmask(Context, Port);
    7.42  
    7.43 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    7.44 +  FUNCTION_EXIT();
    7.45  
    7.46    return STATUS_SUCCESS;
    7.47  }
    7.48 @@ -171,7 +171,7 @@ EvtChn_BindIrq(PVOID Context, evtchn_por
    7.49  {
    7.50    PXENPCI_DEVICE_DATA xpdd = Context;
    7.51  
    7.52 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    7.53 +  FUNCTION_ENTER();
    7.54  
    7.55    if (xpdd->ev_actions[Port].type != EVT_ACTION_TYPE_EMPTY)
    7.56    {
    7.57 @@ -188,7 +188,7 @@ EvtChn_BindIrq(PVOID Context, evtchn_por
    7.58  
    7.59    EvtChn_Unmask(Context, Port);
    7.60  
    7.61 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    7.62 +  FUNCTION_EXIT();
    7.63  
    7.64    return STATUS_SUCCESS;
    7.65  }
    7.66 @@ -256,7 +256,7 @@ EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    7.67  {
    7.68    int i;
    7.69  
    7.70 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    7.71 +  FUNCTION_ENTER();
    7.72  
    7.73    for (i = 0; i < NR_EVENTS; i++)
    7.74    {
    7.75 @@ -284,7 +284,7 @@ EvtChn_Init(PXENPCI_DEVICE_DATA xpdd)
    7.76      xpdd->shared_info_area->vcpu_info[i].evtchn_upcall_mask = 0;
    7.77    }
    7.78    
    7.79 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    7.80 +  FUNCTION_EXIT();
    7.81    
    7.82    return STATUS_SUCCESS;
    7.83  }
     8.1 --- a/xenpci/gnttbl.c	Fri Jul 18 23:22:01 2008 +1000
     8.2 +++ b/xenpci/gnttbl.c	Sat Jul 19 11:35:24 2008 +1000
     8.3 @@ -130,7 +130,7 @@ static inline short InterlockedCompareEx
     8.4      : "r"(exch), "m"(*(dest)), "0"(comp)
     8.5      : "memory");
     8.6  
     8.7 -  KdPrint((__FUNC__ " Check that I work as expected!\n"));
     8.8 +  FUNCTION_MSG(("Check that I work as expected!\n"));
     8.9  
    8.10    return prev;
    8.11  }
     9.1 --- a/xenpci/hypercall.h	Fri Jul 18 23:22:01 2008 +1000
     9.2 +++ b/xenpci/hypercall.h	Sat Jul 19 11:35:24 2008 +1000
     9.3 @@ -35,13 +35,13 @@ hvm_get_parameter(PXENPCI_DEVICE_DATA xp
     9.4    struct xen_hvm_param a;
     9.5    int retval;
     9.6  
     9.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
     9.8 +  FUNCTION_ENTER();
     9.9    a.domid = DOMID_SELF;
    9.10    a.index = hvm_param;
    9.11    //a.value = via;
    9.12    retval = HYPERVISOR_hvm_op(xpdd, HVMOP_get_param, &a);
    9.13    KdPrint((__DRIVER_NAME " HYPERVISOR_hvm_op retval = %d\n", retval));
    9.14 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    9.15 +  FUNCTION_EXIT();
    9.16    return a.value;
    9.17  }
    9.18  
    9.19 @@ -51,14 +51,14 @@ hvm_set_parameter(PXENPCI_DEVICE_DATA xp
    9.20    struct xen_hvm_param a;
    9.21    int retval;
    9.22  
    9.23 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    9.24 +  FUNCTION_ENTER();
    9.25    a.domid = DOMID_SELF;
    9.26    a.index = hvm_param;
    9.27    a.value = value;
    9.28    //a.value = via;
    9.29    retval = HYPERVISOR_hvm_op(xpdd, HVMOP_set_param, &a);
    9.30    KdPrint((__DRIVER_NAME " HYPERVISOR_hvm_op retval = %d\n", retval));
    9.31 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    9.32 +  FUNCTION_EXIT();
    9.33    return retval;
    9.34  }
    9.35  
    9.36 @@ -68,10 +68,10 @@ hvm_shutdown(PXENPCI_DEVICE_DATA xpdd, u
    9.37    struct sched_shutdown ss;
    9.38    int retval;
    9.39  
    9.40 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    9.41 +  FUNCTION_ENTER();
    9.42    ss.reason = reason;
    9.43    retval = HYPERVISOR_sched_op(xpdd, SCHEDOP_shutdown, &ss);
    9.44 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
    9.45 +  FUNCTION_EXIT();
    9.46    return retval;
    9.47  }
    9.48  
    10.1 --- a/xenpci/hypercall_x86_mingw.h	Fri Jul 18 23:22:01 2008 +1000
    10.2 +++ b/xenpci/hypercall_x86_mingw.h	Sat Jul 19 11:35:24 2008 +1000
    10.3 @@ -35,22 +35,22 @@
    10.4      : "memory" );                                               \
    10.5    (type)__res;                                                  \
    10.6  })
    10.7 -
    10.8 -#define _hypercall3(type, name, a1, a2, a3)			                \
    10.9 -({								                                              \
   10.10 -	long __res, __ign1, __ign2, __ign3;			                      \
   10.11 -	asm volatile (						                                    \
   10.12 +
   10.13 +#define _hypercall3(type, name, a1, a2, a3)			                \
   10.14 +({								                                              \
   10.15 +	long __res, __ign1, __ign2, __ign3;			                      \
   10.16 +	asm volatile (						                                    \
   10.17  	  "mov %4,%%eax; "                                            \
   10.18  	  "add $("STR(__HYPERVISOR_##name)" * 32),%%eax; "            \
   10.19    	"call *%%eax"                                               \
   10.20 -		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	            \
   10.21 -		"=d" (__ign3)					                                      \
   10.22 -		: "1" ((long)(a1)), "2" ((long)(a2)),		                    \
   10.23 -		"3" ((long)(a3)), "r" (xpdd->hypercall_stubs)		            \
   10.24 -		: "memory" );					                                      \
   10.25 -	(type)__res;						                                      \
   10.26 -})
   10.27 -
   10.28 +		: "=a" (__res), "=b" (__ign1), "=c" (__ign2), 	            \
   10.29 +		"=d" (__ign3)					                                      \
   10.30 +		: "1" ((long)(a1)), "2" ((long)(a2)),		                    \
   10.31 +		"3" ((long)(a3)), "r" (xpdd->hypercall_stubs)		            \
   10.32 +		: "memory" );					                                      \
   10.33 +	(type)__res;						                                      \
   10.34 +})
   10.35 +
   10.36  
   10.37  static __inline void __cpuid(uint32_t output[4], uint32_t op)
   10.38  {
   10.39 @@ -96,13 +96,13 @@ HYPERVISOR_event_channel_op(PXENPCI_DEVI
   10.40  {
   10.41  	return _hypercall2(int, event_channel_op, cmd, arg);
   10.42  }
   10.43 -
   10.44 static inline int
   10.45 -HYPERVISOR_grant_table_op(
   10.46 -  PXENPCI_DEVICE_DATA xpdd,
   10.47 -  unsigned int cmd,
   10.48 -  void *uop,
   10.49 -  unsigned int count)
   10.50 -{
   10.51 -	return _hypercall3(int, grant_table_op, cmd, uop, count);
   10.52 -}
   10.53 -
   10.54 +
   10.55 static inline int
   10.56 +HYPERVISOR_grant_table_op(
   10.57 +  PXENPCI_DEVICE_DATA xpdd,
   10.58 +  unsigned int cmd,
   10.59 +  void *uop,
   10.60 +  unsigned int count)
   10.61 +{
   10.62 +	return _hypercall3(int, grant_table_op, cmd, uop, count);
   10.63 +}
   10.64 +
    11.1 --- a/xenpci/makefile.mingw	Fri Jul 18 23:22:01 2008 +1000
    11.2 +++ b/xenpci/makefile.mingw	Sat Jul 19 11:35:24 2008 +1000
    11.3 @@ -1,12 +1,8 @@
    11.4  W32API_PATH=/home/agrover/temp/w32api-3.11
    11.5  
    11.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
    11.7 +CFLAGS = -O2 -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas -DDBG
    11.8  
    11.9  xenpci.sys: xenpci.c xenbus.c evtchn.c gnttbl.c xenpci_fdo.c xenpci_pdo.c memory.c ../mingw/mingw_extras.c
   11.10 -	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s -shared -Wl,--entry,_load@8 -nostdlib $^ -lntoskrnl -lhal
   11.11 +	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -shared -Wl,--entry,_DriverEntry@8 -nostartfiles -nostdlib $^ -lntoskrnl -lhal
   11.12  
   11.13 -test.exe: test.c kexec.h
   11.14 -	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s $^ -lkernel32
   11.15  
   11.16 -all: xenpci.sys
   11.17 -
    12.1 --- a/xenpci/xenbus.c	Fri Jul 18 23:22:01 2008 +1000
    12.2 +++ b/xenpci/xenbus.c	Sat Jul 19 11:35:24 2008 +1000
    12.3 @@ -210,7 +210,7 @@ xenbus_msg_reply(
    12.4    xb_write(xpdd, type, id, trans, io, nr_reqs);
    12.5  
    12.6    KeWaitForSingleObject(&xpdd->req_info[id].WaitEvent, Executive, KernelMode, FALSE, NULL);
    12.7 -  
    12.8 +
    12.9    release_xenbus_id(xpdd, id);
   12.10  
   12.11    //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   12.12 @@ -604,7 +604,7 @@ XenBus_Resume(PXENPCI_DEVICE_DATA xpdd)
   12.13    NTSTATUS status;
   12.14    int i;
   12.15  
   12.16 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   12.17 +  FUNCTION_ENTER();
   12.18  
   12.19    status = XenBus_Connect(xpdd);
   12.20    if (!NT_SUCCESS(status))
   12.21 @@ -620,7 +620,7 @@ XenBus_Resume(PXENPCI_DEVICE_DATA xpdd)
   12.22        XenBus_SendAddWatch(xpdd, XBT_NIL, xpdd->XenBus_WatchEntries[i].Path, i);
   12.23      }
   12.24    }
   12.25 -  KdPrint((__DRIVER_NAME " <-- XenBus_AddWatch\n"));
   12.26 +  FUNCTION_EXIT();
   12.27    
   12.28    return STATUS_SUCCESS;
   12.29  }
   12.30 @@ -854,7 +854,7 @@ XenBus_Printf(
   12.31    char buf[512];
   12.32    char *retval;
   12.33  
   12.34 -  //KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   12.35 +//  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   12.36    ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL);
   12.37  
   12.38    va_start(ap, fmt);
   12.39 @@ -862,7 +862,7 @@ XenBus_Printf(
   12.40    va_end(ap);
   12.41    retval = XenBus_Write(xpdd, xbt, path, buf);
   12.42  
   12.43 -  //KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   12.44 +//  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   12.45  
   12.46    return retval;
   12.47  }
    13.1 --- a/xenpci/xenpci.c	Fri Jul 18 23:22:01 2008 +1000
    13.2 +++ b/xenpci/xenpci.c	Sat Jul 19 11:35:24 2008 +1000
    13.3 @@ -128,7 +128,7 @@ XenPci_AddDevice(PDRIVER_OBJECT DriverOb
    13.4    PXENPCI_DEVICE_DATA xpdd;
    13.5    //PWSTR InterfaceList;
    13.6  
    13.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    13.8 +  FUNCTION_ENTER();
    13.9  
   13.10    status = IoCreateDevice(DriverObject,
   13.11      sizeof(XENPCI_DEVICE_DATA),
   13.12 @@ -185,18 +185,18 @@ XenPci_AddDevice(PDRIVER_OBJECT DriverOb
   13.13    
   13.14    fdo->Flags &= ~DO_DEVICE_INITIALIZING;
   13.15  
   13.16 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   13.17 +  FUNCTION_EXIT();
   13.18    return status;
   13.19  }
   13.20  
   13.21 -NTSTATUS
   13.22 +NTSTATUS DDKAPI
   13.23  DriverEntry(PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
   13.24  {
   13.25    NTSTATUS status = STATUS_SUCCESS;
   13.26  
   13.27    UNREFERENCED_PARAMETER(RegistryPath);
   13.28  
   13.29 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   13.30 +  FUNCTION_ENTER();
   13.31  
   13.32    //InitializeListHead(&ShutdownMsgList);
   13.33    //KeInitializeSpinLock(&ShutdownMsgLock);
   13.34 @@ -212,7 +212,7 @@ DriverEntry(PDRIVER_OBJECT DriverObject,
   13.35    DriverObject->MajorFunction[IRP_MJ_WRITE] = NULL; //XenPci_Dummy;
   13.36    DriverObject->MajorFunction[IRP_MJ_SYSTEM_CONTROL] = NULL; //XenPci_Dummy;
   13.37  
   13.38 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   13.39 +  FUNCTION_EXIT();
   13.40  
   13.41    return status;
   13.42  }
    14.1 --- a/xenpci/xenpci_fdo.c	Fri Jul 18 23:22:01 2008 +1000
    14.2 +++ b/xenpci/xenpci_fdo.c	Sat Jul 19 11:35:24 2008 +1000
    14.3 @@ -52,7 +52,7 @@ XenPci_Power_Fdo(PDEVICE_OBJECT device_o
    14.4  
    14.5    UNREFERENCED_PARAMETER(device_object);
    14.6    
    14.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    14.8 +  FUNCTION_ENTER();
    14.9  
   14.10    stack = IoGetCurrentIrpStackLocation(irp);
   14.11    power_type = stack->Parameters.Power.Type;
   14.12 @@ -86,7 +86,7 @@ XenPci_Power_Fdo(PDEVICE_OBJECT device_o
   14.13    IoSkipCurrentIrpStackLocation(irp);
   14.14    status =  PoCallDriver (xpdd->common.lower_do, irp);
   14.15    
   14.16 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   14.17 +  FUNCTION_EXIT();
   14.18  
   14.19    return status;
   14.20  }
   14.21 @@ -98,14 +98,14 @@ XenPci_Dummy_Fdo(PDEVICE_OBJECT device_o
   14.22    PIO_STACK_LOCATION stack;
   14.23    PXENPCI_DEVICE_DATA xpdd;
   14.24  
   14.25 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   14.26 +  FUNCTION_ENTER();
   14.27  
   14.28    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
   14.29    stack = IoGetCurrentIrpStackLocation(irp);
   14.30    IoSkipCurrentIrpStackLocation(irp);
   14.31    status = IoCallDriver(xpdd->common.lower_do, irp);
   14.32  
   14.33 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   14.34 +  FUNCTION_EXIT();
   14.35  
   14.36    return status;
   14.37  }
   14.38 @@ -135,7 +135,7 @@ XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
   14.39    struct xen_add_to_physmap xatp;
   14.40    int ret;
   14.41  
   14.42 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   14.43 +  FUNCTION_ENTER();
   14.44  
   14.45    hvm_get_stubs(xpdd);
   14.46  
   14.47 @@ -156,7 +156,7 @@ XenPci_Init(PXENPCI_DEVICE_DATA xpdd)
   14.48    ret = HYPERVISOR_memory_op(xpdd, XENMEM_add_to_physmap, &xatp);
   14.49    KdPrint((__DRIVER_NAME " hypervisor memory op ret = %d\n", ret));
   14.50  
   14.51 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   14.52 +  FUNCTION_EXIT();
   14.53  
   14.54    return STATUS_SUCCESS;
   14.55  }
   14.56 @@ -168,14 +168,14 @@ XenPci_Pnp_IoCompletion(PDEVICE_OBJECT d
   14.57  
   14.58    UNREFERENCED_PARAMETER(device_object);
   14.59  
   14.60 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   14.61 +  FUNCTION_ENTER();
   14.62  
   14.63    if (irp->PendingReturned)
   14.64    {
   14.65      KeSetEvent(event, IO_NO_INCREMENT, FALSE);
   14.66    }
   14.67  
   14.68 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   14.69 +  FUNCTION_EXIT();
   14.70  
   14.71    return STATUS_MORE_PROCESSING_REQUIRED;
   14.72  }
   14.73 @@ -201,7 +201,7 @@ XenPci_SendAndWaitForIrp(PDEVICE_OBJECT 
   14.74  
   14.75    UNREFERENCED_PARAMETER(device_object);
   14.76  
   14.77 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   14.78 +  FUNCTION_ENTER();
   14.79  
   14.80    KeInitializeEvent(&event, NotificationEvent, FALSE);
   14.81  
   14.82 @@ -218,7 +218,7 @@ XenPci_SendAndWaitForIrp(PDEVICE_OBJECT 
   14.83      status = irp->IoStatus.Status;
   14.84    }
   14.85  
   14.86 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
   14.87 +  FUNCTION_EXIT();
   14.88  
   14.89    return status;
   14.90  }
   14.91 @@ -232,7 +232,7 @@ XenPci_ProcessShutdownIrp(PXENPCI_DEVICE
   14.92    KIRQL old_irql;
   14.93    ULONG length;
   14.94  
   14.95 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   14.96 +  FUNCTION_ENTER();
   14.97  
   14.98    KeAcquireSpinLock(&xpdd->shutdown_ring_lock, &old_irql);
   14.99    if (xpdd->shutdown_irp)
  14.100 @@ -276,7 +276,7 @@ XenPci_ProcessShutdownIrp(PXENPCI_DEVICE
  14.101      status = STATUS_SUCCESS;
  14.102    }  
  14.103  
  14.104 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.105 +  FUNCTION_EXIT();
  14.106  
  14.107    return status;
  14.108  }
  14.109 @@ -287,7 +287,7 @@ XenBus_ShutdownIoCancel(PDEVICE_OBJECT d
  14.110    PXENPCI_DEVICE_DATA xpdd;
  14.111    KIRQL old_irql;
  14.112  
  14.113 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.114 +  FUNCTION_ENTER();
  14.115  
  14.116    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.117    IoReleaseCancelSpinLock(irp->CancelIrql);
  14.118 @@ -302,7 +302,7 @@ XenBus_ShutdownIoCancel(PDEVICE_OBJECT d
  14.119    KeReleaseSpinLock(&xpdd->shutdown_ring_lock, old_irql);
  14.120    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.121  
  14.122 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.123 +  FUNCTION_EXIT();
  14.124  }
  14.125  
  14.126  struct {
  14.127 @@ -320,7 +320,7 @@ XenPci_CompleteResume(PDEVICE_OBJECT dev
  14.128    PXEN_CHILD child;
  14.129  
  14.130    UNREFERENCED_PARAMETER(context);
  14.131 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.132 +  FUNCTION_ENTER();
  14.133  
  14.134    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.135  
  14.136 @@ -346,7 +346,7 @@ XenPci_CompleteResume(PDEVICE_OBJECT dev
  14.137  
  14.138    xpdd->suspend_state = SUSPEND_STATE_NONE;
  14.139  
  14.140 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  14.141 +  FUNCTION_EXIT();
  14.142  }
  14.143  
  14.144  /* Called at DISPATCH_LEVEL */
  14.145 @@ -369,7 +369,8 @@ XenPci_Suspend(
  14.146    UNREFERENCED_PARAMETER(Dpc);
  14.147    UNREFERENCED_PARAMETER(SystemArgument2);
  14.148  
  14.149 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (CPU = %d)\n", KeGetCurrentProcessorNumber()));
  14.150 +  FUNCTION_ENTER();
  14.151 +  FUNCTION_MSG(("(CPU = %d)\n", KeGetCurrentProcessorNumber()));
  14.152  
  14.153    if (KeGetCurrentProcessorNumber() != 0)
  14.154    {
  14.155 @@ -386,9 +387,10 @@ XenPci_Suspend(
  14.156      KeMemoryBarrier();
  14.157      InterlockedDecrement(&suspend_info->nr_spinning);    
  14.158      KdPrint((__DRIVER_NAME "     ...done spinning\n"));
  14.159 -    KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (cpu = %d)\n", KeGetCurrentProcessorNumber()));
  14.160 +    FUNCTION_MSG(("(CPU = %d)\n", KeGetCurrentProcessorNumber()));
  14.161      KeLowerIrql(old_irql);
  14.162      KeSetEvent(&suspend_info->stopped_spinning_event, IO_NO_INCREMENT, FALSE);
  14.163 +    FUNCTION_EXIT();
  14.164      return;
  14.165    }
  14.166    ActiveProcessorCount = (ULONG)KeNumberProcessors;
  14.167 @@ -433,11 +435,11 @@ XenPci_Suspend(
  14.168  	work_item = IoAllocateWorkItem(xpdd->common.fdo);
  14.169  	IoQueueWorkItem(work_item, XenPci_CompleteResume, DelayedWorkQueue, suspend_info);
  14.170    
  14.171 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  14.172 +  FUNCTION_EXIT();
  14.173  }
  14.174  
  14.175  /* Called at PASSIVE_LEVEL */
  14.176 -static VOID
  14.177 +static VOID DDKAPI
  14.178  XenPci_BeginSuspend(PDEVICE_OBJECT device_object, PVOID context)
  14.179  {
  14.180    //KAFFINITY ActiveProcessorMask = 0; // this is for Vista+
  14.181 @@ -450,7 +452,7 @@ XenPci_BeginSuspend(PDEVICE_OBJECT devic
  14.182    PXEN_CHILD child;
  14.183  
  14.184    UNREFERENCED_PARAMETER(context);
  14.185 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.186 +  FUNCTION_ENTER();
  14.187  
  14.188    if (xpdd->suspend_state == SUSPEND_STATE_NONE)
  14.189    {
  14.190 @@ -488,7 +490,7 @@ XenPci_BeginSuspend(PDEVICE_OBJECT devic
  14.191      }
  14.192      KeLowerIrql(OldIrql);
  14.193    }
  14.194 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  14.195 +  FUNCTION_EXIT();
  14.196  }
  14.197  
  14.198  static void
  14.199 @@ -502,7 +504,7 @@ XenPci_ShutdownHandler(char *path, PVOID
  14.200  
  14.201    UNREFERENCED_PARAMETER(path);
  14.202  
  14.203 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.204 +  FUNCTION_ENTER();
  14.205  
  14.206    res = XenBus_Read(xpdd, XBT_NIL, SHUTDOWN_PATH, &value);
  14.207    if (res)
  14.208 @@ -542,7 +544,7 @@ XenPci_ShutdownHandler(char *path, PVOID
  14.209  
  14.210    //XenPci_FreeMem(value);
  14.211  
  14.212 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  14.213 +  FUNCTION_EXIT();
  14.214  }
  14.215  
  14.216  static VOID
  14.217 @@ -555,7 +557,7 @@ XenPci_SysrqHandler(char *path, PVOID co
  14.218  
  14.219    UNREFERENCED_PARAMETER(path);
  14.220  
  14.221 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.222 +  FUNCTION_ENTER();
  14.223  
  14.224    XenBus_Read(xpdd, XBT_NIL, SYSRQ_PATH, &value);
  14.225  
  14.226 @@ -592,7 +594,7 @@ XenPci_SysrqHandler(char *path, PVOID co
  14.227      break;
  14.228    }
  14.229  
  14.230 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  14.231 +  FUNCTION_EXIT();
  14.232  }
  14.233  
  14.234  static VOID
  14.235 @@ -689,7 +691,7 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
  14.236  
  14.237    UNREFERENCED_PARAMETER(device_object);
  14.238  
  14.239 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.240 +  FUNCTION_ENTER();
  14.241  
  14.242    stack = IoGetCurrentIrpStackLocation(irp);
  14.243  
  14.244 @@ -747,7 +749,7 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
  14.245  
  14.246    XenPci_QueueWorkItem(device_object, XenPci_Pnp_StartDeviceCallback, irp);
  14.247  
  14.248 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.249 +  FUNCTION_EXIT();
  14.250    
  14.251    return STATUS_PENDING;
  14.252  }
  14.253 @@ -760,12 +762,12 @@ XenPci_Pnp_StopDevice(PDEVICE_OBJECT dev
  14.254    UNREFERENCED_PARAMETER(device_object);
  14.255    UNREFERENCED_PARAMETER(context);
  14.256  
  14.257 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.258 +  FUNCTION_ENTER();
  14.259  
  14.260    irp->IoStatus.Status = status;
  14.261    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.262  
  14.263 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.264 +  FUNCTION_EXIT();
  14.265  
  14.266    return irp->IoStatus.Status;
  14.267  }
  14.268 @@ -778,7 +780,7 @@ XenPci_Pnp_QueryStopRemoveDevice(PDEVICE
  14.269  
  14.270    UNREFERENCED_PARAMETER(device_object);
  14.271  
  14.272 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.273 +  FUNCTION_ENTER();
  14.274  
  14.275    if (xpdd->common.device_usage_paging
  14.276      || xpdd->common.device_usage_dump
  14.277 @@ -794,7 +796,7 @@ XenPci_Pnp_QueryStopRemoveDevice(PDEVICE
  14.278      status = IoCallDriver(xpdd->common.lower_do, irp);
  14.279    }
  14.280    
  14.281 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.282 +  FUNCTION_EXIT();
  14.283  
  14.284    return status;
  14.285  }
  14.286 @@ -807,14 +809,14 @@ XenPci_Pnp_RemoveDevice(PDEVICE_OBJECT d
  14.287  
  14.288    UNREFERENCED_PARAMETER(device_object);
  14.289  
  14.290 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.291 +  FUNCTION_ENTER();
  14.292  
  14.293    irp->IoStatus.Status = STATUS_SUCCESS;
  14.294    IoSkipCurrentIrpStackLocation(irp);
  14.295    status = IoCallDriver(xpdd->common.lower_do, irp);
  14.296    IoDetachDevice(xpdd->common.lower_do);
  14.297  
  14.298 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.299 +  FUNCTION_EXIT();
  14.300  
  14.301    return status;
  14.302  }
  14.303 @@ -837,7 +839,7 @@ XenPci_Pnp_QueryBusRelationsCallback(PDE
  14.304    CHAR path[128];
  14.305    PDEVICE_OBJECT pdo;
  14.306    
  14.307 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.308 +  FUNCTION_ENTER();
  14.309  
  14.310    msg = XenBus_List(xpdd, XBT_NIL, "device", &devices);
  14.311    if (!msg)
  14.312 @@ -958,7 +960,7 @@ XenPci_Pnp_QueryBusRelationsCallback(PDE
  14.313  
  14.314    IoCompleteRequest (irp, IO_NO_INCREMENT);
  14.315  
  14.316 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.317 +  FUNCTION_EXIT();
  14.318  }
  14.319  
  14.320  static NTSTATUS
  14.321 @@ -968,7 +970,7 @@ XenPci_Pnp_QueryBusRelations(PDEVICE_OBJ
  14.322  
  14.323    UNREFERENCED_PARAMETER(device_object);
  14.324  
  14.325 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.326 +  FUNCTION_ENTER();
  14.327  
  14.328    IoMarkIrpPending(irp);
  14.329  
  14.330 @@ -976,7 +978,7 @@ XenPci_Pnp_QueryBusRelations(PDEVICE_OBJ
  14.331  
  14.332    XenPci_QueueWorkItem(device_object, XenPci_Pnp_QueryBusRelationsCallback, irp);
  14.333  
  14.334 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.335 +  FUNCTION_EXIT();
  14.336  
  14.337    return STATUS_PENDING;
  14.338  }
  14.339 @@ -992,8 +994,9 @@ XenPci_Pnp_FilterResourceRequirementsCal
  14.340    ULONG ird;
  14.341  
  14.342    UNREFERENCED_PARAMETER(device_object);
  14.343 -  
  14.344 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ " (status = %08X)\n", irp->IoStatus.Status));
  14.345 +
  14.346 +  FUNCTION_ENTER();
  14.347 +  FUNCTION_MSG(("IoStatus.status = %08X\n", irp->IoStatus.Status));
  14.348    
  14.349    irrl = (PIO_RESOURCE_REQUIREMENTS_LIST)irp->IoStatus.Information;
  14.350    for (irl = 0; irl < irrl->AlternativeLists; irl++)
  14.351 @@ -1009,9 +1012,7 @@ XenPci_Pnp_FilterResourceRequirementsCal
  14.352    irp->IoStatus.Status = status;
  14.353    IoCompleteRequest (irp, IO_NO_INCREMENT);
  14.354    
  14.355 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.356 -
  14.357 -  return;
  14.358 +  FUNCTION_EXIT();
  14.359  }
  14.360  
  14.361  static NTSTATUS
  14.362 @@ -1021,7 +1022,7 @@ XenPci_Pnp_FilterResourceRequirements(PD
  14.363  
  14.364    UNREFERENCED_PARAMETER(device_object);
  14.365  
  14.366 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.367 +  FUNCTION_ENTER();
  14.368  
  14.369    IoMarkIrpPending(irp);
  14.370  
  14.371 @@ -1029,7 +1030,7 @@ XenPci_Pnp_FilterResourceRequirements(PD
  14.372  
  14.373    XenPci_QueueWorkItem(device_object, XenPci_Pnp_FilterResourceRequirementsCallback, irp);
  14.374  
  14.375 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.376 +  FUNCTION_EXIT();
  14.377  
  14.378    return STATUS_PENDING;
  14.379  }
  14.380 @@ -1043,7 +1044,7 @@ XenPci_Pnp_DeviceUsageNotification(PDEVI
  14.381    
  14.382    UNREFERENCED_PARAMETER(context);
  14.383  
  14.384 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__"\n"));
  14.385 +  FUNCTION_ENTER();
  14.386  
  14.387    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.388    stack = IoGetCurrentIrpStackLocation(irp);
  14.389 @@ -1087,7 +1088,7 @@ XenPci_Pnp_DeviceUsageNotification(PDEVI
  14.390    }
  14.391    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.392  
  14.393 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.394 +  FUNCTION_EXIT();
  14.395    
  14.396    return status;
  14.397  }
  14.398 @@ -1251,14 +1252,14 @@ XenPci_Irp_Create_Fdo(PDEVICE_OBJECT dev
  14.399    PXENPCI_DEVICE_DATA xpdd;
  14.400    NTSTATUS status;
  14.401  
  14.402 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.403 +  FUNCTION_ENTER();
  14.404  
  14.405    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.406    status = STATUS_SUCCESS;    
  14.407    irp->IoStatus.Status = status;
  14.408    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.409  
  14.410 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.411 +  FUNCTION_EXIT();
  14.412  
  14.413    return status;
  14.414  }
  14.415 @@ -1269,7 +1270,7 @@ XenPci_Irp_Close_Fdo(PDEVICE_OBJECT devi
  14.416    PXENPCI_DEVICE_DATA xpdd;
  14.417    NTSTATUS status;
  14.418  
  14.419 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.420 +  FUNCTION_ENTER();
  14.421  
  14.422    // wait until pending irp's 
  14.423    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.424 @@ -1277,7 +1278,7 @@ XenPci_Irp_Close_Fdo(PDEVICE_OBJECT devi
  14.425    irp->IoStatus.Status = status;
  14.426    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.427  
  14.428 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.429 +  FUNCTION_EXIT();
  14.430  
  14.431    return status;
  14.432  }
  14.433 @@ -1290,7 +1291,7 @@ XenPci_Irp_Read_Fdo(PDEVICE_OBJECT devic
  14.434    PIO_STACK_LOCATION stack;
  14.435    KIRQL old_irql;
  14.436  
  14.437 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.438 +  FUNCTION_ENTER();
  14.439  
  14.440    xpdd = (PXENPCI_DEVICE_DATA)device_object->DeviceExtension;
  14.441    stack = IoGetCurrentIrpStackLocation(irp);
  14.442 @@ -1312,7 +1313,8 @@ XenPci_Irp_Read_Fdo(PDEVICE_OBJECT devic
  14.443      KeReleaseSpinLock(&xpdd->shutdown_ring_lock, old_irql);
  14.444      status = XenPci_ProcessShutdownIrp(xpdd);
  14.445    }
  14.446 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.447 +
  14.448 +  FUNCTION_EXIT();
  14.449  
  14.450    return status;
  14.451  }
  14.452 @@ -1325,13 +1327,13 @@ XenPci_Irp_Cleanup_Fdo(PDEVICE_OBJECT de
  14.453  
  14.454    UNREFERENCED_PARAMETER(device_object);
  14.455  
  14.456 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  14.457 +  FUNCTION_ENTER();
  14.458    
  14.459    status = STATUS_SUCCESS;
  14.460    irp->IoStatus.Status = status;
  14.461    IoCompleteRequest(irp, IO_NO_INCREMENT);
  14.462    
  14.463 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  14.464 +  FUNCTION_EXIT();
  14.465  
  14.466    return status;
  14.467  }
    15.1 --- a/xenpci/xenpci_pdo.c	Fri Jul 18 23:22:01 2008 +1000
    15.2 +++ b/xenpci/xenpci_pdo.c	Sat Jul 19 11:35:24 2008 +1000
    15.3 @@ -379,7 +379,7 @@ XenPci_XenShutdownDevice(PVOID Context)
    15.4    PVOID setting;
    15.5    PVOID value;
    15.6  
    15.7 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
    15.8 +  FUNCTION_ENTER();
    15.9  
   15.10    if (xppdd->backend_state == XenbusStateConnected)
   15.11    {
   15.12 @@ -422,7 +422,7 @@ XenPci_XenShutdownDevice(PVOID Context)
   15.13      xppdd->assigned_resources_start = NULL;
   15.14    }
   15.15  
   15.16 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
   15.17 +  FUNCTION_EXIT();
   15.18  
   15.19    return STATUS_SUCCESS;
   15.20  }
   15.21 @@ -451,7 +451,7 @@ XenPci_XenConfigDeviceSpecifyBuffers(PVO
   15.22    grant_ref_t gref;
   15.23    BOOLEAN done_xenbus_init = FALSE;
   15.24   
   15.25 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   15.26 +  FUNCTION_ENTER();
   15.27  
   15.28    in_ptr = src;
   15.29    out_ptr = dst;
   15.30 @@ -611,7 +611,7 @@ XenPci_XenConfigDeviceSpecifyBuffers(PVO
   15.31    ADD_XEN_INIT_RSP(&out_ptr, XEN_INIT_TYPE_END, NULL, NULL);
   15.32    
   15.33  error:
   15.34 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (%08x\n", status));
   15.35 +  FUNCTION_EXIT_STATUS(status);
   15.36  
   15.37    return status;
   15.38  }
   15.39 @@ -687,12 +687,14 @@ XenPci_Pdo_Resume(PDEVICE_OBJECT device_
   15.40    ULONG old_backend_state;
   15.41    PUCHAR src, dst;
   15.42  
   15.43 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   15.44 +  FUNCTION_ENTER();
   15.45  
   15.46    old_backend_state = xppdd->backend_state;
   15.47    status = XenPci_GetBackendAndAddWatch(device_object);
   15.48 -  if (!NT_SUCCESS(status))
   15.49 +  if (!NT_SUCCESS(status)) {
   15.50 +    FUNCTION_ERROR_EXIT();
   15.51      return status;
   15.52 +  }
   15.53    
   15.54    if (xppdd->common.current_pnp_state == Started && old_backend_state == XenbusStateClosed)
   15.55    {
   15.56 @@ -700,6 +702,7 @@ XenPci_Pdo_Resume(PDEVICE_OBJECT device_
   15.57      if (XenPci_ChangeFrontendState(xppdd, XenbusStateInitialising, XenbusStateInitWait, 30000) != STATUS_SUCCESS)
   15.58      {
   15.59        // this is probably an unrecoverable situation...
   15.60 +      FUNCTION_ERROR_EXIT();
   15.61        return STATUS_UNSUCCESSFUL;
   15.62      }
   15.63      if (xppdd->assigned_resources_ptr)
   15.64 @@ -720,9 +723,13 @@ XenPci_Pdo_Resume(PDEVICE_OBJECT device_
   15.65      if (XenPci_ChangeFrontendState(xppdd, XenbusStateConnected, XenbusStateConnected, 30000) != STATUS_SUCCESS)
   15.66      {
   15.67        // this is definitely an unrecoverable situation...
   15.68 +      FUNCTION_ERROR_EXIT();
   15.69        return STATUS_UNSUCCESSFUL;
   15.70      }
   15.71    }
   15.72 +
   15.73 +  FUNCTION_EXIT();
   15.74 +
   15.75    return STATUS_SUCCESS;
   15.76  } 
   15.77  
   15.78 @@ -775,15 +782,17 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
   15.79    ULONG i;
   15.80    char path[128];
   15.81   
   15.82 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
   15.83 +  FUNCTION_ENTER();
   15.84  
   15.85    DUMP_CURRENT_PNP_STATE(xppdd);
   15.86    
   15.87    stack = IoGetCurrentIrpStackLocation(irp);
   15.88  
   15.89    status = XenPci_GetBackendAndAddWatch(device_object);
   15.90 -  if (!NT_SUCCESS(status))
   15.91 +  if (!NT_SUCCESS(status)) {
   15.92 +    FUNCTION_ERROR_EXIT();
   15.93      return status;
   15.94 +  }
   15.95  
   15.96    prl = &stack->Parameters.StartDevice.AllocatedResourcesTranslated->List[0].PartialResourceList;
   15.97    for (i = 0; i < prl->Count; i++)
   15.98 @@ -807,18 +816,18 @@ XenPci_Pnp_StartDevice(PDEVICE_OBJECT de
   15.99        xppdd->assigned_resources_start = xppdd->assigned_resources_ptr = ExAllocatePoolWithTag(NonPagedPool, PAGE_SIZE, XENPCI_POOL_TAG);
  15.100        
  15.101        status = XenPci_XenConfigDevice(xppdd);
  15.102 -
  15.103        if (!NT_SUCCESS(status))
  15.104        {
  15.105          RtlStringCbPrintfA(path, ARRAY_SIZE(path), "%s/state", xppdd->backend_path);
  15.106          XenBus_RemWatch(xpdd, XBT_NIL, path, XenPci_BackEndStateHandler, xppdd);
  15.107 +        FUNCTION_ERROR_EXIT();
  15.108          return status;
  15.109        }
  15.110      }
  15.111    }
  15.112    SET_PNP_STATE(&xppdd->common, Started);
  15.113    
  15.114 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ "\n"));
  15.115 +  FUNCTION_EXIT();
  15.116  
  15.117    return STATUS_SUCCESS;
  15.118  }
  15.119 @@ -833,7 +842,7 @@ XenPci_Pnp_RemoveDevice(PDEVICE_OBJECT d
  15.120  
  15.121    UNREFERENCED_PARAMETER(irp);
  15.122  
  15.123 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  15.124 +  FUNCTION_ENTER();
  15.125  
  15.126    DUMP_CURRENT_PNP_STATE(xppdd);
  15.127  
  15.128 @@ -851,7 +860,7 @@ XenPci_Pnp_RemoveDevice(PDEVICE_OBJECT d
  15.129      IoDeleteDevice(xppdd->common.pdo);
  15.130    }
  15.131    
  15.132 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__ " (status = %08x)\n", status));
  15.133 +  FUNCTION_EXIT_STATUS(status);
  15.134  
  15.135    return status;
  15.136  }
  15.137 @@ -1228,12 +1237,12 @@ XenPci_Irp_Create_Pdo(PDEVICE_OBJECT dev
  15.138  
  15.139    UNREFERENCED_PARAMETER(device_object);
  15.140  
  15.141 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  15.142 +  FUNCTION_ENTER();
  15.143  
  15.144    status = irp->IoStatus.Status;
  15.145    IoCompleteRequest(irp, IO_NO_INCREMENT);
  15.146  
  15.147 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  15.148 +  FUNCTION_EXIT();
  15.149  
  15.150    return status;
  15.151  }
  15.152 @@ -1245,12 +1254,12 @@ XenPci_Irp_Close_Pdo(PDEVICE_OBJECT devi
  15.153  
  15.154    UNREFERENCED_PARAMETER(device_object);
  15.155  
  15.156 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  15.157 +  FUNCTION_ENTER();
  15.158  
  15.159    status = irp->IoStatus.Status;
  15.160    IoCompleteRequest(irp, IO_NO_INCREMENT);
  15.161  
  15.162 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  15.163 +  FUNCTION_EXIT();
  15.164  
  15.165    return status;
  15.166  }
  15.167 @@ -1262,12 +1271,12 @@ XenPci_Irp_Read_Pdo(PDEVICE_OBJECT devic
  15.168  
  15.169    UNREFERENCED_PARAMETER(device_object);
  15.170  
  15.171 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  15.172 +  FUNCTION_ENTER();
  15.173  
  15.174    status = irp->IoStatus.Status;
  15.175    IoCompleteRequest(irp, IO_NO_INCREMENT);
  15.176  
  15.177 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  15.178 +  FUNCTION_EXIT();
  15.179  
  15.180    return status;
  15.181  }
  15.182 @@ -1279,12 +1288,12 @@ XenPci_Irp_Cleanup_Pdo(PDEVICE_OBJECT de
  15.183  
  15.184    UNREFERENCED_PARAMETER(device_object);
  15.185  
  15.186 -  KdPrint((__DRIVER_NAME " --> " __FUNCTION__ "\n"));
  15.187 +  FUNCTION_ENTER();
  15.188    
  15.189    status = irp->IoStatus.Status;
  15.190    IoCompleteRequest(irp, IO_NO_INCREMENT);
  15.191    
  15.192 -  KdPrint((__DRIVER_NAME " <-- " __FUNCTION__"\n"));
  15.193 +  FUNCTION_EXIT();
  15.194  
  15.195    return status;
  15.196  }
    16.1 --- a/xenvbd/makefile.mingw	Fri Jul 18 23:22:01 2008 +1000
    16.2 +++ b/xenvbd/makefile.mingw	Sat Jul 19 11:35:24 2008 +1000
    16.3 @@ -1,7 +1,7 @@
    16.4  W32API_PATH=/home/agrover/temp/w32api-3.11
    16.5  
    16.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
    16.7 +CFLAGS = -O2 -Wall -L$(W32API_PATH)/lib/ddk -I$(W32API_PATH)/include/ddk -I../common/include -I../common/include/public -Wno-multichar -Wno-unknown-pragmas -DDBG
    16.8  
    16.9  xenvbd.sys: xenvbd.c scsiport.c ../mingw/mingw_extras.c
   16.10 -	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -s -shared -Wl,--entry,_load@8 -nostdlib $^ -lntoskrnl -lhal -lscsiport
   16.11 +	i586-mingw32msvc-gcc $(CFLAGS) -o $@ -shared -Wl,--entry,_DriverEntry@8 -nostartfiles -nostdlib -lntoskrnl -lhal -lscsiport
   16.12