Deleted Added
full compact
subr_ndis.c (123822) subr_ndis.c (123832)
1/*
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2003
3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ndis.c 123822 2003-12-25 00:40:02Z wpaul $");
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ndis.c 123832 2003-12-25 21:34:16Z wpaul $");
35
36/*
37 * This file implements a translation layer between the BSD networking
38 * infrasturcture and Windows(R) NDIS network driver modules. A Windows
39 * NDIS driver calls into several functions in the NDIS.SYS Windows
40 * kernel module and exports a table of functions designed to be called
41 * by the NDIS subsystem. Using the PE loader, we can patch our own
42 * versions of the NDIS routines into a given Windows driver module and

--- 835 unchanged lines hidden (view full) ---

878 ndis_timer_function func;
879 void *ctx;
880{
881 struct ndis_timer_entry *ne = NULL;
882 ndis_miniport_block *block;
883 block = (ndis_miniport_block *)handle;
884
885 ne = malloc(sizeof(struct ndis_timer_entry), M_DEVBUF, M_NOWAIT);
35
36/*
37 * This file implements a translation layer between the BSD networking
38 * infrasturcture and Windows(R) NDIS network driver modules. A Windows
39 * NDIS driver calls into several functions in the NDIS.SYS Windows
40 * kernel module and exports a table of functions designed to be called
41 * by the NDIS subsystem. Using the PE loader, we can patch our own
42 * versions of the NDIS routines into a given Windows driver module and

--- 835 unchanged lines hidden (view full) ---

878 ndis_timer_function func;
879 void *ctx;
880{
881 struct ndis_timer_entry *ne = NULL;
882 ndis_miniport_block *block;
883 block = (ndis_miniport_block *)handle;
884
885 ne = malloc(sizeof(struct ndis_timer_entry), M_DEVBUF, M_NOWAIT);
886 callout_handle_init(&ne->nte_ch);
886 callout_init(&ne->nte_ch, CALLOUT_MPSAFE);
887 TAILQ_INSERT_TAIL(&block->nmb_timerlist, ne, link);
888 ne->nte_timer = timer;
889
890 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
891 timer->nmt_dpc.nk_deferredctx = &ne->nte_ch;
892 timer->nmt_timerfunc = func;
893 timer->nmt_timerctx = ctx;
894

--- 27 unchanged lines hidden (view full) ---

922 * so we approximate. Note that we abuse the dpc portion of the
923 * miniport timer structure to hold the UNIX callout handle.
924 */
925__stdcall static void
926ndis_set_timer(timer, msecs)
927 ndis_miniport_timer *timer;
928 uint32_t msecs;
929{
887 TAILQ_INSERT_TAIL(&block->nmb_timerlist, ne, link);
888 ne->nte_timer = timer;
889
890 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
891 timer->nmt_dpc.nk_deferredctx = &ne->nte_ch;
892 timer->nmt_timerfunc = func;
893 timer->nmt_timerctx = ctx;
894

--- 27 unchanged lines hidden (view full) ---

922 * so we approximate. Note that we abuse the dpc portion of the
923 * miniport timer structure to hold the UNIX callout handle.
924 */
925__stdcall static void
926ndis_set_timer(timer, msecs)
927 ndis_miniport_timer *timer;
928 uint32_t msecs;
929{
930 struct callout_handle *ch;
930 struct callout *ch;
931 struct timeval tv;
932
933 tv.tv_sec = 0;
934 tv.tv_usec = msecs * 1000;
935
936 ch = timer->nmt_dpc.nk_deferredctx;
937 timer->nmt_dpc.nk_sysarg2 = ndis_timercall;
938 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
931 struct timeval tv;
932
933 tv.tv_sec = 0;
934 tv.tv_usec = msecs * 1000;
935
936 ch = timer->nmt_dpc.nk_deferredctx;
937 timer->nmt_dpc.nk_sysarg2 = ndis_timercall;
938 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
939 *ch = timeout((timeout_t *)timer->nmt_dpc.nk_sysarg2, (void *)timer,
940 tvtohz(&tv));
939 callout_reset(ch, tvtohz(&tv), timer->nmt_dpc.nk_sysarg2, timer);
941
942 return;
943}
944
945static void
946ndis_tick(arg)
947 void *arg;
948{
949 ndis_miniport_timer *timer;
940
941 return;
942}
943
944static void
945ndis_tick(arg)
946 void *arg;
947{
948 ndis_miniport_timer *timer;
950 struct callout_handle *ch;
949 struct callout *ch;
951 __stdcall ndis_timer_function timerfunc;
952 struct timeval tv;
953
954 timer = arg;
955
956 timer->nmt_ktimer.nk_header.dh_sigstate = FALSE;
957 timerfunc = timer->nmt_timerfunc;
958 timerfunc(NULL, timer->nmt_timerctx, NULL, NULL);
959
960 /* Automatically reload timer. */
961
962 tv.tv_sec = 0;
963 tv.tv_usec = timer->nmt_ktimer.nk_period * 1000;
964 ch = timer->nmt_dpc.nk_deferredctx;
965 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
966 timer->nmt_dpc.nk_sysarg2 = ndis_tick;
950 __stdcall ndis_timer_function timerfunc;
951 struct timeval tv;
952
953 timer = arg;
954
955 timer->nmt_ktimer.nk_header.dh_sigstate = FALSE;
956 timerfunc = timer->nmt_timerfunc;
957 timerfunc(NULL, timer->nmt_timerctx, NULL, NULL);
958
959 /* Automatically reload timer. */
960
961 tv.tv_sec = 0;
962 tv.tv_usec = timer->nmt_ktimer.nk_period * 1000;
963 ch = timer->nmt_dpc.nk_deferredctx;
964 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
965 timer->nmt_dpc.nk_sysarg2 = ndis_tick;
967 *ch = timeout((timeout_t *)timer->nmt_dpc.nk_sysarg2, timer,
968 tvtohz(&tv));
966 callout_reset(ch, tvtohz(&tv), timer->nmt_dpc.nk_sysarg2, timer);
969
970 return;
971}
972
973__stdcall static void
974ndis_set_periodic_timer(timer, msecs)
975 ndis_miniport_timer *timer;
976 uint32_t msecs;
977{
967
968 return;
969}
970
971__stdcall static void
972ndis_set_periodic_timer(timer, msecs)
973 ndis_miniport_timer *timer;
974 uint32_t msecs;
975{
978 struct callout_handle *ch;
976 struct callout *ch;
979 struct timeval tv;
980
981 tv.tv_sec = 0;
982 tv.tv_usec = msecs * 1000;
983
984 timer->nmt_ktimer.nk_period = msecs;
985 ch = timer->nmt_dpc.nk_deferredctx;
986 timer->nmt_dpc.nk_sysarg2 = ndis_tick;
987 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
977 struct timeval tv;
978
979 tv.tv_sec = 0;
980 tv.tv_usec = msecs * 1000;
981
982 timer->nmt_ktimer.nk_period = msecs;
983 ch = timer->nmt_dpc.nk_deferredctx;
984 timer->nmt_dpc.nk_sysarg2 = ndis_tick;
985 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
988 *ch = timeout((timeout_t *)timer->nmt_dpc.nk_sysarg2, timer,
989 tvtohz(&tv));
986 callout_reset(ch, tvtohz(&tv), timer->nmt_dpc.nk_sysarg2, timer);
990
991 return;
992}
993
994__stdcall static void
995ndis_cancel_timer(timer, cancelled)
996 ndis_miniport_timer *timer;
997 uint8_t *cancelled;
998{
987
988 return;
989}
990
991__stdcall static void
992ndis_cancel_timer(timer, cancelled)
993 ndis_miniport_timer *timer;
994 uint8_t *cancelled;
995{
999 struct callout_handle *ch;
996 struct callout *ch;
1000
1001 ch = timer->nmt_dpc.nk_deferredctx;
997
998 ch = timer->nmt_dpc.nk_deferredctx;
1002 untimeout(ch->callout->c_func, ch->callout->c_arg, *ch);
999 callout_stop(ch);
1003 *cancelled = timer->nmt_ktimer.nk_header.dh_sigstate;
1004
1005 return;
1006}
1007
1008__stdcall static void
1009ndis_query_resources(status, adapter, list, buflen)
1010 ndis_status *status;

--- 1360 unchanged lines hidden ---
1000 *cancelled = timer->nmt_ktimer.nk_header.dh_sigstate;
1001
1002 return;
1003}
1004
1005__stdcall static void
1006ndis_query_resources(status, adapter, list, buflen)
1007 ndis_status *status;

--- 1360 unchanged lines hidden ---