From 0c235e38893c9376c7f235f7ecaf83c091436187 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:20 +0100 Subject: ps2: move QOM type definitions from ps2.c to ps2.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the QOM type definitions into the ps2.h header file to allow the new QOM types to be used by other devices. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-6-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 58 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 35d9838..7f2c3f6 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -25,13 +25,69 @@ #ifndef HW_PS2_H #define HW_PS2_H +#include "hw/sysbus.h" + #define PS2_MOUSE_BUTTON_LEFT 0x01 #define PS2_MOUSE_BUTTON_RIGHT 0x02 #define PS2_MOUSE_BUTTON_MIDDLE 0x04 #define PS2_MOUSE_BUTTON_SIDE 0x08 #define PS2_MOUSE_BUTTON_EXTRA 0x10 -typedef struct PS2State PS2State; +/* + * PS/2 buffer size. Keep 256 bytes for compatibility with + * older QEMU versions. + */ +#define PS2_BUFFER_SIZE 256 + +typedef struct { + uint8_t data[PS2_BUFFER_SIZE]; + int rptr, wptr, cwptr, count; +} PS2Queue; + +struct PS2State { + SysBusDevice parent_obj; + + PS2Queue queue; + int32_t write_cmd; + void (*update_irq)(void *, int); + void *update_arg; +}; + +#define TYPE_PS2_DEVICE "ps2-device" +OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE) + +struct PS2KbdState { + PS2State parent_obj; + + int scan_enabled; + int translate; + int scancode_set; /* 1=XT, 2=AT, 3=PS/2 */ + int ledstate; + bool need_high_bit; + unsigned int modifiers; /* bitmask of MOD_* constants above */ +}; + +#define TYPE_PS2_KBD_DEVICE "ps2-kbd" +OBJECT_DECLARE_SIMPLE_TYPE(PS2KbdState, PS2_KBD_DEVICE) + +struct PS2MouseState { + PS2State parent_obj; + + uint8_t mouse_status; + uint8_t mouse_resolution; + uint8_t mouse_sample_rate; + uint8_t mouse_wrap; + uint8_t mouse_type; /* 0 = PS2, 3 = IMPS/2, 4 = IMEX */ + uint8_t mouse_detect_state; + int mouse_dx; /* current values, needed for 'poll' mode */ + int mouse_dy; + int mouse_dz; + int mouse_dw; + uint8_t mouse_buttons; +}; + +#define TYPE_PS2_MOUSE_DEVICE "ps2-mouse" +OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE) /* ps2.c */ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); -- cgit v1.1 From 54334e7387c9da6015cf8b79b58dbf06286f822f Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:21 +0100 Subject: ps2: improve function prototypes in ps2.c and ps2.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the latest changes it is now possible to improve some of the function prototypes in ps2.c and ps.h to use the appropriate PS2KbdState or PS2MouseState type instead of being a void opaque. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-7-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 7f2c3f6..1a3321d 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -92,8 +92,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE) /* ps2.c */ void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); -void ps2_write_mouse(void *, int val); -void ps2_write_keyboard(void *, int val); +void ps2_write_mouse(PS2MouseState *s, int val); +void ps2_write_keyboard(PS2KbdState *s, int val); uint32_t ps2_read_data(PS2State *s); void ps2_queue_noirq(PS2State *s, int b); void ps2_raise_irq(PS2State *s); @@ -101,8 +101,8 @@ void ps2_queue(PS2State *s, int b); void ps2_queue_2(PS2State *s, int b1, int b2); void ps2_queue_3(PS2State *s, int b1, int b2, int b3); void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4); -void ps2_keyboard_set_translation(void *opaque, int mode); -void ps2_mouse_fake_event(void *opaque); +void ps2_keyboard_set_translation(PS2KbdState *s, int mode); +void ps2_mouse_fake_event(PS2MouseState *s); int ps2_queue_empty(PS2State *s); #endif /* HW_PS2_H */ -- cgit v1.1 From 494145b28644dee66c1125c33ba55a02d5585db7 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:22 +0100 Subject: ps2: introduce PS2DeviceClass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is in preparation for allowing the new PS2_KBD_DEVICE and PS2_MOUSE_DEVICE QOM types to reference the parent PS2_DEVICE device reset() function. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-8-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 1a3321d..aef892b 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -33,6 +33,10 @@ #define PS2_MOUSE_BUTTON_SIDE 0x08 #define PS2_MOUSE_BUTTON_EXTRA 0x10 +struct PS2DeviceClass { + SysBusDeviceClass parent_class; +}; + /* * PS/2 buffer size. Keep 256 bytes for compatibility with * older QEMU versions. @@ -54,7 +58,7 @@ struct PS2State { }; #define TYPE_PS2_DEVICE "ps2-device" -OBJECT_DECLARE_SIMPLE_TYPE(PS2State, PS2_DEVICE) +OBJECT_DECLARE_TYPE(PS2State, PS2DeviceClass, PS2_DEVICE) struct PS2KbdState { PS2State parent_obj; -- cgit v1.1 From 108cb22e4837a36bc22959a612f8bb50471139f6 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:23 +0100 Subject: ps2: implement ps2_reset() for the PS2_DEVICE QOM type based upon ps2_common_reset() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The functionality of ps2_common_reset() can be moved into a new ps2_reset() function for the PS2_DEVICE QOM type. Update PS2DeviceClass to hold a reference to the parent reset function and update the PS2_KBD_DEVICE and PS2_MOUSE_DEVICE types to use device_class_set_parent_reset() accordingly. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-9-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index aef892b..4be27de 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -35,6 +35,8 @@ struct PS2DeviceClass { SysBusDeviceClass parent_class; + + DeviceReset parent_reset; }; /* -- cgit v1.1 From 77adda52ef7bcdb5edc9b4dc1678c83f31a02f46 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:34 +0100 Subject: pckbd: move KBDState from pckbd.c to i8042.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows the QOM types in pckbd.c to be used elsewhere by simply including i8042.h. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-20-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index e070f54..84b5aa7 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -11,6 +11,31 @@ #include "hw/isa/isa.h" #include "qom/object.h" +typedef struct KBDState { + uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ + uint8_t status; + uint8_t mode; + uint8_t outport; + uint32_t migration_flags; + uint32_t obsrc; + bool outport_present; + bool extended_state; + bool extended_state_loaded; + /* Bitmask of devices with data available. */ + uint8_t pending; + uint8_t obdata; + uint8_t cbdata; + uint8_t pending_tmp; + void *kbd; + void *mouse; + QEMUTimer *throttle_timer; + + qemu_irq irq_kbd; + qemu_irq irq_mouse; + qemu_irq a20_out; + hwaddr mask; +} KBDState; + #define TYPE_I8042 "i8042" OBJECT_DECLARE_SIMPLE_TYPE(ISAKBDState, I8042) -- cgit v1.1 From c9849a71b997a3b96757b19642b5b9a56c2ccb75 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:35 +0100 Subject: pckbd: move ISAKBDState from pckbd.c to i8042.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows the QOM types in pckbd.c to be used elsewhere by simply including i8042.h. Signed-off-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daudé Acked-by: Helge Deller Message-Id: <20220624134109.881989-21-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 84b5aa7..a246250 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -39,6 +39,16 @@ typedef struct KBDState { #define TYPE_I8042 "i8042" OBJECT_DECLARE_SIMPLE_TYPE(ISAKBDState, I8042) +struct ISAKBDState { + ISADevice parent_obj; + + KBDState kbd; + bool kbd_throttle; + MemoryRegion io[2]; + uint8_t kbd_irq; + uint8_t mouse_irq; +}; + #define I8042_A20_LINE "a20" -- cgit v1.1 From 150ee013ed3f2af7eec493cd68ae774a85d40a2b Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:36 +0100 Subject: pckbd: introduce new I8042_MMIO QOM type Currently i8042_mm_init() creates a new KBDState directly which is used by the MIPS magnum machine. Introduce a new I8042_MMIO QOM type that will soon be used to allow the MIPS magnum machine to be wired up using standard qdev GPIOs. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-22-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index a246250..b7df9ac 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -9,6 +9,7 @@ #define HW_INPUT_I8042_H #include "hw/isa/isa.h" +#include "hw/sysbus.h" #include "qom/object.h" typedef struct KBDState { @@ -49,6 +50,15 @@ struct ISAKBDState { uint8_t mouse_irq; }; +#define TYPE_I8042_MMIO "i8042-mmio" +OBJECT_DECLARE_SIMPLE_TYPE(MMIOKBDState, I8042_MMIO) + +struct MMIOKBDState { + SysBusDevice parent_obj; + + KBDState kbd; +}; + #define I8042_A20_LINE "a20" -- cgit v1.1 From 7b9fff290c20ee65c5deba0ad98f97529061d231 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:39 +0100 Subject: pckbd: add size qdev property to I8042_MMIO device This will soon be used to set the size of the register memory region using a qdev property. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-25-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index b7df9ac..ac4098b 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -57,6 +57,7 @@ struct MMIOKBDState { SysBusDevice parent_obj; KBDState kbd; + uint32_t size; }; #define I8042_A20_LINE "a20" -- cgit v1.1 From f4de68d1d45f1f104535a82f3e0dd3c393c6539e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:40 +0100 Subject: pckbd: implement i8042_mmio_realize() function Move the initialisation of the register memory region to the I8042_MMIO device realize function and expose it using sysbus_init_mmio(). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-26-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index ac4098b..59d695a 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -58,6 +58,7 @@ struct MMIOKBDState { KBDState kbd; uint32_t size; + MemoryRegion region; }; #define I8042_A20_LINE "a20" -- cgit v1.1 From 903dd0e49b5140df55d6f77f97c741f99346c23e Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:42 +0100 Subject: pckbd: alter i8042_mm_init() to return a I8042_MMIO device This exposes the I8042_MMIO device to the caller to allow the register memory region to be mapped outside of i8042_mm_init(). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-28-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 59d695a..d05cd33 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -64,9 +64,9 @@ struct MMIOKBDState { #define I8042_A20_LINE "a20" -void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, - MemoryRegion *region, ram_addr_t size, - hwaddr mask); +MMIOKBDState *i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, + MemoryRegion *region, ram_addr_t size, + hwaddr mask); void i8042_isa_mouse_fake_event(ISAKBDState *isa); void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out); -- cgit v1.1 From 01d924dce88f6d43a0be36c0e626f058e68a9ea4 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:43 +0100 Subject: pckbd: move mapping of I8042_MMIO registers to MIPS magnum machine Now that the register memory region is exposed as a SysBus memory region, move the mapping of the I8042_MMIO registers from i8042_mm_init() to the MIPS magnum machine (which is its only user). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-29-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index d05cd33..9d1f8af 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -65,8 +65,7 @@ struct MMIOKBDState { MMIOKBDState *i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, - MemoryRegion *region, ram_addr_t size, - hwaddr mask); + ram_addr_t size, hwaddr mask); void i8042_isa_mouse_fake_event(ISAKBDState *isa); void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out); -- cgit v1.1 From 52b28f76dd5d1a44c0d3632a98987e5c771cf251 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:46 +0100 Subject: ps2: make ps2_raise_irq() function static This function is no longer used outside of ps2.c and so can be declared static. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-32-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 4be27de..410ec66 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -102,7 +102,6 @@ void ps2_write_mouse(PS2MouseState *s, int val); void ps2_write_keyboard(PS2KbdState *s, int val); uint32_t ps2_read_data(PS2State *s); void ps2_queue_noirq(PS2State *s, int b); -void ps2_raise_irq(PS2State *s); void ps2_queue(PS2State *s, int b); void ps2_queue_2(PS2State *s, int b1, int b2); void ps2_queue_3(PS2State *s, int b1, int b2, int b3); -- cgit v1.1 From 6beb79e11a48b7876dfd63fcfb51d1a603936928 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:49 +0100 Subject: ps2: add gpio for output IRQ and optionally use it in ps2_raise_irq() and ps2_lower_irq() Define the gpio for the PS2 output IRQ in ps2_init() and add logic to optionally use it in ps2_raise_irq() and ps2_lower_irq() if the gpio is connected. If the gpio is not connected then call the legacy update_irq() function as before. This allows the incremental conversion of devices from the legacy update_irq() function to use gpios instead. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-35-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 410ec66..5422aee 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -50,11 +50,15 @@ typedef struct { int rptr, wptr, cwptr, count; } PS2Queue; +/* Output IRQ */ +#define PS2_DEVICE_IRQ 0 + struct PS2State { SysBusDevice parent_obj; PS2Queue queue; int32_t write_cmd; + qemu_irq irq; void (*update_irq)(void *, int); void *update_arg; }; -- cgit v1.1 From c2b1747973d1ff334787d9701cf8214e24fe0798 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:50 +0100 Subject: pckbd: replace irq_kbd and irq_mouse with qemu_irq array in KBDState This allows both IRQs to be declared as a single qdev gpio array. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-36-mark.cave-ayland@ilande.co.uk> --- include/hw/input/i8042.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 9d1f8af..4ba2664 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -12,6 +12,9 @@ #include "hw/sysbus.h" #include "qom/object.h" +#define I8042_KBD_IRQ 0 +#define I8042_MOUSE_IRQ 1 + typedef struct KBDState { uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ uint8_t status; @@ -31,8 +34,7 @@ typedef struct KBDState { void *mouse; QEMUTimer *throttle_timer; - qemu_irq irq_kbd; - qemu_irq irq_mouse; + qemu_irq irqs[2]; qemu_irq a20_out; hwaddr mask; } KBDState; -- cgit v1.1 From 07c68b501056fd45e52db0067fdb3ea0ea571961 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:54 +0100 Subject: lasips2: move lasips2 QOM types from lasips2.c to lasips2.h This allows the QOM types in lasips2.c to be used elsewhere by simply including lasips2.h. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-40-mark.cave-ayland@ilande.co.uk> --- include/hw/input/lasips2.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'include') diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h index 0cd7b59..ddcea74 100644 --- a/include/hw/input/lasips2.h +++ b/include/hw/input/lasips2.h @@ -8,8 +8,30 @@ #define HW_INPUT_LASIPS2_H #include "exec/hwaddr.h" +#include "hw/sysbus.h" + +struct LASIPS2State; +typedef struct LASIPS2Port { + struct LASIPS2State *parent; + MemoryRegion reg; + void *dev; + uint8_t id; + uint8_t control; + uint8_t buf; + bool loopback_rbne; + bool irq; +} LASIPS2Port; + +struct LASIPS2State { + SysBusDevice parent_obj; + + LASIPS2Port kbd; + LASIPS2Port mouse; + qemu_irq irq; +}; #define TYPE_LASIPS2 "lasips2" +OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2) void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq); -- cgit v1.1 From 5cbf35d20f71f87ade944b3835db389c260f2c59 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:55 +0100 Subject: lasips2: rename lasips2_init() to lasips2_initfn() and update it to return the LASIPS2 device When QOMifying a device it is typical to use _init() as the suffix for an instance_init function, however this name is already in use by the legacy LASIPS2 wrapper function. Eventually the wrapper function will be removed, but for now rename it to lasips2_initfn() to avoid a naming collision. At the same time update lasips2_initfn() return the LASIPS2 device so that it can later be accessed using qdev APIs by the HPPA machine. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-41-mark.cave-ayland@ilande.co.uk> --- include/hw/input/lasips2.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h index ddcea74..5a35c22 100644 --- a/include/hw/input/lasips2.h +++ b/include/hw/input/lasips2.h @@ -33,6 +33,7 @@ struct LASIPS2State { #define TYPE_LASIPS2 "lasips2" OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2) -void lasips2_init(MemoryRegion *address_space, hwaddr base, qemu_irq irq); +LASIPS2State *lasips2_initfn(MemoryRegion *address_space, hwaddr base, + qemu_irq irq); #endif /* HW_INPUT_LASIPS2_H */ -- cgit v1.1 From 6479296fe561cc3aacc3ee99adf02ca7d2120713 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:57 +0100 Subject: lasips2: move mapping of LASIPS2 registers to HPPA machine Now that the register memory regions are exposed as SysBus memory regions, move the mapping of the LASIPS2 registers from lasips2_initfn() to the HPPA machine (which is its only user). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-43-mark.cave-ayland@ilande.co.uk> --- include/hw/input/lasips2.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h index 5a35c22..b972307 100644 --- a/include/hw/input/lasips2.h +++ b/include/hw/input/lasips2.h @@ -33,7 +33,6 @@ struct LASIPS2State { #define TYPE_LASIPS2 "lasips2" OBJECT_DECLARE_SIMPLE_TYPE(LASIPS2State, LASIPS2) -LASIPS2State *lasips2_initfn(MemoryRegion *address_space, hwaddr base, - qemu_irq irq); +LASIPS2State *lasips2_initfn(hwaddr base, qemu_irq irq); #endif /* HW_INPUT_LASIPS2_H */ -- cgit v1.1 From 42119fdb2e851b2a0a6cc09197c33ad943dcb6e9 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:40:59 +0100 Subject: lasips2: add base property This is in preparation for handling vmstate_register() within the device. Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Message-Id: <20220624134109.881989-45-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell --- include/hw/input/lasips2.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h index b972307..7e4437b 100644 --- a/include/hw/input/lasips2.h +++ b/include/hw/input/lasips2.h @@ -25,6 +25,7 @@ typedef struct LASIPS2Port { struct LASIPS2State { SysBusDevice parent_obj; + hwaddr base; LASIPS2Port kbd; LASIPS2Port mouse; qemu_irq irq; -- cgit v1.1 From 501f062e91ca97dfbeaa5148be59d6a27448c9d8 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:41:03 +0100 Subject: lasips2: add QEMU interface comment This describes the LASI PS2 device interface implemented within QEMU. Signed-off-by: Mark Cave-Ayland Message-Id: <20220624134109.881989-49-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell --- include/hw/input/lasips2.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/hw/input/lasips2.h b/include/hw/input/lasips2.h index 7e4437b..03f0c9e 100644 --- a/include/hw/input/lasips2.h +++ b/include/hw/input/lasips2.h @@ -4,6 +4,20 @@ * Copyright (c) 2019 Sven Schnelle * */ + +/* + * QEMU interface: + * + sysbus MMIO region 0: MemoryRegion defining the LASI PS2 keyboard + * registers + * + sysbus MMIO region 1: MemoryRegion defining the LASI PS2 mouse + * registers + * + sysbus IRQ 0: LASI PS2 output irq + * + Named GPIO input "ps2-kbd-input-irq": set to 1 if the downstream PS2 + * keyboard device has asserted its irq + * + Named GPIO input "ps2-mouse-input-irq": set to 1 if the downstream PS2 + * mouse device has asserted its irq + */ + #ifndef HW_INPUT_LASIPS2_H #define HW_INPUT_LASIPS2_H -- cgit v1.1 From 57de3c1d35605f3f29c332585d9c4b49503d6639 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:41:05 +0100 Subject: pckbd: add QEMU interface comment for I8042_MMIO device This describes the I8042_MMIO device interface implemented within QEMU. Signed-off-by: Mark Cave-Ayland Message-Id: <20220624134109.881989-51-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell --- include/hw/input/i8042.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index 4ba2664..d4747b6 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -52,6 +52,17 @@ struct ISAKBDState { uint8_t mouse_irq; }; +/* + * QEMU interface: + * + sysbus MMIO region 0: MemoryRegion defining the command/status/data + * registers (access determined by mask property and access type) + * + Named GPIO input "ps2-kbd-input-irq": set to 1 if the downstream PS2 + * keyboard device has asserted its irq + * + Named GPIO input "ps2-mouse-input-irq": set to 1 if the downstream PS2 + * mouse device has asserted its irq + * + Unnamed GPIO output 0-1: i8042 output irqs for keyboard (0) or mouse (1) + */ + #define TYPE_I8042_MMIO "i8042-mmio" OBJECT_DECLARE_SIMPLE_TYPE(MMIOKBDState, I8042_MMIO) -- cgit v1.1 From 38f426b8af844c8243b1cd5e6d883c176c527c3b Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:41:08 +0100 Subject: pckbd: add QEMU interface comment for I8042 device This describes the I8042 device interface implemented within QEMU. Signed-off-by: Mark Cave-Ayland Message-Id: <20220624134109.881989-54-mark.cave-ayland@ilande.co.uk> Reviewed-by: Peter Maydell --- include/hw/input/i8042.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/hw/input/i8042.h b/include/hw/input/i8042.h index d4747b6..ca933d8 100644 --- a/include/hw/input/i8042.h +++ b/include/hw/input/i8042.h @@ -39,6 +39,16 @@ typedef struct KBDState { hwaddr mask; } KBDState; +/* + * QEMU interface: + * + Named GPIO input "ps2-kbd-input-irq": set to 1 if the downstream PS2 + * keyboard device has asserted its irq + * + Named GPIO input "ps2-mouse-input-irq": set to 1 if the downstream PS2 + * mouse device has asserted its irq + * + Named GPIO output "a20": A20 line for x86 PCs + * + Unnamed GPIO output 0-1: i8042 output irqs for keyboard (0) or mouse (1) + */ + #define TYPE_I8042 "i8042" OBJECT_DECLARE_SIMPLE_TYPE(ISAKBDState, I8042) -- cgit v1.1 From 7227de94adce761d9add78ad087a98697b2d82e9 Mon Sep 17 00:00:00 2001 From: Mark Cave-Ayland Date: Fri, 24 Jun 2022 14:41:09 +0100 Subject: ps2: remove update_irq() function and update_arg parameter Now that all the PS2 devices have been converted to use GPIOs the update_irq() callback function and the update_arg parameter can be removed. This allows these arguments to be completely removed from ps2_kbd_init() and ps2_mouse_init(), along with the transitional logic that was added to ps2_raise_irq() and ps2_lower_irq(). Signed-off-by: Mark Cave-Ayland Acked-by: Helge Deller Reviewed-by: Peter Maydell Message-Id: <20220624134109.881989-55-mark.cave-ayland@ilande.co.uk> --- include/hw/input/ps2.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/hw/input/ps2.h b/include/hw/input/ps2.h index 5422aee..a78619d 100644 --- a/include/hw/input/ps2.h +++ b/include/hw/input/ps2.h @@ -59,8 +59,6 @@ struct PS2State { PS2Queue queue; int32_t write_cmd; qemu_irq irq; - void (*update_irq)(void *, int); - void *update_arg; }; #define TYPE_PS2_DEVICE "ps2-device" @@ -100,8 +98,8 @@ struct PS2MouseState { OBJECT_DECLARE_SIMPLE_TYPE(PS2MouseState, PS2_MOUSE_DEVICE) /* ps2.c */ -void *ps2_kbd_init(void (*update_irq)(void *, int), void *update_arg); -void *ps2_mouse_init(void (*update_irq)(void *, int), void *update_arg); +void *ps2_kbd_init(void); +void *ps2_mouse_init(void); void ps2_write_mouse(PS2MouseState *s, int val); void ps2_write_keyboard(PS2KbdState *s, int val); uint32_t ps2_read_data(PS2State *s); -- cgit v1.1