summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pccard/pccardc/rdreg.c
blob: c278ae529c96c658b1bd7b56f4221c9246d9da6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <sys/types.h>
#include <sys/ioctl.h>

#include <pccard/card.h>
int
rdreg_main(argc, argv)
int	argc;
char	*argv[];
{
	if (argc != 2)
		{
		dumpslot(0);
		dumpslot(1);
		}
	else
		dumpslot(atoi(argv[1]));
}
dumpslot(sl)
int	sl;
{
char	name[64];
int	fd;
struct pcic_reg r;

	sprintf(name, "/dev/card%d", sl);
	fd = open(name, 2);
	if (fd < 0)
		{
		perror(name);
		return;
		}
	printf("Registers for slot %d\n", sl);
	for (r.reg = 0; r.reg < 0x40; r.reg++)
		{
		if (ioctl(fd, PIOCGREG, &r))
			{
			perror("ioctl");
			break;
			}
		if ((r.reg % 16)==0)
			printf("%02x:", r.reg);
		printf(" %02x", r.value);
		if ((r.reg % 16)==15)
			printf("\n");
		}
	close(fd);
}
OpenPOWER on IntegriCloud