Changeset View
Changeset View
Standalone View
Standalone View
sys/amd64/vmm/vmm.c
Show First 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | |||||
#include "vmm_mem.h" | #include "vmm_mem.h" | ||||
#include "vmm_util.h" | #include "vmm_util.h" | ||||
#include "vatpic.h" | #include "vatpic.h" | ||||
#include "vatpit.h" | #include "vatpit.h" | ||||
#include "vhpet.h" | #include "vhpet.h" | ||||
#include "vioapic.h" | #include "vioapic.h" | ||||
#include "vlapic.h" | #include "vlapic.h" | ||||
#include "vpmtmr.h" | #include "vpmtmr.h" | ||||
#include "vrtc.h" | |||||
#include "vmm_ipi.h" | #include "vmm_ipi.h" | ||||
#include "vmm_stat.h" | #include "vmm_stat.h" | ||||
#include "vmm_lapic.h" | #include "vmm_lapic.h" | ||||
#include "io/ppt.h" | #include "io/ppt.h" | ||||
#include "io/iommu.h" | #include "io/iommu.h" | ||||
struct vlapic; | struct vlapic; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
struct vm { | struct vm { | ||||
void *cookie; /* (i) cpu-specific data */ | void *cookie; /* (i) cpu-specific data */ | ||||
void *iommu; /* (x) iommu-specific data */ | void *iommu; /* (x) iommu-specific data */ | ||||
struct vhpet *vhpet; /* (i) virtual HPET */ | struct vhpet *vhpet; /* (i) virtual HPET */ | ||||
struct vioapic *vioapic; /* (i) virtual ioapic */ | struct vioapic *vioapic; /* (i) virtual ioapic */ | ||||
struct vatpic *vatpic; /* (i) virtual atpic */ | struct vatpic *vatpic; /* (i) virtual atpic */ | ||||
struct vatpit *vatpit; /* (i) virtual atpit */ | struct vatpit *vatpit; /* (i) virtual atpit */ | ||||
struct vpmtmr *vpmtmr; /* (i) virtual ACPI PM timer */ | struct vpmtmr *vpmtmr; /* (i) virtual ACPI PM timer */ | ||||
struct vrtc *vrtc; /* (o) virtual RTC */ | |||||
volatile cpuset_t active_cpus; /* (i) active vcpus */ | volatile cpuset_t active_cpus; /* (i) active vcpus */ | ||||
int suspend; /* (i) stop VM execution */ | int suspend; /* (i) stop VM execution */ | ||||
volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ | volatile cpuset_t suspended_cpus; /* (i) suspended vcpus */ | ||||
volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */ | volatile cpuset_t halted_cpus; /* (x) cpus in a hard halt */ | ||||
cpuset_t rendezvous_req_cpus; /* (x) rendezvous requested */ | cpuset_t rendezvous_req_cpus; /* (x) rendezvous requested */ | ||||
cpuset_t rendezvous_done_cpus; /* (x) rendezvous finished */ | cpuset_t rendezvous_done_cpus; /* (x) rendezvous finished */ | ||||
void *rendezvous_arg; /* (x) rendezvous func/arg */ | void *rendezvous_arg; /* (x) rendezvous func/arg */ | ||||
vm_rendezvous_func_t rendezvous_func; | vm_rendezvous_func_t rendezvous_func; | ||||
▲ Show 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | vm_init(struct vm *vm, bool create) | ||||
vm->cookie = VMINIT(vm, vmspace_pmap(vm->vmspace)); | vm->cookie = VMINIT(vm, vmspace_pmap(vm->vmspace)); | ||||
vm->iommu = NULL; | vm->iommu = NULL; | ||||
vm->vioapic = vioapic_init(vm); | vm->vioapic = vioapic_init(vm); | ||||
vm->vhpet = vhpet_init(vm); | vm->vhpet = vhpet_init(vm); | ||||
vm->vatpic = vatpic_init(vm); | vm->vatpic = vatpic_init(vm); | ||||
vm->vatpit = vatpit_init(vm); | vm->vatpit = vatpit_init(vm); | ||||
vm->vpmtmr = vpmtmr_init(vm); | vm->vpmtmr = vpmtmr_init(vm); | ||||
if (create) | |||||
vm->vrtc = vrtc_init(vm); | |||||
CPU_ZERO(&vm->active_cpus); | CPU_ZERO(&vm->active_cpus); | ||||
vm->suspend = 0; | vm->suspend = 0; | ||||
CPU_ZERO(&vm->suspended_cpus); | CPU_ZERO(&vm->suspended_cpus); | ||||
for (i = 0; i < VM_MAXCPU; i++) | for (i = 0; i < VM_MAXCPU; i++) | ||||
vcpu_init(vm, i, create); | vcpu_init(vm, i, create); | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int i; | int i; | ||||
ppt_unassign_all(vm); | ppt_unassign_all(vm); | ||||
if (vm->iommu != NULL) | if (vm->iommu != NULL) | ||||
iommu_destroy_domain(vm->iommu); | iommu_destroy_domain(vm->iommu); | ||||
if (destroy) | |||||
vrtc_cleanup(vm->vrtc); | |||||
else | |||||
vrtc_reset(vm->vrtc); | |||||
vpmtmr_cleanup(vm->vpmtmr); | vpmtmr_cleanup(vm->vpmtmr); | ||||
vatpit_cleanup(vm->vatpit); | vatpit_cleanup(vm->vatpit); | ||||
vhpet_cleanup(vm->vhpet); | vhpet_cleanup(vm->vhpet); | ||||
vatpic_cleanup(vm->vatpic); | vatpic_cleanup(vm->vatpic); | ||||
vioapic_cleanup(vm->vioapic); | vioapic_cleanup(vm->vioapic); | ||||
for (i = 0; i < VM_MAXCPU; i++) | for (i = 0; i < VM_MAXCPU; i++) | ||||
vcpu_cleanup(vm, i, destroy); | vcpu_cleanup(vm, i, destroy); | ||||
▲ Show 20 Lines • Show All 1,767 Lines • ▼ Show 20 Lines | vm_atpit(struct vm *vm) | ||||
return (vm->vatpit); | return (vm->vatpit); | ||||
} | } | ||||
struct vpmtmr * | struct vpmtmr * | ||||
vm_pmtmr(struct vm *vm) | vm_pmtmr(struct vm *vm) | ||||
{ | { | ||||
return (vm->vpmtmr); | return (vm->vpmtmr); | ||||
} | |||||
struct vrtc * | |||||
vm_rtc(struct vm *vm) | |||||
{ | |||||
return (vm->vrtc); | |||||
} | } | ||||
enum vm_reg_name | enum vm_reg_name | ||||
vm_segment_name(int seg) | vm_segment_name(int seg) | ||||
{ | { | ||||
static enum vm_reg_name seg_names[] = { | static enum vm_reg_name seg_names[] = { | ||||
VM_REG_GUEST_ES, | VM_REG_GUEST_ES, | ||||
VM_REG_GUEST_CS, | VM_REG_GUEST_CS, | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |