diff options
| author | 2007-07-23 13:30:21 +0000 | |
|---|---|---|
| committer | 2007-07-23 13:30:21 +0000 | |
| commit | 516c7f6ffc607e405d61c39f27abcda3699aa3b4 (patch) | |
| tree | b2a0bd4af089e800726877b0a45dfa9db09f1318 | |
| parent | when multipath routes exist, display them in ospfctl sh fib output. (diff) | |
| download | wireguard-openbsd-516c7f6ffc607e405d61c39f27abcda3699aa3b4.tar.xz wireguard-openbsd-516c7f6ffc607e405d61c39f27abcda3699aa3b4.zip | |
Add glue for a control device for bthub(4). Will be used to configure
device inquiry/discovery parameters, pairings, and what else might be
needed.
From discussion with gwk. MAKEDEV goo follows later.
ok and lots of input from miod.
| -rw-r--r-- | sys/arch/i386/i386/conf.c | 4 | ||||
| -rw-r--r-- | sys/dev/bluetooth/bthub.c | 67 | ||||
| -rw-r--r-- | sys/dev/bluetooth/files.bluetooth | 4 | ||||
| -rw-r--r-- | sys/sys/conf.h | 10 |
4 files changed, 79 insertions, 6 deletions
diff --git a/sys/arch/i386/i386/conf.c b/sys/arch/i386/i386/conf.c index ab58b8397f0..bbe36f466b2 100644 --- a/sys/arch/i386/i386/conf.c +++ b/sys/arch/i386/i386/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.117 2007/05/29 19:03:35 krw Exp $ */ +/* $OpenBSD: conf.c,v 1.118 2007/07/23 13:30:21 mk Exp $ */ /* $NetBSD: conf.c,v 1.75 1996/05/03 19:40:20 christos Exp $ */ /* @@ -153,6 +153,7 @@ cdev_decl(music); #include "joy.h" #include "acpi.h" #include "apm.h" +#include "bthub.h" #include "pctr.h" #include "bios.h" #include "iop.h" @@ -307,6 +308,7 @@ struct cdevsw cdevsw[] = cdev_gpio_init(NGPIO,gpio), /* 83: GPIO interface */ cdev_nvram_init(NNVRAM,nvram), /* 84: NVRAM interface */ cdev_acpi_init(NACPI,acpi), /* 85: ACPI */ + cdev_bthub_init(NBTHUB,bthub), /* 86: bthub */ }; int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]); diff --git a/sys/dev/bluetooth/bthub.c b/sys/dev/bluetooth/bthub.c index 37fcb5e875d..cceab057474 100644 --- a/sys/dev/bluetooth/bthub.c +++ b/sys/dev/bluetooth/bthub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bthub.c,v 1.1 2007/05/31 04:04:56 uwe Exp $ */ +/* $OpenBSD: bthub.c,v 1.2 2007/07/23 13:30:21 mk Exp $ */ /* * Copyright (c) 2007 Uwe Stuehler <uwe@openbsd.org> @@ -17,13 +17,17 @@ */ #include <sys/param.h> -#include <sys/device.h> #include <sys/systm.h> +#include <sys/conf.h> +#include <sys/device.h> +#include <sys/ioctl.h> +#include <sys/vnode.h> #include <netbt/bluetooth.h> struct bthub_softc { struct device sc_dev; + int sc_open; }; int bthub_match(struct device *, void *, void *); @@ -48,6 +52,9 @@ void bthub_attach(struct device *parent, struct device *self, void *aux) { bdaddr_t *addr = aux; + struct bthub_softc *sc = (struct bthub_softc *)self; + + sc->sc_open = 0; printf(" %02x:%02x:%02x:%02x:%02x:%02x\n", addr->b[5], addr->b[4], addr->b[3], @@ -57,5 +64,61 @@ bthub_attach(struct device *parent, struct device *self, void *aux) int bthub_detach(struct device *self, int flags) { + int maj, mn; + + /* Locate the major number */ + for (maj = 0; maj < nchrdev; maj++) + if (cdevsw[maj].d_open == bthubopen) + break; + + /* Nuke the vnodes for any open instances (calls close) */ + mn = self->dv_unit; + vdevgone(maj, mn, mn, VCHR); + + return 0; +} + +int bthubopen(dev_t dev, int flag, int mode, struct proc *p) +{ + struct device *dv; + struct bthub_softc *sc; + + if (minor(dev) != 0) + return (ENXIO); + + dv = device_lookup(&bthub_cd, minor(dev)); + if (dv == NULL) + return (ENXIO); + + sc = (struct bthub_softc *)dv; + if (sc->sc_open) { + device_unref(dv); + return (EBUSY); + } + + sc->sc_open = 1; + device_unref(dv); + return 0; } + +int +bthubclose(dev_t dev, int flag, int mode, struct proc *p) +{ + struct device *dv; + struct bthub_softc *sc; + + dv = device_lookup(&bthub_cd, minor(dev)); + sc = (struct bthub_softc *)dv; + sc->sc_open = 0; + device_unref(dv); + + return (0); +} + +int +bthubioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p) +{ + return ENOTTY; +} + diff --git a/sys/dev/bluetooth/files.bluetooth b/sys/dev/bluetooth/files.bluetooth index 493f6fb84f5..1fc5452b27f 100644 --- a/sys/dev/bluetooth/files.bluetooth +++ b/sys/dev/bluetooth/files.bluetooth @@ -1,8 +1,8 @@ -# $OpenBSD: files.bluetooth,v 1.1 2007/05/31 04:04:56 uwe Exp $ +# $OpenBSD: files.bluetooth,v 1.2 2007/07/23 13:30:21 mk Exp $ # # Config file and device description for machine-independent Bluetooth code. # Included by ports that support Bluetooth host controllers. device bthub {} attach bthub at btbus -file dev/bluetooth/bthub.c bthub +file dev/bluetooth/bthub.c bthub needs-flag diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 28c0749b41c..6359d659a4a 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.h,v 1.82 2007/06/06 17:15:14 deraadt Exp $ */ +/* $OpenBSD: conf.h,v 1.83 2007/07/23 13:30:21 mk Exp $ */ /* $NetBSD: conf.h,v 1.33 1996/05/03 20:03:32 christos Exp $ */ /*- @@ -483,6 +483,13 @@ void randomattach(void); (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ (dev_type_mmap((*))) enodev } +/* open, close, ioctl */ +#define cdev_bthub_init(c,n) { \ + dev_init(c,n,open), dev_init(c,n,close), (dev_type_read((*))) enodev, \ + (dev_type_write((*))) enodev, dev_init(c,n,ioctl), \ + (dev_type_stop((*))) enodev, 0, (dev_type_poll((*))) enodev, \ + (dev_type_mmap((*))) enodev } + #endif /* @@ -623,6 +630,7 @@ cdev_decl(crypto); cdev_decl(systrace); cdev_decl(bio); +cdev_decl(bthub); cdev_decl(gpr); cdev_decl(bktr); |
