2018-03-08 23:39:24 +01:00
|
|
|
/*
|
|
|
|
* QEMU PS/2 Controller
|
|
|
|
*
|
|
|
|
* Copyright (c) 2003 Fabrice Bellard
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*/
|
|
|
|
#ifndef HW_INPUT_I8042_H
|
|
|
|
#define HW_INPUT_I8042_H
|
|
|
|
|
|
|
|
#include "hw/isa/isa.h"
|
2022-06-24 15:40:36 +02:00
|
|
|
#include "hw/sysbus.h"
|
2020-09-03 22:43:22 +02:00
|
|
|
#include "qom/object.h"
|
2018-03-08 23:39:24 +01:00
|
|
|
|
2022-06-24 15:40:50 +02:00
|
|
|
#define I8042_KBD_IRQ 0
|
|
|
|
#define I8042_MOUSE_IRQ 1
|
|
|
|
|
2022-06-24 15:40:34 +02:00
|
|
|
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;
|
|
|
|
|
2022-06-24 15:40:50 +02:00
|
|
|
qemu_irq irqs[2];
|
2022-06-24 15:40:34 +02:00
|
|
|
qemu_irq a20_out;
|
|
|
|
hwaddr mask;
|
|
|
|
} KBDState;
|
|
|
|
|
2018-03-08 23:39:24 +01:00
|
|
|
#define TYPE_I8042 "i8042"
|
2020-09-16 20:25:19 +02:00
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(ISAKBDState, I8042)
|
2018-03-08 23:39:24 +01:00
|
|
|
|
2022-06-24 15:40:35 +02:00
|
|
|
struct ISAKBDState {
|
|
|
|
ISADevice parent_obj;
|
|
|
|
|
|
|
|
KBDState kbd;
|
|
|
|
bool kbd_throttle;
|
|
|
|
MemoryRegion io[2];
|
|
|
|
uint8_t kbd_irq;
|
|
|
|
uint8_t mouse_irq;
|
|
|
|
};
|
|
|
|
|
2022-06-24 15:40:36 +02:00
|
|
|
#define TYPE_I8042_MMIO "i8042-mmio"
|
|
|
|
OBJECT_DECLARE_SIMPLE_TYPE(MMIOKBDState, I8042_MMIO)
|
|
|
|
|
|
|
|
struct MMIOKBDState {
|
|
|
|
SysBusDevice parent_obj;
|
|
|
|
|
|
|
|
KBDState kbd;
|
2022-06-24 15:40:39 +02:00
|
|
|
uint32_t size;
|
2022-06-24 15:40:40 +02:00
|
|
|
MemoryRegion region;
|
2022-06-24 15:40:36 +02:00
|
|
|
};
|
|
|
|
|
2018-03-08 23:39:24 +01:00
|
|
|
#define I8042_A20_LINE "a20"
|
|
|
|
|
2019-10-17 17:06:05 +02:00
|
|
|
|
2022-06-24 15:40:42 +02:00
|
|
|
MMIOKBDState *i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,
|
2022-06-24 15:40:43 +02:00
|
|
|
ram_addr_t size, hwaddr mask);
|
2019-10-17 17:06:05 +02:00
|
|
|
void i8042_isa_mouse_fake_event(ISAKBDState *isa);
|
2018-03-08 23:39:24 +01:00
|
|
|
void i8042_setup_a20_line(ISADevice *dev, qemu_irq a20_out);
|
|
|
|
|
2022-03-04 16:40:30 +01:00
|
|
|
static inline bool i8042_present(void)
|
|
|
|
{
|
|
|
|
bool amb = false;
|
|
|
|
return object_resolve_path_type("", TYPE_I8042, &amb) || amb;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ACPI v2, Table 5-10 - Fixed ACPI Description Table Boot Architecture
|
|
|
|
* Flags, bit offset 1 - 8042.
|
|
|
|
*/
|
|
|
|
static inline uint16_t iapc_boot_arch_8042(void)
|
|
|
|
{
|
|
|
|
return i8042_present() ? 0x1 << 1 : 0x0 ;
|
|
|
|
}
|
|
|
|
|
2018-03-08 23:39:24 +01:00
|
|
|
#endif /* HW_INPUT_I8042_H */
|