13 char * filepath = "/proc/v3vee/v3-mem";
15 unsigned long base_addr = 0;
16 unsigned long long num_pages = 0;
17 unsigned long amount_allocated = 0;
18 unsigned long long block_size = 0;
22 fp = fopen(filepath, "r");
24 fprintf(stderr, "Could not open %s\n", filepath);
29 base_addr = strtoul(line, NULL, 16);
30 base_addr = base_addr / (1024*1024);
33 num_pages = strtoull(line, NULL, 10);
34 amount_allocated = (num_pages*4096)/(1024*1024);
38 /* now get the block size */
39 fp = fopen("/sys/devices/system/memory/block_size_bytes", "r");
41 fprintf(stderr, "Cannot lookup bytes per block size\n");
46 block_size = strtoull(line, NULL, 16);
47 block_size = block_size / (1024*1024); //convert to MB
50 /* turn base_addr into the region number */
51 base_addr = base_addr / block_size;
53 for(i=0;i< (amount_allocated / block_size); i++) {
57 sprintf(path,"/sys/devices/system/memory/memory%d/state",
59 fp = fopen(path, "w+");
61 fprintf(stderr, "Could not open %s\n", path);
64 printf("Sending \"online\" to memory%d\n", base_addr);
65 fprintf(fp, "online");
70 v3_fd = open(v3_dev, O_RDONLY);
72 printf("Error opening V3Vee control device\n");
76 ioctl(v3_fd, V3_RESET_MEMORY, NULL);