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_pci.c
1 /* Host PCI User space tool
2  *  (c) Jack Lange, 2012
3  *  jacklange@cs.pitt.edu 
4  */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <fcntl.h> 
8 #include <sys/ioctl.h> 
9 #include <sys/stat.h> 
10 #include <sys/types.h> 
11 #include <unistd.h>
12 #include <string.h>
13
14
15 #include "v3_ctrl.h"
16
17
18 int main(int argc, char ** argv) {
19     int v3_fd = 0;
20     struct v3_hw_pci_dev dev_info;
21     unsigned int bus = 0;
22     unsigned int dev = 0;
23     unsigned int func = 0;
24     int ret = 0;
25
26     if (argc < 3) {
27         printf("Usage: ./v3_pci <name> <bus> <dev> <func>\n");
28         return -1;
29     }
30
31     bus = atoi(argv[2]);
32     dev = atoi(argv[3]);
33     func = atoi(argv[4]);
34
35     strncpy(dev_info.url, argv[1], 128);
36     dev_info.bus = bus;
37     dev_info.dev = dev;
38     dev_info.func = func;
39     
40
41     v3_fd = open("/dev/v3vee", O_RDONLY);
42
43     if (v3_fd == -1) {
44         printf("Error opening V3Vee device file\n");
45         return -1;
46     }
47
48
49     ret = ioctl(v3_fd, V3_ADD_PCI_HW_DEV, &dev_info);
50     
51
52     if (ret < 0) {
53         printf("Error registering PCI device\n");
54         return -1;
55     }
56
57     close(v3_fd);
58 }