mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-20 15:43:16 +00:00
added "rdattr" (read attribute memory) function.
This commit is contained in:
parent
c383a33f06
commit
88aa4bcb73
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=33852
@ -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
|
||||
|
||||
|
@ -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" },
|
||||
|
95
usr.sbin/pccard/pccardc/rdattr.c
Normal file
95
usr.sbin/pccard/pccardc/rdattr.c
Normal file
@ -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, ®)) {
|
||||
perror("ioctl (PIOCRWFLAG)");
|
||||
exit(1);
|
||||
}
|
||||
if (sscanf(argv[2], "%x", ®) != 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user