The branch main has been updated by brooks:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=bfc99943b04b46a6c1c885ce7bcc6f235b7422aa

commit bfc99943b04b46a6c1c885ce7bcc6f235b7422aa
Author:     Brooks Davis <bro...@one-eyed-alien.net>
AuthorDate: 2021-01-25 21:45:03 +0000
Commit:     Brooks Davis <bro...@freebsd.org>
CommitDate: 2021-01-25 21:45:03 +0000

    ndis(4): remove as previous announced
    
    nids(4) was a clever idea in the early 2000's when the market was
    flooded with 10/100 NICs with Windows-only drivers, but that hasn't been
    the case for ages and the driver has had no meaningful maintenance in
    ages. It only supports Windows-XP era drivers.
    
    Also remove:
     - ndis support from wpa_supplicant
     - ndiscvt(8)
    
    Reviewed By:    emaste, bcr (manpages)
    Differential Revision:  https://reviews.freebsd.org/D27609
---
 ObsoleteFiles.inc                           |    9 +
 share/man/man4/Makefile                     |    4 -
 share/man/man4/ndis.4                       |  155 -
 sys/compat/ndis/cfg_var.h                   |   49 -
 sys/compat/ndis/hal_var.h                   |   55 -
 sys/compat/ndis/kern_ndis.c                 | 1447 ---------
 sys/compat/ndis/kern_windrv.c               | 1170 -------
 sys/compat/ndis/ndis_var.h                  | 1763 -----------
 sys/compat/ndis/ntoskrnl_var.h              | 1517 ---------
 sys/compat/ndis/pe_var.h                    |  555 ----
 sys/compat/ndis/resource_var.h              |  201 --
 sys/compat/ndis/subr_hal.c                  |  482 ---
 sys/compat/ndis/subr_ndis.c                 | 3372 --------------------
 sys/compat/ndis/subr_ntoskrnl.c             | 4446 ---------------------------
 sys/compat/ndis/subr_pe.c                   |  644 ----
 sys/compat/ndis/subr_usbd.c                 | 1461 ---------
 sys/compat/ndis/usbd_var.h                  |  224 --
 sys/compat/ndis/winx32_wrap.S               |  385 ---
 sys/compat/ndis/winx64_wrap.S               |  179 --
 sys/conf/files.amd64                        |    1 -
 sys/conf/files.i386                         |    1 -
 sys/conf/files.x86                          |   10 -
 sys/dev/if_ndis/if_ndis.c                   | 3423 ---------------------
 sys/dev/if_ndis/if_ndis_pci.c               |  357 ---
 sys/dev/if_ndis/if_ndis_usb.c               |  240 --
 sys/dev/if_ndis/if_ndisvar.h                |  263 --
 sys/modules/Makefile                        |    4 -
 sys/modules/if_ndis/Makefile                |   10 -
 targets/pseudo/userland/Makefile.depend     |    3 -
 tools/build/mk/OptionalObsoleteFiles.inc    |    8 -
 tools/kerneldoc/subsys/Doxyfile-dev_if_ndis |   21 -
 usr.sbin/Makefile.amd64                     |    3 -
 usr.sbin/Makefile.i386                      |    3 -
 usr.sbin/ndiscvt/Makefile                   |   27 -
 usr.sbin/ndiscvt/Makefile.depend            |   19 -
 usr.sbin/ndiscvt/inf-parse.y                |  112 -
 usr.sbin/ndiscvt/inf-token.l                |  134 -
 usr.sbin/ndiscvt/inf.c                      |  920 ------
 usr.sbin/ndiscvt/inf.h                      |   61 -
 usr.sbin/ndiscvt/ndiscvt.8                  |  283 --
 usr.sbin/ndiscvt/ndiscvt.c                  |  436 ---
 usr.sbin/ndiscvt/ndisgen.8                  |   86 -
 usr.sbin/ndiscvt/ndisgen.sh                 |  556 ----
 usr.sbin/ndiscvt/windrv_stub.c              |  268 --
 usr.sbin/wpa/Makefile                       |    1 -
 usr.sbin/wpa/ndis_events/Makefile           |    8 -
 usr.sbin/wpa/ndis_events/Makefile.depend    |   18 -
 usr.sbin/wpa/ndis_events/ndis_events.8      |  135 -
 usr.sbin/wpa/ndis_events/ndis_events.c      |  353 ---
 usr.sbin/wpa/wpa_supplicant/Makefile        |    6 +-
 usr.sbin/wpa/wpa_supplicant/Packet32.c      |  415 ---
 usr.sbin/wpa/wpa_supplicant/Packet32.h      |   69 -
 usr.sbin/wpa/wpa_supplicant/ntddndis.h      |   31 -
 53 files changed, 11 insertions(+), 26392 deletions(-)

diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index 1d0766ec894a..29cf25e152e6 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -36,6 +36,15 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
+# 20210125: ndis driver support removed
+OLD_FILES+=usr/sbin/ndiscvt
+OLD_FILES+=usr/sbin/ndisgen
+OLD_FILES+=usr/share/man/man4/ndis.4.gz
+OLD_FILES+=usr/share/man/man4/if_ndis.4.gz
+OLD_FILES+=usr/share/man/man8/ndiscvt.8.gz
+OLD_FILES+=usr/share/man/man8/ndisgen.8.gz
+OLD_FILES+=usr/share/misc/windrv_stub.c
+
 # 20210116: if_wl_wavelan.h removed
 .if ${TARGET_ARCH} == "i386"
 OLD_FILES+=usr/include/machine/if_wl_wavelan.h
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index 10034a72d608..65f8bc817db3 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -325,7 +325,6 @@ MAN=        aac.4 \
        mx25l.4 \
        mxge.4 \
        my.4 \
-       ${_ndis.4} \
        net80211.4 \
        netdump.4 \
        netfpga10g_nf10bmac.4 \
@@ -715,7 +714,6 @@ MLINKS+=msk.4 if_msk.4
 MLINKS+=mwl.4 if_mwl.4
 MLINKS+=mxge.4 if_mxge.4
 MLINKS+=my.4 if_my.4
-MLINKS+=${_ndis.4} ${_if_ndis.4}
 MLINKS+=netfpga10g_nf10bmac.4 if_nf10bmac.4
 MLINKS+=netintro.4 net.4 \
        netintro.4 networking.4
@@ -815,7 +813,6 @@ _hwpstate_intel.4=  hwpstate_intel.4
 _i8254.4=      i8254.4
 _ichwd.4=      ichwd.4
 _if_bxe.4=     if_bxe.4
-_if_ndis.4=    if_ndis.4
 _if_nfe.4=     if_nfe.4
 _if_urtw.4=    if_urtw.4
 _if_vmx.4=     if_vmx.4
@@ -826,7 +823,6 @@ _io.4=              io.4
 _itwd.4=       itwd.4
 _linux.4=      linux.4
 _nda.4=                nda.4
-_ndis.4=       ndis.4
 _nfe.4=                nfe.4
 _nfsmb.4=      nfsmb.4
 _if_ntb.4=     if_ntb.4
diff --git a/share/man/man4/ndis.4 b/share/man/man4/ndis.4
deleted file mode 100644
index 0a1ae39bff62..000000000000
--- a/share/man/man4/ndis.4
+++ /dev/null
@@ -1,155 +0,0 @@
-.\" Copyright (c) 2003
-.\"    Bill Paul <wp...@windriver.com>. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\"    notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\"    notice, this list of conditions and the following disclaimer in the
-.\"    documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\"    must display the following acknowledgement:
-.\"    This product includes software developed by Bill Paul.
-.\" 4. Neither the name of the author nor the names of any co-contributors
-.\"    may be used to endorse or promote products derived from this software
-.\"   without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
-.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-.\" THE POSSIBILITY OF SUCH DAMAGE.
-.\"
-.\" $FreeBSD$
-.\"
-.Dd March 14, 2010
-.Dt NDIS 4
-.Os
-.Sh NAME
-.Nm ndis
-.Nd NDIS miniport driver wrapper
-.Sh SYNOPSIS
-.Cd "options NDISAPI"
-.Cd "device ndis"
-.Cd "device wlan"
-.Sh DESCRIPTION
-The
-.Nm
-driver is a wrapper designed to allow binary
-.Tn Windows\[rg]
-NDIS miniport
-network drivers to be used with
-.Fx .
-The
-.Nm
-driver is provided in source code form and must be combined with
-the
-.Tn Windows\[rg]
-driver supplied with your network adapter.
-The
-.Nm
-driver uses the
-.Nm ndisapi
-kernel subsystem to relocate and link the
-.Tn Windows\[rg]
-binary so
-that it can be used in conjunction with native code.
-The
-.Nm ndisapi
-subsystem provides an interface between the NDIS API and the
-.Fx
-networking infrastructure.
-The
-.Tn Windows\[rg]
-driver is essentially
-fooled into thinking it is running on
-.Tn Windows\[rg] .
-Note that this
-means the
-.Nm
-driver is only useful on x86 machines.
-.Pp
-To build a functional driver, the user must have a copy of the
-driver distribution media for his or her card.
-From this distribution,
-the user must extract two files: the
-.Pa .SYS
-file containing the driver
-binary code, and its companion
-.Pa .INF
-file, which contains the
-definitions for driver-specific registry keys and other installation
-data such as device identifiers.
-These two files can be converted
-into a kernel module file using the
-.Xr ndisgen 8
-utility.
-This file contains a binary image of the driver plus
-registry key data.
-When the
-.Nm
-driver loads, it will create
-.Xr sysctl 3
-nodes for each registry key extracted from the
-.Pa .INF
-file.
-.Pp
-The
-.Nm
-driver is designed to support mainly Ethernet and wireless
-network devices with PCI and USB bus attachments.
-(Cardbus devices are also supported as PCI.)
-It can
-support many different media types and speeds.
-One limitation
-however, is that there is no consistent way to learn if an
-Ethernet device is operating in full or half duplex mode.
-The NDIS API allows for a generic means for determining link
-state and speed, but not the duplex setting.
-There may be
-driver-specific registry keys to control the media setting
-which can be configured via the
-.Xr sysctl 8
-command.
-.Sh DEPRECATION NOTICE
-This driver is scheduled for removal prior to the release of
-.Fx 14.0
-.Sh DIAGNOSTICS
-.Bl -diag
-.It "ndis%d: watchdog timeout"
-A packet was queued for transmission and a transmit command was
-issued, however the device failed to acknowledge the transmission
-before a timeout expired.
-.El
-.Sh SEE ALSO
-.Xr altq 4 ,
-.Xr arp 4 ,
-.Xr netintro 4 ,
-.Xr ng_ether 4 ,
-.Xr ifconfig 8 ,
-.Xr ndis_events 8 ,
-.Xr ndiscvt 8 ,
-.Xr ndisgen 8 ,
-.Xr wpa_supplicant 8
-.Rs
-.%T "NDIS 5.1 specification"
-.%U http://www.microsoft.com
-.Re
-.Sh HISTORY
-The
-.Nm
-device driver first appeared in
-.Fx 5.3 .
-.Sh AUTHORS
-The
-.Nm
-driver was written by
-.An Bill Paul Aq Mt wp...@windriver.com .
diff --git a/sys/compat/ndis/cfg_var.h b/sys/compat/ndis/cfg_var.h
deleted file mode 100644
index ff40a85926be..000000000000
--- a/sys/compat/ndis/cfg_var.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 2003
- *     Bill Paul <wp...@windriver.com>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _CFG_VAR_H_
-#define _CFG_VAR_H_
-
-struct ndis_cfg {
-       char                    *nc_cfgkey;
-       char                    *nc_cfgdesc;
-       char                    nc_val[256];
-       int                     nc_idx;
-};
-
-typedef struct ndis_cfg ndis_cfg;
-
-#endif /* _CFG_VAR_H_ */
diff --git a/sys/compat/ndis/hal_var.h b/sys/compat/ndis/hal_var.h
deleted file mode 100644
index f8864e2e7071..000000000000
--- a/sys/compat/ndis/hal_var.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 2003
- *     Bill Paul <wp...@windriver.com>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef _HAL_VAR_H_
-#define _HAL_VAR_H_
-
-#define NDIS_BUS_SPACE_IO      X86_BUS_SPACE_IO
-#define NDIS_BUS_SPACE_MEM     X86_BUS_SPACE_MEM
-
-extern image_patch_table hal_functbl[];
-
-__BEGIN_DECLS
-extern int hal_libinit(void);
-extern int hal_libfini(void);
-extern uint8_t KfAcquireSpinLock(kspin_lock *);
-extern void KfReleaseSpinLock(kspin_lock *, uint8_t);
-extern uint8_t KfRaiseIrql(uint8_t);
-extern void KfLowerIrql(uint8_t);
-extern uint8_t KeGetCurrentIrql(void);
-__END_DECLS
-
-#endif /* _HAL_VAR_H_ */
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
deleted file mode 100644
index 153849fa1cf6..000000000000
--- a/sys/compat/ndis/kern_ndis.c
+++ /dev/null
@@ -1,1447 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-4-Clause
- *
- * Copyright (c) 2003
- *     Bill Paul <wp...@windriver.com>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by Bill Paul.
- * 4. Neither the name of the author nor the names of any co-contributors
- *    may be used to endorse or promote products derived from this software
- *    without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/unistd.h>
-#include <sys/types.h>
-#include <sys/errno.h>
-#include <sys/callout.h>
-#include <sys/socket.h>
-#include <sys/queue.h>
-#include <sys/sysctl.h>
-#include <sys/proc.h>
-#include <sys/malloc.h>
-#include <sys/lock.h>
-#include <sys/mutex.h>
-#include <sys/conf.h>
-
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/kthread.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-
-#include <net/if.h>
-#include <net/if_var.h>
-#include <net/if_arp.h>
-#include <net/ethernet.h>
-#include <net/if_dl.h>
-#include <net/if_media.h>
-
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_ioctl.h>
-
-#include <dev/usb/usb.h>
-#include <dev/usb/usbdi.h>
-
-#include <compat/ndis/pe_var.h>
-#include <compat/ndis/cfg_var.h>
-#include <compat/ndis/resource_var.h>
-#include <compat/ndis/ntoskrnl_var.h>
-#include <compat/ndis/ndis_var.h>
-#include <compat/ndis/hal_var.h>
-#include <compat/ndis/usbd_var.h>
-#include <dev/if_ndis/if_ndisvar.h>
-
-#define NDIS_DUMMY_PATH "\\\\some\\bogus\\path"
-#define        NDIS_FLAG_RDONLY 1
-
-static void ndis_status_func(ndis_handle, ndis_status, void *, uint32_t);
-static void ndis_statusdone_func(ndis_handle);
-static void ndis_setdone_func(ndis_handle, ndis_status);
-static void ndis_getdone_func(ndis_handle, ndis_status);
-static void ndis_resetdone_func(ndis_handle, ndis_status, uint8_t);
-static void ndis_sendrsrcavail_func(ndis_handle);
-static void ndis_intrsetup(kdpc *, device_object *,
-       irp *, struct ndis_softc *);
-static void ndis_return(device_object *, void *);
-
-static image_patch_table kernndis_functbl[] = {
-       IMPORT_SFUNC(ndis_status_func, 4),
-       IMPORT_SFUNC(ndis_statusdone_func, 1),
-       IMPORT_SFUNC(ndis_setdone_func, 2),
-       IMPORT_SFUNC(ndis_getdone_func, 2),
-       IMPORT_SFUNC(ndis_resetdone_func, 3),
-       IMPORT_SFUNC(ndis_sendrsrcavail_func, 1),
-       IMPORT_SFUNC(ndis_intrsetup, 4),
-       IMPORT_SFUNC(ndis_return, 1),
-       { NULL, NULL, NULL }
-};
-
-static struct nd_head ndis_devhead;
-
-/*
- * This allows us to export our symbols to other modules.
- * Note that we call ourselves 'ndisapi' to avoid a namespace
- * collision with if_ndis.ko, which internally calls itself
- * 'ndis.'
- *
- * Note: some of the subsystems depend on each other, so the
- * order in which they're started is important. The order of
- * importance is:
- *
- * HAL - spinlocks and IRQL manipulation
- * ntoskrnl - DPC and workitem threads, object waiting
- * windrv - driver/device registration
- *
- * The HAL should also be the last thing shut down, since
- * the ntoskrnl subsystem will use spinlocks right up until
- * the DPC and workitem threads are terminated.
- */
-
-static int
-ndis_modevent(module_t mod, int cmd, void *arg)
-{
-       int                     error = 0;
-       image_patch_table       *patch;
-
-       switch (cmd) {
-       case MOD_LOAD:
-               /* Initialize subsystems */
-               hal_libinit();
-               ntoskrnl_libinit();
-               windrv_libinit();
-               ndis_libinit();
-               usbd_libinit();
-
-               patch = kernndis_functbl;
-               while (patch->ipt_func != NULL) {
-                       windrv_wrap((funcptr)patch->ipt_func,
-                           (funcptr *)&patch->ipt_wrap,
-                           patch->ipt_argcnt, patch->ipt_ftype);
-                       patch++;
-               }
-
-               TAILQ_INIT(&ndis_devhead);
-               break;
-       case MOD_SHUTDOWN:
-               if (TAILQ_FIRST(&ndis_devhead) == NULL) {
-                       /* Shut down subsystems */
-                       ndis_libfini();
-                       usbd_libfini();
-                       windrv_libfini();
-                       ntoskrnl_libfini();
-                       hal_libfini();
-
-                       patch = kernndis_functbl;
-                       while (patch->ipt_func != NULL) {
-                               windrv_unwrap(patch->ipt_wrap);
-                               patch++;
-                       }
-               }
-               break;
-       case MOD_UNLOAD:
-               /* Shut down subsystems */
-               ndis_libfini();
-               usbd_libfini();
-               windrv_libfini();
-               ntoskrnl_libfini();
-               hal_libfini();
-
-               patch = kernndis_functbl;
-               while (patch->ipt_func != NULL) {
-                       windrv_unwrap(patch->ipt_wrap);
-                       patch++;
-               }
-
-               break;
-       default:
-               error = EINVAL;
-               break;
-       }
-
-       return (error);
-}
-DEV_MODULE(ndisapi, ndis_modevent, NULL);
-MODULE_VERSION(ndisapi, 1);
-
-static void
-ndis_sendrsrcavail_func(adapter)
-       ndis_handle             adapter;
-{
-}
-
-static void
-ndis_status_func(adapter, status, sbuf, slen)
-       ndis_handle             adapter;
-       ndis_status             status;
-       void                    *sbuf;
-       uint32_t                slen;
-{
-       ndis_miniport_block     *block;
-       struct ndis_softc       *sc;
-       struct ifnet            *ifp;
-
-       block = adapter;
-       sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-       ifp = NDISUSB_GET_IFNET(sc);
-       if ( ifp && ifp->if_flags & IFF_DEBUG)
-               device_printf(sc->ndis_dev, "status: %x\n", status);
-}
-
-static void
-ndis_statusdone_func(adapter)
-       ndis_handle             adapter;
-{
-       ndis_miniport_block     *block;
-       struct ndis_softc       *sc;
-       struct ifnet            *ifp;
-
-       block = adapter;
-       sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-       ifp = NDISUSB_GET_IFNET(sc);
-       if (ifp && ifp->if_flags & IFF_DEBUG)
-               device_printf(sc->ndis_dev, "status complete\n");
-}
-
-static void
-ndis_setdone_func(adapter, status)
-       ndis_handle             adapter;
-       ndis_status             status;
-{
-       ndis_miniport_block     *block;
-       block = adapter;
-
-       block->nmb_setstat = status;
-       KeSetEvent(&block->nmb_setevent, IO_NO_INCREMENT, FALSE);
-}
-
-static void
-ndis_getdone_func(adapter, status)
-       ndis_handle             adapter;
-       ndis_status             status;
-{
-       ndis_miniport_block     *block;
-       block = adapter;
-
-       block->nmb_getstat = status;
-       KeSetEvent(&block->nmb_getevent, IO_NO_INCREMENT, FALSE);
-}
-
-static void
-ndis_resetdone_func(ndis_handle adapter, ndis_status status,
-       uint8_t addressingreset)
-{
-       ndis_miniport_block     *block;
-       struct ndis_softc       *sc;
-       struct ifnet            *ifp;
-
-       block = adapter;
-       sc = device_get_softc(block->nmb_physdeviceobj->do_devext);
-       ifp = NDISUSB_GET_IFNET(sc);
-
-       if (ifp && ifp->if_flags & IFF_DEBUG)
-               device_printf(sc->ndis_dev, "reset done...\n");
-       KeSetEvent(&block->nmb_resetevent, IO_NO_INCREMENT, FALSE);
-}
-
-int
-ndis_create_sysctls(arg)
-       void                    *arg;
-{
-       struct ndis_softc       *sc;
-       ndis_cfg                *vals;
-       char                    buf[256];
-       struct sysctl_oid       *oidp;
-       struct sysctl_ctx_entry *e;
-
-       if (arg == NULL)
-               return (EINVAL);
-
-       sc = arg;
-       /*
-       device_printf(sc->ndis_dev, "ndis_create_sysctls() sc=%p\n", sc);
-       */
-       vals = sc->ndis_regvals;
-
-       TAILQ_INIT(&sc->ndis_cfglist_head);
-
-       /* Add the driver-specific registry keys. */
-
-       while(1) {
-               if (vals->nc_cfgkey == NULL)
-                       break;
-
-               if (vals->nc_idx != sc->ndis_devidx) {
-                       vals++;
-                       continue;
-               }
-
-               /* See if we already have a sysctl with this name */
-
-               oidp = NULL;
-               TAILQ_FOREACH(e, device_get_sysctl_ctx(sc->ndis_dev), link) {
-                       oidp = e->entry;
-                       if (strcasecmp(oidp->oid_name, vals->nc_cfgkey) == 0)
-                               break;
-                       oidp = NULL;
-               }
-
-               if (oidp != NULL) {
-                       vals++;
-                       continue;
-               }
-
-               ndis_add_sysctl(sc, vals->nc_cfgkey, vals->nc_cfgdesc,
-                   vals->nc_val, CTLFLAG_RW);
-               vals++;
-       }
-
-       /* Now add a couple of builtin keys. */
-
-       /*
-        * Environment can be either Windows (0) or WindowsNT (1).
-        * We qualify as the latter.
-        */
-       ndis_add_sysctl(sc, "Environment",
-           "Windows environment", "1", NDIS_FLAG_RDONLY);
-
-       /* NDIS version should be 5.1. */
-       ndis_add_sysctl(sc, "NdisVersion",
-           "NDIS API Version", "0x00050001", NDIS_FLAG_RDONLY);
-
-       /*
-        * Some miniport drivers rely on the existence of the SlotNumber,
-        * NetCfgInstanceId and DriverDesc keys.
-        */
-       ndis_add_sysctl(sc, "SlotNumber", "Slot Numer", "01", NDIS_FLAG_RDONLY);
-       ndis_add_sysctl(sc, "NetCfgInstanceId", "NetCfgInstanceId",
-           "{12345678-1234-5678-CAFE0-123456789ABC}", NDIS_FLAG_RDONLY);
-       ndis_add_sysctl(sc, "DriverDesc", "Driver Description",
-           "NDIS Network Adapter", NDIS_FLAG_RDONLY);
-
-       /* Bus type (PCI, PCMCIA, etc...) */
-       sprintf(buf, "%d", (int)sc->ndis_iftype);
-       ndis_add_sysctl(sc, "BusType", "Bus Type", buf, NDIS_FLAG_RDONLY);
-
-       if (sc->ndis_res_io != NULL) {
-               sprintf(buf, "0x%jx", rman_get_start(sc->ndis_res_io));
-               ndis_add_sysctl(sc, "IOBaseAddress",
-                   "Base I/O Address", buf, NDIS_FLAG_RDONLY);
-       }
-
-       if (sc->ndis_irq != NULL) {
-               sprintf(buf, "%ju", rman_get_start(sc->ndis_irq));
-               ndis_add_sysctl(sc, "InterruptNumber",
-                   "Interrupt Number", buf, NDIS_FLAG_RDONLY);
-       }
-
-       return (0);
-}
-
-int
-ndis_add_sysctl(arg, key, desc, val, flag_rdonly)
-       void                    *arg;
-       char                    *key;
-       char                    *desc;
-       char                    *val;
-       int                     flag_rdonly;
-{
-       struct ndis_softc       *sc;
-       struct ndis_cfglist     *cfg;
-       char                    descstr[256];
-
-       sc = arg;
-
-       cfg = malloc(sizeof(struct ndis_cfglist), M_DEVBUF, M_NOWAIT|M_ZERO);
-
-       if (cfg == NULL) {
-               printf("failed for %s\n", key);
-               return (ENOMEM);
-       }
-
-       cfg->ndis_cfg.nc_cfgkey = strdup(key, M_DEVBUF);
-       if (desc == NULL) {
-               snprintf(descstr, sizeof(descstr), "%s (dynamic)", key);
-               cfg->ndis_cfg.nc_cfgdesc = strdup(descstr, M_DEVBUF);
-       } else
-               cfg->ndis_cfg.nc_cfgdesc = strdup(desc, M_DEVBUF);
-       strcpy(cfg->ndis_cfg.nc_val, val);
-
-       TAILQ_INSERT_TAIL(&sc->ndis_cfglist_head, cfg, link);
-
-       if (flag_rdonly != 0) {
-               cfg->ndis_oid =
-                   SYSCTL_ADD_STRING(device_get_sysctl_ctx(sc->ndis_dev),
-                   SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ndis_dev)),
-                   OID_AUTO, cfg->ndis_cfg.nc_cfgkey, CTLFLAG_RD,
-                   cfg->ndis_cfg.nc_val, sizeof(cfg->ndis_cfg.nc_val),
-                   cfg->ndis_cfg.nc_cfgdesc);
-       } else {
-               cfg->ndis_oid =
-                   SYSCTL_ADD_STRING(device_get_sysctl_ctx(sc->ndis_dev),
-                   SYSCTL_CHILDREN(device_get_sysctl_tree(sc->ndis_dev)),
-                   OID_AUTO, cfg->ndis_cfg.nc_cfgkey, CTLFLAG_RW,
-                   cfg->ndis_cfg.nc_val, sizeof(cfg->ndis_cfg.nc_val),
-                   cfg->ndis_cfg.nc_cfgdesc);
-       }
-       return (0);
-}
-
-/*
- * Somewhere, somebody decided "hey, let's automatically create
- * a sysctl tree for each device instance as it's created -- it'll
- * make life so much easier!" Lies. Why must they turn the kernel
- * into a house of lies?
- */
-
-int
-ndis_flush_sysctls(arg)
-       void                    *arg;
-{
-       struct ndis_softc       *sc;
-       struct ndis_cfglist     *cfg;
-       struct sysctl_ctx_list  *clist;
-
-       sc = arg;
-
-       clist = device_get_sysctl_ctx(sc->ndis_dev);
-
-       while (!TAILQ_EMPTY(&sc->ndis_cfglist_head)) {
-               cfg = TAILQ_FIRST(&sc->ndis_cfglist_head);
-               TAILQ_REMOVE(&sc->ndis_cfglist_head, cfg, link);
-               sysctl_ctx_entry_del(clist, cfg->ndis_oid);
-               sysctl_remove_oid(cfg->ndis_oid, 1, 0);
-               free(cfg->ndis_cfg.nc_cfgkey, M_DEVBUF);
-               free(cfg->ndis_cfg.nc_cfgdesc, M_DEVBUF);
-               free(cfg, M_DEVBUF);
-       }
-
-       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;
-       void                    *arg;
-{
-       ndis_miniport_block     *block;
-       ndis_miniport_characteristics   *ch;
-       ndis_return_handler     returnfunc;
-       ndis_handle             adapter;
-       ndis_packet             *p;
-       uint8_t                 irql;
-       list_entry              *l;
-
-       block = arg;
-       ch = IoGetDriverObjectExtension(dobj->do_drvobj, (void *)1);
-
-       p = arg;
-       adapter = block->nmb_miniportadapterctx;
-
-       if (adapter == NULL)
-               return;
-
-       returnfunc = ch->nmc_return_packet_func;
-
-       KeAcquireSpinLock(&block->nmb_returnlock, &irql);
-       while (!IsListEmpty(&block->nmb_returnlist)) {
-               l = RemoveHeadList((&block->nmb_returnlist));
-               p = CONTAINING_RECORD(l, ndis_packet, np_list);
-               InitializeListHead((&p->np_list));
-               KeReleaseSpinLock(&block->nmb_returnlock, irql);
-               MSCALL2(returnfunc, adapter, p);
-               KeAcquireSpinLock(&block->nmb_returnlock, &irql);
-       }
-       KeReleaseSpinLock(&block->nmb_returnlock, irql);
-}
-
-static void
-ndis_ext_free(struct mbuf *m)
-{
-
-       return (ndis_return_packet(m->m_ext.ext_arg1));
-}
-
-void
-ndis_return_packet(ndis_packet *p)
-{
-       ndis_miniport_block     *block;
-
-       if (p == NULL)
-               return;
-
-       /* Decrement refcount. */
-       p->np_refcnt--;
-
-       /* Release packet when refcount hits zero, otherwise return. */
-       if (p->np_refcnt)
-               return;
-
-       block = ((struct ndis_softc *)p->np_softc)->ndis_block;
-
-       KeAcquireSpinLockAtDpcLevel(&block->nmb_returnlock);
-       InitializeListHead((&p->np_list));
-       InsertHeadList((&block->nmb_returnlist), (&p->np_list));
-       KeReleaseSpinLockFromDpcLevel(&block->nmb_returnlock);
-
-       IoQueueWorkItem(block->nmb_returnitem,
-           (io_workitem_func)kernndis_functbl[7].ipt_wrap,
-           WORKQUEUE_CRITICAL, block);
-}
-
-void
-ndis_free_bufs(b0)
-       ndis_buffer             *b0;
-{
-       ndis_buffer             *next;
-
-       if (b0 == NULL)
-               return;
-
-       while(b0 != NULL) {
-               next = b0->mdl_next;
-               IoFreeMdl(b0);
-               b0 = next;
-       }
-}
-
-void
-ndis_free_packet(p)
-       ndis_packet             *p;
-{
-       if (p == NULL)
-               return;
-
-       ndis_free_bufs(p->np_private.npp_head);
-       NdisFreePacket(p);
-}
-
-int
-ndis_convert_res(arg)
-       void                    *arg;
-{
-       struct ndis_softc       *sc;
-       ndis_resource_list      *rl = NULL;
-       cm_partial_resource_desc        *prd = NULL;
-       ndis_miniport_block     *block;
-       device_t                dev;
-       struct resource_list    *brl;
*** 25949 LINES SKIPPED ***
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to