Index: pciconf.8 =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pciconf/pciconf.8,v retrieving revision 1.12 diff -u -r1.12 pciconf.8 --- pciconf.8 2000/12/07 10:52:59 1.12 +++ pciconf.8 2001/05/31 06:41:02 @@ -38,7 +38,7 @@ .Nm .Fl r Ar selector .Op Fl b | Fl h -.Ar reg +.Ar reg[:reg2] .Nm .Fl w Ar selector .Op Fl b | Fl h @@ -146,6 +146,9 @@ of device .Ar selector and prints out its value in hexadecimal. +The optional second +.Ar reg2 +specifies a range to read. The .Fl w option writes the Index: pciconf.c =================================================================== RCS file: /home/imp/FreeBSD/CVS/src/usr.sbin/pciconf/pciconf.c,v retrieving revision 1.14 diff -u -r1.14 pciconf.c --- pciconf.c 2000/12/09 00:07:46 1.14 +++ pciconf.c 2001/05/31 06:41:02 @@ -81,7 +81,7 @@ fprintf(stderr, "%s\n%s\n%s\n%s\n", "usage: pciconf -l [-v]", " pciconf -a sel", - " pciconf -r [-b | -h] sel addr", + " pciconf -r [-b | -h] sel addr[:addr]", " pciconf -w [-b | -h] sel addr [value]"); exit (1); } @@ -449,23 +449,48 @@ } static void -readit(const char *name, const char *reg, int width) +readone(int fd, struct pcisel *sel, long reg, int width) { - int fd; struct pci_io pi; - pi.pi_sel = getsel(name); - pi.pi_reg = strtoul(reg, (char **)0, 0); /* XXX error check */ + pi.pi_sel = *sel; + pi.pi_reg = reg; pi.pi_width = width; + if (ioctl(fd, PCIOCREAD, &pi) < 0) + err(1, "ioctl(PCIOCREAD)"); + + printf("0x%08x", pi.pi_data); +} + +static void +readit(const char *name, const char *reg, int width) +{ + long rstart; + long rend; + long r; + char *end; + int i; + int fd; + struct pcisel sel; + fd = open(_PATH_DEVPCI, O_RDWR, 0); if (fd < 0) err(1, "%s", _PATH_DEVPCI); - if (ioctl(fd, PCIOCREAD, &pi) < 0) - err(1, "ioctl(PCIOCREAD)"); - - printf("0x%08x\n", pi.pi_data); + rend = rstart = strtol(reg, &end, 0); + if (end && *end == ':') { + end++; + rend = strtol(end, (char **) 0, 0); + } + sel = getsel(name); + for (i = 1, r = rstart; r <= rend; i++, r += width) { + readone(fd, &sel, r, width); + putchar(i % 4 ? ' ' : '\n'); + } + if (i % 4 != 1) + putchar('\n'); + close(fd); } static void