aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-04-16 17:20:48 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-04-16 17:20:48 +0000
commitb92bb99b80166f76fae32e166b3deaa22fec8687 (patch)
tree9bbdc62bf2297ac90ab2e025722346132950de6e /hw
parent3a6078548d3abf01ea24df75eae794d078194481 (diff)
downloadqemu-b92bb99b80166f76fae32e166b3deaa22fec8687.zip
qemu-b92bb99b80166f76fae32e166b3deaa22fec8687.tar.gz
qemu-b92bb99b80166f76fae32e166b3deaa22fec8687.tar.bz2
Memory-mapped interface for PS/2 controller, by Herve Poussineau.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2685 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw')
-rw-r--r--hw/pckbd.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/hw/pckbd.c b/hw/pckbd.c
index a6f9d09..52b65d7 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -124,6 +124,7 @@ typedef struct KBDState {
qemu_irq irq_kbd;
qemu_irq irq_mouse;
+ target_phys_addr_t base;
} KBDState;
KBDState kbd_state;
@@ -140,7 +141,7 @@ static void kbd_update_irq(KBDState *s)
s->status &= ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF);
if (s->pending) {
s->status |= KBD_STAT_OBF;
- /* kdb data takes priority over aux data. */
+ /* kbd data takes priority over aux data. */
if (s->pending == KBD_PENDING_AUX) {
s->status |= KBD_STAT_MOUSE_OBF;
if (s->mode & KBD_MODE_MOUSE_INT)
@@ -362,7 +363,7 @@ void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
s->irq_kbd = kbd_irq;
s->irq_mouse = mouse_irq;
-
+
kbd_reset(s);
register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
register_ioport_read(io_base, 1, 1, kbd_read_data, s);
@@ -377,3 +378,59 @@ void i8042_init(qemu_irq kbd_irq, qemu_irq mouse_irq, uint32_t io_base)
#endif
qemu_register_reset(kbd_reset, s);
}
+
+/* Memory mapped interface */
+uint32_t kbd_mm_readb (void *opaque, target_phys_addr_t addr)
+{
+ KBDState *s = opaque;
+
+ if (addr == s->base)
+ return kbd_read_data(s, 0);
+ else
+ return kbd_read_status(s, 0);
+}
+
+void kbd_mm_writeb (void *opaque,
+ target_phys_addr_t addr, uint32_t value)
+{
+ KBDState *s = opaque;
+
+ if (addr == s->base)
+ kbd_write_data(s, 0, value);
+ else
+ kbd_write_command(s, 0, value);
+}
+
+static CPUReadMemoryFunc *kbd_mm_read[] = {
+ &kbd_mm_readb,
+ &kbd_mm_readb,
+ &kbd_mm_readb,
+};
+
+static CPUWriteMemoryFunc *kbd_mm_write[] = {
+ &kbd_mm_writeb,
+ &kbd_mm_writeb,
+ &kbd_mm_writeb,
+};
+
+void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, target_ulong base, int it_shift)
+{
+ KBDState *s = &kbd_state;
+ int s_io_memory;
+
+ s->irq_kbd = kbd_irq;
+ s->irq_mouse = mouse_irq;
+ s->base = base;
+
+ kbd_reset(s);
+ register_savevm("pckbd", 0, 3, kbd_save, kbd_load, s);
+ s_io_memory = cpu_register_io_memory(0, kbd_mm_read, kbd_mm_write, s);
+ cpu_register_physical_memory(base & ~(TARGET_PAGE_SIZE - 1), TARGET_PAGE_SIZE, s_io_memory);
+
+ s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
+ s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
+#ifdef TARGET_I386
+ vmmouse_init(s->mouse);
+#endif
+ qemu_register_reset(kbd_reset, s);
+}