Index: sys/compat/ndis/subr_ntoskrnl.c =================================================================== RCS file: /home/ncvs/src/sys/compat/ndis/subr_ntoskrnl.c,v retrieving revision 1.87 diff -u -r1.87 subr_ntoskrnl.c --- sys/compat/ndis/subr_ntoskrnl.c 16 May 2006 14:37:57 -0000 1.87 +++ sys/compat/ndis/subr_ntoskrnl.c 25 Nov 2006 07:28:51 -0000 @@ -197,6 +197,16 @@ static uint32_t InterlockedIncrement(volatile uint32_t *); static uint32_t InterlockedDecrement(volatile uint32_t *); static void ExInterlockedAddLargeStatistic(uint64_t *, uint32_t); +static void *MmAllocateContiguousMemory(uint32_t, uint64_t); +static void *MmAllocateContiguousMemorySpecifyCache(uint32_t, + uint64_t, uint64_t, uint64_t, uint32_t); +static void MmFreeContiguousMemory(void *); +static void MmFreeContiguousMemorySpecifyCache(void *, uint32_t, uint32_t); +/* +#ifdef MMGETPHYSICALADDRESS +staic uint64_t MmGetPhysicalAddress(void *); +#endif +*/ static uint32_t MmSizeOfMdl(void *, size_t); static void *MmMapLockedPages(mdl *, uint8_t); static void *MmMapLockedPagesSpecifyCache(mdl *, @@ -232,6 +242,9 @@ uint32_t, void *); static uint32_t WmiTraceMessage(uint64_t, uint32_t, void *, uint16_t, ...); static uint32_t IoWMIRegistrationControl(device_object *, uint32_t); +#ifdef MEMCHR +static void *ntoskrnl_memchr(const void *, int, size_t); +#endif static void *ntoskrnl_memset(void *, int, size_t); static void *ntoskrnl_memmove(void *, void *, size_t); static char *ntoskrnl_strstr(char *, char *); @@ -433,6 +446,32 @@ return(dst); } +#ifdef MEMCHR + +/* + * /usr/src/sys/modules/ndis/../../compat/ndis/subr_ntoskrnl.c: In function `ntoskrnl_memchr': + * /usr/src/sys/modules/ndis/../../compat/ndis/subr_ntoskrnl.c:458: warning: cast discards qualifiers from pointer target type + * *** Error code 1 + */ + +static void * +ntoskrnl_memchr(buf, ch, len) + const void *buf; + int ch; + size_t len; +{ + if (len != 0) { + const unsigned char *p = buf; + + do { + if (*p++ == ch) + return ((void *)(p - 1)); /* error occurs here */ + } while (--len != 0); + } + return (NULL); +} +#endif + static char * ntoskrnl_strstr(s, find) char *s, *find; @@ -2471,6 +2510,66 @@ return; } +static void * +MmAllocateContiguousMemory(size, highest) + uint32_t size; /* Specifies the number of bytes to allocate */ + uint64_t highest; /* Specifies the highest valid physical address that the driver can use. */ +{ + void *addr; + size_t pagelength = ((size + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; + + addr = ExAllocatePoolWithTag(NonPagedPool, pagelength, 0); + + return(addr); +} + +static void * +MmAllocateContiguousMemorySpecifyCache(size, lowest, highest, boundary, cachetype) + uint32_t size; /* Specifies the number of bytes to allocate */ + uint64_t lowest; /* Specifies the lowest valid physical address that the driver can use. */ + uint64_t highest; /* Specifies the highest valid physical address that the driver can use. */ + uint64_t boundary; /* If nonzero, this value specifies the physical address multiple that */ + /* the allocated buffer must not cross. */ + uint32_t cachetype; /* indicates the type of caching allowed for the requested memory */ +{ + void *addr; + size_t pagelength = ((size + PAGE_SIZE -1) / PAGE_SIZE) * PAGE_SIZE; + + addr = ExAllocatePoolWithTag(NonPagedPool, pagelength, 0); + + return(addr); +} + +static void +MmFreeContiguousMemory(base) + void *base; /* Specifies the base address of the buffer to be freed */ +{ + ExFreePool(base); +} + +static void +MmFreeContiguousMemorySpecifyCache(base, size, cachetype) + void *base; /* Specifies the base address of the buffer to be freed */ + uint32_t size; /* Specifies the size in bytes of the buffer to be freed. Must match the */ + /* size requested when the buffer was allocated */ + uint32_t cachetype; /* Specifies the cache type of the buffer to be freed */ +{ + ExFreePool(base); +} + +#ifdef MMGETPHYSICALADDRESS +/* The MmGetPhysicalAddress routine returns the physical address corresponding to a valid virtual address. */ + +staic uint64_t +MmGetPhysicalAddress(base); + void *base; /* Pointer to the virtual address for which to return the physical address. */ +{ + void *physical; /* physical address that corresponds to the given virtual address. */ + + return(physical); +} +#endif + static uint32_t MmSizeOfMdl(vaddr, len) void *vaddr; @@ -4144,6 +4243,7 @@ IMPORT_SFUNC(DbgBreakPoint, 0), IMPORT_CFUNC(strncmp, 0), IMPORT_CFUNC(strcmp, 0), + IMPORT_CFUNC_MAP(stricmp, strcasecmp, 0), IMPORT_CFUNC(strncpy, 0), IMPORT_CFUNC(strcpy, 0), IMPORT_CFUNC(strlen, 0), @@ -4151,6 +4251,10 @@ IMPORT_CFUNC_MAP(tolower, ntoskrnl_tolower, 0), IMPORT_CFUNC_MAP(strstr, ntoskrnl_strstr, 0), IMPORT_CFUNC_MAP(strchr, index, 0), + IMPORT_CFUNC_MAP(strrchr, rindex, 0), +#ifdef MEMCHR + IMPORT_CFUNC_MAP(memchr, ntoskrnl_memchr, 0), +#endif IMPORT_CFUNC(memcpy, 0), IMPORT_CFUNC_MAP(memmove, ntoskrnl_memmove, 0), IMPORT_CFUNC_MAP(memset, ntoskrnl_memset, 0), @@ -4239,6 +4343,13 @@ IMPORT_FFUNC(ExInterlockedAddLargeStatistic, 2), IMPORT_SFUNC(IoAllocateMdl, 5), IMPORT_SFUNC(IoFreeMdl, 1), + IMPORT_SFUNC(MmAllocateContiguousMemory, 2), + IMPORT_SFUNC(MmAllocateContiguousMemorySpecifyCache, 5), + IMPORT_SFUNC(MmFreeContiguousMemory, 1), + IMPORT_SFUNC(MmFreeContiguousMemorySpecifyCache, 3), +#ifdef MMGETPHYSICALADDRESS + IMPORT_SFUNC(MmGetPhysicalAddress, 1), +#endif IMPORT_SFUNC(MmSizeOfMdl, 1), IMPORT_SFUNC(MmMapLockedPages, 2), IMPORT_SFUNC(MmMapLockedPagesSpecifyCache, 6),