diff options
-rw-r--r-- | sbin/Makefile | 4 | ||||
-rw-r--r-- | sbin/config_slot/Makefile | 15 | ||||
-rw-r--r-- | sbin/config_slot/config_slot.c | 235 | ||||
-rw-r--r-- | sbin/config_slot/read_conf.c | 290 | ||||
-rw-r--r-- | sbin/pcmcia_cntrl/Makefile | 6 | ||||
-rw-r--r-- | sbin/pcmcia_cntrl/pcmcia_cntrl.8 | 74 | ||||
-rw-r--r-- | sbin/pcmcia_cntrl/pcmcia_cntrl.c | 167 | ||||
-rw-r--r-- | usr.sbin/pcmciad/Makefile | 16 | ||||
-rw-r--r-- | usr.sbin/pcmciad/pathnames.h | 32 | ||||
-rw-r--r-- | usr.sbin/pcmciad/pcmciad.8 | 79 | ||||
-rw-r--r-- | usr.sbin/pcmciad/pcmciad.c | 463 | ||||
-rw-r--r-- | usr.sbin/pcmciad/test.config | 2 |
12 files changed, 1 insertions, 1382 deletions
diff --git a/sbin/Makefile b/sbin/Makefile index 558a2ba948e..4c5631d88a5 100644 --- a/sbin/Makefile +++ b/sbin/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.43 1999/07/11 16:31:07 niklas Exp $ +# $OpenBSD: Makefile,v 1.44 1999/07/23 22:17:38 niklas Exp $ # Not ported: XNSrouted enpload scsiformat startslip # Missing: icheck @@ -29,9 +29,7 @@ SUBDIR+= mount_xfs .if make(clean) || make(cleandir) || make(obj) SUBDIR+= bim edlabel fdisk wicontrol .elif ${MACHINE} == "i386" -#SUBDIR+= config_slot SUBDIR+= fdisk -#SUBDIR+= pcmcia_cntrl SUBDIR+= wicontrol .elif (${MACHINE} == "arc") || (${MACHINE} == "powerpc") || (${MACHINE} == "alpha") SUBDIR+= fdisk diff --git a/sbin/config_slot/Makefile b/sbin/config_slot/Makefile deleted file mode 100644 index ed1473a6cfd..00000000000 --- a/sbin/config_slot/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 1997/09/21 11:36:11 deraadt Exp $ - -SRCS= config_slot.c pcmcia_conf.c -#dumpreg.c - -.PATH: ${.CURDIR}/../../sys/dev/pcmcia - -CFLAGS+=-Wmissing-prototypes -I${.CURDIR}/../../sys -PROG= config_slot -NOMAN= - -pcmcia_conf.o: pcmcia_conf.c - ${COMPILE.c} -D_KERNEL $< - -.include <bsd.prog.mk> diff --git a/sbin/config_slot/config_slot.c b/sbin/config_slot/config_slot.c deleted file mode 100644 index aec51b85fd0..00000000000 --- a/sbin/config_slot/config_slot.c +++ /dev/null @@ -1,235 +0,0 @@ -/* $OpenBSD: config_slot.c,v 1.2 1996/06/23 14:30:02 deraadt Exp $ */ - -/* - * Copyright (c) 1993, 1994 Stefan Grefen. 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 dipclaimer. - * 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 Stefan Grefen. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/device.h> - -#include <dev/pcmcia/pcmciareg.h> -#include <dev/pcmcia/pcmciavar.h> -#include <dev/pcmcia/pcmcia_ioctl.h> - -void parse_device(u_char *, int, int); -void parse_ver1(u_char *, int, int); -void parse_config(u_char *, int, int); -void read_extended_speed(u_char *, int *); -const char *tuple_name(int), *dtype_name(int), *dsize_name(int), - *dspeed_name(int); -void parse_tuples(u_char *buf, int print_tuples); -int dumpcf(struct pcmcia_conf *pc_cf); -void usage(void); -int readiowin(char **argv,struct iowin *io); -void dcp(char **argv,char *target); -void parse_cmdline(int argc,char **argv,struct pcmcia_conf *pc_cf); - -int iowins=0; - -dumpcf(struct pcmcia_conf *pc_cf) { - int i; - static char *ios[]= { - "auto","8bit","16bit","illegal" - }; - printf("Driver name '%s'\n",pc_cf->driver_name); - printf("CFG offset %x\n",pc_cf->cfg_off ); - printf("IRQ type %s\n",pc_cf->irq_level?"Level":pc_cf->irq_pulse?"Pulse":"None"); - printf("CFG Entry %x %s\n",pc_cf->cfgtype,pc_cf->cfgtype&DOSRESET?"dosreset":""); - printf("IRQ num %x\n",pc_cf->irq_num&0xf); - printf("Cardtype %s\n",pc_cf->iocard?"IO":"MEM"); - for (i=0;i<pc_cf->iowin;i++) { - printf("iowin %x-%x %s\n",pc_cf->io[i].start, - pc_cf->io[i].start+pc_cf->io[i].len-1, - ios[(pc_cf->io[i].flags&(PCMCIA_MAP_8|PCMCIA_MAP_16))>>8]); - } - for (i=0;i<pc_cf->memwin;i++) { - printf("memwin (%x)%x-%x %x\n", - pc_cf->mem[i].caddr, - pc_cf->mem[i].start, - pc_cf->mem[i].start+pc_cf->mem[i].len-1, - pc_cf->mem[i].flags); - } -} - -void -usage(void) { - fprintf(stderr,"usage: config_slot <slotid> [driver name][iocard]\\\n"); - fprintf(stderr," [irq num][lirq][iowin start len width]\n"); - fprintf(stderr," [** not yet memwin start offs len width]\n"); -} - - -main(int argc,char **argv) { - char namebuf[64]; - struct pcmcia_status stbuf; - struct pcmcia_info inbuf; - struct pcmcia_conf pc_cf; - char manu[MAX_CIS_NAMELEN]; - char model[MAX_CIS_NAMELEN]; - char addinf1[MAX_CIS_NAMELEN]; - char addinf2[MAX_CIS_NAMELEN]; - int sockid; - int fd,cfg; - - if(argc<2 || !isdigit(argv[1][0])) { - usage(); - exit(1); - } - - sockid=atoi(argv[1]); - - bzero(pc_cf,sizeof(pc_cf)); - - argc-=2;argv+=2; - sprintf(namebuf,"/dev/pcmcia/slot%d",sockid); - - if((fd=open(namebuf,O_RDWR))<0) { - printf("errno %d\n",errno); - perror("open"); - exit(1); - } - if(ioctl(fd,PCMCIAIO_GET_STATUS,&stbuf)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_GET_STATUS"); - exit(1); - } - if(!(stbuf.status&PCMCIA_CARD_PRESENT)) { - printf("No card in slot %d\n",stbuf.slot); - exit(1); - } - if(!(stbuf.status&PCMCIA_POWER)) { - int pw=PCMCIA_POWER_5V; - printf("Card in slot %d no power\n",stbuf.slot); - if(ioctl(fd,PCMCIAIO_SET_POWER,&pw)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_SET_POWER"); - exit(1); - } - /*exit(1);/**/ - } - if(ioctl(fd,PCMCIAIO_GET_STATUS,&stbuf)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_GET_STATUS"); - exit(1); - } - printf("Status slot %d %x\n",stbuf.slot,stbuf.status); - if(!(stbuf.status&PCMCIA_READY)) { - printf("Card in slot %d not ready\n",stbuf.slot); - /*exit(1);/**/ - } - if(ioctl(fd,PCMCIAIO_GET_INFO,&inbuf)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_GET_INFO"); - exit(1); - } - /*dbuf(inbuf.cis_data,512);/**/ - bzero(&pc_cf,sizeof(pc_cf)); - /*parse_cmdline(argc,argv,&pc_cf);/**/ - printf("* %x\n",pc_cf.cfgtype); - cfg=pc_cf.cfgtype&CFGENTRYMASK; - if(pcmcia_get_cf(0, inbuf.cis_data,512,CFGENTRYMASK,&pc_cf)) { - fprintf(stderr,"read_conf failed\n"); - exit(1); - } - if(pc_cf.cfgtype&CFGENTRYID) { - if(pcmcia_get_cf(0, inbuf.cis_data,512,cfg,&pc_cf)) { - fprintf(stderr,"read_conf failed\n"); - exit(1); - } - } - parse_cmdline(argc,argv,&pc_cf); - if(iowins && pc_cf.iowin!=iowins) { - pc_cf.iowin=iowins; - } - dumpcf(&pc_cf); - if (pcmcia_get_cisver1(0, (u_char *)&inbuf.cis_data, 512, - manu, model, addinf1, addinf2) == 0) { - printf(" <%s, %s", manu, model); - if (addinf1[0]) - printf(", %s", addinf1); - if (addinf2[0]) - printf(", %s", addinf2); - printf(">\n"); - } - printf("PCMCIAIO_CONFIGURE==%x\n",PCMCIAIO_CONFIGURE); - if(ioctl(fd,PCMCIAIO_CONFIGURE,&pc_cf)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_CONFIGURE"); - exit(1); - } - - exit(0); - -} -#define OPT_ARG(opt,arg,func) if(argc>1 && !strcmp(argv[0],opt)) { \ - arg=func(argv[1]); argv+=2;argc-=2 ;continue;} -#define OPT(opt,arg) if(!strcmp(argv[0],opt)) { \ - arg=1; argv++;argc-- ;continue;} -#define OPTOV_ARG(opt,op,func,arg) if(!strcmp(argv[0],opt)) { \ - arg op func(argv[1]); argv+=2;argc-=2 ;continue;} -#define OPTOV(opt,op,val,arg) if(!strcmp(argv[0],opt)) { \ - arg op val; argv++;argc-- ;continue;} -#define OPT_ARGN(opt,n,arg,func) if(argc>n && !strcmp(argv[0],opt)) { \ - func(&argv[1],&(arg)); argv+=n+1;argc-=n+1 ;continue;} -readiowin(char **argv,struct iowin *io) { - io->start=strtol(argv[0],NULL,0); - io->len=strtol(argv[1],NULL,0); - if(!strcmp(argv[2],"auto")) { - io->flags=0; - } else if(!strcmp(argv[2],"8bit")) { - io->flags=PCMCIA_MAP_8; - } else if(!strcmp(argv[2],"16bit")) { - io->flags=PCMCIA_MAP_16; - } -} - -void -dcp(char **argv,char *target) { - strcpy(target,argv[0]); -} - -void -parse_cmdline(int argc,char **argv,struct pcmcia_conf *pc_cf) { - int memwin=0; - while(argc>0) { - OPT_ARG("irq", pc_cf->irq_num,atoi); - OPT_ARGN("iowin",3,pc_cf->io[iowins++],readiowin); - /*OPT_ARGN("-memwin",4,pc_cf->mem,readmem,win);/**/ - OPT("pirq", pc_cf->irq_pulse); - OPT("lirq", pc_cf->irq_level); - OPT("iocard", pc_cf->iocard); - OPTOV("dosreset", |= ,DOSRESET,pc_cf->cfgtype); - OPTOV_ARG("configid",|= CFGENTRYID |,atoi,pc_cf->cfgtype); - OPT_ARGN("driver",1, pc_cf->driver_name[0][0],dcp); - printf("illegal option '%s'\n",argv[0]); - argc--;argv++; - } -} diff --git a/sbin/config_slot/read_conf.c b/sbin/config_slot/read_conf.c deleted file mode 100644 index 333b93ac097..00000000000 --- a/sbin/config_slot/read_conf.c +++ /dev/null @@ -1,290 +0,0 @@ -/* $OpenBSD: read_conf.c,v 1.2 1996/06/23 14:30:03 deraadt Exp $ */ - -/* - * Copyright (c) 1993, 1994 Stefan Grefen. 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 dipclaimer. - * 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 Stefan Grefen. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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. - */ -/* With 'help' of Barry Jaspan's code */ - -#include <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/device.h> - -#include <dev/pcmcia/pcmcia.h> -#include <dev/pcmcia/pcmciabus.h> -#include <dev/pcmcia/pcmcia_ioctl.h> - -read_conf(u_char *buf, int blen,int cfidx,struct pcmcia_conf *pc_cf) -{ - u_char code, len,*tbuf,*endp=buf+blen; - int done; - - done = 0; - while (!done && buf<endp) { - code=*buf++; - if (code == CIS_NULL) { - continue; - } - - len=*buf++; - - tbuf=buf; - buf+=len; - switch (code) { - case CIS_END: - done = 1; - break; - case CIS_CFG_INFO: - read_cfg_info(tbuf, len, pc_cf); - break; - case CIS_CFG_ENT: - parse_cfent(tbuf, len,cfidx, pc_cf); - break; - default: - break; - } - } - return 0; -} - -read_cfg_info(u_char *tbuf, int len, struct pcmcia_conf *pc_cf) -{ - int i, rasz, rmsz; - - i = 0; - rasz = (tbuf[i] & TPCC_RASZ) >> TPCC_RASZ_SHIFT; - rmsz = (tbuf[i] & TPCC_RMSZ) >> TPCC_RMSZ_SHIFT; - - i+=2; - pc_cf->cfg_off = 0; - switch (rasz) { - case 3: - pc_cf->cfg_off |= (tbuf[i+3] << 24); - case 2: - pc_cf->cfg_off |= (tbuf[i+2] << 16); - case 1: - pc_cf->cfg_off |= (tbuf[i+1] << 8); - case 0: - pc_cf->cfg_off |= tbuf[i]; - } - i+=rasz; - pc_cf->cfg_regmask = 0; - switch (rmsz) { - default: - case 3: - pc_cf->cfg_regmask |= (tbuf[i+3] << 24); - case 2: - pc_cf->cfg_regmask |= (tbuf[i+2] << 16); - case 1: - pc_cf->cfg_regmask |= (tbuf[i+1] << 8); - case 0: - pc_cf->cfg_regmask |= tbuf[i]; - } - -} - -parse_cfent(u_char *tbuf, int len,int slotid, struct pcmcia_conf *pc_cf) -{ - int i, idx,defp,iop,io_16,ios,ftrs,intface,k; - int host_addr_p, addr_size, len_size; - - i = 0; - intface = (tbuf[i] & TPCE_INDX_INT); - idx = (tbuf[i] & TPCE_INDX_ENTRY); - defp = (tbuf[i] & TPCE_INDX_DEF); - printf("%x %x\n",idx,slotid); - if((idx==slotid) ||(defp && slotid==-1)) { - int j; - printf("** %x %x\n",idx,slotid); - if (intface) { - i++; - pc_cf->iocard=(tbuf[i] & TPCE_IF_TYPE)==1; - } - - i++; - ftrs = tbuf[i++]; - for (j = 0; j < (ftrs & TPCE_FS_PWR); j++) { - int pwr_desc = tbuf[i++]; - /* for each struct, skip all parameter defns */ - for (k = 0; k < 8; pwr_desc >>= 1, k++) { - if (pwr_desc & 0x01) { - /* skip bytes until non-ext found */ - while (tbuf[i++] & 0x80) - ; - } - } - } - - if (ftrs & TPCE_FS_TD) { - i++; - } - - if (ftrs & TPCE_FS_IO) { - int io_addrs[16],io_lens[16]; - int io_16,io_block_len, io_block_size; - iop = 1; - io_16 = tbuf[i] & TPCE_FS_IO_BUS16; - i++; - ios--; /*TMPFIX*/; - io_block_len = (tbuf[i] & TPCE_FS_IO_LEN) >> - TPCE_FS_IO_LEN_SHIFT; - io_block_size = (tbuf[i] & TPCE_FS_IO_SIZE) >> - TPCE_FS_IO_SIZE_SHIFT; - ios = (tbuf[i] & TPCE_FS_IO_NUM) + 1; - i++; - for (j = 0; j < ios; j++) { - io_addrs[j] = io_lens[j] = 0; - switch (io_block_size) { - case 3: - io_addrs[j] |= tbuf[i+3] << 24; - io_addrs[j] |= tbuf[i+2] << 16; - case 2: - io_addrs[j] |= tbuf[i+1] << 8; - case 1: - io_addrs[j] |= tbuf[i]; - break; - } - pc_cf->io[j].start=io_addrs[j]; - i += io_block_size + (io_block_size == 3 ? 1 - : 0); - switch (io_block_len) { - case 3: - io_lens[j] |= tbuf[i+3] << 24; - io_lens[j] |= tbuf[i+2] << 16; - case 2: - io_lens[j] |= tbuf[i+1] << 8; - case 1: - io_lens[j] |= tbuf[i]; - break; - } - /* io_lens[j]++; /*TMPFIX*/; - pc_cf->io[j].len=io_lens[j]; - pc_cf->io[j].flags=io_16?PCMCIA_MAP_16:PCMCIA_MAP_8; - i += io_block_len + (io_block_len == 3 ? 1 - : 0); - - } - pc_cf->iowin=ios; - } - - if (ftrs & TPCE_FS_IRQ) { - int irq_mask,irqp,irq; - pc_cf->irq_level=!!(tbuf[i] & TPCE_FS_IRQ_LEVEL); - pc_cf->irq_pulse=!!(tbuf[i] & TPCE_FS_IRQ_PULSE); - pc_cf->irq_share=!!(tbuf[i] & TPCE_FS_IRQ_SHARE); - if (tbuf[i] & TPCE_FS_IRQ_MASK) { - irq_mask = (tbuf[i+2] << 8) + tbuf[i+1]; - i += 2; - } else { - pc_cf->irq_num = tbuf[i] & TPCE_FS_IRQ_IRQN; - } - - i++; - } - - if (ftrs & TPCE_FS_MEM) { - int memp,mems,mem_lens[16],mem_caddrs[16],mem_haddrs[16]; - memp = 1; - switch ((ftrs & TPCE_FS_MEM) >> TPCE_FS_MEM_SHIFT) { - case 1: - mems = 1; - mem_lens[0] = (tbuf[i+1] << 8) + tbuf[i]; - mem_lens[0] <<= 8; - printf("\tmem: len %d\n", mem_lens[0]); - - break; - case 2: - mems = 1; - mem_lens[0] = (tbuf[i+1] << 8) + tbuf[i]; - mem_caddrs[0] = mem_haddrs[0] = - (tbuf[i+3] << 8) + tbuf[i+2]; - - mem_lens[0] <<= 8; - mem_caddrs[0] <<= 8; - - break; - case 3: - host_addr_p = tbuf[i] & TPCE_FS_MEM_HOST; - addr_size = (tbuf[i] & TPCE_FS_MEM_ADDR) >> - TPCE_FS_MEM_ADDR_SHIFT; - len_size = (tbuf[i] & TPCE_FS_MEM_LEN) >> - TPCE_FS_MEM_LEN_SHIFT; - mems = (tbuf[i] & TPCE_FS_MEM_WINS) + 1; - i++; - for (j = 0; j < mems; j++) { - mem_lens[j] = 0; - mem_caddrs[j] = 0; - mem_haddrs[j] = 0; - switch (len_size) { - case 3: - mem_lens[j] |= (tbuf[i+2] << 16); - case 2: - mem_lens[j] |= (tbuf[i+1] << 8); - case 1: - mem_lens[j] |= tbuf[i]; - } - i += len_size; - switch (addr_size) { - case 3: - mem_caddrs[j] |= (tbuf[i+2] << 16); - case 2: - mem_caddrs[j] |= (tbuf[i+1] << 8); - case 1: - mem_caddrs[j] |= tbuf[i]; - } - i += addr_size; - if (host_addr_p) { - switch (addr_size) { - case 3: - mem_haddrs[j] |= - (tbuf[i+2] << 16); - case 2: - mem_haddrs[j] |= - (tbuf[i+1] << 8); - case 1: - mem_haddrs[j] |= - tbuf[i]; - } - i += addr_size; - } - - mem_lens[j] <<= 8; - mem_caddrs[j] <<= 8; - mem_haddrs[j] <<= 8; - - } - } - } - } -} - - - - diff --git a/sbin/pcmcia_cntrl/Makefile b/sbin/pcmcia_cntrl/Makefile deleted file mode 100644 index 6fdf672bd6f..00000000000 --- a/sbin/pcmcia_cntrl/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 1997/12/21 00:53:08 millert Exp $ - -PROG= pcmcia_cntrl -MAN= pcmcia_cntrl.8 - -.include <bsd.prog.mk> diff --git a/sbin/pcmcia_cntrl/pcmcia_cntrl.8 b/sbin/pcmcia_cntrl/pcmcia_cntrl.8 deleted file mode 100644 index 1ff629ee31d..00000000000 --- a/sbin/pcmcia_cntrl/pcmcia_cntrl.8 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $OpenBSD: pcmcia_cntrl.8,v 1.6 1999/06/04 02:45:20 aaron Exp $ -.\" Copyright (c) 1994 Stefan Grefen -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the Institute of Electrical and Electronics Engineers, Inc. -.\" -.\" 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 the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.\" from: @(#)pwd.1 6.5 (Berkeley) 6/27/91 -.\" -.Dd May 31, 1994 -.Dt PCMCIA_CNTRL 8 -.Os -.Sh NAME -.Nm pcmcia_cntrl -.Nd change the status of a pcmcia slot -.Sh SYNOPSIS -.Nm pcmcia_cntrl -.Ar slotid -.Op on | off | unmap | probe -.Sh DESCRIPTION -.Nm -controls the operation of a PCMCIA card. It operates on the card in slot -.Ar slotid . -\. -.Pp -The options are as follows: -.Bl -tag -width flag -.It Fl on -Turns power on -.It Fl off -Turns power off -.It Fl unmap -Unmaps and unconfigures a active card (not all drivers may support this). -.It Fl probe -Probes and attaches the card found in the slot. Works only for devices that -have kernel support for mapping. -Use config_slot for other devices. -.El -.Pp -The -.Nm -utility exits 0 on success or >0 if an error occurred. -.Sh SEE ALSO -.Xr pcmcia 4 -.Sh BUGS -Too numerous to mention. diff --git a/sbin/pcmcia_cntrl/pcmcia_cntrl.c b/sbin/pcmcia_cntrl/pcmcia_cntrl.c deleted file mode 100644 index c37f5f50cb4..00000000000 --- a/sbin/pcmcia_cntrl/pcmcia_cntrl.c +++ /dev/null @@ -1,167 +0,0 @@ -/* $OpenBSD: pcmcia_cntrl.c,v 1.2 1996/06/23 14:32:00 deraadt Exp $ */ - -/* - * Copyright (c) 1993, 1994 Stefan Grefen. 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 dipclaimer. - * 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 Stefan Grefen. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/device.h> - -#include <dev/pcmcia/pcmciavar.h> -#include <dev/pcmcia/pcmciareg.h> -#include <dev/pcmcia/pcmcia_ioctl.h> - -#define HAS_POWER(a) (!!(a&(PCMCIA_POWER))) - -void -usage(void) { - fprintf(stderr,"usage: pcmcia_cntrl [-f fd] <slotid> on|off|unmap|unconf|probe\n"); -} - -main(int argc,char **argv) { - int fd = -1; - char namebuf[64]; - int sockid; - struct pcmcia_status stbuf; - struct pcmcia_info inbuf; - int onoff=-1; - int unmap=-1; - int unconf=-1; - int probe=-1; - int force=-1; - - if (argv[1] && strcmp(argv[1], "-f") == 0 && - argv[2]) { - fd = atoi(argv[2]); - argv += 2; - argc -= 2; - } - - if(argc!=3 || !isdigit(argv[1][0])) { - usage(); - exit(1); - } - sockid=atoi(argv[1]); - - - if(!strcmp(argv[2],"on")) { - onoff=1; - } else if(!strcmp(argv[2],"off")) { - onoff=0; - } else if(!strcmp(argv[2],"unconf")) { - unmap=1; - unconf=1; - } else if(!strcmp(argv[2],"unconfforce")) { - unmap=1; - unconf=1; - force=1; - } else if(!strcmp(argv[2],"unmap")) { - unmap=1; - } else if(!strcmp(argv[2],"probe")) { - probe=1; - } else { - usage(); - exit(1); - } - - sprintf(namebuf,"/dev/pcmcia/slot%d",sockid); - - if (fd == -1 && (fd=open(namebuf,O_RDWR))<0) { - perror("open"); - exit(1); - } - if(ioctl(fd,PCMCIAIO_GET_STATUS,&stbuf)<0) { - perror("ioctl PCMCIAIO_GET_STATUS"); - exit(1); - } - if(!(stbuf.status&PCMCIA_CARD_PRESENT) && force < 0) { - fprintf(stderr,"No card in slot %d\n",stbuf.slot); - exit(1); - } - if(onoff>=0) { - if(stbuf.status&PCMCIA_CARD_IS_MAPPED) { - fprintf(stderr,"Card in slot %d is mapped, can't turn it %s\n",stbuf.slot,onoff?"on":"off"); - exit(1); - } - if((HAS_POWER(stbuf.status&PCMCIA_POWER))^(!!onoff)) { - int pw=onoff?PCMCIASIO_POWER_5V:PCMCIASIO_POWER_OFF; - printf("Card in slot %d power %s\n",stbuf.slot,onoff?"on":"off" ); - if(ioctl(fd,PCMCIAIO_SET_POWER,&pw)<0) { - printf("errno %d\n",errno); - perror("ioctl PCMCIAIO_SET_POWER"); - exit(1); - } - /*exit(1);/**/ - } - } - if (unconf >= 0) { - int o; - if(!(stbuf.status&PCMCIA_CARD_IS_MAPPED)) { - fprintf(stderr,"Card in slot %d is not mapped\n",stbuf.slot); - exit(1); - } - if(ioctl(fd,PCMCIAIO_UNCONFIGURE,0)<0) { - perror("ioctl PCMCIAIO_UNCONFIGURE"); - exit(1); - } - } - if (unmap >= 0) { - if (!unconf && (stbuf.status&PCMCIA_CARD_INUSE)) { - fprintf(stderr, "Card in slot %d is configured--unconfigure before unmapping.\n", stbuf.slot); - exit(1); - } - if(!(stbuf.status&PCMCIA_CARD_IS_MAPPED)) { - fprintf(stderr,"Card in slot %d is not mapped\n",stbuf.slot); - exit(1); - } - if(ioctl(fd,PCMCIAIO_UNMAP,0)<0) { - perror("ioctl PCMCIAIO_UNMAP"); - exit(1); - } - } - if(probe>=0) { - struct pcmcia_conf pc_cf; - if(stbuf.status&PCMCIA_CARD_IS_MAPPED) { - fprintf(stderr,"Card in slot %d is mapped, can't probe it\n", - stbuf.slot); - exit(1); - } - bzero(pc_cf,sizeof(pc_cf)); - if(ioctl(fd,PCMCIAIO_CONFIGURE,&pc_cf)<0) { - perror("ioctl PCMCIAIO_CONFIGURE"); - exit(1); - } - } - exit(0); -} - diff --git a/usr.sbin/pcmciad/Makefile b/usr.sbin/pcmciad/Makefile deleted file mode 100644 index 6a9e5e77849..00000000000 --- a/usr.sbin/pcmciad/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -# $OpenBSD: Makefile,v 1.5 1997/09/21 11:44:02 deraadt Exp $ - -SRCS= pcmciad.c pcmcia_conf.c -.PATH: ${.CURDIR}/../../sys/dev/pcmcia - -CFLAGS+=-Wmissing-prototypes -I${.CURDIR}/../../sys -PROG= pcmciad -MAN= pcmciad.8 - -pcmcia_conf.o: pcmcia_conf.c - ${COMPILE.c} -D_KERNEL $< -clean:: - rm -f a.out [Ee]rrs mklog core *.core pcmciad pcmcia_conf.o pcmciad.o - - -.include <bsd.prog.mk> diff --git a/usr.sbin/pcmciad/pathnames.h b/usr.sbin/pcmciad/pathnames.h deleted file mode 100644 index f28474271e9..00000000000 --- a/usr.sbin/pcmciad/pathnames.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 1996 John T. Kohl - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 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. - * - */ - -#define _PATH_DEV_SPEAKER "/dev/speaker" -#define _PATH_PCMCIA_CONF "/etc/pcmciad.conf" - diff --git a/usr.sbin/pcmciad/pcmciad.8 b/usr.sbin/pcmciad/pcmciad.8 deleted file mode 100644 index daa0876905c..00000000000 --- a/usr.sbin/pcmciad/pcmciad.8 +++ /dev/null @@ -1,79 +0,0 @@ -.\" Copyright (c) 1995 John T. Kohl -.\" 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. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR `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 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: pcmciad.8,v 1.4 1999/05/23 14:11:34 aaron Exp $ -.\" -.Dd October 29, 1995 -.Dt PCMCIAD 8 -.Os -.Sh NAME -.Nm pcmciad -.Nd PC-CARD slot monitor daemon -.Sh SYNOPSIS -.Nm pcmciad -.Op Fl d -.Op Fl q -.Op Fl c Ar conf-file -.Sh DESCRIPTION -.Nm -monitors a set of PCMCIA slots for card change events, and acts on those -events. -It reads the configuration file specified with the -.Fl c -flag, or, if no file is specified, the default configuration file -.Pa /etc/pcmciad.conf . -.Pp -Each line of the configuration file contains a list of PCMCIA slot -device files to monitor and a command name for that slot. -Whenever a card event occurs on a monitored slot, -.Nm -attempts to -configure (upon insertion) or unconfigure (upon removal) the card. If -the action succeeds, the slot's command is run, passed the slot number, -event type (insert or delete), and device type name. -.Pp -.Nm -announces card insertion/configuration/removal events on the speaker -(using the -.Pa /dev/speaker -device). A short high note announces a card insertion. A low note -followed by a high note indicates successful card configuration; a -single low note indicates an unknown card or configuration failure. A -high note followed by a low note indicates a card removal. -.Pp -When the -.Fl q -flag is specified, the card insertion/removal events are not announced -on the speaker. -.Sh SEE ALSO -.Xr speaker 4 , -.Xr config_slot 8 , -.Xr pcmcia_cntrl 8 -.Sh HISTORY -The -.Nm pcmciad -command appeared in -.Ox 1.2 . diff --git a/usr.sbin/pcmciad/pcmciad.c b/usr.sbin/pcmciad/pcmciad.c deleted file mode 100644 index a615d7d1127..00000000000 --- a/usr.sbin/pcmciad/pcmciad.c +++ /dev/null @@ -1,463 +0,0 @@ -/* $NetBSD$ */ -/* - * Copyright (c) 1995 John T. Kohl. All rights reserved. - * Copyright (c) 1993, 1994 Stefan Grefen. 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 dipclaimer. - * 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 Stefan Grefen. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 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 <stdio.h> -#include <errno.h> -#include <sys/types.h> -#include <sys/file.h> -#include <sys/ioctl.h> -#include <sys/device.h> -#include <sys/wait.h> -#include <syslog.h> -#include <signal.h> -#include <unistd.h> -#include <string.h> -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/wait.h> -#include <errno.h> -#include <dev/pcmcia/pcmciareg.h> -#include <dev/pcmcia/pcmciavar.h> -#include <dev/pcmcia/pcmcia_ioctl.h> -#include "pathnames.h" - -#define PCMCIABUS_UNIT(a) (minor(a)) -#define PCMCIABUS_SLOT(a) (a&0x7) - -#define HAS_POWER(a) ISSET(a,PCMCIA_POWER) - -/* Macros to clear/set/test flags. */ -#define SET(t, f) (t) |= (f) -#define CLR(t, f) (t) &= ~(f) -#define ISSET(t, f) ((t) & (f)) - -extern const char *__progname; - -extern char *optarg; -extern int optind; -extern int optopt; -extern int opterr; -extern int optreset; - -const char conffile[] = _PATH_PCMCIA_CONF; - -enum speaker_tones { - SINGLE_HIGH, - SHORT_HIGH, - LOW_HIGH, - HIGH_LOW, - SINGLE_LOW -}; - - -void make_noise __P((enum speaker_tones)); -void child_death __P((int)); -void usage __P((void)); -void handle_fd __P((int fd)); - -extern int read_conf(u_char *buf, - int blen, - int cfidx, - struct pcmcia_conf *pc_cf); - -void -usage(void) -{ - fprintf(stderr,"usage: %s [-d] [-c configfile]\n", __progname); - exit(1); -} - -dev_t devices_opened[64]; /* XXX fixed size */ -int slot_status[64]; /* XXX fixed size */ - -int speaker_ok = 1; - -void /* XXX */ -main(int argc, - char *argv[]) -{ - int fd, ch, maxfd = 0, ready; - int debug = 0; - FILE *infile = NULL; - const char *fname = conffile; - char confline[128]; - fd_set sockets; - fd_set selcopy; - struct stat statb; - - while ((ch = getopt(argc, argv, "qdc:")) != -1) - switch(ch) { - case 'q': - speaker_ok = 0; - break; - case 'd': - debug = 1; - break; - case 'c': - fname = optarg; - break; - case '?': - default: - usage(); - } - argc -= optind; - argv += optind; - - if ((infile = fopen(fname, "r")) == NULL) { - (void)err(1, "cannot open config file `%s'", fname); - } - if (debug) { - openlog(__progname, LOG_CONS, LOG_LOCAL1); - } else { - openlog(__progname, LOG_CONS, LOG_DAEMON); - setlogmask(LOG_UPTO(LOG_NOTICE)); - daemon(0, 0); - } - syslog(LOG_DEBUG, "opened config file %s", fname); - FD_ZERO(&sockets); - while (fgets(confline, sizeof(confline), infile) != NULL) { - if (confline[strlen(confline)-1] == '\n') - confline[strlen(confline)-1] = '\0'; - fd = open(confline, O_RDWR); - if (fd != -1) { - struct pcmcia_status stbuf; - if (ioctl(fd, PCMCIAIO_GET_STATUS, &stbuf) < 0) { - syslog(LOG_ERR,"ioctl PCMCIAIO_GET_STATUS %s: %m", - confline); - close(fd); - } else { - FD_SET(fd, &sockets); - syslog(LOG_DEBUG, "%s is fd %d", confline, fd); - if (fstat(fd, &statb) == -1) { - syslog(LOG_ERR, "cannot fstat %s: %m", - confline); - (void) close(fd); - } else { - maxfd = MAX(fd, maxfd); - devices_opened[fd] = statb.st_rdev; - } - slot_status[fd] = ISSET(stbuf.status, - PCMCIA_CARD_PRESENT); - if (ISSET(stbuf.status, PCMCIA_CARD_INUSE)) - make_noise(LOW_HIGH); - else if (ISSET(stbuf.status, - PCMCIA_CARD_IS_MAPPED)) - make_noise(SINGLE_LOW); - else if (ISSET(stbuf.status, - PCMCIA_CARD_PRESENT)) - handle_fd(fd); - - } - } else - syslog(LOG_DEBUG, "%s: %m", confline); - } - fclose(infile); - - if (maxfd == 0) { - syslog(LOG_ERR, "no files to monitor"); - exit(1); - } - syslog(LOG_DEBUG, "maxfd = %d", maxfd); - - signal(SIGCHLD, child_death); - while (1) { - for (selcopy = sockets; - (ready = select(maxfd+1, 0, 0, &selcopy, 0)) > 0; - selcopy = sockets) { - register int i; - syslog(LOG_DEBUG, "%d ready descriptors", ready); - for (i = 0; ready && i <= maxfd; i++) { - if (FD_ISSET(i, &selcopy)) { - syslog(LOG_DEBUG, "fd %d is exceptionally ready", i); - /* sleep to let it settle */ - sleep(2); - ready--; - handle_fd(i); - } - } - } - if (ready == -1) { - if (errno != EINTR) - syslog(LOG_ERR, "select failed: %m"); - continue; - } else { - syslog(LOG_ERR, "leaving with ready == 0?"); - break; - } - } -} - -void -handle_fd(int fd) -{ - struct pcmcia_status stbuf; - struct pcmcia_info inbuf; - struct pcmcia_conf pc_cf; - int status; - int pw; - int first=1; - char manu[MAX_CIS_NAMELEN]; - char model[MAX_CIS_NAMELEN]; - char addinf1[MAX_CIS_NAMELEN]; - char addinf2[MAX_CIS_NAMELEN]; - char cmd[64]; - - if (ioctl(fd, PCMCIAIO_GET_STATUS, &stbuf) < 0) { - syslog(LOG_ERR,"ioctl PCMCIAIO_GET_STATUS: %m"); - return; - } - status = ISSET(stbuf.status, PCMCIA_CARD_PRESENT); - if (!status) { - syslog(LOG_INFO,"No card in slot %d",stbuf.slot); - if (ISSET(stbuf.status, PCMCIA_CARD_INUSE) || - ISSET(stbuf.status, PCMCIA_CARD_IS_MAPPED)) { - if (ioctl(fd, - ISSET(stbuf.status, PCMCIA_CARD_INUSE) ? - PCMCIAIO_UNCONFIGURE : PCMCIAIO_UNMAP, 0) < 0) - syslog(LOG_ERR, - "ioctl PCMCIAIO_UNCONFIGURE slot %d: %m", - stbuf.slot); - else { - if (status != slot_status[fd]) { - make_noise(HIGH_LOW); - } - } - slot_status[fd] = status; - if (ioctl(fd, PCMCIAIO_GET_STATUS, &stbuf) < 0) { - syslog(LOG_ERR, "ioctl PCMCIAIO_GET_STATUS: %m"); - make_noise(SINGLE_LOW); - return; - } - } else { - syslog(LOG_DEBUG,"Card in slot %d is not mapped", - stbuf.slot); - if (status != slot_status[fd]) { - make_noise(HIGH_LOW); - } - slot_status[fd] = status; - return; - } - if (ISSET(stbuf.status, PCMCIA_POWER)) { - pw = PCMCIASIO_POWER_OFF; - if (ioctl(fd, PCMCIAIO_SET_POWER, &pw) < 0) - syslog(LOG_ERR,"ioctl PCMCIAIO_SET_POWER slot %d: %m", - stbuf.slot); - } -#if 0 - sprintf(cmd, "/sbin/pcmcia_cntrl -f %d %d unmapforce", fd, - PCMCIABUS_SLOT(PCMCIABUS_UNIT(devices_opened[fd]))); -#endif - return; - } else { - if (status != slot_status[fd]) - make_noise(SHORT_HIGH); - if (ISSET(stbuf.status, PCMCIA_CARD_INUSE)) { - syslog(LOG_INFO, - "Card in slot %d is attached, can't probe it", - stbuf.slot); - /* make_noise(SINGLE_LOW); */ - return; - } - /* unmap the card to clean up. */ - if (ISSET(stbuf.status, PCMCIA_CARD_IS_MAPPED) && - ioctl(fd, PCMCIAIO_UNMAP, 0) == -1) { - syslog(LOG_NOTICE, - "cannot unmap card in slot %d: %m", stbuf.slot); - make_noise(SINGLE_LOW); - return; - } - -tryagain: - pw = PCMCIASIO_POWER_OFF; - if (ioctl(fd, PCMCIAIO_SET_POWER, &pw) == -1) { - syslog(LOG_ERR,"ioctl PCMCIAIO_SET_POWER slot %d: %m", - stbuf.slot); - make_noise(SINGLE_LOW); - return; - } - pw = PCMCIASIO_POWER_AUTO; - if (ioctl(fd, PCMCIAIO_SET_POWER, &pw) == -1) { - syslog(LOG_ERR,"ioctl PCMCIAIO_SET_POWER slot %d: %m", - stbuf.slot); - make_noise(SINGLE_LOW); - return; - } - if (ioctl(fd, PCMCIAIO_GET_INFO, &inbuf) < 0) - syslog(LOG_ERR, "ioctl PCMCIAIO_GETINFO: %m"); - else { - syslog(LOG_DEBUG, "config: %s", inbuf.cis_data); - } - memset(&pc_cf, 0, sizeof(pc_cf)); - if (pcmcia_get_cf(0, inbuf.cis_data, 512, CFGENTRYMASK, - &pc_cf)) { - syslog(LOG_ERR, "can't interpret config info"); - } else { - if (pcmcia_get_cisver1(0, (u_char *)&inbuf.cis_data, - 512, manu, model, addinf1, - addinf2) == 0) { - syslog(LOG_INFO,"<%s, %s, %s, %s>", - manu, model, addinf1, addinf2); - } else { - syslog(LOG_ERR, "can't get CIS info"); - if (first) { - first = 0; - goto tryagain; - } - } - } -#if 0 - sprintf(cmd, "/sbin/pcmcia_cntrl -f %d %d probe", fd, - PCMCIABUS_SLOT(PCMCIABUS_UNIT(devices_opened[fd]))); -#endif -#if 0 || 0 - if (ioctl(fd, PCMCIAIO_CONFIGURE, &pc_cf) == -1) { - syslog(LOG_ERR, "ioctl PCMCIAIO_CONFIGURE: %m"); - return; - } -#endif - memset(&pc_cf, 0, sizeof(pc_cf)); - if (ioctl(fd, PCMCIAIO_CONFIGURE, &pc_cf) == -1) { - syslog(LOG_ERR, "ioctl PCMCIAIO_CONFIGURE: %m"); - make_noise(SINGLE_LOW); - } else - if (status != slot_status[fd]) - make_noise(LOW_HIGH); - slot_status[fd] = status; - return; - } -#if 0 - syslog(LOG_DEBUG, "execing `%s'", cmd); - status = system(cmd); - if (status == -1) - syslog(LOG_ERR, "cannot run %s", cmd); - else if (WIFEXITED(status)) { - if (WEXITSTATUS(status) != 0) - syslog(LOG_ERR, - "%s returned %d", cmd, WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - syslog(LOG_ERR, - "%s died from signal %d", cmd, WTERMSIG(status)); - } - return; -#endif -} - -/* - * Insert/remove tones. We do the same tones as Wildboar (BSD/OS kit): - * - * single high note: suspend/resume (look at apmd instead) - * short high note: card insertion noticed - * low then high note: successful attach - * high then low note: card eject noticed - * single low note: unknown card or attach failure - * - * we do the sound via /dev/speaker. - */ - -const char *tone_string[] = { -/* SINGLE_HIGH*/"o4c", -/* SHORT_HIGH,*/"t240o4c", -/* LOW_HIGH,*/ "t180o2co4c", -/* HIGH_LOW,*/ "t180o4co2c", -/* SINGLE_LOW*/ "t180o2c" -}; - -void -make_noise(tones) - enum speaker_tones tones; -{ - pid_t pid; - int spkrfd; - int trycnt; - - if (!speaker_ok) /* don't bother after sticky errors */ - return; - - pid = fork(); - switch (pid) { - case -1: - syslog(LOG_ERR, "cannot fork for speaker tones: %m"); - return; - case 0: - /* child */ - for (trycnt = 0; trycnt < 3; trycnt++) { - spkrfd = open(_PATH_DEV_SPEAKER, O_WRONLY); - if (spkrfd == -1) { - switch (errno) { - case EBUSY: - usleep(1000000); - errno = EBUSY; - continue; - case ENOENT: - case ENODEV: - case ENXIO: - case EPERM: - case EACCES: - syslog(LOG_INFO, - "speaker device " _PATH_DEV_SPEAKER " unavailable: %m"); - exit(2); - break; - } - } else - break; - } - if (spkrfd == -1) { - syslog(LOG_WARNING, - "cannot open " _PATH_DEV_SPEAKER ": %m"); - exit(1); - } - syslog(LOG_DEBUG, - "sending %s to speaker", tone_string[tones]); - write (spkrfd, tone_string[tones], strlen(tone_string[tones])); - exit(0); - default: - /* parent */ - return; - } -} - -void -child_death(sig) - int sig; -{ - int status; - int save_errno = errno; - - if (wait(&status) == -1) { - syslog(LOG_ERR, "wait error for signaled child: %m"); - errno = save_errno; - return; - } - if (WEXITSTATUS(status) == 2) - speaker_ok = 0; - errno = save_errno; -} diff --git a/usr.sbin/pcmciad/test.config b/usr.sbin/pcmciad/test.config deleted file mode 100644 index 4d78866480e..00000000000 --- a/usr.sbin/pcmciad/test.config +++ /dev/null @@ -1,2 +0,0 @@ -/dev/pcmcia/slot0 -/dev/pcmcia/slot1 |