diff options
author | imp <imp@FreeBSD.org> | 2001-05-31 18:31:43 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2001-05-31 18:31:43 +0000 |
commit | ce2cd03ba2aa741fa04795da6d399002974da513 (patch) | |
tree | c0b7a357617d371cd2b161f28297433e89dfad93 /usr.sbin | |
parent | bfdc5a0e560812f7c844a2bddadd28ecba9898c2 (diff) | |
download | FreeBSD-src-ce2cd03ba2aa741fa04795da6d399002974da513.zip FreeBSD-src-ce2cd03ba2aa741fa04795da6d399002974da513.tar.gz |
Support a range of registers to read.
eg pciconf -r pci0:10:0 0:0xff
and keep the output of the old singleton the same.
Reviewed by: audit@, dd
MFC after: 10 days
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/pciconf/pciconf.8 | 5 | ||||
-rw-r--r-- | usr.sbin/pciconf/pciconf.c | 43 |
2 files changed, 38 insertions, 10 deletions
diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8 index 7e8e893..8f51c6e 100644 --- a/usr.sbin/pciconf/pciconf.8 +++ b/usr.sbin/pciconf/pciconf.8 @@ -38,7 +38,7 @@ .Nm .Fl r Ar selector .Op Fl b | Fl h -.Ar reg +.Ar reg Ns Op : Ns Ar reg2 .Nm .Fl w Ar selector .Op Fl b | Fl h @@ -146,6 +146,9 @@ option reads a configuration space register at byte offset 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 diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 27e5cd3..d42759c 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -81,7 +81,7 @@ usage() 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 @@ getsel(const char *str) } 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 |