Date: Thu, 4 Mar 2004 16:04:39 -0800 (PST) From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 48166 for review Message-ID: <200403050004.i2504deo079081@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=48166 Change 48166 by rwatson@rwatson_tislabs on 2004/03/04 16:04:36 Integ netperf_socket just to be sure; mostly NDIS. Affected files ... .. //depot/projects/netperf_socket/sys/compat/ndis/ntoskrnl_var.h#3 integrate .. //depot/projects/netperf_socket/sys/compat/ndis/subr_ntoskrnl.c#4 integrate .. //depot/projects/netperf_socket/sys/dev/usb/usbdi.c#2 integrate .. //depot/projects/netperf_socket/sys/modules/ndis/Makefile#3 integrate Differences ... ==== //depot/projects/netperf_socket/sys/compat/ndis/ntoskrnl_var.h#3 (text+ko) ==== @@ -29,7 +29,7 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. * - * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.8 2004/02/16 02:50:03 wpaul Exp $ + * $FreeBSD: src/sys/compat/ndis/ntoskrnl_var.h,v 1.9 2004/03/04 23:04:02 wpaul Exp $ */ #ifndef _NTOSKRNL_VAR_H_ @@ -212,14 +212,35 @@ #define EVENT_TYPE_NOTIFY 0 #define EVENT_TYPE_SYNC 1 +/* + * We need to use the timeout()/untimeout() API for ktimers + * since timers can be initialized, but not destroyed (so + * malloc()ing our own callout structures would mean a leak, + * since there'd be no way to free() them). This means we + * need to use struct callout_handle, which is really just a + * pointer. To make it easier to deal with, we use a union + * to overlay the callout_handle over the k_timerlistentry. + * The latter is a list_entry, which is two pointers, so + * there's enough space available to hide a callout_handle + * there. + */ + struct ktimer { nt_dispatch_header k_header; uint64_t k_duetime; - list_entry k_timerlistentry; + union { + list_entry k_timerlistentry; + struct callout_handle k_handle; + } u; void *k_dpc; uint32_t k_period; }; +#define k_timerlistentry u.k_timerlistentry +#define k_handle u.k_handle + +typedef struct ktimer ktimer; + struct nt_kevent { nt_dispatch_header k_header; }; @@ -243,6 +264,8 @@ uint32_t *k_lock; }; +typedef struct kdpc kdpc; + /* * Note: the acquisition count is BSD-specific. The Microsoft * documentation says that mutexes can be acquired recursively @@ -256,13 +279,18 @@ */ struct kmutant { nt_dispatch_header km_header; - list_entry km_listentry; + union { + list_entry km_listentry; + uint32_t km_acquirecnt; + } u; void *km_ownerthread; uint8_t km_abandoned; uint8_t km_apcdisable; - uint32_t km_acquirecnt; }; +#define km_listentry u.km_listentry +#define km_acquirecnt u.km_acquirecnt + typedef struct kmutant kmutant; #define LOOKASIDE_DEPTH 256 ==== //depot/projects/netperf_socket/sys/compat/ndis/subr_ntoskrnl.c#4 (text+ko) ==== @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.25 2004/03/04 00:17:14 wpaul Exp $"); +__FBSDID("$FreeBSD: src/sys/compat/ndis/subr_ntoskrnl.c,v 1.26 2004/03/04 23:04:02 wpaul Exp $"); #include <sys/ctype.h> #include <sys/unistd.h> @@ -64,8 +64,6 @@ #include <compat/ndis/ntoskrnl_var.h> #include <compat/ndis/ndis_var.h> -#include "opt_ddb.h" - #define __regparm __attribute__((regparm(3))) #define FUNC void(*)(void) @@ -92,6 +90,15 @@ __stdcall static uint32_t ntoskrnl_read_event(nt_kevent *); __stdcall static uint32_t ntoskrnl_set_event(nt_kevent *, uint32_t, uint8_t); __stdcall static uint32_t ntoskrnl_reset_event(nt_kevent *); +static void ntoskrnl_timercall(void *); +__stdcall static void ntoskrnl_init_dpc(kdpc *, void *, void *); +__stdcall static void ntoskrnl_init_timer(ktimer *); +__stdcall static void ntoskrnl_init_timer_ex(ktimer *, uint32_t); +__stdcall static uint8_t ntoskrnl_set_timer(ktimer *, int64_t, kdpc *); +__stdcall static uint8_t ntoskrnl_set_timer_ex(ktimer *, int64_t, + uint32_t, kdpc *); +__stdcall static uint8_t ntoskrnl_cancel_timer(ktimer *); +__stdcall static uint8_t ntoskrnl_read_timer(ktimer *); __stdcall static void ntoskrnl_writereg_ushort(uint16_t *, uint16_t); __stdcall static uint16_t ntoskrnl_readreg_ushort(uint16_t *); __stdcall static void ntoskrnl_writereg_ulong(uint32_t *, uint32_t); @@ -1636,14 +1643,177 @@ __stdcall static void ntoskrnl_debugger(void) { -#ifdef DDB - Debugger("debug from winkernel module"); -#else - printf("ntoskrnl_debugger(): DDB not present\n"); -#endif + Debugger("ntoskrnl_debugger(): breakpoint"); + return; +} + +static void +ntoskrnl_timercall(arg) + void *arg; +{ + ktimer *timer; + __stdcall kdpc_func timerfunc; + kdpc *dpc; + struct timeval tv; + + timer = arg; + dpc = timer->k_dpc; + timerfunc = (kdpc_func)dpc->k_deferedfunc; + timerfunc(dpc, dpc->k_deferredctx, dpc->k_sysarg1, dpc->k_sysarg2); + + ntoskrnl_wakeup(&timer->k_header); + + /* + * If this is a periodic timer, re-arm it + * so it will fire again. + */ + + if (timer->k_period) { + tv.tv_sec = 0; + tv.tv_usec = timer->k_period * 1000; + timer->k_handle = + timeout(ntoskrnl_timercall, timer, tvtohz(&tv)); + } + + return; +} + +__stdcall static void +ntoskrnl_init_timer(timer) + ktimer *timer; +{ + if (timer == NULL) + return; + + INIT_LIST_HEAD((&timer->k_header.dh_waitlisthead)); + timer->k_header.dh_sigstate = FALSE; + timer->k_header.dh_type = EVENT_TYPE_NOTIFY; + timer->k_header.dh_size = OTYPE_TIMER; + callout_handle_init(&timer->k_handle); + + return; +} + +__stdcall static void +ntoskrnl_init_timer_ex(timer, type) + ktimer *timer; + uint32_t type; +{ + if (timer == NULL) + return; + + INIT_LIST_HEAD((&timer->k_header.dh_waitlisthead)); + timer->k_header.dh_sigstate = FALSE; + timer->k_header.dh_type = type; + timer->k_header.dh_size = OTYPE_TIMER; + callout_handle_init(&timer->k_handle); + + return; +} + +__stdcall static void +ntoskrnl_init_dpc(dpc, dpcfunc, dpcctx) + kdpc *dpc; + void *dpcfunc; + void *dpcctx; +{ + if (dpc == NULL) + return; + + dpc->k_deferedfunc = dpcfunc; + dpc->k_deferredctx = dpcctx; + return; } +__stdcall static uint8_t +ntoskrnl_set_timer_ex(timer, duetime, period, dpc) + ktimer *timer; + int64_t duetime; + uint32_t period; + kdpc *dpc; +{ + struct timeval tv; + uint64_t curtime; + uint8_t pending; + + if (timer == NULL) + return(FALSE); + + if (timer->k_handle.callout != NULL && + callout_pending(timer->k_handle.callout)) + pending = TRUE; + else + pending = FALSE; + + timer->k_duetime = duetime; + timer->k_period = period; + timer->k_header.dh_sigstate = FALSE; + timer->k_dpc = dpc; + + if (duetime < 0) { + tv.tv_sec = - (duetime) / 10000000 ; + tv.tv_usec = (- (duetime) / 10) - + (tv.tv_sec * 1000000); + } else { + ntoskrnl_time(&curtime); + tv.tv_sec = ((duetime) - curtime) / 10000000 ; + tv.tv_usec = ((duetime) - curtime) / 10 - + (tv.tv_sec * 1000000); + } + + timer->k_handle = timeout(ntoskrnl_timercall, timer, tvtohz(&tv)); + + return(pending); +} + +__stdcall static uint8_t +ntoskrnl_set_timer(timer, duetime, dpc) + ktimer *timer; + int64_t duetime; + kdpc *dpc; +{ + return (ntoskrnl_set_timer_ex(timer, duetime, 0, dpc)); +} + +__stdcall static uint8_t +ntoskrnl_cancel_timer(timer) + ktimer *timer; +{ + uint8_t pending; + + if (timer == NULL) + return(FALSE); + + if (timer->k_handle.callout != NULL && + callout_pending(timer->k_handle.callout)) + pending = TRUE; + else + pending = FALSE; + + untimeout(ntoskrnl_timercall, timer, timer->k_handle); + + return(pending); +} + +__stdcall static uint8_t +ntoskrnl_read_timer(timer) + ktimer *timer; +{ + uint8_t pending; + + if (timer == NULL) + return(FALSE); + + if (timer->k_handle.callout != NULL && + callout_pending(timer->k_handle.callout)) + pending = TRUE; + else + pending = FALSE; + + return(pending); +} + __stdcall static void dummy() { @@ -1730,15 +1900,13 @@ { "KeResetEvent", (FUNC)ntoskrnl_reset_event }, { "KeClearEvent", (FUNC)ntoskrnl_clear_event }, { "KeReadStateEvent", (FUNC)ntoskrnl_read_event }, -#ifdef notyet - { "KeInitializeTimer", - { "KeInitializeTimerEx", - { "KeCancelTimer", - { "KeSetTimer", - { "KeSetTimerEx", - { "KeReadStateTimer", - { "KeInitializeDpc", -#endif + { "KeInitializeTimer", (FUNC)ntoskrnl_init_timer }, + { "KeInitializeTimerEx", (FUNC)ntoskrnl_init_timer_ex }, + { "KeInitializeDpc", (FUNC)ntoskrnl_init_dpc }, + { "KeSetTimer", (FUNC)ntoskrnl_set_timer }, + { "KeSetTimerEx", (FUNC)ntoskrnl_set_timer_ex }, + { "KeCancelTimer", (FUNC)ntoskrnl_cancel_timer }, + { "KeReadStateTimer", (FUNC)ntoskrnl_read_timer }, { "ObReferenceObjectByHandle", (FUNC)ntoskrnl_objref }, { "ObfDereferenceObject", (FUNC)ntoskrnl_objderef }, { "ZwClose", (FUNC)ntoskrnl_zwclose }, ==== //depot/projects/netperf_socket/sys/dev/usb/usbdi.c#2 (text+ko) ==== @@ -1,7 +1,7 @@ /* $NetBSD: usbdi.c,v 1.103 2002/09/27 15:37:38 provos Exp $ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD: src/sys/dev/usb/usbdi.c,v 1.84 2003/11/09 23:56:19 joe Exp $"); +__FBSDID("$FreeBSD: src/sys/dev/usb/usbdi.c,v 1.85 2004/03/04 20:49:03 phk Exp $"); /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1117,11 +1117,9 @@ int usbd_ratecheck(struct timeval *last) { -#if 0 - static struct timeval errinterval = { 0, 250000 }; /* 0.25 s*/ - - return (ratecheck(last, &errinterval)); -#endif + if (last->tv_sec == time_second) + return (0); + last->tv_sec = time_second; return (1); } ==== //depot/projects/netperf_socket/sys/modules/ndis/Makefile#3 (text+ko) ==== @@ -1,10 +1,9 @@ -# $FreeBSD: src/sys/modules/ndis/Makefile,v 1.4 2004/03/03 17:57:05 wpaul Exp $ +# $FreeBSD: src/sys/modules/ndis/Makefile,v 1.5 2004/03/04 23:04:02 wpaul Exp $ .PATH: ${.CURDIR}/../../compat/ndis KMOD= ndis SRCS= subr_pe.c subr_ndis.c subr_hal.c subr_ntoskrnl.c kern_ndis.c SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h card_if.h vnode_if.h -SRCS+= opt_ddb.h .include <bsd.kmod.mk>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200403050004.i2504deo079081>