Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/io/vhpet.c
Show All 26 Lines | |||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
* | * | ||||
* $FreeBSD$ | * $FreeBSD$ | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_bhyve_snapshot.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/lock.h> | #include <sys/lock.h> | ||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <dev/acpica/acpi_hpet.h> | #include <dev/acpica/acpi_hpet.h> | ||||
#include <machine/vmm.h> | #include <machine/vmm.h> | ||||
#include <machine/vmm_dev.h> | #include <machine/vmm_dev.h> | ||||
#include <machine/vmm_snapshot.h> | |||||
#include "vmm_lapic.h" | #include "vmm_lapic.h" | ||||
#include "vatpic.h" | #include "vatpic.h" | ||||
#include "vioapic.h" | #include "vioapic.h" | ||||
#include "vhpet.h" | #include "vhpet.h" | ||||
#include "vmm_ktr.h" | #include "vmm_ktr.h" | ||||
▲ Show 20 Lines • Show All 702 Lines • ▼ Show 20 Lines | |||||
int | int | ||||
vhpet_getcap(struct vm_hpet_cap *cap) | vhpet_getcap(struct vm_hpet_cap *cap) | ||||
{ | { | ||||
cap->capabilities = vhpet_capabilities(); | cap->capabilities = vhpet_capabilities(); | ||||
return (0); | return (0); | ||||
} | } | ||||
#ifdef BHYVE_SNAPSHOT | |||||
int | |||||
vhpet_snapshot(struct vhpet *vhpet, struct vm_snapshot_meta *meta) | |||||
{ | |||||
int i, ret; | |||||
uint32_t countbase; | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->freq_sbt, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->config, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->isr, meta, ret, done); | |||||
/* at restore time the countbase should have the value it had when the | |||||
* snapshot was created; since the value is not directly kept in | |||||
* vhpet->countbase, but rather computed relative to the current system | |||||
* uptime using countbase_sbt, save the value retured by vhpet_counter | |||||
*/ | |||||
if (meta->op == VM_SNAPSHOT_SAVE) | |||||
countbase = vhpet_counter(vhpet, NULL); | |||||
SNAPSHOT_VAR_OR_LEAVE(countbase, meta, ret, done); | |||||
if (meta->op == VM_SNAPSHOT_RESTORE) | |||||
vhpet->countbase = countbase; | |||||
for (i = 0; i < nitems(vhpet->timer); i++) { | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->timer[i].cap_config, | |||||
meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->timer[i].msireg, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->timer[i].compval, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->timer[i].comprate, meta, ret, done); | |||||
SNAPSHOT_VAR_OR_LEAVE(vhpet->timer[i].callout_sbt, | |||||
meta, ret, done); | |||||
} | |||||
done: | |||||
return (ret); | |||||
} | |||||
int | |||||
vhpet_restore_time(struct vhpet *vhpet) | |||||
{ | |||||
if (vhpet_counter_enabled(vhpet)) | |||||
vhpet_start_counting(vhpet); | |||||
return (0); | |||||
} | |||||
#endif |