/* ** From: David Mosberger ** To: ia64_rd@ldl.fc.hp.com ** Subject: [ia64 R&D] linux utility to tweak Pluto prefetch ** Date: Fri, 10 May 2002 15:32:18 -0700 ** ** If you're tired of having to reboot just to tweak the Pluto prefetch ** setting, you might like the attached utility. Use, e.g., like this: ** ** # mmio fed09420 0000087b58a418a3 ** ** where fed09420 is the address to poke and 0000087b58a418a3 is the ** new value to write. The utility isn't limited to poking Pluto ** registers: it will poke *any* kernel address, so use with care! ** ** --david */ #include #include #include #include #include int main(int argc, char **argv) { int fd = open("/dev/mem", O_RDWR | O_SYNC); unsigned long i, addr, val, offset, old, page_size = getpagesize(); volatile unsigned long *mem; if (fd < 0) perror("open"); if (argc < 3) exit(-2); addr = strtol(argv[1], NULL, 16); val = strtol(argv[2], NULL, 16); offset = addr & ~(page_size - 1); i = (addr - offset) / sizeof(mem[0]); mem = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset); if (mem == MAP_FAILED) { perror("memmap"); exit(-1); } old = mem[i]; printf("%016lx -> %016lx\n", old, val); mem[i] = val; return 0; }