本文整理汇总了Golang中novmm/platform.Vm.MapSpecialMemory方法的典型用法代码示例。如果您正苦于以下问题:Golang Vm.MapSpecialMemory方法的具体用法?Golang Vm.MapSpecialMemory怎么用?Golang Vm.MapSpecialMemory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类novmm/platform.Vm
的用法示例。
在下文中一共展示了Vm.MapSpecialMemory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Reserve
func (memory *MemoryMap) Reserve(
vm *platform.Vm,
device Device,
memtype MemoryType,
start platform.Paddr,
size uint64,
user []byte) error {
// Verbose messages.
device.Debug(
"reserving (type: %d) of size %x in [%x,%x]",
memtype,
size,
start,
start.After(size-1))
// Ensure all targets are aligned.
if (start.Align(platform.PageSize, false) != start) ||
(size%platform.PageSize != 0) {
return MemoryUnaligned
}
// Ensure underlying map is aligned.
// This may be harder to detect later on.
if user != nil &&
uintptr(unsafe.Pointer(&user[0]))%platform.PageSize != 0 {
return MemoryUnaligned
}
// Add the region.
region := &TypedMemoryRegion{
MemoryRegion: MemoryRegion{start, size},
MemoryType: memtype,
Device: device,
user: user,
allocated: make(map[uint64]uint64),
}
err := memory.Add(region)
if err != nil {
return err
}
// Do the mapping.
switch region.MemoryType {
case MemoryTypeUser:
err = vm.MapUserMemory(region.Start, region.Size, region.user)
case MemoryTypeReserved:
err = vm.MapReservedMemory(region.Start, region.Size)
case MemoryTypeAcpi:
err = vm.MapUserMemory(region.Start, region.Size, region.user)
case MemoryTypeSpecial:
err = vm.MapSpecialMemory(region.Start)
}
return err
}