Add option to disable PS/2 mouse.
RFC PATCH 1/2 Add option to disable PS/2 mouse.
Hello
I tried to patch qemu to allow disabling the PS/2 mouse.
This patch works for me, when I disable the mouse Windows no longer detects it.
I am not sure this is entirely correct. Specifically there is KBD_MODE_DISABLE_MOUSE bit which can probably still be disabled and KBD_MODE_MOUSE_INT is enabled.
Thanks
Michal
Signed-off-by Michal Suchanek <[email protected]>
--- hw/isa.h | 1 + hw/pckbd.c | 36 +++++++++++++++++++++--------------- qemu-options.hx | 9 +++++++++ vl.c | 4 ++++ 4 files changed, 35 insertions(+), 15 deletions(-)
hw/isa.h +1 -0
@@ -31,6 +31,7 @@ ISADevice *isa_create(const char *name);ISADevice *isa_create_simple (const char *name);extern target_phys_addr_t isa_mem_base; +extern int isa_psaux;void isa_mmio_init (target_phys_addr_t base,target_phys_addr_t size,int be);
hw/pckbd.c +21 -15
@@ -169,7 +169,7 @@ static void kbd_update_irq(KBDState *s) } }qemu_set_irq (s->irq_kbd, irq_kbd_level); -qemu_set_irq (s->irq_mouse, irq_mouse_level); +if (s->mouse)qemu_set_irq (s->irq_mouse, irq_mouse_level); }static void kbd_update_kbd_irq (void *opaque,int level)
@@ -205,10 +205,11 @@ static uint32_t kbd_read_status(void *opaque, uint32_t addr)static void kbd_queue (KBDState *s,int b,int aux) { -if (aux) -ps2_queue (s->mouse, b); -else +if (aux) { +if (s->mouse)ps2_queue (s->mouse, b); + }else {ps2_queue (s->kbd, b); + } }static void ioport92_write (void *opaque,uint32_t addr,uint32_t val)
@@ -323,12 +324,13 @@ static void kbd_write_command(void *opaque, uint32_t addr, uint32_t val)static uint32_t kbd_read_data (void *opaque,uint32_t addr) {KBDState *s = opaque; -uint32_t val; +uint32_t val =0 ; -if (s->pending ==KBD_PENDING_AUX ) - val =ps2_read_data (s->mouse); -else +if (s->pending ==KBD_PENDING_AUX ) { +if (s->mouse) val =ps2_read_data (s->mouse); + }else { val =ps2_read_data (s->kbd); + }DPRINTF ("kbd: read data=0x%02x\n" , val);return val;
@@ -354,13 +356,13 @@ static void kbd_write_data(void *opaque, uint32_t addr, uint32_t val)kbd_queue (s, val,0 );break ;case KBD_CCMD_WRITE_AUX_OBUF : -kbd_queue (s, val,1 ); +if (s->mouse)kbd_queue (s, val,1 );break ;case KBD_CCMD_WRITE_OUTPORT :ioport92_write (s,0 , val);break ;case KBD_CCMD_WRITE_MOUSE : -ps2_write_mouse (s->mouse, val); +if (s->mouse)ps2_write_mouse (s->mouse, val);break ;default :break ;
@@ -430,9 +432,10 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, {KBDState *s =qemu_mallocz (sizeof (KBDState));int s_io_memory; +int mouse_enabled = isa_psaux; s->irq_kbd = kbd_irq; - s->irq_mouse = mouse_irq; +if (mouse_enabled) s->irq_mouse = mouse_irq; s->mask = mask;vmstate_register (NULL ,0 , &vmstate_kbd, s);
@@ -440,7 +443,8 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,cpu_register_physical_memory (base, size, s_io_memory); s->kbd =ps2_kbd_init (kbd_update_kbd_irq, s); - s->mouse =ps2_mouse_init (kbd_update_aux_irq, s); + s->mouse =NULL ; +if (mouse_enabled) s->mouse =ps2_mouse_init (kbd_update_aux_irq, s);qemu_register_reset (kbd_reset, s); }
@@ -454,7 +458,7 @@ void i8042_isa_mouse_fake_event(void *opaque)ISADevice *dev = opaque;KBDState *s = &(DO_UPCAST (ISAKBDState, dev, dev)->kbd); -ps2_mouse_fake_event (s->mouse); +if (s->mouse)ps2_mouse_fake_event (s->mouse); }void i8042_setup_a20_line (ISADevice *dev,qemu_irq *a20_out)
@@ -478,9 +482,10 @@ static const VMStateDescription vmstate_kbd_isa = {static int i8042_initfn (ISADevice *dev) {KBDState *s = &(DO_UPCAST (ISAKBDState, dev, dev)->kbd); +int mouse_enabled = isa_psaux;isa_init_irq (dev, &s->irq_kbd,1 ); -isa_init_irq (dev, &s->irq_mouse,12 ); +if (mouse_enabled)isa_init_irq (dev, &s->irq_mouse,12 );register_ioport_read (0x60 ,1 ,1 , kbd_read_data, s);register_ioport_write (0x60 ,1 ,1 , kbd_write_data, s);
@@ -490,7 +495,8 @@ static int i8042_initfn(ISADevice *dev)register_ioport_write (0x92 ,1 ,1 , ioport92_write, s); s->kbd =ps2_kbd_init (kbd_update_kbd_irq, s); - s->mouse =ps2_mouse_init (kbd_update_aux_irq, s); + s->mouse =NULL ; +if (mouse_enabled) s->mouse =ps2_mouse_init (kbd_update_aux_irq, s);qemu_register_reset (kbd_reset, s);return 0 ; }
qemu-options.hx +9 -0
@@ -1746,6 +1746,15 @@ Three button serial mouse. Configure the guest to use Microsoft protocol. @end table ETEXI +DEF("no-psaux", 0, QEMU_OPTION_nopsaux, \ + "-no-psaux disable PS/2 mouse\n", + QEMU_ARCH_ALL) +STEXI +@item -no-psaux +Disables the PS/2 mouse port on machines which have it hanging from the i8042. + +ETEXI + DEF("parallel", HAS_ARG, QEMU_OPTION_parallel, \ "-parallel dev redirect the parallel port to char device 'dev'\n", QEMU_ARCH_ALL)
vl.c +4 -0
@@ -227,6 +227,7 @@ int ctrl_grab = 0;unsigned int nb_prom_envs =0 ;const char *prom_envs[MAX_PROM_ENVS ];int boot_menu; +int isa_psaux =1 ;int nb_numa_nodes;uint64_t node_mem[MAX_NODES ];
@@ -2052,6 +2053,9 @@ int main(int argc, char **argv, char **envp)case QEMU_OPTION_portrait: graphic_rotate =1 ;break ; +case QEMU_OPTION_nopsaux: + isa_psaux =0 ; +break ;case QEMU_OPTION_kernel: kernel_filename = optarg;break ;
Signature · 1 line
1.7.1