win-pvdrivers

changeset 371:f7fa99be363d

update mingw build doc and add diff of w32api changes needed.
author Andy Grover <andy.grover@oracle.com>
date Wed Jul 09 00:35:41 2008 -0700 (2008-07-09)
parents d76831a77d19
children 6b1c00d218e9 aceae9864ad8
files doc/BUILDING_mingw.txt mingw/w32api.diff
line diff
     1.1 --- a/doc/BUILDING_mingw.txt	Wed Jul 09 00:26:05 2008 -0700
     1.2 +++ b/doc/BUILDING_mingw.txt	Wed Jul 09 00:35:41 2008 -0700
     1.3 @@ -9,24 +9,26 @@ 1. sudo apt-get install mingw mingw-binu
     1.4  2. mingw-runtime headers need to be modified. Download the latest w32api-src.tar.gz
     1.5     package from mingw.sf.net.
     1.6  
     1.7 -3. Untar, then edit lib/ddk/ntoskrnl.def. Remove ";" from line ~545, which says
     1.8 -   "KeNumberProcessors DATA". Add a line "KeFlushQueuedDpcs@0"
     1.9 +3. Untar to a directory.
    1.10  
    1.11 -4. Type: "./configure i586-mingw32-msvc;make"
    1.12 -
    1.13 -2. Use Mercurial and type:
    1.14 +4. Use Mercurial and type:
    1.15     "hg clone http://xenbits.xensource.com/ext/win-pvdrivers.hg"
    1.16  
    1.17 -4. Change to the win-pvdrivers.hg/xenpci dir.
    1.18 +5. Apply the patch "w32api.diff" in the mingw directory to the untarred w32api
    1.19 +   source: "cd w32api-<version>;patch -p1 < ~/hg/win-pvdrivers.hg/mingw/w32api.diff"
    1.20  
    1.21 -5. Modify the W32API_PATH at the top of makefile.mingw to point to the lib/ddk
    1.22 +6. Type: "./configure i586-mingw32-msvc;make"
    1.23 +
    1.24 +7. Change to the win-pvdrivers.hg/xenpci dir.
    1.25 +
    1.26 +8. Modify the W32API_PATH at the top of makefile.mingw to point to the lib/ddk
    1.27     directory of the w32api package compiled above.
    1.28  
    1.29 -6. Type: "make -f makefile.mingw"
    1.30 +9. Type: "make -f makefile.mingw"
    1.31  
    1.32 -7. Building the shutdown monitor is not supported (maybe using Mono is an option
    1.33 +10. Building the shutdown monitor is not supported (maybe using Mono is an option
    1.34     here?)
    1.35 -
    1.36 -8. This is still an extremely alpha build method, so this will give you a
    1.37 +
    1.38 +11. This is still an extremely alpha build method, so this will give you a
    1.39     .sys file but you're on your own for the rest!
    1.40  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/mingw/w32api.diff	Wed Jul 09 00:35:41 2008 -0700
     2.3 @@ -0,0 +1,373 @@
     2.4 +diff -r 79e257d5a1f7 include/ddk/ndis.h
     2.5 +--- a/include/ddk/ndis.h	Tue Jul 08 22:16:37 2008 -0700
     2.6 ++++ b/include/ddk/ndis.h	Wed Jul 09 00:34:21 2008 -0700
     2.7 +@@ -52,12 +52,16 @@ extern "C" {
     2.8 + #if defined(NDIS50_MINIPORT)
     2.9 + #ifndef NDIS50
    2.10 + #define NDIS50
    2.11 ++#define NDIS_MINIPORT_MAJOR_VERSION 5
    2.12 ++#define NDIS_MINIPORT_MINOR_VERSION 0
    2.13 + #endif
    2.14 + #endif /* NDIS50_MINIPORT */
    2.15 + 
    2.16 + #if defined(NDIS51_MINIPORT)
    2.17 + #ifndef NDIS51
    2.18 + #define NDIS51
    2.19 ++#define NDIS_MINIPORT_MAJOR_VERSION 5
    2.20 ++#define NDIS_MINIPORT_MINOR_VERSION 1
    2.21 + #endif
    2.22 + #endif /* NDIS51_MINIPORT */
    2.23 + 
    2.24 +@@ -399,19 +403,19 @@ typedef struct _NDIS_PACKET_PRIVATE {
    2.25 + 
    2.26 + typedef struct _NDIS_PACKET {
    2.27 +   NDIS_PACKET_PRIVATE  Private;
    2.28 +-  union {
    2.29 +-    struct {
    2.30 ++  _ANONYMOUS_UNION union {
    2.31 ++    _ANONYMOUS_STRUCT struct {
    2.32 +       UCHAR  MiniportReserved[2 * sizeof(PVOID)];
    2.33 +       UCHAR  WrapperReserved[2 * sizeof(PVOID)];
    2.34 +-    } s1;
    2.35 +-    struct {
    2.36 ++    } DUMMYSTRUCTNAME;
    2.37 ++    _ANONYMOUS_STRUCT struct {
    2.38 +       UCHAR  MiniportReservedEx[3 * sizeof(PVOID)];
    2.39 +       UCHAR  WrapperReservedEx[sizeof(PVOID)];
    2.40 +-    } s2;
    2.41 +-    struct {
    2.42 ++    } DUMMYSTRUCTNAME;
    2.43 ++    _ANONYMOUS_STRUCT struct {
    2.44 +       UCHAR  MacReserved[4 * sizeof(PVOID)];
    2.45 +-    } s3;
    2.46 +-  } u;
    2.47 ++    } DUMMYSTRUCTNAME;
    2.48 ++  } DUMMYUNIONNAME;
    2.49 +   ULONG_PTR  Reserved[2];
    2.50 +   UCHAR  ProtocolReserved[1];
    2.51 + } NDIS_PACKET, *PNDIS_PACKET, **PPNDIS_PACKET;
    2.52 +@@ -642,6 +646,13 @@ typedef enum _NDIS_PNP_DEVICE_STATE {
    2.53 + #define NDIS_DEVICE_DISABLE_WAKE_ON_MAGIC_PACKET  0x00000080
    2.54 + #define NDIS_DEVICE_DISABLE_WAKE_ON_PATTERN_MATCH 0x00000100
    2.55 + 
    2.56 ++typedef enum _NDIS_DEVICE_PNP_EVENT
    2.57 ++{
    2.58 ++  /* couldn't find public docs on other values */
    2.59 ++  NdisDevicePnpEventSurpriseRemoved=2,
    2.60 ++  NdisDevicePnpEventPowerProfileChanged=5
    2.61 ++} NDIS_DEVICE_PNP_EVENT;
    2.62 ++
    2.63 + 
    2.64 + /* OID_GEN_NETWORK_LAYER_ADDRESSES */
    2.65 + typedef struct _NETWORK_ADDRESS {
    2.66 +@@ -915,6 +926,33 @@ typedef struct _NDIS_TASK_IPSEC {
    2.67 +   } V4ESP;
    2.68 + } NDIS_TASK_IPSEC, *PNDIS_TASK_IPSEC;
    2.69 + 
    2.70 ++typedef enum _NDIS_ENCAPSULATION {
    2.71 ++  UNSPECIFIED_Encapsulation,
    2.72 ++  NULL_Encapsulation,
    2.73 ++  IEEE_802_3_Encapsulation,
    2.74 ++  IEEE_802_5_Encapsulation,
    2.75 ++  LLC_SNAP_ROUTED_Encapsulation,
    2.76 ++  LLC_SNAP_BRIDGED_Encapsulation
    2.77 ++} NDIS_ENCAPSULATION;
    2.78 ++
    2.79 ++typedef struct _NDIS_ENCAPSULATION_FORMAT {
    2.80 ++  NDIS_ENCAPSULATION  Encapsulation;
    2.81 ++  struct {
    2.82 ++    ULONG  FixedHeaderSize : 1;
    2.83 ++    ULONG  Reserved : 31;
    2.84 ++  } Flags;
    2.85 ++  ULONG  EncapsulationHeaderSize;
    2.86 ++} NDIS_ENCAPSULATION_FORMAT, *PNDIS_ENCAPSULATION_FORMAT;
    2.87 ++
    2.88 ++typedef struct _NDIS_TASK_OFFLOAD_HEADER
    2.89 ++{
    2.90 ++  ULONG Version;
    2.91 ++  ULONG Size;
    2.92 ++  ULONG Reserved;
    2.93 ++  UCHAR OffsetFirstTask;
    2.94 ++  NDIS_ENCAPSULATION_FORMAT EncapsulationFormat;
    2.95 ++} NDIS_TASK_OFFLOAD_HEADER, *PNDIS_TASK_OFFLOAD_HEADER;
    2.96 ++
    2.97 + typedef struct _NDIS_TASK_OFFLOAD {
    2.98 +   ULONG  Version;
    2.99 +   ULONG  Size;
   2.100 +@@ -926,24 +964,6 @@ typedef struct _NDIS_TASK_OFFLOAD {
   2.101 + 
   2.102 + /* NDIS_TASK_OFFLOAD_HEADER.Version constants */
   2.103 + #define NDIS_TASK_OFFLOAD_VERSION 1
   2.104 +-
   2.105 +-typedef enum _NDIS_ENCAPSULATION {
   2.106 +-  UNSPECIFIED_Encapsulation,
   2.107 +-  NULL_Encapsulation,
   2.108 +-  IEEE_802_3_Encapsulation,
   2.109 +-  IEEE_802_5_Encapsulation,
   2.110 +-  LLC_SNAP_ROUTED_Encapsulation,
   2.111 +-  LLC_SNAP_BRIDGED_Encapsulation
   2.112 +-} NDIS_ENCAPSULATION;
   2.113 +-
   2.114 +-typedef struct _NDIS_ENCAPSULATION_FORMAT {
   2.115 +-  NDIS_ENCAPSULATION  Encapsulation;
   2.116 +-  struct {
   2.117 +-    ULONG  FixedHeaderSize : 1;
   2.118 +-    ULONG  Reserved : 31;
   2.119 +-  } Flags;
   2.120 +-  ULONG  EncapsulationHeaderSize;
   2.121 +-} NDIS_ENCAPSULATION_FORMAT, *PNDIS_ENCAPSULATION_FORMAT;
   2.122 + 
   2.123 + typedef struct _NDIS_TASK_TCP_IP_CHECKSUM {
   2.124 +   struct {
   2.125 +@@ -1542,6 +1562,8 @@ NdisAllocatePacketPool(
   2.126 +   /*OUT*/ PNDIS_HANDLE  PoolHandle,
   2.127 +   /*IN*/ UINT  NumberOfDescriptors,
   2.128 +   /*IN*/ UINT  ProtocolReservedLength);
   2.129 ++
   2.130 ++#define PROTOCOL_RESERVED_SIZE_IN_PACKET (4 * sizeof(PVOID))
   2.131 + 
   2.132 + NDISAPI
   2.133 + VOID
   2.134 +@@ -1756,6 +1778,46 @@ NdisFreeBuffer(
   2.135 + 
   2.136 + /*
   2.137 +  * VOID
   2.138 ++ * NdisGetFirstBufferFromPacketSafe(
   2.139 ++ * IN PNDIS_PACKET  _Packet,
   2.140 ++ * OUT PNDIS_BUFFER  * _FirstBuffer,
   2.141 ++ * OUT PVOID  * _FirstBufferVA,
   2.142 ++ * OUT PUINT  _FirstBufferLength,
   2.143 ++ * OUT PUINT  _TotalBufferLength),
   2.144 ++ * IN MM_PAGE_PRIORITY _Priority)
   2.145 ++ */
   2.146 ++#define NdisGetFirstBufferFromPacketSafe(_Packet,         \
   2.147 ++                                     _FirstBuffer,        \
   2.148 ++                                     _FirstBufferVA,      \
   2.149 ++                                     _FirstBufferLength,  \
   2.150 ++                                     _TotalBufferLength,  \
   2.151 ++                                     _Priority)           \
   2.152 ++{                                                         \
   2.153 ++  PNDIS_BUFFER _Buffer;                                   \
   2.154 ++                                                          \
   2.155 ++  _Buffer         = (_Packet)->Private.Head;              \
   2.156 ++  *(_FirstBuffer) = _Buffer;                              \
   2.157 ++  if (_Buffer != NULL)                                    \
   2.158 ++    {                                                     \
   2.159 ++            *(_FirstBufferVA)     = MmGetSystemAddressForMdlSafe(_Buffer, _Priority);  \
   2.160 ++            *(_FirstBufferLength) = MmGetMdlByteCount(_Buffer);         \
   2.161 ++            _Buffer = _Buffer->Next;                                    \
   2.162 ++                  *(_TotalBufferLength) = *(_FirstBufferLength);              \
   2.163 ++                  while (_Buffer != NULL) {                                   \
   2.164 ++                    *(_TotalBufferLength) += MmGetMdlByteCount(_Buffer);      \
   2.165 ++                    _Buffer = _Buffer->Next;                                  \
   2.166 ++                  }                                                           \
   2.167 ++    }                             \
   2.168 ++  else                            \
   2.169 ++    {                             \
   2.170 ++      *(_FirstBufferVA) = 0;      \
   2.171 ++      *(_FirstBufferLength) = 0;  \
   2.172 ++      *(_TotalBufferLength) = 0;  \
   2.173 ++    } \
   2.174 ++}
   2.175 ++
   2.176 ++/*
   2.177 ++ * VOID
   2.178 +  * NdisQueryBuffer(
   2.179 +  * IN PNDIS_BUFFER  Buffer,
   2.180 +  * OUT PVOID  *VirtualAddress OPTIONAL,
   2.181 +@@ -2092,7 +2154,7 @@ NdisFreeBuffer(
   2.182 +  * NdisReinitializePacket(
   2.183 +  * IN OUT  PNDIS_PACKET  Packet);
   2.184 +  */
   2.185 +-#define NdisReinitializePacketCounts(Packet)    \
   2.186 ++#define NdisReinitializePacket(Packet)          \
   2.187 + {                                               \
   2.188 + 	(Packet)->Private.Head = (PNDIS_BUFFER)NULL;  \
   2.189 + 	(Packet)->Private.ValidCounts = FALSE;        \
   2.190 +@@ -2967,6 +3029,11 @@ NdisMWanIndicateReceive(
   2.191 +   /*IN*/ PUCHAR  PacketBuffer,
   2.192 +   /*IN*/ UINT  PacketSize);
   2.193 + 
   2.194 ++#define NdisMIndicateReceivePacket(_handle, _packets, _number) \
   2.195 ++{  \
   2.196 ++  (*((PNDIS_MINIPORT_BLOCK)(_handle))->PacketIndicateHandler)(_handle, _packets, _number); \
   2.197 ++}
   2.198 ++
   2.199 + NDISAPI
   2.200 + VOID
   2.201 + DDKAPI
   2.202 +@@ -3155,6 +3222,13 @@ DDKAPI
   2.203 + DDKAPI
   2.204 + NdisPacketPoolUsage(
   2.205 +   /*IN*/ NDIS_HANDLE  PoolHandle);
   2.206 ++
   2.207 ++NTOSAPI
   2.208 ++VOID
   2.209 ++DDKAPI
   2.210 ++NdisSetPacketPoolProtocolId(
   2.211 ++  /*IN*/ NDIS_HANDLE PacketPoolHandle,
   2.212 ++  /*IN*/ UINT ProtocolId);
   2.213 + 
   2.214 + NDISAPI
   2.215 + NDIS_STATUS
   2.216 +@@ -4517,6 +4591,29 @@ struct _NDIS_OPEN_BLOCK
   2.217 + 
   2.218 + /* Routines for NDIS miniport drivers */
   2.219 + 
   2.220 ++NTOSAPI
   2.221 ++VOID
   2.222 ++DDKAPI
   2.223 ++NdisMInitializeTimer(
   2.224 ++  /*IN*/ /*OUT*/ PNDIS_MINIPORT_TIMER Timer,
   2.225 ++  /*IN*/ NDIS_HANDLE MiniportAdapterHandle,
   2.226 ++  /*IN*/ PNDIS_TIMER_FUNCTION TimerFunction,
   2.227 ++  /*IN*/ PVOID FunctionContext);
   2.228 ++
   2.229 ++NTOSAPI
   2.230 ++VOID
   2.231 ++DDKAPI
   2.232 ++NdisMSetPeriodicTimer(
   2.233 ++  /*IN*/ PNDIS_MINIPORT_TIMER Timer,
   2.234 ++  /*IN*/ UINT MillisecondsPeriod);
   2.235 ++
   2.236 ++NTOSAPI
   2.237 ++VOID
   2.238 ++DDKAPI
   2.239 ++NdisMCancelTimer(
   2.240 ++  /*IN*/ PNDIS_MINIPORT_TIMER Timer,
   2.241 ++  /*OUT*/ PBOOLEAN TimerCancelled);
   2.242 ++
   2.243 + NDISAPI
   2.244 + VOID
   2.245 + DDKAPI
   2.246 +diff -r 79e257d5a1f7 include/ddk/ntddndis.h
   2.247 +--- a/include/ddk/ntddndis.h	Tue Jul 08 22:16:37 2008 -0700
   2.248 ++++ b/include/ddk/ntddndis.h	Wed Jul 09 00:34:21 2008 -0700
   2.249 +@@ -179,6 +179,13 @@ typedef struct _NDIS_PNP_CAPABILITIES {
   2.250 + #define NDIS_MINIPORT_SUPPORTS_CANCEL_SEND_PACKETS    0x00800000
   2.251 + #define NDIS_MINIPORT_64BITS_DMA                      0x01000000
   2.252 + 
   2.253 ++/* TCP offload OIDs */
   2.254 ++#define OID_TCP_TASK_OFFLOAD                0xFC010201
   2.255 ++#define OID_TCP_TASK_IPSEC_ADD_SA           0xFC010202
   2.256 ++#define OID_TCP_TASK_IPSEC_ADD_UDPESP_SA    0xFC010203
   2.257 ++#define OID_TCP_TASK_IPSEC_DELETE_SA        0xFC010204
   2.258 ++#define OID_TCP_TASK_IPSEC_DELETE_UDPESP_SA 0xFC010205
   2.259 ++
   2.260 + #pragma pack(pop)
   2.261 + 
   2.262 + #ifdef __cplusplus
   2.263 +diff -r 79e257d5a1f7 include/ddk/winddk.h
   2.264 +--- a/include/ddk/winddk.h	Tue Jul 08 22:16:37 2008 -0700
   2.265 ++++ b/include/ddk/winddk.h	Wed Jul 09 00:34:21 2008 -0700
   2.266 +@@ -4896,6 +4896,10 @@ RtlStringFromGUID(
   2.267 +   /*IN*/ REFGUID  Guid, 
   2.268 +   /*OUT*/ PUNICODE_STRING  GuidString);
   2.269 + 
   2.270 ++#define RtlStringCbCopyA(dst, dst_len, src) strncpy(dst, src, dst_len)
   2.271 ++#define RtlStringCbPrintfA(args...) snprintf(args)
   2.272 ++#define RtlStringCbVPrintfA(args...) vsnprintf(args)
   2.273 ++
   2.274 + NTOSAPI
   2.275 + BOOLEAN
   2.276 + DDKAPI
   2.277 +@@ -7726,38 +7730,18 @@ KeWaitForSingleObject(
   2.278 +   /*IN*/ BOOLEAN  Alertable,
   2.279 +   /*IN*/ PLARGE_INTEGER  Timeout  /*OPTIONAL*/);
   2.280 + 
   2.281 +-#if defined(_X86_)
   2.282 +-
   2.283 +-NTOSAPI
   2.284 +-VOID
   2.285 +-FASTCALL
   2.286 +-KfLowerIrql(
   2.287 +-  /*IN*/ KIRQL  NewIrql);
   2.288 +-
   2.289 +-NTOSAPI
   2.290 +-KIRQL
   2.291 +-FASTCALL
   2.292 +-KfRaiseIrql(
   2.293 +-  /*IN*/ KIRQL  NewIrql);
   2.294 +-
   2.295 +-#define KeLowerIrql(a) KfLowerIrql(a)
   2.296 +-#define KeRaiseIrql(a,b) *(b) = KfRaiseIrql(a)
   2.297 +-
   2.298 +-#else
   2.299 +-
   2.300 +-NTOSAPI
   2.301 +-VOID
   2.302 +-DDKAPI
   2.303 ++NTOSAPI
   2.304 ++VOID
   2.305 ++DDKAPI
   2.306 ++KeRaiseIrql(
   2.307 ++  /*IN*/ KIRQL new_irql,
   2.308 ++  /*OUT*/ PKIRQL old_irql);
   2.309 ++
   2.310 ++NTOSAPI
   2.311 ++VOID
   2.312 ++DDKAPI
   2.313 + KeLowerIrql(
   2.314 +-  /*IN*/ KIRQL  NewIrql);
   2.315 +-
   2.316 +-NTOSAPI
   2.317 +-KIRQL
   2.318 +-DDKAPI
   2.319 +-KeRaiseIrql(
   2.320 +-  /*IN*/ KIRQL  NewIrql);
   2.321 +-
   2.322 +-#endif
   2.323 ++  /*IN*/ KIRQL irql);
   2.324 + 
   2.325 + NTOSAPI
   2.326 + KIRQL
   2.327 +diff -r 79e257d5a1f7 lib/ddk/ndis.def
   2.328 +--- a/lib/ddk/ndis.def	Tue Jul 08 22:16:37 2008 -0700
   2.329 ++++ b/lib/ddk/ndis.def	Wed Jul 09 00:34:21 2008 -0700
   2.330 +@@ -130,8 +130,8 @@ NdisImmediateReadSharedMemory@16
   2.331 + ;NdisImmediateWritePortUlong
   2.332 + ;NdisImmediateWritePortUshort
   2.333 + NdisImmediateWriteSharedMemory@16
   2.334 +-;NdisInitAnsiString DATA
   2.335 +-;NdisInitUnicodeString DATA
   2.336 ++NdisInitAnsiString@8
   2.337 ++NdisInitUnicodeString@8
   2.338 + ;NdisInitializeEvent
   2.339 + NdisInitializeReadWriteLock@4
   2.340 + ;NdisInitializeString
   2.341 +@@ -149,7 +149,7 @@ NdisMAllocateMapRegisters@20
   2.342 + NdisMAllocateMapRegisters@20
   2.343 + NdisMAllocateSharedMemory@20
   2.344 + NdisMAllocateSharedMemoryAsync@16
   2.345 +-;NdisMCancelTimer
   2.346 ++NdisMCancelTimer@8
   2.347 + NdisMCloseLog@4
   2.348 + NdisMCmActivateVc@8
   2.349 + NdisMCmCreateVc@16
   2.350 +@@ -179,7 +179,7 @@ NdisMGetDeviceProperty@24
   2.351 + ;NdisMIndicateStatus
   2.352 + ;NdisMIndicateStatusComplete
   2.353 + NdisMInitializeScatterGatherDma@12
   2.354 +-;NdisMInitializeTimer
   2.355 ++NdisMInitializeTimer@16
   2.356 + NdisMMapIoSpace@20
   2.357 + ;NdisMPciAssignResources
   2.358 + NdisMPromoteMiniport@4
   2.359 +@@ -202,7 +202,7 @@ NdisMSetAttributesEx@20
   2.360 + NdisMSetAttributesEx@20
   2.361 + ;NdisMSetInformationComplete
   2.362 + NdisMSetMiniportSecondary@8
   2.363 +-;NdisMSetPeriodicTimer
   2.364 ++NdisMSetPeriodicTimer@8
   2.365 + ;NdisMSetTimer
   2.366 + NdisMSleep@4
   2.367 + ;NdisMStartBufferPhysicalMapping
   2.368 +@@ -252,7 +252,7 @@ NdisSendPackets@12
   2.369 + NdisSendPackets@12
   2.370 + ;NdisSetEvent
   2.371 + ;NdisSetPacketCancelId
   2.372 +-;NdisSetPacketPoolProtocolId
   2.373 ++NdisSetPacketPoolProtocolId@8
   2.374 + ;NdisSetPacketStatus
   2.375 + ;NdisSetProtocolFilter
   2.376 + ;NdisSetTimer