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.


VNC server interface to graphics console source code
[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                              mouse_data[3];
11 };
12
13 #define V3_VM_FB_QUERY 256+2
14 #define __user 
15 struct v3_fb_query_response {
16     enum e { V3_FB_DATA_ALL, V3_FB_DATA_BOX, V3_FB_UPDATE, V3_FB_SPEC }  request_type;
17     struct v3_frame_buffer_spec spec;    // in: desired spec; out: actual spec
18     uint32_t x, y, w, h;                 // region to copy (0s = all) in/out args
19     int updated;                         // whether this region has been updated or not
20     void __user *data;                   // user space pointer to copy data to
21 };
22
23 int v3_send_key(int fd, uint8_t scan_code) 
24 {
25     struct v3_fb_input e;
26
27     e.data_type=V3_FB_KEY;
28     e.scan_code=scan_code;
29
30     if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) { 
31         perror("v3_send_key");
32         return -1;
33     }
34     
35     return 0;
36 }
37
38
39 int v3_send_mouse(int fd, uint8_t mx, uint8_t my, uint8_t button)
40 {
41     struct v3_fb_input e;
42
43     e.data_type=V3_FB_MOUSE;
44     e.mouse_data[0]=mx;
45     e.mouse_data[1]=my;
46     e.mouse_data[2]=button;
47
48     if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) { 
49         perror("v3_send_mouse");
50         return -1;
51     }
52
53     return 0;
54 }
55
56 int v3_get_fb_spec(int fd, struct v3_frame_buffer_spec *spec)
57 {
58     struct v3_fb_query_response q;
59
60     q.request_type=V3_FB_SPEC;
61     
62     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) { 
63         perror("v3_get_fb_spec");
64         return -1;
65
66     }
67
68     *spec = q.spec;
69     
70     return 0;
71 }
72
73 int v3_get_fb_data(int fd, struct v3_frame_buffer_spec *spec, void *data)
74 {
75     struct v3_fb_query_response q;
76
77     q.request_type=V3_FB_DATA_ALL;
78     q.spec=*spec;
79     q.data=data;
80
81     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) { 
82         perror("v3_get_fb_data");
83         return -1;
84     }
85
86     *spec = q.spec;
87     
88     return 0;
89     
90 }
91
92 int v3_have_update(int fd)
93 {
94     struct v3_fb_query_response q;
95     int updated;
96
97     q.request_type=V3_FB_UPDATE;
98     q.x=0;
99     q.y=0;
100     q.w=(uint32_t) -1;
101     q.h=(uint32_t) -1;
102
103     if (ioctl(fd,V3_VM_FB_QUERY,&q)<0) {
104         perror("v3_get_fb_data");
105         return -1;
106     }
107
108     return q.updated;
109
110 }