version 1.1.2.4, 2002/10/18 02:38:34 |
version 1.1.2.5, 2002/11/11 22:00:12 |
Line 128 dev_type_open(apmopen); |
|
Line 128 dev_type_open(apmopen); |
|
dev_type_close(apmclose); |
dev_type_close(apmclose); |
dev_type_ioctl(apmioctl); |
dev_type_ioctl(apmioctl); |
dev_type_poll(apmpoll); |
dev_type_poll(apmpoll); |
|
dev_type_kqfilter(apmkqfilter); |
|
|
const struct cdevsw apm_cdevsw = { |
const struct cdevsw apm_cdevsw = { |
apmopen, apmclose, noread, nowrite, apmioctl, |
apmopen, apmclose, noread, nowrite, apmioctl, |
nostop, notty, apmpoll, nommap, |
nostop, notty, apmpoll, nommap, apmkqfilter, |
}; |
}; |
#endif |
#endif |
|
|
Line 142 int apm_evindex; |
|
Line 143 int apm_evindex; |
|
#define APMDEV_NORMAL 0 |
#define APMDEV_NORMAL 0 |
#define APMDEV_CTL 8 |
#define APMDEV_CTL 8 |
|
|
#ifdef __OpenBSD__ |
|
void filt_apmrdetach(struct knote *kn); |
|
int filt_apmread(struct knote *kn, long hint); |
|
int apmkqfilter(dev_t dev, struct knote *kn); |
|
|
|
struct filterops apmread_filtops = |
|
{ 1, NULL, filt_apmrdetach, filt_apmread}; |
|
#endif |
|
|
|
/* |
/* |
* Flags to control kernel display |
* Flags to control kernel display |
* SCFLAG_NOPRINT: do not output APM power messages due to |
* SCFLAG_NOPRINT: do not output APM power messages due to |
Line 431 apmpoll(dev, events, p) |
|
Line 423 apmpoll(dev, events, p) |
|
} |
} |
#endif |
#endif |
|
|
#ifdef __OpenBSD__ |
static void |
void |
filt_apmrdetach(struct knote *kn) |
filt_apmrdetach(kn) |
|
struct knote *kn; |
|
{ |
{ |
struct apm_softc *sc = (struct apm_softc *)kn->kn_hook; |
struct apm_softc *sc = (struct apm_softc *)kn->kn_hook; |
|
|
SLIST_REMOVE(&sc->sc_note, kn, knote, kn_selnext); |
APM_LOCK(sc); |
|
SLIST_REMOVE(&sc->sc_rsel.si_klist, kn, knote, kn_selnext); |
|
APM_UNLOCK(sc); |
} |
} |
|
|
int |
static int |
filt_apmread(kn, hint) |
filt_apmread(struct knote *kn, long hint) |
struct knote *kn; |
|
long hint; |
|
{ |
{ |
/* XXX weird kqueue_scan() semantics */ |
struct apm_softc *sc = kn->kn_hook; |
if (hint && !kn->kn_data) |
|
kn->kn_data = (int)hint; |
|
|
|
return (1); |
kn->kn_data = sc->event_count; |
|
return (kn->kn_data > 0); |
} |
} |
|
|
|
static struct filterops apmread_filtops = |
|
{ 1, NULL, filt_apmrdetach, filt_apmread}; |
|
|
int |
int |
apmkqfilter(dev, kn) |
apmkqfilter(dev, kn) |
dev_t dev; |
dev_t dev; |
struct knote *kn; |
struct knote *kn; |
{ |
{ |
struct apm_softc *sc; |
struct apm_softc *sc = apm_cd.cd_devs[APMUNIT(dev)]; |
|
struct klist *klist; |
/* apm0 only */ |
|
if (!apm_cd.cd_ndevs || APMUNIT(dev) != 0 || |
|
!(sc = apm_cd.cd_devs[APMUNIT(dev)])) |
|
return ENXIO; |
|
|
|
switch (kn->kn_filter) { |
switch (kn->kn_filter) { |
case EVFILT_READ: |
case EVFILT_READ: |
|
klist = &sc->sc_rsel.si_klist; |
kn->kn_fop = &apmread_filtops; |
kn->kn_fop = &apmread_filtops; |
break; |
break; |
default: |
default: |
return (1); |
return (1); |
} |
} |
|
|
kn->kn_hook = (caddr_t)sc; |
kn->kn_hook = sc; |
SLIST_INSERT_HEAD(&sc->sc_note, kn, kn_selnext); |
|
|
APM_LOCK(sc); |
|
SLIST_INSERT_HEAD(klist, kn, kn_selnext); |
|
APM_UNLOCK(sc); |
|
|
return (0); |
return (0); |
} |
} |
#endif |
|