diff options
author | Marco Peereboom <marco@cvs.openbsd.org> | 2005-08-01 16:39:11 +0000 |
---|---|---|
committer | Marco Peereboom <marco@cvs.openbsd.org> | 2005-08-01 16:39:11 +0000 |
commit | c9621e5d79e4c8eacf6fb86ae67d7aa5b01651da (patch) | |
tree | 0aec29e34a4121ace85fa7c378549a79cf68c872 | |
parent | a4d3093c760c6082964d44bdc34a2ceaac856b23 (diff) |
Add alarm control.
Fix buglet where ami does not count physical drives correctly.
Reported by Stephan Tesch stephan at tesch dot cx
-rw-r--r-- | sys/dev/ic/ami.c | 72 | ||||
-rw-r--r-- | sys/dev/ic/amireg.h | 3 |
2 files changed, 70 insertions, 5 deletions
diff --git a/sys/dev/ic/ami.c b/sys/dev/ic/ami.c index b37a5a6afe3..7d55cc77206 100644 --- a/sys/dev/ic/ami.c +++ b/sys/dev/ic/ami.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ami.c,v 1.51 2005/07/29 16:59:26 marco Exp $ */ +/* $OpenBSD: ami.c,v 1.52 2005/08/01 16:39:10 marco Exp $ */ /* * Copyright (c) 2001 Michael Shalayeff @@ -143,6 +143,7 @@ int ami_ioctl(struct device *, u_long, caddr_t); int ami_ioctl_inq(struct ami_softc *, bioc_inq *); int ami_ioctl_vol(struct ami_softc *, bioc_vol *); int ami_ioctl_disk(struct ami_softc *, bioc_disk *); +int ami_ioctl_alarm(struct ami_softc *, bioc_alarm *); #endif /* NBIO > 0 */ struct ami_ccb * @@ -1716,6 +1717,7 @@ ami_ioctl(dev, cmd, addr) case BIOCINQ: case BIOCVOL: case BIOCDISK: + case BIOCALARM: sc->sc_flags |= AMI_CMDWAIT; while (!TAILQ_EMPTY(&sc->sc_ccbq)) if (tsleep(&sc->sc_free_ccb, PRIBIO, "ami_ioctl", @@ -1739,6 +1741,11 @@ ami_ioctl(dev, cmd, addr) error = ami_ioctl_disk(sc, (bioc_disk *)addr); break; + case BIOCALARM: + AMI_DPRINTF(AMI_D_IOCTL, ("alarm ")); + error = ami_ioctl_alarm(sc, (bioc_alarm *)addr); + break; + default: AMI_DPRINTF(AMI_D_IOCTL, ("%s: invalid ioctl\n", sc->sc_dev.dv_xname)); @@ -1845,8 +1852,20 @@ ami_mgmt(sc, opcode, par1, par2, size, buffer) cmd = ccb->ccb_cmd; cmd->acc_cmd = opcode; - cmd->acc_io.aio_channel = par1; - cmd->acc_io.aio_param = par2; + + /* + * some commands require data to be written to idata before sending + * command to fw + */ + switch (opcode) { + case AMI_SPEAKER: + *((char *)idata) = par1; + break; + default: + cmd->acc_io.aio_channel = par1; + cmd->acc_io.aio_param = par2; + }; + cmd->acc_io.aio_data = htole32(pa); if (ami_cmd(ccb, BUS_DMA_WAITOK, 1) == 0) @@ -1890,7 +1909,7 @@ ami_ioctl_inq(sc, bi) goto bail2; } - memset(plist, 0, sizeof plist); + memset(plist, 0, AMI_BIG_MAX_PDRIVES); bi->novol = p->ada_nld; bi->nodisk = 0; @@ -2084,6 +2103,51 @@ bail: return (error); } + +int ami_ioctl_alarm(sc, ba) + struct ami_softc *sc; + bioc_alarm *ba; +{ + int error = 0; + u_int8_t func, ret; + + switch(ba->opcode) { + case BIOC_SADISABLE: + func = AMI_SPKR_OFF; + break; + + case BIOC_SAENABLE: + func = AMI_SPKR_ON; + break; + + case BIOC_SASILENCE: + func = AMI_SPKR_SHUT; + break; + + case BIOC_GASTATUS: + func = AMI_SPKR_GVAL; + break; + + case BIOC_SATEST: + func = AMI_SPKR_TEST; + break; + + default: + AMI_DPRINTF(AMI_D_IOCTL, ("%s: biocalarm invalid opcode %x\n", + sc->sc_dev.dv_xname, ba->opcode)); + error = EINVAL; + } + + if (ami_mgmt(sc, AMI_SPEAKER, func, 0, sizeof ret, &ret)) + error = EINVAL; + else + if (ba->opcode == BIOC_GASTATUS) + ba->status = ret; + else + ba->status = 0; + + return (error); +} #endif /* NBIO > 0 */ #ifdef AMI_DEBUG diff --git a/sys/dev/ic/amireg.h b/sys/dev/ic/amireg.h index 5396d775984..830e23cca4d 100644 --- a/sys/dev/ic/amireg.h +++ b/sys/dev/ic/amireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: amireg.h,v 1.19 2005/07/29 16:30:02 marco Exp $ */ +/* $OpenBSD: amireg.h,v 1.20 2005/08/01 16:39:10 marco Exp $ */ /* * Copyright (c) 2000 Michael Shalayeff @@ -120,6 +120,7 @@ #define AMI_SPKR_ON 1 #define AMI_SPKR_SHUT 2 #define AMI_SPKR_GVAL 3 +#define AMI_SPKR_TEST 4 #define AMI_GDUMP 0x52 /* get error condition in text */ #define AMI_SENSEDUMPA 0x53 /* get SCSI sense dump area */ #define AMI_STDIAG 0x54 /* start diagnostics -- 2.1 */ |