summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard/pccardc
diff options
context:
space:
mode:
authorhosokawa <hosokawa@FreeBSD.org>1998-02-26 14:36:01 +0000
committerhosokawa <hosokawa@FreeBSD.org>1998-02-26 14:36:01 +0000
commit728f78d263764ac2b84d0c01789f722741d68a3b (patch)
tree6acda6f8b7bfb0c35e7424001188fe3ddc2eda0e /usr.sbin/pccard/pccardc
parente472abe28a651d29867a80295762abf79076477f (diff)
downloadFreeBSD-src-728f78d263764ac2b84d0c01789f722741d68a3b.zip
FreeBSD-src-728f78d263764ac2b84d0c01789f722741d68a3b.tar.gz
added "rdattr" (read attribute memory) function.
Diffstat (limited to 'usr.sbin/pccard/pccardc')
-rw-r--r--usr.sbin/pccard/pccardc/Makefile4
-rw-r--r--usr.sbin/pccard/pccardc/pccardc.c4
-rw-r--r--usr.sbin/pccard/pccardc/rdattr.c95
3 files changed, 100 insertions, 3 deletions
diff --git a/usr.sbin/pccard/pccardc/Makefile b/usr.sbin/pccard/pccardc/Makefile
index 28683df..095b1cf 100644
--- a/usr.sbin/pccard/pccardc/Makefile
+++ b/usr.sbin/pccard/pccardc/Makefile
@@ -1,12 +1,12 @@
#
# pccardc Makefile
#
-# $Id$
+# $Id: Makefile,v 1.6 1997/02/22 16:08:35 peter Exp $
#
PROG= pccardc
NOMAN= noman
SRCS= dumpcis.c enabler.c pccardc.c pccardmem.c printcis.c \
- rdmap.c rdreg.c readcis.c wrattr.c wrreg.c
+ rdattr.c rdmap.c rdreg.c readcis.c wrattr.c wrreg.c
CFLAGS+= -I${.CURDIR}/../pccardd
diff --git a/usr.sbin/pccard/pccardc/pccardc.c b/usr.sbin/pccard/pccardc/pccardc.c
index e18d66c..c925ea4 100644
--- a/usr.sbin/pccard/pccardc/pccardc.c
+++ b/usr.sbin/pccard/pccardc/pccardc.c
@@ -26,7 +26,7 @@
#ifndef lint
static const char rcsid[] =
- "$Id$";
+ "$Id: pccardc.c,v 1.6 1997/10/06 11:35:54 charnier Exp $";
#endif /* not lint */
#include <err.h>
@@ -40,6 +40,7 @@ DECL(dumpcis_main);
DECL(enabler_main);
DECL(help_main);
DECL(pccardmem_main);
+DECL(rdattr_main);
DECL(rdmap_main);
DECL(rdreg_main);
DECL(wrattr_main);
@@ -54,6 +55,7 @@ struct {
{ "enabler", enabler_main, "Device driver enabler" },
{ "help", help_main, "Prints command summary" },
{ "pccardmem", pccardmem_main, "Allocate memory for pccard driver" },
+ { "rdattr", rdattr_main, "Read attribute memory" },
{ "rdmap", rdmap_main, "Read pcic mappings" },
{ "rdreg", rdreg_main, "Read pcic register" },
{ "wrattr", wrattr_main, "Write byte to attribute memory" },
diff --git a/usr.sbin/pccard/pccardc/rdattr.c b/usr.sbin/pccard/pccardc/rdattr.c
new file mode 100644
index 0000000..9347d97
--- /dev/null
+++ b/usr.sbin/pccard/pccardc/rdattr.c
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1995 Andrew McRae. 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.
+ */
+
+/*
+ * Code cleanup, bug-fix and extension
+ * by Tatsumi Hosokawa <hosokawa@mt.cs.keio.ac.jp>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <pccard/card.h>
+
+int
+rdattr_main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int i, reg, length;
+ char name[64];
+ u_char *buf;
+ int fd;
+ off_t offs;
+
+ if (argc != 4) {
+ fprintf(stderr, "usage: %s rdattr slot offs length\n", argv[0]);
+ exit(1);
+ }
+ sprintf(name, CARD_DEVICE, atoi(argv[1]));
+ fd = open(name, 2);
+ if (fd < 0) {
+ perror(name);
+ exit(1);
+ }
+ reg = MDF_ATTR;
+ if (ioctl(fd, PIOCRWFLAG, &reg)) {
+ perror("ioctl (PIOCRWFLAG)");
+ exit(1);
+ }
+ if (sscanf(argv[2], "%x", &reg) != 1 ||
+ sscanf(argv[3], "%x", &length) != 1) {
+ fprintf(stderr, "arg error\n");
+ exit(1);
+ }
+ offs = reg;
+ if ((buf = malloc(length)) == 0) {
+ perror(name);
+ exit(1);
+ }
+ lseek(fd, offs, SEEK_SET);
+ if (read(fd, buf, length) != length) {
+ perror(name);
+ exit(1);
+ }
+ for (i = 0; i < length; i++) {
+ if (i % 16 == 0) {
+ printf("%04x: ", (int) offs + i);
+ }
+ printf("%02x ", buf[i]);
+ if (i % 16 == 15) {
+ printf("\n");
+ }
+ }
+ if (i % 16 != 0) {
+ printf("\n");
+ }
+ return 0;
+}
OpenPOWER on IntegriCloud