8 char * filepath = "/proc/v3vee/v3-mem";
10 unsigned long base_addr = 0;
11 unsigned long long num_pages = 0;
12 unsigned long amount_allocated = 0;
13 unsigned long long block_size = 0;
16 fp = fopen(filepath, "r");
18 fprintf(stderr, "Could not open %s\n", filepath);
23 base_addr = strtoul(line, NULL, 16);
24 base_addr = base_addr / (1024*1024);
27 num_pages = strtoull(line, NULL, 10);
28 amount_allocated = (num_pages*4096)/(1024*1024);
32 /* now get the block size */
33 fp = fopen("/sys/devices/system/memory/block_size_bytes", "r");
35 fprintf(stderr, "Cannot lookup bytes per block size\n");
40 block_size = strtoull(line, NULL, 16);
41 block_size = block_size / (1024*1024); //convert to MB
44 /* turn base_addr into the region number */
45 base_addr = base_addr / block_size;
47 for(i=0;i< (amount_allocated / block_size); i++) {
51 sprintf(path,"/sys/devices/system/memory/memory%d/state",
53 fp = fopen(path, "w+");
55 fprintf(stderr, "Could not open %s\n", path);
58 printf("Sending \"online\" to memory%d\n", base_addr);
59 fprintf(fp, "online");