Deleted Added
full compact
subr_ndis.c (123757) subr_ndis.c (123821)
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 123757 2003-12-23 04:08:22Z wpaul $");
34__FBSDID("$FreeBSD: head/sys/compat/ndis/subr_ndis.c 123821 2003-12-24 21:21:18Z 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

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

867
868__stdcall static void
869ndis_create_timer(timer, handle, func, ctx)
870 ndis_miniport_timer *timer;
871 ndis_handle *handle;
872 ndis_timer_function func;
873 void *ctx;
874{
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

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

867
868__stdcall static void
869ndis_create_timer(timer, handle, func, ctx)
870 ndis_miniport_timer *timer;
871 ndis_handle *handle;
872 ndis_timer_function func;
873 void *ctx;
874{
875 struct callout_handle *ch;
875 struct ndis_timer_entry *ne = NULL;
876 ndis_miniport_block *block;
877 block = (ndis_miniport_block *)handle;
876
878
877 ch = (struct callout_handle *)&timer->nmt_dpc;
878 callout_handle_init(ch);
879 ne = malloc(sizeof(struct ndis_timer_entry), M_DEVBUF, M_NOWAIT);
880 callout_handle_init(&ne->nte_ch);
881 TAILQ_INSERT_TAIL(&block->nmb_timerlist, ne, link);
882 ne->nte_timer = timer;
883
884 timer->nmt_ktimer.nk_header.dh_sigstate = TRUE;
885 timer->nmt_dpc.nk_deferredctx = &ne->nte_ch;
879 timer->nmt_timerfunc = func;
880 timer->nmt_timerctx = ctx;
881
882 return;
883}
884
885/*
886 * The driver's timer callout is __stdcall function, so we need this

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

891ndis_timercall(arg)
892 void *arg;
893{
894 ndis_miniport_timer *timer;
895 __stdcall ndis_timer_function timerfunc;
896
897 timer = arg;
898
886 timer->nmt_timerfunc = func;
887 timer->nmt_timerctx = ctx;
888
889 return;
890}
891
892/*
893 * The driver's timer callout is __stdcall function, so we need this

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

898ndis_timercall(arg)
899 void *arg;
900{
901 ndis_miniport_timer *timer;
902 __stdcall ndis_timer_function timerfunc;
903
904 timer = arg;
905
906 timer->nmt_ktimer.nk_header.dh_sigstate = FALSE;
899 timerfunc = timer->nmt_timerfunc;
900 timerfunc(NULL, timer->nmt_timerctx, NULL, NULL);
901
902 return;
903}
904
905/*
906 * Windows specifies timeouts in milliseconds. We specify timeouts

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

914 uint32_t msecs;
915{
916 struct callout_handle *ch;
917 struct timeval tv;
918
919 tv.tv_sec = 0;
920 tv.tv_usec = msecs * 1000;
921
907 timerfunc = timer->nmt_timerfunc;
908 timerfunc(NULL, timer->nmt_timerctx, NULL, NULL);
909
910 return;
911}
912
913/*
914 * Windows specifies timeouts in milliseconds. We specify timeouts

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

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

--- 1297 unchanged lines hidden ---
998
999 return;
1000}
1001
1002__stdcall static void
1003ndis_query_resources(status, adapter, list, buflen)
1004 ndis_status *status;
1005 ndis_handle adapter;

--- 1297 unchanged lines hidden ---