Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_usr / v3_inject_ecc_scrubber_mce.c
1 /*
2  * V3 ECC DRAM Scrubber MCE
3  * (c) Philip Soltero, 2010
4  */
5
6 #include <fcntl.h>
7 #include <stdint.h>
8 #include <stdio.h>
9
10 #define V3_VM_INJECT_SCRUBBER_MCE (10224+20)
11
12 int main(int argc, char * argv[]) {
13     char * end_ptr;
14     char * vm_device;
15     unsigned int cpu;
16     uint64_t address;
17     int v3_fd = 0;
18
19     if (argc <= 3) {
20         fprintf(stderr, "usage: v3_inject_ecc_scrubber_mce <vm_device> <cpu> <hex address>\n");
21         return -1;
22     }
23
24     vm_device = argv[1];
25
26     cpu = strtol(argv[2], &end_ptr, 10);
27     if (strcmp(end_ptr, "\0") != 0) {
28         fprintf(stderr, "The specified cpu is not a valid integer '%s', in particular '%s'.\n", argv[2], end_ptr);
29         return -1;
30     }
31
32     address = strtoll(argv[3], &end_ptr, 16);
33     if (strcmp(end_ptr, "\0") != 0) {
34         fprintf(stderr, "The specified address is not a valid integer '%s', in particular '%s'.\n", argv[3], end_ptr);
35         return -1;
36     }
37
38     v3_fd = open(vm_device, O_RDONLY);
39
40     if (v3_fd == -1) {
41         fprintf(stderr, "Error opening V3Vee control device.\n");
42         return -1;
43     }
44
45     ioctl(v3_fd, V3_VM_INJECT_SCRUBBER_MCE, address);
46
47     /* Close the file descriptor.  */
48     close(v3_fd);
49
50     return 0;
51 }