本文整理汇总了Golang中novmm/platform.Vm.Vcpus方法的典型用法代码示例。如果您正苦于以下问题:Golang Vm.Vcpus方法的具体用法?Golang Vm.Vcpus怎么用?Golang Vm.Vcpus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类novmm/platform.Vm
的用法示例。
在下文中一共展示了Vm.Vcpus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Attach
func (acpi *Acpi) Attach(vm *platform.Vm, model *Model) error {
// Do we already have data?
rebuild := true
if acpi.Data == nil {
// Create our data.
acpi.Data = make([]byte, platform.PageSize, platform.PageSize)
} else {
// Align our data.
// This is necessary because we map this in
// directly. It's possible that the data was
// decoded and refers to the middle of some
// larger array somewhere, and isn't aligned.
acpi.Data = platform.AlignBytes(acpi.Data)
rebuild = false
}
// Allocate our memory block.
err := model.Reserve(
vm,
acpi,
MemoryTypeAcpi,
acpi.Addr,
platform.PageSize,
acpi.Data)
if err != nil {
return err
}
// Already done.
if !rebuild {
return nil
}
// Find our APIC information.
// This will find the APIC device if it
// is attached, otherwise the MADT table
// will unfortunately have be a bit invalid.
var IOApic platform.Paddr
var LApic platform.Paddr
for _, device := range model.Devices() {
apic, ok := device.(*Apic)
if ok {
IOApic = apic.IOApic
LApic = apic.LApic
break
}
}
// Load the MADT.
madt_bytes := C.build_madt(
unsafe.Pointer(&acpi.Data[0]),
C.__u32(LApic),
C.int(len(vm.Vcpus())),
C.__u32(IOApic),
C.__u32(0), // I/O APIC interrupt?
)
acpi.Debug("MADT %x @ %x", madt_bytes, acpi.Addr)
// Align offset.
offset := madt_bytes
if offset%64 != 0 {
offset += 64 - (offset % 64)
}
// Load the DSDT.
dsdt_address := uint64(acpi.Addr) + uint64(offset)
dsdt_bytes := C.build_dsdt(
unsafe.Pointer(&acpi.Data[int(offset)]),
)
acpi.Debug("DSDT %x @ %x", dsdt_bytes, dsdt_address)
// Align offset.
offset += dsdt_bytes
if offset%64 != 0 {
offset += 64 - (offset % 64)
}
// Load the XSDT.
xsdt_address := uint64(acpi.Addr) + uint64(offset)
xsdt_bytes := C.build_xsdt(
unsafe.Pointer(&acpi.Data[int(offset)]),
C.__u64(acpi.Addr), // MADT address.
)
acpi.Debug("XSDT %x @ %x", xsdt_bytes, xsdt_address)
// Align offset.
offset += xsdt_bytes
if offset%64 != 0 {
offset += 64 - (offset % 64)
}
// Load the RSDT.
rsdt_address := uint64(acpi.Addr) + uint64(offset)
rsdt_bytes := C.build_rsdt(
unsafe.Pointer(&acpi.Data[int(offset)]),
C.__u32(acpi.Addr), // MADT address.
)
acpi.Debug("RSDT %x @ %x", rsdt_bytes, rsdt_address)
//.........这里部分代码省略.........