Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/bhyve/atkbdc.c
Show All 27 Lines | |||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include <sys/types.h> | #include <sys/types.h> | ||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||
#include <machine/vmm_snapshot.h> | |||||
#include <vmmapi.h> | #include <vmmapi.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <stdbool.h> | #include <stdbool.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
▲ Show 20 Lines • Show All 88 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 395 Lines • ▼ Show 20 Lines | atkbdc_init(struct vmctx *ctx) | ||||
pci_irq_reserve(KBD_DEV_IRQ); | pci_irq_reserve(KBD_DEV_IRQ); | ||||
sc->kbd.irq = KBD_DEV_IRQ; | sc->kbd.irq = KBD_DEV_IRQ; | ||||
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 | |||||
assert(atkbdc_sc == NULL); | |||||
atkbdc_sc = sc; | |||||
#endif | |||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | |||||
int | |||||
atkbdc_snapshot(struct vm_snapshot_meta *meta) | |||||
{ | |||||
int ret; | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->status, meta, ret, done); | |||||
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(atkbdc_sc->kbd.irq, meta, ret, done); | |||||
SNAPSHOT_BUF_OR_LEAVE(atkbdc_sc->kbd.buffer, | |||||
sizeof(atkbdc_sc->kbd.buffer), meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.brd, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(atkbdc_sc->kbd.bwr, 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(atkbdc_sc->aux.irq, meta, ret, done); | |||||
ret = ps2kbd_snapshot(atkbdc_sc->ps2kbd_sc, meta); | |||||
if (ret != 0) | |||||
goto done; | |||||
ret = ps2mouse_snapshot(atkbdc_sc->ps2mouse_sc, meta); | |||||
done: | |||||
return (ret); | |||||
} | |||||
#endif | |||||
static void | static void | ||||
atkbdc_dsdt(void) | atkbdc_dsdt(void) | ||||
{ | { | ||||
dsdt_line(""); | dsdt_line(""); | ||||
dsdt_line("Device (KBD)"); | dsdt_line("Device (KBD)"); | ||||
dsdt_line("{"); | dsdt_line("{"); | ||||
Show All 27 Lines |