#include #include #include #include #include int main(int argc, char *argv[]) { void *mapped_base; int i, memfd, offset = 0, size = 1; memfd = open("/dev/mem", O_RDWR | O_SYNC); mapped_base = mmap(0, 0x08000000, PROT_READ, MAP_SHARED, memfd, 0x00800000); if (mapped_base == MAP_FAILED) { perror("mmap failure"); return 1; } if (argc > 1) offset = strtol(argv[1], NULL, 0) - 0x00800000; if (argc > 2) size = strtol(argv[2], NULL, 0); #if 0 /* hack unlock ahci regs */ *((int *)(mapped_base + 0x180fc)) = 0; #endif for (i = 0; i < size; i++) printf("%08x: %08x\n", 0x00800000 + offset + i * 4, *((int *)(mapped_base + offset + i * 4))); #if 0 /* hack re-lock ahci regs */ *((int *)(mapped_base + 0x180fc)) = 7; #endif munmap(mapped_base, 0x08000000); close(memfd); return 0; }