[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [win-pv-devel] [PATCH] Unify the three variants of util.h
The new header is placed a new src/common sub-directory. Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx> --- src/common/util.h | 355 ++++++++++++++++++++++++++++++++++++++++ src/xencrsh/util.h | 197 ---------------------- src/xendisk/util.h | 359 ----------------------------------------- src/xenvbd/blockring.c | 17 +- src/xenvbd/buffer.c | 11 +- src/xenvbd/driver.c | 3 +- src/xenvbd/fdo.c | 28 ++-- src/xenvbd/frontend.c | 9 +- src/xenvbd/granter.c | 5 +- src/xenvbd/notifier.c | 5 +- src/xenvbd/pdo.c | 24 +-- src/xenvbd/pdoinquiry.c | 9 +- src/xenvbd/registry.c | 5 +- src/xenvbd/thread.c | 9 +- src/xenvbd/util.h | 318 ------------------------------------ vs2012/xencrsh/xencrsh.vcxproj | 2 +- vs2012/xendisk/xendisk.vcxproj | 2 +- vs2012/xenvbd/xenvbd.vcxproj | 4 +- vs2013/xencrsh/xencrsh.vcxproj | 2 +- vs2013/xendisk/xendisk.vcxproj | 2 +- vs2013/xenvbd/xenvbd.vcxproj | 6 +- vs2015/xencrsh/xencrsh.vcxproj | 4 +- vs2015/xendisk/xendisk.vcxproj | 4 +- vs2015/xenvbd/xenvbd.vcxproj | 4 +- 24 files changed, 425 insertions(+), 959 deletions(-) create mode 100644 src/common/util.h delete mode 100644 src/xencrsh/util.h delete mode 100644 src/xendisk/util.h delete mode 100644 src/xenvbd/util.h diff --git a/src/common/util.h b/src/common/util.h new file mode 100644 index 0000000..9383817 --- /dev/null +++ b/src/common/util.h @@ -0,0 +1,355 @@ +/* Copyright (c) Citrix Systems Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, + * with or without modification, are permitted provided + * that the following conditions are met: + * + * * Redistributions of source code must retain the above + * copyright notice, this list of conditions and the + * following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the + * following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND + * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _COMMON_UTIL_H +#define _COMMON_UTIL_H + +#include <ntddk.h> + +#include "assert.h" + +#define P2ROUNDUP(_x, _a) \ + (-(-(_x) & -(_a))) + +static FORCEINLINE LONG +__ffs( + IN unsigned long long mask + ) +{ + unsigned char *array = (unsigned char *)&mask; + unsigned int byte; + unsigned int bit; + unsigned char val; + + val = 0; + + byte = 0; + while (byte < 8) { + val = array[byte]; + + if (val != 0) + break; + + byte++; + } + if (byte == 8) + return -1; + + bit = 0; + while (bit < 8) { + if (val & 0x01) + break; + + val >>= 1; + bit++; + } + + return (byte * 8) + bit; +} + +#define __ffu(_mask) \ + __ffs(~(_mask)) + +static FORCEINLINE VOID +__CpuId( + IN ULONG Leaf, + OUT PULONG EAX OPTIONAL, + OUT PULONG EBX OPTIONAL, + OUT PULONG ECX OPTIONAL, + OUT PULONG EDX OPTIONAL + ) +{ + ULONG Value[4] = {0}; + + __cpuid(Value, Leaf); + + if (EAX) + *EAX = Value[0]; + + if (EBX) + *EBX = Value[1]; + + if (ECX) + *ECX = Value[2]; + + if (EDX) + *EDX = Value[3]; +} + +static FORCEINLINE LONG +__InterlockedAdd( + IN LONG *Value, + IN LONG Delta + ) +{ + LONG New; + LONG Old; + + do { + Old = *Value; + New = Old + Delta; + } while (InterlockedCompareExchange(Value, New, Old) != Old); + + return New; +} + +static FORCEINLINE LONG +__InterlockedSubtract( + IN LONG *Value, + IN LONG Delta + ) +{ + LONG New; + LONG Old; + + do { + Old = *Value; + New = Old - Delta; + } while (InterlockedCompareExchange(Value, New, Old) != Old); + + return New; +} + +__checkReturn +static FORCEINLINE PVOID +__AllocatePoolWithTag( + IN POOL_TYPE PoolType, + IN SIZE_T NumberOfBytes, + IN ULONG Tag + ) +{ + PUCHAR Buffer; + + __analysis_assume(PoolType == NonPagedPool || + PoolType == PagedPool); + +#pragma warning(suppress:28160) // annotation error + Buffer = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); + if (Buffer == NULL) + return NULL; + + RtlZeroMemory(Buffer, NumberOfBytes); + return Buffer; +} + +static FORCEINLINE VOID +__FreePoolWithTag( + IN PVOID Buffer, + IN ULONG Tag + ) +{ + ExFreePoolWithTag(Buffer, Tag); +} + +static FORCEINLINE PMDL +__AllocatePages( + IN ULONG Count + ) +{ + PHYSICAL_ADDRESS LowAddress; + PHYSICAL_ADDRESS HighAddress; + LARGE_INTEGER SkipBytes; + SIZE_T TotalBytes; + PMDL Mdl; + PUCHAR MdlMappedSystemVa; + NTSTATUS status; + + LowAddress.QuadPart = 0ull; + HighAddress.QuadPart = ~0ull; + SkipBytes.QuadPart = 0ull; + TotalBytes = (SIZE_T)PAGE_SIZE * Count; + + Mdl = MmAllocatePagesForMdlEx(LowAddress, + HighAddress, + SkipBytes, + TotalBytes, + MmCached, + MM_DONT_ZERO_ALLOCATION); + + status = STATUS_NO_MEMORY; + if (Mdl == NULL) + goto fail1; + + if (Mdl->ByteCount < TotalBytes) + goto fail2; + + ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | + MDL_PARTIAL_HAS_BEEN_MAPPED | + MDL_PARTIAL | + MDL_PARENT_MAPPED_SYSTEM_VA | + MDL_SOURCE_IS_NONPAGED_POOL | + MDL_IO_SPACE)) == 0); + + MdlMappedSystemVa = MmMapLockedPagesSpecifyCache(Mdl, + KernelMode, + MmCached, + NULL, + FALSE, + NormalPagePriority); + + status = STATUS_UNSUCCESSFUL; + if (MdlMappedSystemVa == NULL) + goto fail3; + + ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa); + + RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount); + + return Mdl; + +fail3: +fail2: + MmFreePagesFromMdl(Mdl); + ExFreePool(Mdl); + +fail1: + return NULL; +} + +#define __AllocatePage() __AllocatePages(1) + +static FORCEINLINE VOID +__FreePages( + IN PMDL Mdl + ) +{ + PUCHAR MdlMappedSystemVa; + + ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA); + MdlMappedSystemVa = Mdl->MappedSystemVa; + + MmUnmapLockedPages(MdlMappedSystemVa, Mdl); + + MmFreePagesFromMdl(Mdl); + ExFreePool(Mdl); +} + +#define __FreePage(_Mdl) __FreePages(_Mdl) + +static FORCEINLINE PCHAR +__strtok_r( + IN PCHAR Buffer, + IN PCHAR Delimiter, + IN OUT PCHAR *Context + ) +{ + PCHAR Token; + PCHAR End; + + if (Buffer != NULL) + *Context = Buffer; + + Token = *Context; + + if (Token == NULL) + return NULL; + + while (*Token != '\0' && + strchr(Delimiter, *Token) != NULL) + Token++; + + if (*Token == '\0') + return NULL; + + End = Token + 1; + while (*End != '\0' && + strchr(Delimiter, *End) == NULL) + End++; + + if (*End != '\0') + *End++ = '\0'; + + *Context = End; + + return Token; +} + +static FORCEINLINE PWCHAR +__wcstok_r( + IN PWCHAR Buffer, + IN PWCHAR Delimiter, + IN OUT PWCHAR *Context + ) +{ + PWCHAR Token; + PWCHAR End; + + if (Buffer != NULL) + *Context = Buffer; + + Token = *Context; + + if (Token == NULL) + return NULL; + + while (*Token != L'\0' && + wcschr(Delimiter, *Token) != NULL) + Token++; + + if (*Token == L'\0') + return NULL; + + End = Token + 1; + while (*End != L'\0' && + wcschr(Delimiter, *End) == NULL) + End++; + + if (*End != L'\0') + *End++ = L'\0'; + + *Context = End; + + return Token; +} + +static FORCEINLINE CHAR +__toupper( + IN CHAR Character + ) +{ + if (Character < 'a' || Character > 'z') + return Character; + + return 'A' + Character - 'a'; +} + +static FORCEINLINE CHAR +__tolower( + IN CHAR Character + ) +{ + if (Character < 'A' || Character > 'Z') + return Character; + + return 'a' + Character - 'A'; +} + +#endif // _COMMON_UTIL_H diff --git a/src/xencrsh/util.h b/src/xencrsh/util.h deleted file mode 100644 index bdfd2cd..0000000 --- a/src/xencrsh/util.h +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (c) Citrix Systems Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _UTIL_H -#define _UTIL_H - -#include <ntddk.h> - -#include "assert.h" - -#define P2ROUNDUP(_x, _a) \ - (-(-(_x) & -(_a))) - -static FORCEINLINE LONG -__ffs( - IN unsigned long long mask - ) -{ - unsigned char *array = (unsigned char *)&mask; - unsigned int byte; - unsigned int bit; - unsigned char val; - - val = 0; - - byte = 0; - while (byte < 8) { - val = array[byte]; - - if (val != 0) - break; - - byte++; - } - if (byte == 8) - return -1; - - bit = 0; - while (bit < 8) { - if (val & 0x01) - break; - - val >>= 1; - bit++; - } - - return (byte * 8) + bit; -} - -#define __ffu(_mask) \ - __ffs(~(_mask)) - -static FORCEINLINE LONG -__InterlockedAdd( - IN LONG *Value, - IN LONG Delta - ) -{ - LONG New; - LONG Old; - - do { - Old = *Value; - New = Old + Delta; - } while (InterlockedCompareExchange(Value, New, Old) != Old); - - return New; -} - -static FORCEINLINE LONG -__InterlockedSubtract( - IN LONG *Value, - IN LONG Delta - ) -{ - LONG New; - LONG Old; - - do { - Old = *Value; - New = Old - Delta; - } while (InterlockedCompareExchange(Value, New, Old) != Old); - - return New; -} - -typedef struct _NON_PAGED_BUFFER_HEADER { - SIZE_T Length; - ULONG Tag; -} NON_PAGED_BUFFER_HEADER, *PNON_PAGED_BUFFER_HEADER; - -typedef struct _NON_PAGED_BUFFER_TRAILER { - ULONG Tag; -} NON_PAGED_BUFFER_TRAILER, *PNON_PAGED_BUFFER_TRAILER; - -static FORCEINLINE PVOID -__AllocateNonPagedPoolWithTag( - IN SIZE_T Length, - IN ULONG Tag - ) -{ - PUCHAR Buffer; - PNON_PAGED_BUFFER_HEADER Header; - PNON_PAGED_BUFFER_TRAILER Trailer; - - ASSERT(Length != 0); - - Buffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER), - Tag); - if (Buffer == NULL) - goto done; - - RtlZeroMemory(Buffer, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER)); - - Header = (PNON_PAGED_BUFFER_HEADER)Buffer; - Header->Length = Length; - Header->Tag = Tag; - - Buffer += sizeof (NON_PAGED_BUFFER_HEADER); - - Trailer = (PNON_PAGED_BUFFER_TRAILER)(Buffer + Length); - Trailer->Tag = Tag; - -done: - return Buffer; -} - -static FORCEINLINE VOID -__FreePoolWithTag( - IN PVOID _Buffer, - IN ULONG Tag - ) -{ - PUCHAR Buffer = (PUCHAR)_Buffer; - SIZE_T Length; - PNON_PAGED_BUFFER_HEADER Header; - PNON_PAGED_BUFFER_TRAILER Trailer; - - ASSERT(Buffer != NULL); - - Buffer -= sizeof (NON_PAGED_BUFFER_HEADER); - - Header = (PNON_PAGED_BUFFER_HEADER)Buffer; - ASSERT3U(Tag, ==, Header->Tag); - Length = Header->Length; - - Buffer += sizeof (NON_PAGED_BUFFER_HEADER); - - Trailer = (PNON_PAGED_BUFFER_TRAILER)(Buffer + Length); - ASSERT3U(Tag, ==, Trailer->Tag); - - Buffer -= sizeof (NON_PAGED_BUFFER_HEADER); - - RtlFillMemory(Buffer, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER), - 0xAA); - - ExFreePoolWithTag(Buffer, Tag); -} - -#endif // _UTIL_H diff --git a/src/xendisk/util.h b/src/xendisk/util.h deleted file mode 100644 index 169dc6c..0000000 --- a/src/xendisk/util.h +++ /dev/null @@ -1,359 +0,0 @@ -/* Copyright (c) Citrix Systems Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _XENDISK_UTIL_H -#define _XENDISK_UTIL_H - -#include <ntddk.h> - -#include "assert.h" - -#define P2ROUNDUP(_x, _a) \ - (-(-(_x) & -(_a))) - -static FORCEINLINE LONG -__ffs( - IN unsigned long long mask - ) -{ - unsigned char *array = (unsigned char *)&mask; - unsigned int byte; - unsigned int bit; - unsigned char val; - - val = 0; - - byte = 0; - while (byte < 8) { - val = array[byte]; - - if (val != 0) - break; - - byte++; - } - if (byte == 8) - return -1; - - bit = 0; - while (bit < 8) { - if (val & 0x01) - break; - - val >>= 1; - bit++; - } - - return (byte * 8) + bit; -} - -#define __ffu(_mask) \ - __ffs(~(_mask)) - -static FORCEINLINE VOID -__CpuId( - IN ULONG Leaf, - OUT PULONG EAX OPTIONAL, - OUT PULONG EBX OPTIONAL, - OUT PULONG ECX OPTIONAL, - OUT PULONG EDX OPTIONAL - ) -{ - ULONG Value[4] = {0}; - - __cpuid(Value, Leaf); - - if (EAX) - *EAX = Value[0]; - - if (EBX) - *EBX = Value[1]; - - if (ECX) - *ECX = Value[2]; - - if (EDX) - *EDX = Value[3]; -} - -static FORCEINLINE LONG -__InterlockedAdd( - IN LONG *Value, - IN LONG Delta - ) -{ - LONG New; - LONG Old; - - do { - Old = *Value; - New = Old + Delta; - } while (InterlockedCompareExchange(Value, New, Old) != Old); - - return New; -} - -static FORCEINLINE LONG -__InterlockedSubtract( - IN LONG *Value, - IN LONG Delta - ) -{ - LONG New; - LONG Old; - - do { - Old = *Value; - New = Old - Delta; - } while (InterlockedCompareExchange(Value, New, Old) != Old); - - return New; -} - -static FORCEINLINE PVOID -__AllocatePoolWithTag( - IN POOL_TYPE PoolType, - IN SIZE_T NumberOfBytes, - IN ULONG Tag - ) -{ - PUCHAR Buffer; - - __analysis_assume(PoolType == NonPagedPool || - PoolType == PagedPool); - - Buffer = ExAllocatePoolWithTag(PoolType, NumberOfBytes, Tag); - if (Buffer == NULL) - return NULL; - - RtlZeroMemory(Buffer, NumberOfBytes); - return Buffer; -} - -static FORCEINLINE VOID -__FreePoolWithTag( - IN PVOID Buffer, - IN ULONG Tag - ) -{ - ExFreePoolWithTag(Buffer, Tag); -} - -static FORCEINLINE PMDL -__AllocatePages( - IN ULONG Count - ) -{ - PHYSICAL_ADDRESS LowAddress; - PHYSICAL_ADDRESS HighAddress; - LARGE_INTEGER SkipBytes; - SIZE_T TotalBytes; - PMDL Mdl; - PUCHAR MdlMappedSystemVa; - NTSTATUS status; - - LowAddress.QuadPart = 0ull; - HighAddress.QuadPart = ~0ull; - SkipBytes.QuadPart = 0ull; - TotalBytes = (SIZE_T)PAGE_SIZE * Count; - - Mdl = MmAllocatePagesForMdlEx(LowAddress, - HighAddress, - SkipBytes, - TotalBytes, - MmCached, - MM_DONT_ZERO_ALLOCATION); - - status = STATUS_NO_MEMORY; - if (Mdl == NULL) - goto fail1; - - if (Mdl->ByteCount < TotalBytes) - goto fail2; - - ASSERT((Mdl->MdlFlags & (MDL_MAPPED_TO_SYSTEM_VA | - MDL_PARTIAL_HAS_BEEN_MAPPED | - MDL_PARTIAL | - MDL_PARENT_MAPPED_SYSTEM_VA | - MDL_SOURCE_IS_NONPAGED_POOL | - MDL_IO_SPACE)) == 0); - - MdlMappedSystemVa = MmMapLockedPagesSpecifyCache(Mdl, - KernelMode, - MmCached, - NULL, - FALSE, - NormalPagePriority); - - status = STATUS_UNSUCCESSFUL; - if (MdlMappedSystemVa == NULL) - goto fail3; - - ASSERT3P(MdlMappedSystemVa, ==, Mdl->MappedSystemVa); - - RtlZeroMemory(MdlMappedSystemVa, Mdl->ByteCount); - - return Mdl; - -fail3: - Error("fail3\n"); - -fail2: - Error("fail2\n"); - - MmFreePagesFromMdl(Mdl); - ExFreePool(Mdl); - -fail1: - Error("fail1 (%08x)\n", status); - - return NULL; -} - -#define __AllocatePage() __AllocatePages(1) - -static FORCEINLINE VOID -__FreePages( - IN PMDL Mdl - ) -{ - PUCHAR MdlMappedSystemVa; - - ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA); - MdlMappedSystemVa = Mdl->MappedSystemVa; - - MmUnmapLockedPages(MdlMappedSystemVa, Mdl); - - MmFreePagesFromMdl(Mdl); - ExFreePool(Mdl); -} - -#define __FreePage(_Mdl) __FreePages(_Mdl) - -static FORCEINLINE PCHAR -__strtok_r( - IN PCHAR Buffer, - IN PCHAR Delimiter, - IN OUT PCHAR *Context - ) -{ - PCHAR Token; - PCHAR End; - - if (Buffer != NULL) - *Context = Buffer; - - Token = *Context; - - if (Token == NULL) - return NULL; - - while (*Token != '\0' && - strchr(Delimiter, *Token) != NULL) - Token++; - - if (*Token == '\0') - return NULL; - - End = Token + 1; - while (*End != '\0' && - strchr(Delimiter, *End) == NULL) - End++; - - if (*End != '\0') - *End++ = '\0'; - - *Context = End; - - return Token; -} - -static FORCEINLINE PWCHAR -__wcstok_r( - IN PWCHAR Buffer, - IN PWCHAR Delimiter, - IN OUT PWCHAR *Context - ) -{ - PWCHAR Token; - PWCHAR End; - - if (Buffer != NULL) - *Context = Buffer; - - Token = *Context; - - if (Token == NULL) - return NULL; - - while (*Token != L'\0' && - wcschr(Delimiter, *Token) != NULL) - Token++; - - if (*Token == L'\0') - return NULL; - - End = Token + 1; - while (*End != L'\0' && - wcschr(Delimiter, *End) == NULL) - End++; - - if (*End != L'\0') - *End++ = L'\0'; - - *Context = End; - - return Token; -} - -static FORCEINLINE CHAR -__toupper( - IN CHAR Character - ) -{ - if (Character < 'a' || Character > 'z') - return Character; - - return 'A' + Character - 'a'; -} - -static FORCEINLINE CHAR -__tolower( - IN CHAR Character - ) -{ - if (Character < 'A' || Character > 'Z') - return Character; - - return 'a' + Character - 'A'; -} - -#endif // _XENDISK_UTIL_H diff --git a/src/xenvbd/blockring.c b/src/xenvbd/blockring.c index 7cf5c84..a865c75 100644 --- a/src/xenvbd/blockring.c +++ b/src/xenvbd/blockring.c @@ -70,10 +70,7 @@ __BlockRingAllocate( IN ULONG Length ) { - return __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Length, - BLOCKRING_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Length, BLOCKRING_POOL_TAG); } static FORCEINLINE VOID @@ -299,11 +296,15 @@ BlockRingConnect( BlockRing->Order = 0; } + BlockRing->Mdl = __AllocatePages(1 << BlockRing->Order); + status = STATUS_NO_MEMORY; - BlockRing->SharedRing = __AllocPages((SIZE_T)PAGE_SIZE << BlockRing->Order, &BlockRing->Mdl); - if (BlockRing->SharedRing == NULL) + if (BlockRing->Mdl == NULL) goto fail2; + BlockRing->SharedRing = MmGetSystemAddressForMdlSafe(BlockRing->Mdl, + NormalPagePriority); + #pragma warning(push) #pragma warning(disable: 4305) #pragma warning(disable: 4311) @@ -330,7 +331,7 @@ fail3: } RtlZeroMemory(&BlockRing->FrontRing, sizeof(BlockRing->FrontRing)); - __FreePages(BlockRing->SharedRing, BlockRing->Mdl); + __FreePages(BlockRing->Mdl); BlockRing->SharedRing = NULL; BlockRing->Mdl = NULL; @@ -443,7 +444,7 @@ BlockRingDisconnect( } RtlZeroMemory(&BlockRing->FrontRing, sizeof(BlockRing->FrontRing)); - __FreePages(BlockRing->SharedRing, BlockRing->Mdl); + __FreePages(BlockRing->Mdl); BlockRing->SharedRing = NULL; BlockRing->Mdl = NULL; diff --git a/src/xenvbd/buffer.c b/src/xenvbd/buffer.c index 3caadcb..9de7792 100644 --- a/src/xenvbd/buffer.c +++ b/src/xenvbd/buffer.c @@ -76,16 +76,19 @@ __BufferAlloc() { PXENVBD_BUFFER BufferId; - BufferId = (PXENVBD_BUFFER)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, sizeof(XENVBD_BUFFER), BUFFER_POOL_TAG); + BufferId = (PXENVBD_BUFFER)__AllocatePoolWithTag(NonPagedPool, sizeof(XENVBD_BUFFER), BUFFER_POOL_TAG); if (BufferId == NULL) goto fail1; RtlZeroMemory(BufferId, sizeof(XENVBD_BUFFER)); - BufferId->VAddr = __AllocPages(PAGE_SIZE, &BufferId->Mdl); - if (BufferId->VAddr == NULL) + BufferId->Mdl = __AllocatePage(); + if (BufferId->Mdl == NULL) goto fail2; + BufferId->VAddr = MmGetSystemAddressForMdlSafe(BufferId->Mdl, + NormalPagePriority); + BufferId->Pfn = (PFN_NUMBER)(MmGetPhysicalAddress(BufferId->VAddr).QuadPart >> PAGE_SHIFT); ++__Buffer.Allocated; @@ -104,7 +107,7 @@ __BufferFree( if (BufferId == NULL) return; - __FreePages(BufferId->VAddr, BufferId->Mdl); + __FreePage(BufferId->Mdl); __FreePoolWithTag((PVOID)BufferId, BUFFER_POOL_TAG); ++__Buffer.Freed; diff --git a/src/xenvbd/driver.c b/src/xenvbd/driver.c index 776d5ae..114c740 100644 --- a/src/xenvbd/driver.c +++ b/src/xenvbd/driver.c @@ -237,7 +237,8 @@ __DriverFormatV( ULONG Size = 32; for (;;) { - Str = (PCHAR)__AllocateNonPagedPoolWithTag(__FUNCTION__, __LINE__, Size, XENVBD_POOL_TAG); + Str = (PCHAR)__AllocatePoolWithTag(NonPagedPool, Size, + XENVBD_POOL_TAG); if (!Str) { return NULL; } diff --git a/src/xenvbd/fdo.c b/src/xenvbd/fdo.c index b49a217..c1aeeb5 100644 --- a/src/xenvbd/fdo.c +++ b/src/xenvbd/fdo.c @@ -674,10 +674,9 @@ __FdoMultiSzToAnsi( } } - Ansi = __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - sizeof (ANSI_STRING) * (Count + 1), - FDO_SIGNATURE); + Ansi = __AllocatePoolWithTag(NonPagedPool, + sizeof (ANSI_STRING) * (Count + 1), + FDO_SIGNATURE); status = STATUS_NO_MEMORY; if (Ansi == NULL) @@ -688,10 +687,9 @@ __FdoMultiSzToAnsi( Length = (ULONG)strlen(Buffer); Ansi[Index].MaximumLength = (USHORT)(Length + 1); - Ansi[Index].Buffer = __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Ansi[Index].MaximumLength, - FDO_SIGNATURE); + Ansi[Index].Buffer = __AllocatePoolWithTag(NonPagedPool, + Ansi[Index].MaximumLength, + FDO_SIGNATURE); status = STATUS_NO_MEMORY; if (Ansi[Index].Buffer == NULL) @@ -745,10 +743,9 @@ __FdoMultiSzToUpcaseAnsi( } } - Ansi = __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - sizeof (ANSI_STRING) * (Count + 1), - FDO_SIGNATURE); + Ansi = __AllocatePoolWithTag(NonPagedPool, + sizeof (ANSI_STRING) * (Count + 1), + FDO_SIGNATURE); status = STATUS_NO_MEMORY; if (Ansi == NULL) @@ -759,10 +756,9 @@ __FdoMultiSzToUpcaseAnsi( Length = (ULONG)strlen(Buffer); Ansi[Index].MaximumLength = (USHORT)(Length + 1); - Ansi[Index].Buffer = __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Ansi[Index].MaximumLength, - FDO_SIGNATURE); + Ansi[Index].Buffer = __AllocatePoolWithTag(NonPagedPool, + Ansi[Index].MaximumLength, + FDO_SIGNATURE); status = STATUS_NO_MEMORY; if (Ansi[Index].Buffer == NULL) diff --git a/src/xenvbd/frontend.c b/src/xenvbd/frontend.c index d48b6e6..11e9121 100644 --- a/src/xenvbd/frontend.c +++ b/src/xenvbd/frontend.c @@ -106,15 +106,12 @@ __drv_allocatesMem(mem) __bcount(Size) static FORCEINLINE PVOID #pragma warning(suppress: 28195) -___FrontendAlloc( - __in PCHAR Caller, - __in ULONG Line, - __in ULONG Size +__FrontendAlloc( + __in ULONG Size ) { - return __AllocateNonPagedPoolWithTag(Caller, Line, Size, FRONTEND_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Size, FRONTEND_POOL_TAG); } -#define __FrontendAlloc(Size) ___FrontendAlloc(__FUNCTION__, __LINE__, Size) static FORCEINLINE VOID #pragma warning(suppress: 28197) diff --git a/src/xenvbd/granter.c b/src/xenvbd/granter.c index c2054de..e8c1161 100644 --- a/src/xenvbd/granter.c +++ b/src/xenvbd/granter.c @@ -57,10 +57,7 @@ __GranterAllocate( IN ULONG Length ) { - return __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Length, - GRANTER_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Length, GRANTER_POOL_TAG); } static FORCEINLINE VOID diff --git a/src/xenvbd/notifier.c b/src/xenvbd/notifier.c index 0b2664f..36e2ba1 100644 --- a/src/xenvbd/notifier.c +++ b/src/xenvbd/notifier.c @@ -59,10 +59,7 @@ __NotifierAllocate( IN ULONG Length ) { - return __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Length, - NOTIFIER_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Length, NOTIFIER_POOL_TAG); } static FORCEINLINE VOID diff --git a/src/xenvbd/pdo.c b/src/xenvbd/pdo.c index 8e28b3c..dd5b6ea 100644 --- a/src/xenvbd/pdo.c +++ b/src/xenvbd/pdo.c @@ -134,15 +134,12 @@ __drv_allocatesMem(mem) __bcount(Size) static FORCEINLINE PVOID #pragma warning(suppress: 28195) -___PdoAlloc( - __in PCHAR Caller, - __in ULONG Line, - __in ULONG Size +__PdoAlloc( + __in ULONG Size ) { - return __AllocateNonPagedPoolWithTag(Caller, Line, Size, PDO_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Size, PDO_POOL_TAG); } -#define __PdoAlloc(Size) ___PdoAlloc(__FUNCTION__, __LINE__, Size) static FORCEINLINE VOID #pragma warning(suppress: 28197) @@ -572,10 +569,13 @@ PdoGetIndirect( RtlZeroMemory(Indirect, sizeof(XENVBD_INDIRECT)); - Indirect->Page = __AllocPages(PAGE_SIZE, &Indirect->Mdl); - if (Indirect->Page == NULL) + Indirect->Mdl = __AllocatePage(); + if (Indirect->Mdl == NULL) goto fail2; + Indirect->Page = MmGetSystemAddressForMdlSafe(Indirect->Mdl, + NormalPagePriority); + status = GranterGet(Granter, MmGetMdlPfnArray(Indirect->Mdl)[0], TRUE, @@ -586,7 +586,7 @@ PdoGetIndirect( return Indirect; fail3: - __FreePages(Indirect->Page, Indirect->Mdl); + __FreePage(Indirect->Mdl); fail2: __LookasideFree(&Pdo->IndirectList, Indirect); fail1: @@ -604,7 +604,7 @@ PdoPutIndirect( if (Indirect->Grant) GranterPut(Granter, Indirect->Grant); if (Indirect->Page) - __FreePages(Indirect->Page, Indirect->Mdl); + __FreePage(Indirect->Mdl); RtlZeroMemory(Indirect, sizeof(XENVBD_INDIRECT)); __LookasideFree(&Pdo->IndirectList, Indirect); @@ -833,6 +833,8 @@ __PdoPriority( return HighPagePriority; } +#define __min(_x, _y) ((_x) < (_y)) ? (_x) : (_y) + static FORCEINLINE VOID SGListGet( IN OUT PXENVBD_SG_LIST SGList @@ -1884,7 +1886,7 @@ PdoModeSense( // Finish this SRB Srb->SrbStatus = SRB_STATUS_SUCCESS; - Srb->DataTransferLength = __min(Cdb_AllocationLength(Srb), Header->ModeDataLength + 1); + Srb->DataTransferLength = __min(Cdb_AllocationLength(Srb), (ULONG)(Header->ModeDataLength + 1)); } static DECLSPEC_NOINLINE VOID diff --git a/src/xenvbd/pdoinquiry.c b/src/xenvbd/pdoinquiry.c index 4460f3d..5a21c91 100644 --- a/src/xenvbd/pdoinquiry.c +++ b/src/xenvbd/pdoinquiry.c @@ -75,15 +75,12 @@ __drv_allocatesMem(mem) __bcount(Size) static FORCEINLINE PVOID #pragma warning(suppress: 28195) -___InquiryAlloc( - __in PCHAR Caller, - __in ULONG Line, - __in SIZE_T Size +__InquiryAlloc( + __in SIZE_T Size ) { - return __AllocateNonPagedPoolWithTag(Caller, Line, Size, INQUIRY_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Size, INQUIRY_POOL_TAG); } -#define __InquiryAlloc(Size) ___InquiryAlloc(__FUNCTION__, __LINE__, Size) static FORCEINLINE VOID #pragma warning(suppress: 28197) diff --git a/src/xenvbd/registry.c b/src/xenvbd/registry.c index 9ceffa5..40c77f1 100644 --- a/src/xenvbd/registry.c +++ b/src/xenvbd/registry.c @@ -44,10 +44,7 @@ __RegistryAllocate( IN ULONG Length ) { - return __AllocateNonPagedPoolWithTag(__FUNCTION__, - __LINE__, - Length, - REGISTRY_TAG); + return __AllocatePoolWithTag(NonPagedPool, Length, REGISTRY_TAG); } static FORCEINLINE VOID diff --git a/src/xenvbd/thread.c b/src/xenvbd/thread.c index 4cd2d18..dd4c8a0 100644 --- a/src/xenvbd/thread.c +++ b/src/xenvbd/thread.c @@ -53,15 +53,12 @@ __drv_allocatesMem(mem) __bcount(Length) static FORCEINLINE PVOID #pragma warning(suppress: 28195) -___ThreadAllocate( - __in PCHAR Caller, - __in ULONG Line, - __in ULONG Length +__ThreadAllocate( + __in ULONG Length ) { - return __AllocateNonPagedPoolWithTag(Caller, Line, Length, THREAD_POOL_TAG); + return __AllocatePoolWithTag(NonPagedPool, Length, THREAD_POOL_TAG); } -#define __ThreadAllocate(Length) ___ThreadAllocate(__FUNCTION__, __LINE__, Length) static FORCEINLINE VOID #pragma warning(suppress: 28197) diff --git a/src/xenvbd/util.h b/src/xenvbd/util.h deleted file mode 100644 index d9e6400..0000000 --- a/src/xenvbd/util.h +++ /dev/null @@ -1,318 +0,0 @@ -/* Copyright (c) Citrix Systems Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, - * with or without modification, are permitted provided - * that the following conditions are met: - * - * * Redistributions of source code must retain the above - * copyright notice, this list of conditions and the - * following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the - * following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND - * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef _UTIL_H -#define _UTIL_H - -#include <ntddk.h> - -#include "assert.h" - -static FORCEINLINE ULONG -__min( - IN ULONG a, - IN ULONG b - ) -{ - return a < b ? a : b; -} - -typedef struct _NON_PAGED_BUFFER_HEADER { - SIZE_T Length; - ULONG Tag; -} NON_PAGED_BUFFER_HEADER, *PNON_PAGED_BUFFER_HEADER; - -typedef struct _NON_PAGED_BUFFER_TRAILER { - ULONG Tag; -} NON_PAGED_BUFFER_TRAILER, *PNON_PAGED_BUFFER_TRAILER; - -static FORCEINLINE PVOID -__AllocateNonPagedPoolWithTag( - IN PCHAR Caller, - IN ULONG Line, - IN SIZE_T Length, - IN ULONG Tag - ) -{ - PUCHAR Buffer; - PNON_PAGED_BUFFER_HEADER Header; - PNON_PAGED_BUFFER_TRAILER Trailer; - - ASSERT3S(Length, !=, 0); - - Buffer = (PUCHAR)ExAllocatePoolWithTag(NonPagedPool, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER), - Tag); - if (Buffer == NULL) { - Warning("%s:%u : AllocFailed %d bytes, %08x tag\n", Caller, Line, Length, Tag); - goto done; - } - - RtlZeroMemory(Buffer, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER)); - - Header = (PNON_PAGED_BUFFER_HEADER)Buffer; - Header->Length = Length; - Header->Tag = Tag; - - Buffer += sizeof (NON_PAGED_BUFFER_HEADER); - - Trailer = (PNON_PAGED_BUFFER_TRAILER)(Buffer + Length); - Trailer->Tag = Tag; - -done: - return Buffer; -} - -static FORCEINLINE VOID -__FreePoolWithTag( - IN PVOID _Buffer, - IN ULONG Tag - ) -{ - PUCHAR Buffer = (PUCHAR)_Buffer; - SIZE_T Length; - PNON_PAGED_BUFFER_HEADER Header; - PNON_PAGED_BUFFER_TRAILER Trailer; - - ASSERT3P(Buffer, !=, NULL); - - Buffer -= sizeof (NON_PAGED_BUFFER_HEADER); - - Header = (PNON_PAGED_BUFFER_HEADER)Buffer; - ASSERT3U(Tag, ==, Header->Tag); - Length = Header->Length; - - Buffer += sizeof (NON_PAGED_BUFFER_HEADER); - - Trailer = (PNON_PAGED_BUFFER_TRAILER)(Buffer + Length); - ASSERT3U(Tag, ==, Trailer->Tag); - - Buffer -= sizeof (NON_PAGED_BUFFER_HEADER); - - RtlFillMemory(Buffer, - sizeof (NON_PAGED_BUFFER_HEADER) + - Length + - sizeof (NON_PAGED_BUFFER_TRAILER), - 0xAA); - - ExFreePoolWithTag(Buffer, Tag); -} - -static FORCEINLINE PMDL -__AllocPagesForMdl( - IN SIZE_T Size - ) -{ - PMDL Mdl; - PHYSICAL_ADDRESS LowAddr; - PHYSICAL_ADDRESS HighAddr; - PHYSICAL_ADDRESS SkipBytes; - - SkipBytes.QuadPart = 0ull; - HighAddr.QuadPart = ~0ull; - - // try > 4GB - LowAddr.QuadPart = 0x100000000ull; - Mdl = MmAllocatePagesForMdlEx(LowAddr, HighAddr, SkipBytes, Size, MmCached, 0); - if (Mdl) { - if (MmGetMdlByteCount(Mdl) == Size) { - goto done; - } - MmFreePagesFromMdl(Mdl); - ExFreePool(Mdl); - Mdl = NULL; - } - - // try > 2GB - LowAddr.QuadPart = 0x80000000ull; - Mdl = MmAllocatePagesForMdlEx(LowAddr, HighAddr, SkipBytes, Size, MmCached, 0); - if (Mdl) { - if (MmGetMdlByteCount(Mdl) == Size) { - goto done; - } - MmFreePagesFromMdl(Mdl); - ExFreePool(Mdl); - Mdl = NULL; - } - - // try anywhere - LowAddr.QuadPart = 0ull; - Mdl = MmAllocatePagesForMdlEx(LowAddr, HighAddr, SkipBytes, Size, MmCached, 0); - // Mdl byte count gets checked again after this returns - -done: - return Mdl; -} -static FORCEINLINE PVOID -___AllocPages( - IN PCHAR Caller, - IN ULONG Line, - IN SIZE_T Size, - OUT PMDL* Mdl - ) -{ - PVOID Buffer; - - *Mdl = __AllocPagesForMdl(Size); - if (*Mdl == NULL) { - Warning("%s:%u : MmAllocatePagesForMdlEx Failed %d bytes\n", Caller, Line, Size); - goto fail1; - } - - if (MmGetMdlByteCount(*Mdl) != Size) { - Warning("%s:%u : %d bytes != %d bytes requested\n", Caller, Line, MmGetMdlByteCount(*Mdl), Size); - goto fail2; - } - - Buffer = MmMapLockedPagesSpecifyCache(*Mdl, KernelMode, MmCached, NULL, FALSE, NormalPagePriority); - if (Buffer == NULL) { - Warning("%s:%u : MmMapLockedPagesSpecifyCache Failed %d bytes\n", Caller, Line, Size); - goto fail3; - } - - return Buffer; - -fail3: -fail2: - MmFreePagesFromMdl(*Mdl); - ExFreePool(*Mdl); -fail1: - *Mdl = NULL; - return NULL; -} -#define __AllocPages(Size, Mdl) ___AllocPages(__FUNCTION__, __LINE__, Size, Mdl) - -static FORCEINLINE VOID -__FreePages( - IN PVOID Buffer, - IN PMDL Mdl - ) -{ - if (Buffer && Mdl) { - MmUnmapLockedPages(Buffer, Mdl); - MmFreePagesFromMdl(Mdl); - ExFreePool(Mdl); - } -} - -static FORCEINLINE PCHAR -__strtok_r( - IN PCHAR Buffer, - IN PCHAR Delimiter, - IN OUT PCHAR *Context - ) -{ - PCHAR Token; - PCHAR End; - - if (Buffer != NULL) - *Context = Buffer; - - Token = *Context; - - if (Token == NULL) - return NULL; - - while (*Token != '\0' && - strchr(Delimiter, *Token) != NULL) - Token++; - - if (*Token == '\0') - return NULL; - - End = Token + 1; - while (*End != '\0' && - strchr(Delimiter, *End) == NULL) - End++; - - if (*End != '\0') - *End++ = '\0'; - - *Context = End; - - return Token; -} - -static FORCEINLINE PWCHAR -__wcstok_r( - IN PWCHAR Buffer, - IN PWCHAR Delimiter, - IN OUT PWCHAR *Context - ) -{ - PWCHAR Token; - PWCHAR End; - - if (Buffer != NULL) - *Context = Buffer; - - Token = *Context; - - if (Token == NULL) - return NULL; - - while (*Token != L'\0' && - wcschr(Delimiter, *Token) != NULL) - Token++; - - if (*Token == L'\0') - return NULL; - - End = Token + 1; - while (*End != L'\0' && - wcschr(Delimiter, *End) == NULL) - End++; - - if (*End != L'\0') - *End++ = L'\0'; - - *Context = End; - - return Token; -} - -static FORCEINLINE CHAR -__toupper( - IN CHAR Character - ) -{ - if (Character < 'a' || Character > 'z') - return Character; - - return 'A' + Character - 'a'; -} - -#endif // _UTIL_H diff --git a/vs2012/xencrsh/xencrsh.vcxproj b/vs2012/xencrsh/xencrsh.vcxproj index 7af512f..fa24d37 100644 --- a/vs2012/xencrsh/xencrsh.vcxproj +++ b/vs2012/xencrsh/xencrsh.vcxproj @@ -23,7 +23,7 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>..\..\include;$(IncludePath)</IncludePath> + <IncludePath>..\..\include;..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> diff --git a/vs2012/xendisk/xendisk.vcxproj b/vs2012/xendisk/xendisk.vcxproj index 478b7f0..b0d7983 100644 --- a/vs2012/xendisk/xendisk.vcxproj +++ b/vs2012/xendisk/xendisk.vcxproj @@ -23,7 +23,7 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>$(ProjectDir)..\..\include;$(IncludePath)</IncludePath> + <IncludePath>$(ProjectDir)..\..\include;..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> diff --git a/vs2012/xenvbd/xenvbd.vcxproj b/vs2012/xenvbd/xenvbd.vcxproj index 07fb837..78395f9 100644 --- a/vs2012/xenvbd/xenvbd.vcxproj +++ b/vs2012/xenvbd/xenvbd.vcxproj @@ -23,7 +23,7 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>$(ProjectDir)..\..\include;$(IncludePath)</IncludePath> + <IncludePath>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> @@ -92,4 +92,4 @@ <Inf Include="..\xenvbd.inf" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project> \ No newline at end of file +</Project> diff --git a/vs2013/xencrsh/xencrsh.vcxproj b/vs2013/xencrsh/xencrsh.vcxproj index 9e8de24..908e8ca 100644 --- a/vs2013/xencrsh/xencrsh.vcxproj +++ b/vs2013/xencrsh/xencrsh.vcxproj @@ -53,7 +53,7 @@ <Import Project="..\targets.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>..\..\include;$(IncludePath)</IncludePath> + <IncludePath>..\..\include;..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> diff --git a/vs2013/xendisk/xendisk.vcxproj b/vs2013/xendisk/xendisk.vcxproj index 73812d8..cb0f3a1 100644 --- a/vs2013/xendisk/xendisk.vcxproj +++ b/vs2013/xendisk/xendisk.vcxproj @@ -53,7 +53,7 @@ <Import Project="..\targets.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>$(ProjectDir)..\..\include;$(IncludePath)</IncludePath> + <IncludePath>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> diff --git a/vs2013/xenvbd/xenvbd.vcxproj b/vs2013/xenvbd/xenvbd.vcxproj index 566235f..453261a 100644 --- a/vs2013/xenvbd/xenvbd.vcxproj +++ b/vs2013/xenvbd/xenvbd.vcxproj @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="utf-8"?> +<?xml version="1.0" encoding="utf-8"?> <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="..\configs.props" /> <PropertyGroup Label="Globals"> @@ -53,7 +53,7 @@ <Import Project="..\targets.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <PropertyGroup> - <IncludePath>$(ProjectDir)..\..\include;$(IncludePath)</IncludePath> + <IncludePath>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\common;$(IncludePath)</IncludePath> <RunCodeAnalysis>true</RunCodeAnalysis> <EnableInf2cat>false</EnableInf2cat> <IntDir>..\$(ProjectName)\$(ConfigurationName)\$(Platform)\</IntDir> @@ -120,4 +120,4 @@ <Inf Include="..\xenvbd.inf" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> -</Project> \ No newline at end of file +</Project> diff --git a/vs2015/xencrsh/xencrsh.vcxproj b/vs2015/xencrsh/xencrsh.vcxproj index 5782816..986614e 100644 --- a/vs2015/xencrsh/xencrsh.vcxproj +++ b/vs2015/xencrsh/xencrsh.vcxproj @@ -20,7 +20,7 @@ </PropertyGroup> <ItemDefinitionGroup> <ClCompile> - <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>__MODULE__="XENCRSH";POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <WarningLevel>EnableAllWarnings</WarningLevel> <DisableSpecificWarnings>4464;4548;4711;4820;4668;4255;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings> @@ -28,7 +28,7 @@ <EnablePREfast>true</EnablePREfast> </ClCompile> <ResourceCompile> - <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Link> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> diff --git a/vs2015/xendisk/xendisk.vcxproj b/vs2015/xendisk/xendisk.vcxproj index 36ceee6..291ec91 100644 --- a/vs2015/xendisk/xendisk.vcxproj +++ b/vs2015/xendisk/xendisk.vcxproj @@ -20,7 +20,7 @@ </PropertyGroup> <ItemDefinitionGroup> <ClCompile> - <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <BufferSecurityCheck>false</BufferSecurityCheck> <PreprocessorDefinitions>__MODULE__="XENDISK";POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <WarningLevel>EnableAllWarnings</WarningLevel> @@ -29,7 +29,7 @@ <EnablePREfast>true</EnablePREfast> </ClCompile> <ResourceCompile> - <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Link> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> diff --git a/vs2015/xenvbd/xenvbd.vcxproj b/vs2015/xenvbd/xenvbd.vcxproj index fd99abc..18e753e 100644 --- a/vs2015/xenvbd/xenvbd.vcxproj +++ b/vs2015/xenvbd/xenvbd.vcxproj @@ -20,7 +20,7 @@ </PropertyGroup> <ItemDefinitionGroup> <ClCompile> - <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(WindowsSdkDir)\include\km;..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>__MODULE__="XENVBD";POOL_NX_OPTIN=1;%(PreprocessorDefinitions)</PreprocessorDefinitions> <WarningLevel>EnableAllWarnings</WarningLevel> <DisableSpecificWarnings>4464;4548;4711;4820;4668;4255;6001;6054;28196;30030;30029;%(DisableSpecificWarnings)</DisableSpecificWarnings> @@ -28,7 +28,7 @@ <EnablePREfast>true</EnablePREfast> </ClCompile> <ResourceCompile> - <AdditionalIncludeDirectories>..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>..\..\include;..\..\src\common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ResourceCompile> <Link> <ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers> -- 2.5.3 _______________________________________________ win-pv-devel mailing list win-pv-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |