vbox: Minor cleanup, don't process events we didn't get an IRQ for

This commit is contained in:
K. Lange 2021-10-31 22:25:18 +09:00
parent 739d3972f4
commit 710b336235

View File

@ -160,15 +160,18 @@ static int mouse_state;
#define PACKETS_IN_PIPE 1024 #define PACKETS_IN_PIPE 1024
#define DISCARD_POINT 32 #define DISCARD_POINT 32
static int vbox_irq_handler(struct regs *r) { #define VMM_Event_DisplayChange (1 << 2)
if (!vbox_vmmdev[2]) return 0; static void vbox_do_modeset(void) {
outportl(vbox_port, vbox_phys_disp);
vbox_irq_ack->events = vbox_vmmdev[2]; outportl(vbox_port, vbox_phys_disp);
outportl(vbox_port, vbox_phys_ack); if (lfb_resolution_x && vbox_disp->xres && (vbox_disp->xres != lfb_resolution_x || vbox_disp->yres != lfb_resolution_y)) {
irq_ack(vbox_irq); lfb_set_resolution(vbox_disp->xres, vbox_disp->yres);
}
}
#define VMM_Event_Mouse (1 << 9)
static void vbox_do_mouse(void) {
outportl(vbox_port, vbox_phys_mouse_get); outportl(vbox_port, vbox_phys_mouse_get);
unsigned int x, y; unsigned int x, y;
if (lfb_vid_memory && lfb_resolution_x && lfb_resolution_y && vbox_mg->x && vbox_mg->y) { if (lfb_vid_memory && lfb_resolution_x && lfb_resolution_y && vbox_mg->x && vbox_mg->y) {
@ -190,12 +193,19 @@ static int vbox_irq_handler(struct regs *r) {
read_fs(mouse_pipe, 0, sizeof(packet), (uint8_t *)&bitbucket); read_fs(mouse_pipe, 0, sizeof(packet), (uint8_t *)&bitbucket);
} }
write_fs(mouse_pipe, 0, sizeof(packet), (uint8_t *)&packet); write_fs(mouse_pipe, 0, sizeof(packet), (uint8_t *)&packet);
}
outportl(vbox_port, vbox_phys_disp); static int vbox_irq_handler(struct regs *r) {
if (lfb_resolution_x && vbox_disp->xres && (vbox_disp->xres != lfb_resolution_x || vbox_disp->yres != lfb_resolution_y)) { if (!vbox_vmmdev[2]) return 0;
lfb_set_resolution(vbox_disp->xres, vbox_disp->yres); uint32_t events;
}
events = vbox_irq_ack->events = vbox_vmmdev[2];
outportl(vbox_port, vbox_phys_ack);
irq_ack(vbox_irq);
if (events & VMM_Event_Mouse) vbox_do_mouse();
if (events & VMM_Event_DisplayChange) vbox_do_modeset();
return 1; return 1;
} }
@ -375,7 +385,7 @@ static int vbox_install(int argc, char * argv[]) {
vbox_pointershape->header.rc = 0; vbox_pointershape->header.rc = 0;
vbox_pointershape->header.reserved1 = 0; vbox_pointershape->header.reserved1 = 0;
vbox_pointershape->header.reserved2 = 0; vbox_pointershape->header.reserved2 = 0;
vbox_pointershape->flags = (1 << 0) | (1 << 1) | (1 << 2); vbox_pointershape->flags = (1 << 0) | (1 << 1) | (1 << 2); /* visible, alpha, shape */
vbox_pointershape->xHot = 26; vbox_pointershape->xHot = 26;
vbox_pointershape->yHot = 26; vbox_pointershape->yHot = 26;
vbox_pointershape->width = 48; vbox_pointershape->width = 48;
@ -453,6 +463,9 @@ static int vbox_install(int argc, char * argv[]) {
} }
} }
/* Try a mode set */
vbox_do_modeset();
vbox_vmmdev[3] = 0xFFFFFFFF; /* Enable all for now */ vbox_vmmdev[3] = 0xFFFFFFFF; /* Enable all for now */
return 0; return 0;