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.


HVM capability enhancement: asynchronous upcalls to ROS userspace
[palacios.git] / linux_usr / v3_fb.c
1 #include "v3_fb.h"
2
3
4 // This is the data structure that is passed back and forth with user-land
5 // ioctl
6 #define V3_VM_FB_INPUT 256+1
7 struct v3_fb_input {
8     enum { V3_FB_KEY, V3_FB_MOUSE, V3_FB_BOTH}   data_type;
9     uint8_t scan_code;
10     uint8_t sx;      // sign bit for deltax
11     uint8_t dx;      // deltax
12     uint8_t sy;      // sign bit for deltay
13     uint8_t dy;      // deltay
14     uint8_t buttons; // button state
15 };
16
17 #define V3_VM_FB_QUERY 256+2
18 #define __user 
19 struct v3_fb_query_response {
20     enum e { V3_FB_DATA_ALL, V3_FB_DATA_BOX, V3_FB_UPDATE, V3_FB_SPEC }  request_type;
21     struct v3_frame_buffer_spec spec;    // in: desired spec; out: actual spec
22     uint32_t x, y, w, h;                 // region to copy (0s = all) in/out args
23     int updated;                         // whether this region has been updated or not
24     void __user *data;                   // user space pointer to copy data to
25 };
26
27 int v3_send_key(int fd, uint8_t scan_code) 
28 {
29     struct v3_fb_input e;
30
31     e.data_type=V3_FB_KEY;
32     e.scan_code=scan_code;
33
34     if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) { 
35         perror("v3_send_key");
36         return -1;
37     }
38     
39     return 0;
40 }
41
42
43 int v3_send_mouse(int fd, uint8_t sx, uint8_t dx, uint8_t sy, uint8_t dy, uint8_t buttons)
44 {
45     struct v3_fb_input e;
46
47     e.data_type=V3_FB_MOUSE;
48     e.sx=sx;
49     e.dx=dx;
50     e.sy=sy;
51     e.dy=dy;
52     e.buttons=buttons;
53
54     if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) { 
55         perror("v3_send_mouse");
56         return -1;
57     }
58
59     return 0;
60 }
61
62 int v3_get_fb_spec(int fd, struct v3_frame_buffer_spec *spec)
63 {
64     struct v3_fb_query_response q;
65
66     q.request_type=V3_FB_SPEC;
67     
68     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) { 
69         perror("v3_get_fb_spec");
70         return -1;
71
72     }
73
74     *spec = q.spec;
75     
76     return 0;
77 }
78
79 int v3_get_fb_data(int fd, struct v3_frame_buffer_spec *spec, void *data)
80 {
81     struct v3_fb_query_response q;
82
83     q.request_type=V3_FB_DATA_ALL;
84     q.spec=*spec;
85     q.data=data;
86
87     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) { 
88         perror("v3_get_fb_data");
89         return -1;
90     }
91
92     *spec = q.spec;
93     
94     return 0;
95     
96 }
97
98 int v3_have_update(int fd)
99 {
100     struct v3_fb_query_response q;
101     int updated;
102
103     q.request_type=V3_FB_UPDATE;
104     q.x=0;
105     q.y=0;
106     q.w=(uint32_t) -1;
107     q.h=(uint32_t) -1;
108
109     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) {
110         perror("v3_get_fb_data");
111         return -1;
112     }
113
114     return q.updated;
115
116 }