Latest Broadcom NDIS driver requires 4 additional functions
- From: "Scot Hetzel" <swhetzel@xxxxxxxxx>
- Date: Sat, 25 Nov 2006 12:51:28 -0600
I'm trying to upgrade my ndis driver from version 3.100.64.0 to
4.40.19.0, but when I try to load the driver I get a Fatal trap 12
error.
#fetch ftp://ftp.hp.com/pub/softpaq/sp33001-33500/sp33008.exe
#cabextract -q -L -F 'bcmwl5*' sp33008.exe
#ndisgen bcmwl5.inf bcmwl564.sys
#kldloadd ./bcmwl564_sys.ko
no match for strrchr
no match for MmFreeContiguousMemorySpecifyCache
no match for MmAllocateContiguousMemorySpecifyCache
no match for MmGetPhysicalAddress
ichsmb0: <SMBus Controller> port 0x8400-0x840f mem
0xc0003000-0xc0003fff at device 20.0 on pci0
device_attach: ichsmb0 attach returned 6
ndis0: <Broadcom 802.11b/g WLAN> mem 0xc0204000-0xc0205fff irq 21 at
device 20.0 on pci6
ndis0: NDIS API Version: 5.1
fpudna in kernel mode!
ntoskrnl dummy called...
Fatal trap 12: page fault while in kernel mode
cpuid = 0; apic id = 00
fault virtual address = 0x1a
fault code = supervisor read, page not present
instruction pointer = 0x8:0xffffffffa2b1b1eb
stack pointer = 0x10:0xffffffffa2a6f100
frame pointer = 0x10:0xffffffffa2b82140
code segment = base 0x0, limit 0xfffff, type 0x1b
= DPL 0, pres 1, long 1, def32 0, gran 1
processor eflags = intrrupt enabled, resume, IOPL=0
current process = 1503 (kldload)
[thread pid 1503 tid 100099]
stopped at 0xffffffffa2b1b1eb: cmpb (%rax, %rdx, 1), %cl
db>bt
tracing pid 1503 tid 100099 td 0xffffff002f569810
bcmwl564_sys_drv_data_start() at 0xffffffffa2b1b1eb
(null)() at 0x11600000000
NOTE: This fatal trap 12 was caused by the missing strrchr function,
after implementing only that function, and recompiling the ndis.ko
module the driver nolonger crashed the kernel.
I was able to create the first 3 functions for the NDIS compatibility
layer, but I'm not sure how to find the Physical address from the
Virtual Address for the MmGetPhysicalAddress function.
Implemented Functions:
stricmp
strrchr
MmAllocateContiguousMemory
MmAllocateContiguousMemorySpecifyCache
MmFreeContiguousMemory
MmFreeContiguousMemorySpecifyCache
Unimplemented Functions:
memchr - implemented but causes "cast discards qualifiers from
pointer target type" (copied from lib/libc/string/memchr.c)
MmGetPhysicalAddress - needs to be implemented
Any ideas as to how to fix memchr, and implement MmGetPhysicalAddress?
Scot
--
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.
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),
_______________________________________________
freebsd-current@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscribe@xxxxxxxxxxx"
- Follow-Ups:
- Re: Latest Broadcom NDIS driver requires 4 additional functions
- From: Rainer Alves
- Re: Latest Broadcom NDIS driver requires 4 additional functions
- From: Scott Long
- Re: Latest Broadcom NDIS driver requires 4 additional functions
- Prev by Date: Re: freebsd-update the src ?
- Next by Date: Re: Latest Broadcom NDIS driver requires 4 additional functions
- Previous by thread: freebsd-update the src ?
- Next by thread: Re: Latest Broadcom NDIS driver requires 4 additional functions
- Index(es):
Relevant Pages
|
|