6 #define PARAGRAPH_SYSFS_RESOURCE "/sys/devices/pci0000:00/0000:00:02.0/resource0"
7 #define PARAGRAPH_LEN (1024*1024*4)
9 int main(int argc, char *argv[])
15 printf("Usage: write_paragraph_sysfs sysfsresource start\nyou probably want to use %s\n",PARAGRAPH_SYSFS_RESOURCE);
20 start = atoi(argv[2]);
22 int fd = open(res, O_RDWR | O_SYNC);
25 perror("Cannot open sysfs file");
26 printf("sysfs file = %s\n", res);
30 unsigned char *mem = mmap(NULL, PARAGRAPH_LEN, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
32 if (mem == MAP_FAILED) {
33 perror("Can't map memory");
36 printf("Mapped to 0x%p (%d bytes)\n", mem, PARAGRAPH_LEN);
40 for (i = 0; i < PARAGRAPH_LEN; i++) {
42 if (i<16) { printf("0x%p = %d\n", mem+i, *(mem+i)); }
44 printf("Wrote %d bytes\n", PARAGRAPH_LEN);