Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Aug 1996 16:31:36 -0600 (MDT)
From:      Nate Williams <nate@mt.sri.com>
To:        mobile@freebsd.org
Cc:        hosokawa@mt.cs.keio.ac.jp, Nate Williams <nate@mt.sri.com>
Subject:   Pccardc complete diffs
Message-ID:  <199608062231.QAA29192@rocky.mt.sri.com>

next in thread | raw e-mail | index | archive | help
OK, here's a resend of the pccardc patches.  If you have the first set
you can ignore these as I've made only minor-formatting changes (fixed a
mis-spelling, etc..) and no functional changes.  I'm resending these so
folks can grab them again if they missed them the first time.

Again, these should be applied against a FreeBSD-current system as of
today (8/6/96), and when I make changes against -current I'll provide a
new set of patches for folks to apply.



Nate
-----
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	cdif
#	beep.c
#	power.c
#	rdattr.c
#
echo x - cdif
sed 's/^X//' >cdif << 'END-of-cdif'
XIndex: Makefile
X===================================================================
XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/Makefile,v
Xretrieving revision 1.2
Xdiff -c -r1.2 Makefile
X*** Makefile	1996/04/09 23:31:51	1.2
X--- Makefile	1996/08/06 17:19:32
X***************
X*** 5,12 ****
X  #
X  PROG=	pccardc
X  NOMAN=	noman
X! SRCS=	pccardc.c dumpcis.c readcis.c printcis.c enabler.c pccardmem.c \
X! 	rdmap.c rdreg.c wrattr.c wrreg.c 
X  
X  CFLAGS+=	-I. -I${.CURDIR}/../pccardd
X  
X--- 5,12 ----
X  #
X  PROG=	pccardc
X  NOMAN=	noman
X! SRCS=	beep.c dumpcis.c enabler.c pccardc.c pccardmem.c power.c printcis.c \
X! 	rdattr.c rdmap.c rdreg.c readcis.c wrattr.c wrreg.c 
X  
X  CFLAGS+=	-I. -I${.CURDIR}/../pccardd
X  
XIndex: pccardc.c
X===================================================================
XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/pccardc.c,v
Xretrieving revision 1.3
Xdiff -c -r1.3 pccardc.c
X*** pccardc.c	1996/04/18 04:24:54	1.3
X--- pccardc.c	1996/08/06 17:27:38
X***************
X*** 31,40 ****
X--- 31,43 ----
X  typedef int (*main_t)(int, char **);
X  
X  #define DECL(foo) int foo(int, char**);
X+ DECL(beep_main);
X  DECL(dumpcis_main);
X  DECL(enabler_main);
X  DECL(help_main);
X  DECL(pccardmem_main);
X+ DECL(power_main);
X+ DECL(rdattr_main);
X  DECL(rdmap_main);
X  DECL(rdreg_main);
X  DECL(wrattr_main);
X***************
X*** 45,54 ****
X--- 48,60 ----
X  	main_t  func;
X  	char   *help;
X  } subcommands[] = {
X+ 	{ "beep", beep_main, "Beep type" },
X  	{ "dumpcis", dumpcis_main, "Prints CIS for all cards" },
X  	{ "enabler", enabler_main, "Device driver enabler" },
X  	{ "help", help_main, "Prints command summary" },
X  	{ "pccardmem", pccardmem_main, "Allocate memory for pccard driver" },
X+ 	{ "power", power_main, "Power on/off slots" },
X+ 	{ "rdattr", rdattr_main, "Read attribute memory" },
X  	{ "rdmap", rdmap_main, "Read pcic mappings" },
X  	{ "rdreg", rdreg_main, "Read pcic register" },
X  	{ "wrattr", wrattr_main, "Write byte to attribute memory" },
X***************
X*** 81,87 ****
X  	fprintf(stderr, "\t%s <subcommand> <arg> ...\n", argv[0]);
X  	fprintf(stderr, "Subcommands:\n");
X  	for (i = 0; subcommands[i].name; i++)
X! 		fprintf(stderr, "\t%s\n\t\t%s\n",
X  		    subcommands[i].name, subcommands[i].help);
X  	return 1;
X  }
X--- 87,93 ----
X  	fprintf(stderr, "\t%s <subcommand> <arg> ...\n", argv[0]);
X  	fprintf(stderr, "Subcommands:\n");
X  	for (i = 0; subcommands[i].name; i++)
X! 		fprintf(stderr, "\t%s\t: %s\n",
X  		    subcommands[i].name, subcommands[i].help);
X  	return 1;
X  }
XIndex: printcis.c
X===================================================================
XRCS file: /home/CVS/src/usr.sbin/pccard/pccardc/printcis.c,v
Xretrieving revision 1.5
Xdiff -c -r1.5 printcis.c
X*** printcis.c	1996/08/01 15:45:46	1.5
X--- printcis.c	1996/08/06 17:21:22
X***************
X*** 25,30 ****
X--- 25,36 ----
X   *
X   * $Id: printcis.c,v 1.5 1996/08/01 15:45:46 nate Exp $
X   */
X+ 
X+ /* 
X+  * Code cleanup, bug-fix and extension
X+  * by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>                   
X+  */
X+ 
X  #include <stdio.h>
X  #include <unistd.h>
X  #include <stdlib.h>
X***************
X*** 236,242 ****
X  		case 5:
X  		case 6:
X  		case 7:
X- 		case 8:
X  			printf("(custom)");
X  			break;
X  		}
X--- 242,247 ----
X***************
X*** 282,304 ****
X  		break;
X  	}
X  	if (feat & CIS_FEAT_TIMING) {
X! 		i = CIS_WAIT_SCALE(*p);
X! 		j = CIS_READY_SCALE(*p);
X! 		p++;
X! 		if (i != 3) {
X  			printf("\tWait scale ");
X! 			print_ext_speed(*p, i);
X! 			while (*p & 0x80)
X! 				p++;
X  			printf("\n");
X  		}
X  		if (j != 7) {
X  			printf("\tRDY/BSY scale ");
X! 			print_ext_speed(*p, j);
X! 			while (*p & 0x80)
X! 				p++;
X  			printf("\n");
X  		}
X  	}
X  	if (feat & CIS_FEAT_I_O) {
X  		if (CIS_IO_ADDR(*p))
X--- 287,311 ----
X  		break;
X  	}
X  	if (feat & CIS_FEAT_TIMING) {
X! 		i = *p++;
X! 		j = CIS_WAIT_SCALE(i);
X! 		if (j != 3) {
X  			printf("\tWait scale ");
X! 			print_ext_speed(*p++, j);
X  			printf("\n");
X  		}
X+ 		j = CIS_READY_SCALE(i);
X  		if (j != 7) {
X  			printf("\tRDY/BSY scale ");
X! 			print_ext_speed(*p++, j);
X  			printf("\n");
X  		}
X+ 		j = CIS_RESERVED_SCALE(i);
X+ 		if (j != 7) {
X+ 			printf("\tExternal scale ");
X+ 			print_ext_speed(*p++, j);
X+  			printf("\n");
X+ 		}
X  	}
X  	if (feat & CIS_FEAT_I_O) {
X  		if (CIS_IO_ADDR(*p))
X***************
X*** 320,327 ****
X  			break;
X  		}
X  		printf("\n");
X! 		if (*p & CIS_IO_RANGE) {
X! 			p++;
X  			c = *p++;
X  			for (i = 0; i <= CIS_IO_BLKS(c); i++) {
X  				printf("\t\tI/O address # %d: ", i + 1);
X--- 327,333 ----
X  			break;
X  		}
X  		printf("\n");
X! 		if (*p++ & CIS_IO_RANGE) {
X  			c = *p++;
X  			for (i = 0; i <= CIS_IO_BLKS(c); i++) {
X  				printf("\t\tI/O address # %d: ", i + 1);
X***************
X*** 380,386 ****
X  			printf("%c Shared", c);
X  		printf("\n");
X  		if (*p & CIS_IRQ_MASK) {
X! 			i = p[0] | (p[1] << 8);
X  			printf("\t\tIRQs: ");
X  			if (*p & 1)
X  				printf(" NMI");
X--- 386,392 ----
X  			printf("%c Shared", c);
X  		printf("\n");
X  		if (*p & CIS_IRQ_MASK) {
X! 			i = p[1] | (p[2] << 8);
X  			printf("\t\tIRQs: ");
X  			if (*p & 1)
X  				printf(" NMI");
X***************
X*** 589,595 ****
X  			len--;
X  			if (*p) {
X  				printf("\t\t");
X! 				print_ext_speed(*p, 0);
X  				while (*p & 0x80) {
X  					p++;
X  					len--;
X--- 595,601 ----
X  			len--;
X  			if (*p) {
X  				printf("\t\t");
X! 				print_ext_speed(*p++, 0);
X  				while (*p & 0x80) {
X  					p++;
X  					len--;
END-of-cdif
echo x - beep.c
sed 's/^X//' >beep.c << 'END-of-beep.c'
X/*
X * Copyright (c) 1995 Andrew McRae.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. The name of the author may not be used to endorse or promote products
X *    derived from this software without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X */
X
X/*
X * Code cleanup, bug-fix and extension
X * by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
X */
X
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <fcntl.h>
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <ctype.h>
X
X#include <pccard/card.h>
X
Xint
Xbeep_main(argc, argv)
X	int     argc;
X	char   *argv[];
X{
X	int     fd, newstat, valid = 1;
X	char    name[64], *p;
X
X	if (argc != 2)
X		valid = 0;
X	if (valid) {
X		for (p = argv[1]; *p; p++) {
X			if (!isdigit(*p)) {
X				valid = 0;
X				break;
X			}
X		}
X	}
X	if (!valid) {
X		fprintf(stderr, "usage: %s beep newstat\n", argv[0]);
X		exit(1);
X	}
X	sscanf(argv[1], "%d", &newstat);
X	sprintf(name, CARD_DEVICE, 0);
X	fd = open(name, O_RDWR);
X	if (fd < 0) {
X		perror(name);
X		exit(1);
X	}
X
X	if (ioctl(fd, PIOCSBEEP, &newstat) < 0) {
X		perror("beep");
X		exit(1);
X	}
X
X	return 0;
X}
END-of-beep.c
echo x - power.c
sed 's/^X//' >power.c << 'END-of-power.c'
X/*
X * Copyright (c) 1995 Andrew McRae.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. The name of the author may not be used to endorse or promote products
X *    derived from this software without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X */
X
X/*
X * Code cleanup, bug-fix and extension
X * by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
X */
X
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <fcntl.h>
X#include <sys/types.h>
X#include <sys/ioctl.h>
X#include <ctype.h>
X
X#include <pccard/card.h>
X
Xint
Xpower_main(argc, argv)
X	int     argc;
X	char   *argv[];
X{
X	int     fd, i, newstat, valid = 1;
X	char    name[64], *p;
X
X	if (argc != 3)
X		valid = 0;
X	for (i = 1; i <= 2; i++) {
X		if (valid) {
X			for (p = argv[i]; *p; p++) {
X				if (!isdigit(*p)) {
X					valid = 0;
X					break;
X				}
X			}
X		}
X	}
X	if (!valid) {
X		fprintf(stderr, "usage: %s power slot newstat\n", argv[0]);
X		exit(1);
X	}
X	sscanf(argv[2], "%d", &newstat);
X	sprintf(name, CARD_DEVICE, atoi(argv[1]));
X	fd = open(name, O_RDWR);
X	if (fd < 0) {
X		perror(name);
X		exit(1);
X	}
X
X	newstat = newstat ? 1 : 0;
X	if (ioctl(fd, PIOCSVIR, &newstat) < 0) {
X		perror("ioctl");
X		exit(1);
X	}
X
X	return 0;
X}
END-of-power.c
echo x - rdattr.c
sed 's/^X//' >rdattr.c << 'END-of-rdattr.c'
X/*
X * Copyright (c) 1995 Andrew McRae.  All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. The name of the author may not be used to endorse or promote products
X *    derived from this software without specific prior written permission.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X */
X
X/*
X * Code cleanup, bug-fix and extension
X * by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
X */
X
X#include <stdio.h>
X#include <stdlib.h>
X#include <unistd.h>
X#include <fcntl.h>
X#include <sys/types.h>
X#include <sys/ioctl.h>
X
X#include <pccard/card.h>
X
Xint
Xrdattr_main(argc, argv)
X	int     argc;
X	char   *argv[];
X{
X	int     i, reg, length;
X	char    name[64];
X	u_char *buf;
X	int     fd;
X	off_t   offs;
X
X	if (argc != 4) {
X		fprintf(stderr, "usage: %s rdattr slot offs length\n", argv[0]);
X		exit(1);
X	}
X	sprintf(name, CARD_DEVICE, atoi(argv[1]));
X	fd = open(name, 2);
X	if (fd < 0) {
X		perror(name);
X		exit(1);
X	}
X	reg = MDF_ATTR;
X	if (ioctl(fd, PIOCRWFLAG, &reg)) {
X		perror("ioctl (PIOCRWFLAG)");
X		exit(1);
X	}
X	if (sscanf(argv[2], "%x", &reg) != 1 ||
X	    sscanf(argv[3], "%x", &length) != 1) {
X		fprintf(stderr, "arg error\n");
X		exit(1);
X	}
X	offs = reg;
X	if ((buf = malloc(length)) == 0) {
X		perror(name);
X		exit(1);
X	}
X	lseek(fd, offs, SEEK_SET);
X	if (read(fd, buf, length) != length) {
X		perror(name);
X		exit(1);
X	}
X	for (i = 0; i < length; i++) {
X		if (i % 16 == 0) {
X			printf("%04x: ", (int) offs + i);
X		}
X		printf("%02x ", buf[i]);
X		if (i % 16 == 15) {
X			printf("\n");
X		}
X	}
X	if (i % 16 != 0) {
X		printf("\n");
X	}
X	return 0;
X}
END-of-rdattr.c
exit




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199608062231.QAA29192>