Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 2010 20:54:54 +0000 (UTC)
From:      Bernhard Schmidt <bschmidt@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r216242 - head/sys/compat/ndis
Message-ID:  <201012062054.oB6Kss52044561@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bschmidt
Date: Mon Dec  6 20:54:53 2010
New Revision: 216242
URL: http://svn.freebsd.org/changeset/base/216242

Log:
  Implement NdisGetRoutineAddress and MmGetSystemRoutineAddress used in
  newer Ralink drivers.
  
  Submitted by:	Paul B Mahol <onemda at gmail.com>

Modified:
  head/sys/compat/ndis/kern_ndis.c
  head/sys/compat/ndis/ndis_var.h
  head/sys/compat/ndis/ntoskrnl_var.h
  head/sys/compat/ndis/subr_ndis.c
  head/sys/compat/ndis/subr_ntoskrnl.c

Modified: head/sys/compat/ndis/kern_ndis.c
==============================================================================
--- head/sys/compat/ndis/kern_ndis.c	Mon Dec  6 20:40:15 2010	(r216241)
+++ head/sys/compat/ndis/kern_ndis.c	Mon Dec  6 20:54:53 2010	(r216242)
@@ -433,6 +433,19 @@ ndis_flush_sysctls(arg)
 	return (0);
 }
 
+void *
+ndis_get_routine_address(functbl, name)
+	struct image_patch_table *functbl;
+	char			*name;
+{
+	int			i;
+
+	for (i = 0; functbl[i].ipt_name != NULL; i++)
+		if (strcmp(name, functbl[i].ipt_name) == 0)
+			return (functbl[i].ipt_wrap);
+	return (NULL);
+}
+
 static void
 ndis_return(dobj, arg)
 	device_object		*dobj;

Modified: head/sys/compat/ndis/ndis_var.h
==============================================================================
--- head/sys/compat/ndis/ndis_var.h	Mon Dec  6 20:40:15 2010	(r216241)
+++ head/sys/compat/ndis/ndis_var.h	Mon Dec  6 20:54:53 2010	(r216242)
@@ -1729,6 +1729,7 @@ extern int ndis_mtop(struct mbuf *, ndis
 extern int ndis_ptom(struct mbuf **, ndis_packet *);
 extern int ndis_get_info(void *, ndis_oid, void *, int *);
 extern int ndis_set_info(void *, ndis_oid, void *, int *);
+extern void *ndis_get_routine_address(struct image_patch_table *, char *);
 extern int ndis_get_supported_oids(void *, ndis_oid **, int *);
 extern int ndis_send_packets(void *, ndis_packet **, int);
 extern int ndis_send_packet(void *, ndis_packet *);

Modified: head/sys/compat/ndis/ntoskrnl_var.h
==============================================================================
--- head/sys/compat/ndis/ntoskrnl_var.h	Mon Dec  6 20:40:15 2010	(r216241)
+++ head/sys/compat/ndis/ntoskrnl_var.h	Mon Dec  6 20:54:53 2010	(r216242)
@@ -1466,6 +1466,7 @@ extern uint32_t IoConnectInterrupt(kinte
 	kspin_lock *, uint32_t, uint8_t, uint8_t, uint8_t, uint8_t,
 	uint32_t, uint8_t);
 extern uint8_t MmIsAddressValid(void *);
+extern void *MmGetSystemRoutineAddress(unicode_string *);
 extern void *MmMapIoSpace(uint64_t, uint32_t, uint32_t);
 extern void MmUnmapIoSpace(void *, size_t);
 extern void MmBuildMdlForNonPagedPool(mdl *);

Modified: head/sys/compat/ndis/subr_ndis.c
==============================================================================
--- head/sys/compat/ndis/subr_ndis.c	Mon Dec  6 20:40:15 2010	(r216241)
+++ head/sys/compat/ndis/subr_ndis.c	Mon Dec  6 20:54:53 2010	(r216242)
@@ -197,6 +197,7 @@ static ndis_status NdisMMapIoSpace(void 
 	ndis_physaddr, uint32_t);
 static void NdisMUnmapIoSpace(ndis_handle, void *, uint32_t);
 static uint32_t NdisGetCacheFillSize(void);
+static void *NdisGetRoutineAddress(unicode_string *);
 static uint32_t NdisMGetDmaAlignment(ndis_handle);
 static ndis_status NdisMInitializeScatterGatherDma(ndis_handle,
 	uint8_t, uint32_t);
@@ -1642,6 +1643,17 @@ NdisGetCacheFillSize(void)
 	return (128);
 }
 
+static void *
+NdisGetRoutineAddress(ustr)
+	unicode_string		*ustr;
+{
+	ansi_string		astr;
+
+	if (RtlUnicodeStringToAnsiString(&astr, ustr, TRUE))
+		return (NULL);
+	return (ndis_get_routine_address(ndis_functbl, astr.as_buf));
+}
+
 static uint32_t
 NdisMGetDmaAlignment(handle)
 	ndis_handle		handle;
@@ -3246,6 +3258,7 @@ image_patch_table ndis_functbl[] = {
 	IMPORT_SFUNC(NdisInitializeString, 2),
 	IMPORT_SFUNC(NdisFreeString, 1),
 	IMPORT_SFUNC(NdisGetCurrentSystemTime, 1),
+	IMPORT_SFUNC(NdisGetRoutineAddress, 1),
 	IMPORT_SFUNC(NdisGetSystemUpTime, 1),
 	IMPORT_SFUNC(NdisGetVersion, 0),
 	IMPORT_SFUNC(NdisMSynchronizeWithInterrupt, 3),

Modified: head/sys/compat/ndis/subr_ntoskrnl.c
==============================================================================
--- head/sys/compat/ndis/subr_ntoskrnl.c	Mon Dec  6 20:40:15 2010	(r216241)
+++ head/sys/compat/ndis/subr_ntoskrnl.c	Mon Dec  6 20:54:53 2010	(r216242)
@@ -2589,6 +2589,17 @@ MmGetPhysicalAddress(void *base)
 	return (pmap_extract(kernel_map->pmap, (vm_offset_t)base));
 }
 
+void *
+MmGetSystemRoutineAddress(ustr)
+	unicode_string		*ustr;
+{
+	ansi_string		astr;
+
+	if (RtlUnicodeStringToAnsiString(&astr, ustr, TRUE))
+		return (NULL);
+	return (ndis_get_routine_address(ntoskrnl_functbl, astr.as_buf));
+}
+
 uint8_t
 MmIsAddressValid(vaddr)
 	void			*vaddr;
@@ -4382,6 +4393,7 @@ image_patch_table ntoskrnl_functbl[] = {
 	IMPORT_SFUNC(MmUnmapLockedPages, 2),
 	IMPORT_SFUNC(MmBuildMdlForNonPagedPool, 1),
 	IMPORT_SFUNC(MmGetPhysicalAddress, 1),
+	IMPORT_SFUNC(MmGetSystemRoutineAddress, 1),
 	IMPORT_SFUNC(MmIsAddressValid, 1),
 	IMPORT_SFUNC(MmMapIoSpace, 3 + 1),
 	IMPORT_SFUNC(MmUnmapIoSpace, 2),



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012062054.oB6Kss52044561>