Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first cut at an example version

  • Loading branch information...
commit c97726f0b906e40183e1daa7dae4f27d0ae324c4 0 parents
@gregkh authored
Showing with 31 additions and 0 deletions.
  1. +31 −0 readpci.c
31 readpci.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+
+
+#define PCI_DEV "0000:00:02.0"
+#define OFFSET 0xf4
+
+
+int main(int argc, const char *argv[])
+{
+ int file;
+ char *pci_device = "/sys/bus/pci/devices/" PCI_DEV;
+ void *map;
+ unsigned char *config;
+ unsigned char value;
+
+ file = open("/sys/bus/pci/devices/"PCI_DEV"/config", O_RDONLY);
+ if (file == -1) {
+ fprintf(stderr, "Could not open the pci device %s\n", pci_device);
+ return -1;
+ }
+
+ lseek(file, OFFSET, SEEK_SET);
+ read(file, &value, 0x01);
+ fprintf(stdout, "value at offset 0x%x is 0x%x\n", OFFSET, value);
+
+ close(file);
+
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.