/* * pcitest.c - read the contents of specific pci device registers * the device is memory mapped at address 0xa006000 * */ #include #include #include #include #include #include #include int main() { void *map; int fd; int i = 0; char buf[16]; ulong base; ulong length; // 1090 14e44320 34 a0006000 00000000 00000000 00000000 00000000 00000000 00000000 // 00002000 00000000 00000000 00000000 00000000 00000000 00000000 // base = 0xa0006000; length = 0x2000; // base = 0x0; fd = open("/dev/mem", O_RDWR|O_SYNC); map = mmap(NULL, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, base); if (map == MAP_FAILED) { printf("map failed: %s\n", strerror(errno)); exit(1); } for (i = 0x0; i <= length; i = i + 0x10) { memcpy(&buf, map + i, 0x10); printf("0x%04x: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", base + i, buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11], buf[12], buf[13], buf[14], buf[15]); } }