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.


Revised mouse-related host events, graphics console, and userland support; mouse...
Peter Dinda [Fri, 12 Apr 2013 23:03:17 +0000 (18:03 -0500)]
linux_module/iface-graphics-console.c
linux_module/iface-graphics-console.h
linux_usr/v3_fb.c
linux_usr/v3_fb.h
palacios/include/palacios/vmm_host_events.h
palacios/src/devices/keyboard.c

index d47819c..748c8b3 100644 (file)
@@ -269,16 +269,20 @@ static int palacios_graphics_console_key(struct v3_guest * guest,
 
 static int palacios_graphics_console_mouse(struct v3_guest * guest, 
                                           struct palacios_graphics_console *cons, 
-                                          uint8_t x, uint8_t y, uint8_t buttons)
+                                          uint8_t sx, uint8_t dx,
+                                          uint8_t sy, uint8_t dy,
+                                          uint8_t buttons)
 {
-  /*
+
     struct v3_mouse_event e;
-    e.data[0]=x;
-    e.data[1]=y;
-    e.data[2]=buttons;   // These three are completely wrong, of course - ignoring mouse for now
-  */
-    // mouse delivery is broken, so don't do it.
-    // v3_deliver_mouse_event(guest->v3_ctx,&e);
+
+    e.sx=sx;
+    e.dx=dx;
+    e.sy=sy;
+    e.dy=dy;
+    e.buttons=buttons;
+
+    v3_deliver_mouse_event(guest->v3_ctx,&e);
 
     return 0;
 }
@@ -432,8 +436,7 @@ static int fb_input(struct v3_guest * guest,
     }
 
     if ((inp.data_type == V3_FB_MOUSE) || (inp.data_type == V3_FB_BOTH)) { 
-       rc |= palacios_graphics_console_mouse(guest, cons, inp.mouse_data[0],
-                                             inp.mouse_data[1], inp.mouse_data[2]);
+       rc |= palacios_graphics_console_mouse(guest, cons, inp.sx, inp.dx, inp.sy, inp.dy, inp.buttons);
        //DEBUG("palacios: mouse delivered to palacios\n");
     }
 
index aef5330..040aa36 100644 (file)
@@ -23,8 +23,10 @@ struct v3_fb_query_response {
 // This is what userland sends down for input events
 struct v3_fb_input {
     enum { V3_FB_KEY, V3_FB_MOUSE, V3_FB_BOTH}             data_type;
-    uint8_t                              scan_code;
-    uint8_t                              mouse_data[3];
+    uint8_t                              scan_code;     // kbd scan code
+    uint8_t                              sx, dx;        // mouse horizontal sign and dx
+    uint8_t                              sy, dy;        // mouse vertical sign and dy
+    uint8_t                              buttons;       // mouse buttons
 };
 
 
index 69240ec..5c95e16 100644 (file)
@@ -6,8 +6,12 @@
 #define V3_VM_FB_INPUT 256+1
 struct v3_fb_input {
     enum { V3_FB_KEY, V3_FB_MOUSE, V3_FB_BOTH}   data_type;
-    uint8_t                              scan_code;
-    uint8_t                              mouse_data[3];
+    uint8_t scan_code;
+    uint8_t sx;      // sign bit for deltax
+    uint8_t dx;      // deltax
+    uint8_t sy;      // sign bit for deltay
+    uint8_t dy;      // deltay
+    uint8_t buttons; // button state
 };
 
 #define V3_VM_FB_QUERY 256+2
@@ -36,14 +40,16 @@ int v3_send_key(int fd, uint8_t scan_code)
 }
 
 
-int v3_send_mouse(int fd, uint8_t mx, uint8_t my, uint8_t button)
+int v3_send_mouse(int fd, uint8_t sx, uint8_t dx, uint8_t sy, uint8_t dy, uint8_t buttons)
 {
     struct v3_fb_input e;
 
     e.data_type=V3_FB_MOUSE;
-    e.mouse_data[0]=mx;
-    e.mouse_data[1]=my;
-    e.mouse_data[2]=button;
+    e.sx=sx;
+    e.dx=dx;
+    e.sy=sy;
+    e.dy=dy;
+    e.buttons=buttons;
 
     if (ioctl(fd,V3_VM_FB_INPUT,&e)<0) { 
        perror("v3_send_mouse");
index 4c93c57..7920ff7 100644 (file)
@@ -26,7 +26,10 @@ EXTERNC int v3_get_fb_data(int fd, struct v3_frame_buffer_spec *spec, void *data
 
 
 EXTERNC int v3_send_key(int fd, uint8_t scan_code);
-EXTERNC int v3_send_mouse(int fd, uint8_t mx, uint8_t my, uint8_t button);
+EXTERNC int v3_send_mouse(int fd, 
+                         uint8_t sx, uint8_t dx, // dx sign and dx
+                         uint8_t sy, uint8_t dy, // dy sign and dy
+                         uint8_t buttons);       // button state
 
 
 
index 21d4c01..d2fb211 100644 (file)
 
 
 struct v3_keyboard_event {
+    // A keyboard event is a PS/2 scancode and status reg
     unsigned char status;
     unsigned char scan_code;
 };
 
 struct v3_mouse_event {
-    unsigned char data[3];
+    // A mouse event is a PS/2 mouse packet
+    unsigned char sx;      // sign bit for deltax
+    unsigned char dx;      // deltax
+    unsigned char sy;      // sign bit for deltay
+    unsigned char dy;      // deltay
+    unsigned char buttons; // button state
 };
 
 struct v3_timer_event {
index 3a8e58a..10f3732 100644 (file)
@@ -434,16 +434,35 @@ static int mouse_event_handler(struct v3_vm_info * vm,
 
     switch (kbd->mouse_state) { 
        case STREAM:
-
+           // packet is 3 bytes of form
+           // YO | XO | YS | XS | 1 | MIDDLE | RIGHT | LEFT
+           // DX
+           // YY
            if (kbd->cmd.mouse_disable == 0) {
-               push_to_output_queue(kbd, evt->data[0], DATA, MOUSE);
-               push_to_output_queue(kbd, evt->data[1], DATA, MOUSE);
-               push_to_output_queue(kbd, evt->data[2], DATA, MOUSE);
+               uint8_t h;
+               // YO=0
+               // XO=0
+               // bit 3 set
+               h=0x08; 
+               // YS bit
+               h |= (!!(evt->sy)) << 5;
+               // XS bit
+               h |= (!!(evt->sx)) << 4;
+               // buttons
+               h |= (evt->buttons) & 0x7;
+               // header byte
+               push_to_output_queue(kbd, h, DATA, MOUSE);
+               // dx
+               push_to_output_queue(kbd, evt->dx, DATA, MOUSE);
+               // dy
+               push_to_output_queue(kbd, evt->dy, DATA, MOUSE);
+           } else {
+               PrintDebug(vm,VCORE_NONE, "Ignoring mouse event because mouse is disabled\n");
            }
            break;
        default:
-           PrintError(vm, VCORE_NONE, "Invalid mouse state\n");
-           ret = -1;
+           PrintDebug(vm, VCORE_NONE, "Ignoring mouse event due to mouse not being in stream mode\n");
+           ret = 0;
            break;
     }