summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pciconf/pciconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/pciconf/pciconf.c')
-rw-r--r--usr.sbin/pciconf/pciconf.c79
1 files changed, 67 insertions, 12 deletions
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
index 0ea232a..3639f00 100644
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -64,6 +64,7 @@ struct pci_vendor_info
TAILQ_HEAD(,pci_vendor_info) pci_vendors;
+static void dobar(const char *);
static void list_devs(int vendors);
static void list_verbose(struct pci_conf *p);
static char *guess_class(struct pci_conf *p);
@@ -90,17 +91,29 @@ int
main(int argc, char **argv)
{
int c;
- int listmode, readmode, writemode, attachedmode, verbose;
+ int listmode, readmode, writemode, attachedmode, barmode, verbose;
int byte, isshort;
- listmode = readmode = writemode = attachedmode = verbose = byte = isshort = 0;
+ barmode = listmode = readmode = writemode = attachedmode = verbose = byte = isshort = 0;
- while ((c = getopt(argc, argv, "alrwbhv")) != -1) {
+ while ((c = getopt(argc, argv, "aBbhlrwv")) != -1) {
switch(c) {
case 'a':
attachedmode = 1;
break;
+ case 'B':
+ barmode = 1;
+ break;
+
+ case 'b':
+ byte = 1;
+ break;
+
+ case 'h':
+ isshort = 1;
+ break;
+
case 'l':
listmode = 1;
break;
@@ -113,14 +126,6 @@ main(int argc, char **argv)
writemode = 1;
break;
- case 'b':
- byte = 1;
- break;
-
- case 'h':
- isshort = 1;
- break;
-
case 'v':
verbose = 1;
break;
@@ -133,7 +138,8 @@ main(int argc, char **argv)
if ((listmode && optind != argc)
|| (writemode && optind + 3 != argc)
|| (readmode && optind + 2 != argc)
- || (attachedmode && optind + 1 != argc))
+ || (attachedmode && optind + 1 != argc)
+ || (barmode && optind + 1 != argc)
usage();
if (listmode) {
@@ -147,6 +153,7 @@ main(int argc, char **argv)
} else if (writemode) {
writeit(argv[optind], argv[optind + 1], argv[optind + 2],
byte ? 1 : isshort ? 2 : 4);
+ } else if (barmode) {
} else {
usage();
}
@@ -472,6 +479,54 @@ readone(int fd, struct pcisel *sel, long reg, int width)
}
static void
+dobar(const char *name)
+{
+#define NBAR 6
+ long rstart = 0x10;
+ long rend = 0x24;
+ long r;
+ char *end;
+ int i;
+ int fd;
+ uint32_t bars[NBAR];
+ struct pcisel sel;
+ struct pci_io pi;
+
+
+ fd = open(_PATH_DEVPCI, O_RDWR, 0);
+ if (fd < 0)
+ err(1, "%s", _PATH_DEVPCI);
+
+ /*
+ * Read in the bars
+ */
+ sel = getsel(name);
+ for (i = 0, r = rstart; r <= rend; i++, r += 4) {
+ pi.pi_sel = sel;
+ pi.pi_reg = r;
+ pi.pi_width = 4;
+ if (ioctl(fd, PCIOCREAD, &pi) < 0)
+ err(1, "ioctl(PCIOCREAD)");
+ bars[i++] = pi.pi_data;
+ }
+
+ /*
+ * Print the bars
+ */
+ for (i = 0; i < NBAR; i++) {
+ if (bars[i] == 0)
+ next;
+ if (bars[i] & 1) {
+ /* I/O bar */
+ } else {
+ /* Memory bar */
+ }
+ }
+
+ close(fd);
+}
+
+static void
readit(const char *name, const char *reg, int width)
{
long rstart;
OpenPOWER on IntegriCloud