Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/atkbdc.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#include "atkbdc.h" | #include "atkbdc.h" | ||||
#include "inout.h" | #include "inout.h" | ||||
#include "pci_emul.h" | #include "pci_emul.h" | ||||
#include "pci_irq.h" | #include "pci_irq.h" | ||||
#include "pci_lpc.h" | #include "pci_lpc.h" | ||||
#include "ps2kbd.h" | #include "ps2kbd.h" | ||||
#include "ps2mouse.h" | #include "ps2mouse.h" | ||||
#ifdef BHYVE_SNAPSHOT | |||||
#include "snapshot.h" | |||||
#endif | |||||
#define KBD_DATA_PORT 0x60 | #define KBD_DATA_PORT 0x60 | ||||
#define KBD_STS_CTL_PORT 0x64 | #define KBD_STS_CTL_PORT 0x64 | ||||
#define KBDC_RESET 0xfe | #define KBDC_RESET 0xfe | ||||
#define KBD_DEV_IRQ 1 | #define KBD_DEV_IRQ 1 | ||||
#define AUX_DEV_IRQ 12 | #define AUX_DEV_IRQ 12 | ||||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | struct atkbdc_softc { | ||||
uint32_t curcmd; /* current command for next byte */ | uint32_t curcmd; /* current command for next byte */ | ||||
uint32_t ctrlbyte; | uint32_t ctrlbyte; | ||||
struct kbd_dev kbd; | struct kbd_dev kbd; | ||||
struct aux_dev aux; | struct aux_dev aux; | ||||
}; | }; | ||||
#ifdef BHYVE_SNAPSHOT | |||||
static struct atkbdc_softc *atkbdc_sc = NULL; | |||||
#endif | |||||
static void | static void | ||||
atkbdc_assert_kbd_intr(struct atkbdc_softc *sc) | atkbdc_assert_kbd_intr(struct atkbdc_softc *sc) | ||||
{ | { | ||||
if ((sc->ram[0] & KBD_ENABLE_KBD_INT) != 0) { | if ((sc->ram[0] & KBD_ENABLE_KBD_INT) != 0) { | ||||
sc->kbd.irq_active = true; | sc->kbd.irq_active = true; | ||||
vm_isa_pulse_irq(sc->ctx, sc->kbd.irq, sc->kbd.irq); | vm_isa_pulse_irq(sc->ctx, sc->kbd.irq, sc->kbd.irq); | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 353 Lines • ▼ Show 20 Lines | atkbdc_event(struct atkbdc_softc *sc, int iskbd) | ||||
if (iskbd) | if (iskbd) | ||||
atkbdc_kbd_poll(sc); | atkbdc_kbd_poll(sc); | ||||
else | else | ||||
atkbdc_aux_poll(sc); | atkbdc_aux_poll(sc); | ||||
pthread_mutex_unlock(&sc->mtx); | pthread_mutex_unlock(&sc->mtx); | ||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | |||||
extern int atkbdc_snapshot(struct vm_snapshot_meta *, void *); | |||||
static struct snapshot_ops atkbdc_snapshot_ops = { | |||||
.snapshot_cb = atkbdc_snapshot, | |||||
}; | |||||
#endif | |||||
void | void | ||||
atkbdc_init(struct vmctx *ctx) | atkbdc_init(struct vmctx *ctx) | ||||
{ | { | ||||
struct inout_port iop; | struct inout_port iop; | ||||
struct atkbdc_softc *sc; | struct atkbdc_softc *sc; | ||||
int error; | int error; | ||||
sc = calloc(1, sizeof(struct atkbdc_softc)); | sc = calloc(1, sizeof(struct atkbdc_softc)); | ||||
Show All 28 Lines | atkbdc_init(struct vmctx *ctx) | ||||
pci_irq_reserve(AUX_DEV_IRQ); | pci_irq_reserve(AUX_DEV_IRQ); | ||||
sc->aux.irq = AUX_DEV_IRQ; | sc->aux.irq = AUX_DEV_IRQ; | ||||
sc->ps2kbd_sc = ps2kbd_init(sc); | sc->ps2kbd_sc = ps2kbd_init(sc); | ||||
sc->ps2mouse_sc = ps2mouse_init(sc); | sc->ps2mouse_sc = ps2mouse_init(sc); | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
assert(atkbdc_sc == NULL); | register_snapshot_dev("atkbdc", &atkbdc_snapshot_ops, sc); | ||||
atkbdc_sc = sc; | |||||
#endif | #endif | ||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | #ifdef BHYVE_SNAPSHOT | ||||
int | int | ||||
atkbdc_snapshot(struct vm_snapshot_meta *meta) | atkbdc_snapshot(struct vm_snapshot_meta *meta, void *cbdata) | ||||
{ | { | ||||
int ret; | int ret; | ||||
struct atkbdc_softc *sc = (struct atkbdc_softc *)cbdata; | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->status, meta, ret, done); | assert(sc != NULL); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->outport, meta, ret, done); | |||||
SNAPSHOT_BUF_OR_LEAVE(atkbdc_sc->ram, | |||||
sizeof(atkbdc_sc->ram), meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->curcmd, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->ctrlbyte, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.irq_active, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->status, meta, ret, done); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.irq, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->outport, meta, ret, done); | ||||
SNAPSHOT_BUF_OR_LEAVE(atkbdc_sc->kbd.buffer, | SNAPSHOT_BUF_OR_LEAVE(sc->ram, sizeof (sc->ram), meta, ret, done); | ||||
sizeof(atkbdc_sc->kbd.buffer), meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->curcmd, meta, ret, done); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.brd, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->ctrlbyte, meta, ret, done); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.bwr, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->kbd, meta, ret, done); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.bcnt, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->aux.irq_active, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->kbd.irq_active, meta, ret, done); | ||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->aux.irq, meta, ret, done); | SNAPSHOT_VAR_OR_LEAVE(sc->kbd.irq, meta, ret, done); | ||||
SNAPSHOT_BUF_OR_LEAVE(sc->kbd.buffer, | |||||
sizeof (sc->kbd.buffer), meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(sc->kbd.brd, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(sc->kbd.bwr, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(sc->kbd.bcnt, meta, ret, done); | |||||
ret = ps2kbd_snapshot(atkbdc_sc->ps2kbd_sc, meta); | SNAPSHOT_VAR_OR_LEAVE(sc->aux.irq_active, meta, ret, done); | ||||
if (ret != 0) | SNAPSHOT_VAR_OR_LEAVE(sc->aux.irq, meta, ret, done); | ||||
goto done; | |||||
ret = ps2mouse_snapshot(atkbdc_sc->ps2mouse_sc, meta); | ret = ps2kbd_snapshot(sc->ps2kbd_sc, meta); | ||||
if (ret == 0) | |||||
ret = ps2mouse_snapshot(sc->ps2mouse_sc, meta); | |||||
done: | done: | ||||
return (ret); | return (ret); | ||||
} | } | ||||
#endif | #endif | ||||
static void | static void | ||||
atkbdc_dsdt(void) | atkbdc_dsdt(void) | ||||
{ | { | ||||
Show All 31 Lines |