static uint32_t map_size = 0x08000000; static uint32_t map_base = 0x18000000; static uint32_t map_addr = 0x00000000; static uint64_t cycle_count = 0x1000000; static char *dev_mem = "/dev/mem"; int main(int argc, char **argv) { int fd; uint8_t *buf; if ((fd = open(dev_mem, O_RDWR | O_SYNC)) == -1) { printf("can't open /dev/mem .\n"); exit(EXIT_FAILURE); } buf = (uint8_t *) malloc(sizeof(uint8_t)); if (buf == 0) { printf("Can't be mapped. \n"); exit(EXIT_FAILURE); } else map_addr = (long unsigned) buf; uint8_t sum = 0; while (cycle_count-- > 0) sum += *buf++; printf("%u\n", sum); close(fd); exit(EXIT_SUCCESS); return 0; }
malloc()
buf
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)