The branch main has been updated by imp:

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

commit 23e124c78bcb46ac78d9f06449c4454f43732805
Author:     Warner Losh <[email protected]>
AuthorDate: 2021-01-07 22:52:49 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2021-01-08 03:40:41 +0000

    pccard: Remove bt3c(4) driver
    
    pccard is being removed, so remove bt3c driver since it only has PC
    Card attachment. Also remove bt3cfw(8) since it's the firmware for this
    driver.
    
    Relnotes: Yes
---
 ObsoleteFiles.inc                                  |    5 +-
 share/man/man4/Makefile                            |    1 -
 share/man/man4/ng_bt3c.4                           |  132 ---
 sys/conf/NOTES                                     |    1 -
 sys/conf/files                                     |    1 -
 sys/modules/netgraph/bluetooth/Makefile            |    1 -
 sys/modules/netgraph/bluetooth/bt3c/Makefile       |   12 -
 .../bluetooth/drivers/bt3c/ng_bt3c_pccard.c        | 1227 --------------------
 sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_var.h  |  108 --
 sys/netgraph/bluetooth/include/ng_bt3c.h           |  112 --
 usr.sbin/bluetooth/Makefile                        |    1 -
 usr.sbin/bluetooth/bt3cfw/Makefile                 |   11 -
 usr.sbin/bluetooth/bt3cfw/Makefile.depend          |   18 -
 usr.sbin/bluetooth/bt3cfw/bt3cfw.8                 |   73 --
 usr.sbin/bluetooth/bt3cfw/bt3cfw.c                 |  230 ----
 15 files changed, 4 insertions(+), 1929 deletions(-)

diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc
index d5b7e22ab9e2..85d6e3eecd43 100644
--- a/ObsoleteFiles.inc
+++ b/ObsoleteFiles.inc
@@ -36,8 +36,11 @@
 #   xargs -n1 | sort | uniq -d;
 # done
 
-# 20210108: retire cmx driver
+# 20210108: retire cmx, ng_bt3c drivers
+OLD_FILES+=usr/sbin/bt3cfw
 OLD_FILES+=usr/share/man/man4/cmw.4.gz
+OLD_FILES+=usr/share/man/man4/ng_bt3c.4.gz
+OLD_FILES+=usr/share/man/man8/bt3cfw.8.gz
 
 # 20210107: retire a.out support
 OLD_DIRS+=usr/lib/aout
diff --git a/share/man/man4/Makefile b/share/man/man4/Makefile
index beb5d47c46b2..95f11ed3ca1b 100644
--- a/share/man/man4/Makefile
+++ b/share/man/man4/Makefile
@@ -337,7 +337,6 @@ MAN=        aac.4 \
        ng_atmllc.4 \
        ng_bpf.4 \
        ng_bridge.4 \
-       ng_bt3c.4 \
        ng_btsocket.4 \
        ng_car.4 \
        ng_ccatm.4 \
diff --git a/share/man/man4/ng_bt3c.4 b/share/man/man4/ng_bt3c.4
deleted file mode 100644
index d3942ea1d7fc..000000000000
--- a/share/man/man4/ng_bt3c.4
+++ /dev/null
@@ -1,132 +0,0 @@
-.\" Copyright (c) 2001-2002 Maksim Yevmenkin <[email protected]>
-.\" 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.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR OR CONTRIBUTORS 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.
-.\"
-.\" $Id: ng_bt3c.4,v 1.3 2003/09/14 23:28:51 max Exp $
-.\" $FreeBSD$
-.\"
-.Dd December 17, 2004
-.Dt NG_BT3C 4
-.Os
-.Sh NAME
-.Nm ng_bt3c
-.Nd Netgraph node type that is also a 3Com Bluetooth PC card driver
-.Sh SYNOPSIS
-.In sys/types.h
-.In netgraph/bluetooth/include/ng_bt3c.h
-.Sh DEPRECATION NOTICE
-This driver is scheduled for removal prior to the release of
-.Fx 13.0
-.Sh DESCRIPTION
-The
-.Nm btccc
-node type is both a persistent Netgraph node type and a driver for the
-3Com Bluetooth PC card (3CRWB6096-HP).
-It implements a Bluetooth HCI
-UART transport layer as per chapter H4 of the Bluetooth Specification
-Book v1.1.
-A new node is created when the card is plugged.
-.Pp
-In order to use the card one
-.Em MUST
-download the firmware first.
-Due to copyright issues the firmware cannot be provided with this driver.
-The firmware can be obtained
-from the Windows driver package that can be downloaded from the 3Com web
-site at no charge.
-The firmware name is
-.Pa BT3CPCC.BIN .
-To load the firmware into the card, use
-.Xr bt3cfw 8 .
-I am using the original firmware that came with the card on CD-ROM.
-.Pp
-.Dl "MD5 (BT3CPCC.BIN) = 36170fda56ea9fdbf1702c966f8a97f1"
-.Pp
-The node has a single hook called
-.Dv hook .
-Incoming bytes received on the device are re-assembled into HCI frames
-(according to the length).
-Full HCI frames are sent out on the hook.
-HCI frames received on
-.Dv hook
-are transmitted out.
-No modification to the data is performed in either direction.
-.Sh HARDWARE
-The
-.Nm
-driver provides support for the 3Com/HP 3CRWB6096-A PCCARD bluetooth adapter.
-.Sh HOOKS
-This node type supports the following hooks:
-.Bl -tag -width ".Va hook"
-.It Va hook
-single HCI frame contained in single
-.Vt mbuf
-structure.
-.El
-.Sh CONTROL MESSAGES
-This node type supports the generic control messages, plus the following:
-.Bl -tag -width foo
-.It Dv NGM_BT3C_NODE_GET_STATE Pq Ic get_state
-Returns the current receiving state for the node.
-.It Dv NGM_BT3C_NODE_SET_DEBUG Pq Ic set_debug
-This command takes an integer argument and sets the current debug level
-for the node.
-.It Dv NGM_BT3C_NODE_GET_DEBUG Pq Ic get_debug
-Returns an integer containing the current debug level for the node.
-.It Dv NGM_BT3C_NODE_GET_QLEN Pq Ic get_qlen
-This command takes a parameter that specifies queue number and returns
-the current length of the queue for the node.
-.It Dv NGM_BT3C_NODE_SET_QLEN Pq Ic set_qlen
-This command takes two parameters that specify the queue number and
-the maximum length of the queue and sets the maximum length of the queue for
-the node.
-.It Dv NGM_BT3C_NODE_GET_STAT Pq Ic get_stat
-Returns various statistic information for the node, such as: number of
-bytes (frames) sent, number of bytes (frames) received and number of
-input (output) errors.
-.It Dv NGM_BT3C_NODE_RESET_STAT Pq Ic reset_stat
-Reset all statistic counters to zero.
-.It Dv NGM_BT3C_NODE_DOWNLOAD_FIRMWARE
-Download card firmware.
-.El
-.Sh SHUTDOWN
-This node shuts down when the corresponding card is un-plugged.
-.Sh SEE ALSO
-.Xr cardbus 4 ,
-.Xr netgraph 4 ,
-.Xr pccbb 4 ,
-.Xr pcic 4 ,
-.Xr pccard.conf 5 ,
-.Xr bt3cfw 8 ,
-.Xr ngctl 8
-.Sh HISTORY
-The
-.Nm btccc
-node type was implemented in
-.Fx 5.0 .
-.Sh AUTHORS
-.An Maksim Yevmenkin Aq Mt [email protected]
-.Sh BUGS
-The driver is based on information obtained from
-.An Jose Orlando Pereira Aq Mt [email protected]
-and disassembled the W2K driver.
diff --git a/sys/conf/NOTES b/sys/conf/NOTES
index 103b0929a56c..c3a9c097dedb 100644
--- a/sys/conf/NOTES
+++ b/sys/conf/NOTES
@@ -769,7 +769,6 @@ options     NETGRAPH_ASYNC
 options        NETGRAPH_ATMLLC
 options        NETGRAPH_ATM_ATMPIF
 options        NETGRAPH_BLUETOOTH              # ng_bluetooth(4)
-options        NETGRAPH_BLUETOOTH_BT3C         # ng_bt3c(4)
 options        NETGRAPH_BLUETOOTH_HCI          # ng_hci(4)
 options        NETGRAPH_BLUETOOTH_L2CAP        # ng_l2cap(4)
 options        NETGRAPH_BLUETOOTH_SOCKET       # ng_btsocket(4)
diff --git a/sys/conf/files b/sys/conf/files
index d58d2e6c2e0d..370b67709ad6 100644
--- a/sys/conf/files
+++ b/sys/conf/files
@@ -4259,7 +4259,6 @@ netgraph/atm/sscop/ng_sscop.c optional ngatm_sscop \
 netgraph/atm/uni/ng_uni.c      optional ngatm_uni \
        compile-with "${NORMAL_C} -I$S/contrib/ngatm"
 netgraph/bluetooth/common/ng_bluetooth.c optional netgraph_bluetooth
-netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c optional 
netgraph_bluetooth_bt3c
 netgraph/bluetooth/drivers/h4/ng_h4.c optional netgraph_bluetooth_h4
 netgraph/bluetooth/drivers/ubt/ng_ubt.c optional netgraph_bluetooth_ubt usb
 netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c optional netgraph_bluetooth_ubt 
usb
diff --git a/sys/modules/netgraph/bluetooth/Makefile 
b/sys/modules/netgraph/bluetooth/Makefile
index 9169cf113491..4d353fd94f4b 100644
--- a/sys/modules/netgraph/bluetooth/Makefile
+++ b/sys/modules/netgraph/bluetooth/Makefile
@@ -6,7 +6,6 @@ SUBDIR= \
        hci     \
        l2cap   \
        socket  \
-       bt3c    \
        ubt     \
        ubtbcmfw
 
diff --git a/sys/modules/netgraph/bluetooth/bt3c/Makefile 
b/sys/modules/netgraph/bluetooth/bt3c/Makefile
deleted file mode 100644
index 47c4f7a0f140..000000000000
--- a/sys/modules/netgraph/bluetooth/bt3c/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-# $Id: Makefile,v 1.2 2002/11/24 20:50:56 max Exp $
-# $FreeBSD$
-
-.PATH: ${SRCTOP}/sys/netgraph/bluetooth/drivers/bt3c
-
-CFLAGS+=       -I${SRCTOP}/sys/netgraph/bluetooth/include \
-               -I${SRCTOP}/sys/netgraph/bluetooth/drivers/bt3c
-
-KMOD=          ng_bt3c
-SRCS=          ng_bt3c_pccard.c bus_if.h card_if.h device_if.h pccarddevs.h
-
-.include <bsd.kmod.mk>
diff --git a/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c 
b/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c
deleted file mode 100644
index c9045e84f256..000000000000
--- a/sys/netgraph/bluetooth/drivers/bt3c/ng_bt3c_pccard.c
+++ /dev/null
@@ -1,1227 +0,0 @@
-/*
- * ng_bt3c_pccard.c
- */
-
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2001-2002 Maksim Yevmenkin <[email protected]>
- * 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.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 THE AUTHOR OR CONTRIBUTORS 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.
- *
- * $Id: ng_bt3c_pccard.c,v 1.5 2003/04/01 18:15:21 max Exp $
- * $FreeBSD$
- *
- * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX 
- *
- * Based on information obrained from: Jose Orlando Pereira <[email protected]>
- * and disassembled w2k driver.
- *
- * XXX XXX XX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX 
- *
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <sys/bus.h>
-#include <machine/bus.h>
-
-#include <sys/conf.h>
-#include <sys/endian.h>
-#include <sys/interrupt.h>
-#include <sys/kernel.h>
-#include <sys/mbuf.h>
-#include <sys/module.h>
-
-#include <machine/resource.h>
-#include <sys/rman.h>
-
-#include <sys/socket.h>
-#include <net/if.h>
-#include <net/if_var.h>
-
-#include <dev/pccard/pccardreg.h>
-#include <dev/pccard/pccardvar.h>
-#include "pccarddevs.h"
-
-#include <netgraph/ng_message.h>
-#include <netgraph/netgraph.h>
-#include <netgraph/ng_parse.h>
-#include <netgraph/bluetooth/include/ng_bluetooth.h>
-#include <netgraph/bluetooth/include/ng_hci.h>
-#include <netgraph/bluetooth/include/ng_bt3c.h>
-#include <netgraph/bluetooth/drivers/bt3c/ng_bt3c_var.h>
-
-/* Netgraph methods */
-static ng_constructor_t        ng_bt3c_constructor;
-static ng_shutdown_t   ng_bt3c_shutdown;
-static ng_newhook_t    ng_bt3c_newhook;
-static ng_connect_t    ng_bt3c_connect;
-static ng_disconnect_t ng_bt3c_disconnect;
-static ng_rcvmsg_t     ng_bt3c_rcvmsg;
-static ng_rcvdata_t    ng_bt3c_rcvdata;
-
-/* PCMCIA driver methods */
-static int     bt3c_pccard_probe       (device_t);
-static int     bt3c_pccard_attach      (device_t);
-static int     bt3c_pccard_detach      (device_t);
-
-static void    bt3c_intr               (void *);
-static void    bt3c_receive            (bt3c_softc_p);
-
-static void    bt3c_swi_intr           (void *);
-static void    bt3c_forward            (node_p, hook_p, void *, int);
-static void    bt3c_send               (node_p, hook_p, void *, int);
-
-static void    bt3c_download_firmware  (bt3c_softc_p, char const *, int);
-
-#define        bt3c_set_address(sc, address) \
-do { \
-       bus_space_write_1((sc)->iot, (sc)->ioh, BT3C_ADDR_L, ((address) & 
0xff)); \
-       bus_space_write_1((sc)->iot, (sc)->ioh, BT3C_ADDR_H, (((address) >> 8) 
& 0xff)); \
-} while (0)
-
-#define        bt3c_read_data(sc, data) \
-do { \
-       (data)  = bus_space_read_1((sc)->iot, (sc)->ioh, BT3C_DATA_L); \
-       (data) |= ((bus_space_read_1((sc)->iot, (sc)->ioh, BT3C_DATA_H) & 0xff) 
<< 8); \
-} while (0)
-
-#define        bt3c_write_data(sc, data) \
-do { \
-       bus_space_write_1((sc)->iot, (sc)->ioh, BT3C_DATA_L, ((data) & 0xff)); \
-       bus_space_write_1((sc)->iot, (sc)->ioh, BT3C_DATA_H, (((data) >> 8) & 
0xff)); \
-} while (0)
-
-#define        bt3c_read_control(sc, data) \
-do { \
-       (data) = bus_space_read_1((sc)->iot, (sc)->ioh, BT3C_CONTROL); \
-} while (0)
-
-#define        bt3c_write_control(sc, data) \
-do { \
-       bus_space_write_1((sc)->iot, (sc)->ioh, BT3C_CONTROL, (data)); \
-} while (0)
-
-#define bt3c_read(sc, address, data) \
-do { \
-       bt3c_set_address((sc), (address)); \
-       bt3c_read_data((sc), (data)); \
-} while(0)
-
-#define bt3c_write(sc, address, data) \
-do { \
-       bt3c_set_address((sc), (address)); \
-       bt3c_write_data((sc), (data)); \
-} while(0)
-
-static MALLOC_DEFINE(M_BT3C, "bt3c", "bt3c data structures");
-
-/****************************************************************************
- ****************************************************************************
- **                           Netgraph specific
- ****************************************************************************
- ****************************************************************************/
-
-/*
- * Netgraph node type
- */
-
-/* Queue length */
-static const struct ng_parse_struct_field      ng_bt3c_node_qlen_type_fields[] 
=
-{
-       { "queue", &ng_parse_int32_type, },
-       { "qlen",  &ng_parse_int32_type, },
-       { NULL, }
-};
-static const struct ng_parse_type              ng_bt3c_node_qlen_type = {
-       &ng_parse_struct_type,
-       &ng_bt3c_node_qlen_type_fields
-};
-
-/* Stat info */
-static const struct ng_parse_struct_field      ng_bt3c_node_stat_type_fields[] 
=
-{
-       { "pckts_recv", &ng_parse_uint32_type, },
-       { "bytes_recv", &ng_parse_uint32_type, },
-       { "pckts_sent", &ng_parse_uint32_type, },
-       { "bytes_sent", &ng_parse_uint32_type, },
-       { "oerrors",    &ng_parse_uint32_type, },
-       { "ierrors",    &ng_parse_uint32_type, },
-       { NULL, }
-};
-static const struct ng_parse_type              ng_bt3c_node_stat_type = {
-       &ng_parse_struct_type,
-       &ng_bt3c_node_stat_type_fields
-};
-
-static const struct ng_cmdlist ng_bt3c_cmdlist[] = {
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_GET_STATE,
-       "get_state",
-       NULL,
-       &ng_parse_uint16_type
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_SET_DEBUG,
-       "set_debug",
-       &ng_parse_uint16_type,
-       NULL
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_GET_DEBUG,
-       "get_debug",
-       NULL,
-       &ng_parse_uint16_type
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_GET_QLEN,
-       "get_qlen",
-       NULL,
-       &ng_bt3c_node_qlen_type
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_SET_QLEN,
-       "set_qlen",
-       &ng_bt3c_node_qlen_type,
-       NULL
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_GET_STAT,
-       "get_stat",
-       NULL,
-       &ng_bt3c_node_stat_type
-},
-{
-       NGM_BT3C_COOKIE,
-       NGM_BT3C_NODE_RESET_STAT,
-       "reset_stat",
-       NULL,
-       NULL
-},
-{ 0, }
-};
-
-static struct ng_type  typestruct = {
-       .version =      NG_ABI_VERSION,
-       .name =         NG_BT3C_NODE_TYPE,
-       .constructor =  ng_bt3c_constructor,
-       .rcvmsg =       ng_bt3c_rcvmsg,
-       .shutdown =     ng_bt3c_shutdown,
-       .newhook =      ng_bt3c_newhook,
-       .connect =      ng_bt3c_connect,
-       .rcvdata =      ng_bt3c_rcvdata,
-       .disconnect =   ng_bt3c_disconnect,
-        .cmdlist =     ng_bt3c_cmdlist 
-};
-
-/*
- * Netgraph node constructor. Do not allow to create node of this type.
- */
-
-static int
-ng_bt3c_constructor(node_p node)
-{
-       return (EINVAL);
-} /* ng_bt3c_constructor */
-
-/*
- * Netgraph node destructor. Destroy node only when device has been detached
- */
-
-static int
-ng_bt3c_shutdown(node_p node)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) NG_NODE_PRIVATE(node);
-
-       /* Let old node go */
-       NG_NODE_SET_PRIVATE(node, NULL);
-       NG_NODE_UNREF(node);
-
-       /* Create new fresh one if we are not going down */
-       if (sc == NULL)
-               goto out;
-
-       /* Create new Netgraph node */
-       if (ng_make_node_common(&typestruct, &sc->node) != 0) {
-               device_printf(sc->dev, "Could not create Netgraph node\n");
-               sc->node = NULL;
-               goto out;
-       }
-
-       /* Name new Netgraph node */
-       if (ng_name_node(sc->node,  device_get_nameunit(sc->dev)) != 0) {
-               device_printf(sc->dev, "Could not name Netgraph node\n");
-               NG_NODE_UNREF(sc->node);
-               sc->node = NULL;
-               goto out;
-       }
-
-       NG_NODE_SET_PRIVATE(sc->node, sc);
-out:
-       return (0);
-} /* ng_bt3c_shutdown */
-
-/*
- * Create new hook. There can only be one.
- */
-
-static int
-ng_bt3c_newhook(node_p node, hook_p hook, char const *name)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) NG_NODE_PRIVATE(node);
-
-       if (strcmp(name, NG_BT3C_HOOK) != 0)
-               return (EINVAL);
-
-       if (sc->hook != NULL)
-               return (EISCONN);
-
-       sc->hook = hook;
-
-       return (0);
-} /* ng_bt3c_newhook */
-
-/*
- * Connect hook. Say YEP, that's OK with me.
- */
-
-static int
-ng_bt3c_connect(hook_p hook)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
-
-       if (hook != sc->hook) {
-               sc->hook = NULL;
-               return (EINVAL);
-       }
-
-       /* set the hook into queueing mode (for incoming (from wire) packets) */
-       NG_HOOK_FORCE_QUEUE(NG_HOOK_PEER(hook));
-
-       return (0);
-} /* ng_bt3c_connect */
-
-/*
- * Disconnect hook
- */
-
-static int
-ng_bt3c_disconnect(hook_p hook)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
-
-       /*
-        * We need to check for sc != NULL because we can be called from
-        * bt3c_pccard_detach() via ng_rmnode_self()
-        */
-
-       if (sc != NULL) {
-               if (hook != sc->hook)
-                       return (EINVAL);
-
-               IF_DRAIN(&sc->inq);
-               IF_DRAIN(&sc->outq);
-
-               sc->hook = NULL;
-       }
-
-       return (0);
-} /* ng_bt3c_disconnect */
-
-/*
- * Process control message
- */
-
-static int
-ng_bt3c_rcvmsg(node_p node, item_p item, hook_p lasthook)
-{
-       bt3c_softc_p     sc = (bt3c_softc_p) NG_NODE_PRIVATE(node);
-       struct ng_mesg  *msg = NULL, *rsp = NULL;
-       int              error = 0;
-
-       if (sc == NULL) {
-               NG_FREE_ITEM(item);
-               return (EHOSTDOWN);
-       }
-
-       NGI_GET_MSG(item, msg);
-
-       switch (msg->header.typecookie) {
-       case NGM_GENERIC_COOKIE:
-               switch (msg->header.cmd) {
-               case NGM_TEXT_STATUS:
-                       NG_MKRESPONSE(rsp, msg, NG_TEXTRESPONSE, M_NOWAIT);
-                       if (rsp == NULL)
-                               error = ENOMEM;
-                       else
-                               snprintf(rsp->data, NG_TEXTRESPONSE,
-                                       "Hook: %s\n" \
-                                       "Flags: %#x\n" \
-                                       "Debug: %d\n"  \
-                                       "State: %d\n"  \
-                                       "IncmQ: [len:%d,max:%d]\n" \
-                                       "OutgQ: [len:%d,max:%d]\n",
-                                       (sc->hook != NULL)? NG_BT3C_HOOK : "",
-                                       sc->flags,
-                                       sc->debug,
-                                       sc->state,
-                                       _IF_QLEN(&sc->inq), /* XXX */
-                                       sc->inq.ifq_maxlen, /* XXX */
-                                       _IF_QLEN(&sc->outq), /* XXX */
-                                       sc->outq.ifq_maxlen /* XXX */
-                                       );
-                       break;
-
-               default:
-                       error = EINVAL;
-                       break;
-               }
-               break;
-
-       case NGM_BT3C_COOKIE:
-               switch (msg->header.cmd) {
-               case NGM_BT3C_NODE_GET_STATE:
-                       NG_MKRESPONSE(rsp, msg, sizeof(ng_bt3c_node_state_ep),
-                               M_NOWAIT);
-                       if (rsp == NULL)
-                               error = ENOMEM;
-                       else
-                               *((ng_bt3c_node_state_ep *)(rsp->data)) = 
-                                       sc->state;
-                       break;
-
-               case NGM_BT3C_NODE_SET_DEBUG:
-                       if (msg->header.arglen != sizeof(ng_bt3c_node_debug_ep))
-                               error = EMSGSIZE;
-                       else
-                               sc->debug =
-                                       *((ng_bt3c_node_debug_ep *)(msg->data));
-                       break;
-
-               case NGM_BT3C_NODE_GET_DEBUG:
-                       NG_MKRESPONSE(rsp, msg, sizeof(ng_bt3c_node_debug_ep),
-                               M_NOWAIT);
-                       if (rsp == NULL)
-                               error = ENOMEM;
-                       else
-                               *((ng_bt3c_node_debug_ep *)(rsp->data)) = 
-                                       sc->debug;
-                       break;
-
-               case NGM_BT3C_NODE_GET_QLEN:
-                       NG_MKRESPONSE(rsp, msg, sizeof(ng_bt3c_node_qlen_ep),
-                               M_NOWAIT);
-                       if (rsp == NULL) {
-                               error = ENOMEM;
-                               break;
-                       }
-
-                       switch (((ng_bt3c_node_qlen_ep *)(msg->data))->queue) {
-                       case NGM_BT3C_NODE_IN_QUEUE:
-                               ((ng_bt3c_node_qlen_ep *)(rsp->data))->queue =
-                                       NGM_BT3C_NODE_IN_QUEUE;
-                               ((ng_bt3c_node_qlen_ep *)(rsp->data))->qlen =
-                                       sc->inq.ifq_maxlen;
-                               break;
-
-                       case NGM_BT3C_NODE_OUT_QUEUE:
-                               ((ng_bt3c_node_qlen_ep *)(rsp->data))->queue =
-                                       NGM_BT3C_NODE_OUT_QUEUE;
-                               ((ng_bt3c_node_qlen_ep *)(rsp->data))->qlen =
-                                       sc->outq.ifq_maxlen;
-                               break;
-
-                       default:
-                               NG_FREE_MSG(rsp);
-                               error = EINVAL;
-                               break;
-                       }
-                       break;
-
-               case NGM_BT3C_NODE_SET_QLEN:
-                       if (msg->header.arglen != sizeof(ng_bt3c_node_qlen_ep)){
-                               error = EMSGSIZE;
-                               break;
-                       }
-
-                       if (((ng_bt3c_node_qlen_ep *)(msg->data))->qlen <= 0) {
-                               error = EINVAL;
-                               break;
-                       }
-
-                       switch (((ng_bt3c_node_qlen_ep *)(msg->data))->queue) {
-                       case NGM_BT3C_NODE_IN_QUEUE:
-                               sc->inq.ifq_maxlen = ((ng_bt3c_node_qlen_ep *)
-                                       (msg->data))->qlen; /* XXX */
-                               break;
-
-                       case NGM_BT3C_NODE_OUT_QUEUE:
-                               sc->outq.ifq_maxlen = ((ng_bt3c_node_qlen_ep *)
-                                       (msg->data))->qlen; /* XXX */
-                               break;
-
-                       default:
-                               error = EINVAL;
-                               break;
-                       }
-                       break;
-
-               case NGM_BT3C_NODE_GET_STAT:
-                       NG_MKRESPONSE(rsp, msg, sizeof(ng_bt3c_node_stat_ep),
-                               M_NOWAIT);
-                       if (rsp == NULL)
-                               error = ENOMEM;
-                       else
-                               bcopy(&sc->stat, rsp->data,
-                                       sizeof(ng_bt3c_node_stat_ep));
-                       break;
-
-               case NGM_BT3C_NODE_RESET_STAT:
-                       NG_BT3C_STAT_RESET(sc->stat);
-                       break;
-
-               case NGM_BT3C_NODE_DOWNLOAD_FIRMWARE:
-                       if (msg->header.arglen < 
-                                       sizeof(ng_bt3c_firmware_block_ep))
-                               error = EMSGSIZE;
-                       else    
-                               bt3c_download_firmware(sc, msg->data,
-                                                       msg->header.arglen);
-                       break;
-
-               default:
-                       error = EINVAL;
-                       break;
-               }
-               break;
-
-       default:
-               error = EINVAL;
-               break;
-       }
-
-       NG_RESPOND_MSG(error, node, item, rsp);
-       NG_FREE_MSG(msg);
-
-       return (error);
-} /* ng_bt3c_rcvmsg */
-
-/*
- * Process data
- */
-
-static int
-ng_bt3c_rcvdata(hook_p hook, item_p item)
-{
-       bt3c_softc_p     sc = (bt3c_softc_p)NG_NODE_PRIVATE(NG_HOOK_NODE(hook));
-       struct mbuf     *m = NULL;
-       int              error = 0;
-
-       if (sc == NULL) {
-               error = EHOSTDOWN;
-               goto out;
-       }
-
-       if (hook != sc->hook) {
-               error = EINVAL;
-               goto out;
-       }
-
-       NGI_GET_M(item, m);
-
-       IF_LOCK(&sc->outq);
-       if (_IF_QFULL(&sc->outq)) {
-               NG_BT3C_ERR(sc->dev,
-"Outgoing queue is full. Dropping mbuf, len=%d\n", m->m_pkthdr.len);
-
-               NG_BT3C_STAT_OERROR(sc->stat);
-
-               NG_FREE_M(m);
-       } else 
-               _IF_ENQUEUE(&sc->outq, m);
-       IF_UNLOCK(&sc->outq);
-
-       error = ng_send_fn(sc->node, NULL, bt3c_send, NULL, 0 /* new send */);
-out:
-        NG_FREE_ITEM(item);
-
-       return (error);
-} /* ng_bt3c_rcvdata */
-
-/****************************************************************************
- ****************************************************************************
- **                         PCMCIA driver specific
- ****************************************************************************
- ****************************************************************************/
-
-/*
- * PC Card (PCMCIA) probe routine
- */
-
-static struct pccard_product const     bt3c_pccard_products[] = {
-       PCMCIA_CARD(3COM, 3CRWB609),
-       { NULL, }
-};
-
-static int
-bt3c_pccard_probe(device_t dev)
-{
-       struct pccard_product const     *pp = NULL;
-
-       pp = pccard_product_lookup(dev, bt3c_pccard_products,
-                       sizeof(bt3c_pccard_products[0]), NULL);
-       if (pp == NULL)
-               return (ENXIO);
-
-       device_set_desc(dev, pp->pp_name);
-
-       return (0);
-} /* bt3c_pccard_probe */
-
-/*
- * PC Card (PCMCIA) attach routine
- */
-
-static int
-bt3c_pccard_attach(device_t dev)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) device_get_softc(dev);
-
-       /* Allocate I/O ports */
-       sc->iobase_rid = 0;
-       sc->iobase = bus_alloc_resource_anywhere(dev, SYS_RES_IOPORT,
-                       &sc->iobase_rid, 8, RF_ACTIVE);
-       if (sc->iobase == NULL) {
-               device_printf(dev, "Could not allocate I/O ports\n");
-               goto bad;
-       }
-       sc->iot = rman_get_bustag(sc->iobase);
-       sc->ioh = rman_get_bushandle(sc->iobase);
-
-       /* Allocate IRQ */
-       sc->irq_rid = 0;
-       sc->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &sc->irq_rid,
-                       RF_ACTIVE);
-       if (sc->irq == NULL) {
-               device_printf(dev, "Could not allocate IRQ\n");
-               goto bad;
-       }
-
-       sc->irq_cookie = NULL;
-       if (bus_setup_intr(dev, sc->irq, INTR_TYPE_TTY, NULL, bt3c_intr, sc,
-                       &sc->irq_cookie) != 0) {
-               device_printf(dev, "Could not setup ISR\n");
-               goto bad;
-       }
-
-       /* Attach handler to TTY SWI thread */
-       sc->ith = NULL;
-       if (swi_add(&tty_intr_event, device_get_nameunit(dev),
-                       bt3c_swi_intr, sc, SWI_TTY, 0, &sc->ith) < 0) {
-               device_printf(dev, "Could not setup SWI ISR\n");
-               goto bad;
-       }
-
-       /* Create Netgraph node */
-       if (ng_make_node_common(&typestruct, &sc->node) != 0) {
-               device_printf(dev, "Could not create Netgraph node\n");
-               sc->node = NULL;
-               goto bad;
-       }
-
-       /* Name Netgraph node */
-       if (ng_name_node(sc->node, device_get_nameunit(dev)) != 0) {
-               device_printf(dev, "Could not name Netgraph node\n");
-               NG_NODE_UNREF(sc->node);
-               sc->node = NULL;
-               goto bad;
-       }
-
-       sc->dev = dev;
-       sc->debug = NG_BT3C_WARN_LEVEL;
-
-       sc->inq.ifq_maxlen = sc->outq.ifq_maxlen = BT3C_DEFAULTQLEN;
-       mtx_init(&sc->inq.ifq_mtx, "BT3C inq", NULL, MTX_DEF);
-       mtx_init(&sc->outq.ifq_mtx, "BT3C outq", NULL, MTX_DEF);
-
-       sc->state = NG_BT3C_W4_PKT_IND;
-       sc->want = 1;
-
-       NG_NODE_SET_PRIVATE(sc->node, sc);
-
-       gone_in_dev(dev, 13, "pccard removed");
-
-       return (0);
-bad:
-       if (sc->ith != NULL) {
-               swi_remove(sc->ith);
-               sc->ith = NULL;
-       }
-
-       if (sc->irq != NULL) {
-               if (sc->irq_cookie != NULL)
-                       bus_teardown_intr(dev, sc->irq, sc->irq_cookie);
-
-               bus_release_resource(dev, SYS_RES_IRQ,
-                       sc->irq_rid, sc->irq);
-
-               sc->irq = NULL;
-               sc->irq_rid = 0;
-       }
-
-       if (sc->iobase != NULL) {
-               bus_release_resource(dev, SYS_RES_IOPORT,
-                       sc->iobase_rid, sc->iobase);
-
-               sc->iobase = NULL;
-               sc->iobase_rid = 0;
-       }
-
-       return (ENXIO);
-} /* bt3c_pccacd_attach */
-
-/*
- * PC Card (PCMCIA) detach routine
- */
-
-static int
-bt3c_pccard_detach(device_t dev)
-{
-       bt3c_softc_p    sc = (bt3c_softc_p) device_get_softc(dev);
-
-       if (sc == NULL)
-               return (0);
-
-       swi_remove(sc->ith);
-       sc->ith = NULL;
-
*** 1102 LINES SKIPPED ***
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to