mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-25 16:13:17 +00:00
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
This commit is contained in:
parent
e010799732
commit
8d0421472a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=77533
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user