From: Paul Durrant Date: Thu, 25 Jan 2018 12:51:06 +0000 (+0000) Subject: Update util.h X-Git-Tag: 9.0.0-rc1~14 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=90e73e25d85606d82dc802c491a9269a6c3f21ba;p=pvdrivers%2Fwin%2Fxennet.git Update util.h XENNET does not use much of the functionality in util.h, including the __AllocatePages()/__FreePages() functions modified by this change, however it is good to keep the header in-sync with the other drivers. Signed-off-by: Paul Durrant --- diff --git a/src/xennet/util.h b/src/xennet/util.h index d634033..83008ad 100644 --- a/src/xennet/util.h +++ b/src/xennet/util.h @@ -170,8 +170,8 @@ __FreePoolWithTag( } static FORCEINLINE PMDL -__AllocatePage( - VOID +__AllocatePages( + IN ULONG Count ) { PHYSICAL_ADDRESS LowAddress; @@ -185,7 +185,7 @@ __AllocatePage( LowAddress.QuadPart = 0ull; HighAddress.QuadPart = ~0ull; SkipBytes.QuadPart = 0ull; - TotalBytes = (SIZE_T)PAGE_SIZE; + TotalBytes = (SIZE_T)PAGE_SIZE * Count; Mdl = MmAllocatePagesForMdlEx(LowAddress, HighAddress, @@ -198,7 +198,7 @@ __AllocatePage( if (Mdl == NULL) goto fail1; - if (Mdl->ByteCount < PAGE_SIZE) + if (Mdl->ByteCount < TotalBytes) goto fail2; ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | @@ -219,9 +219,13 @@ __AllocatePage( if (MdlMappedSystemVa == NULL) goto fail3; - ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa); + Mdl->StartVa = PAGE_ALIGN(MdlMappedSystemVa); - RtlZeroMemory(MdlMappedSystemVa, PAGE_SIZE); + ASSERT3U(Mdl->ByteOffset, ==, 0); + ASSERT3P(Mdl->StartVa, ==, MdlMappedSystemVa); + ASSERT3P(Mdl->MappedSystemVa, ==, MdlMappedSystemVa); + + RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount); return Mdl; @@ -240,8 +244,10 @@ fail1: return NULL; } +#define __AllocatePage() __AllocatePages(1) + static FORCEINLINE VOID -__FreePage( +__FreePages( IN PMDL Mdl ) { @@ -250,13 +256,14 @@ __FreePage( ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA); MdlMappedSystemVa = Mdl->MappedSystemVa; - RtlFillMemory(MdlMappedSystemVa, PAGE_SIZE, 0xAA); - MmUnmapLockedPages(MdlMappedSystemVa, Mdl); MmFreePagesFromMdl(Mdl); + ExFreePool(Mdl); } +#define __FreePage(_Mdl) __FreePages(_Mdl) + static FORCEINLINE PCHAR __strtok_r( IN PCHAR Buffer,