public MmappedRegion(SafeUnixHandle handle, int size = 0x1000, int offset = 0) { Pointer = Mmap(null, Length = (ulong)size, 4 | 2, 1, (int)handle.DangerousGetHandle(), (ulong)offset); if (Pointer == null) { throw new KvmException("Could not mmap region"); } }
internal RegWrapper(SafeUnixHandle handle, ulong @base, ulong stride) { Handle = handle; Base = @base; Stride = stride; }
internal VecWrapper(SafeUnixHandle handle, ulong @base) { Handle = handle; Base = @base; }
internal static bool VcpuSetGuestDebug(SafeUnixHandle handle, KvmGuestDebug debug) => Ioctl(handle, KVM_SET_GUEST_DEBUG, &debug) == 0;
internal static bool VcpuSetOneReg(SafeUnixHandle handle, KvmOneReg reg) => Ioctl(handle, KVM_SET_ONE_REG, ®) == 0;
internal static bool VmArmPreferredTarget(SafeUnixHandle handle, out KvmVcpuInit init) { fixed(KvmVcpuInit *ptr = &init) return(Ioctl(handle, KVM_ARM_PREFERRED_TARGET, ptr) == 0); }
internal static bool VcpuArmInit(SafeUnixHandle handle, KvmVcpuInit init) => Ioctl(handle, KVM_ARM_VCPU_INIT, &init) == 0;
internal static SafeUnixHandle VmCreateVcpu(SafeUnixHandle handle, int id) => IoctlHandle(handle, KVM_CREATE_VCPU);
internal static bool VcpuRun(SafeUnixHandle handle) => Ioctl(handle, KVM_RUN) == 0;
internal static SafeUnixHandle KvmCreateVm(SafeUnixHandle handle) => IoctlHandle(handle, KVM_CREATE_VM);
internal static int VmSetUserMemoryRegion(SafeUnixHandle handle, KvmUserspaceMemoryRegion region) => Ioctl(handle, KVM_SET_USER_MEMORY_REGION, ®ion);
internal static uint KvmGetApiVersion(SafeUnixHandle handle) => (uint)Ioctl(handle, KVM_GET_API_VERSION);
internal static SafeUnixHandle IoctlHandle(SafeUnixHandle handle, uint request, int param) => IoctlHandle(handle, request, (void *)(uint)param);
internal static SafeUnixHandle IoctlHandle(SafeUnixHandle handle, uint request) => IoctlHandle(handle, request, null);
internal static int Ioctl(SafeUnixHandle handle, uint request) => Ioctl(handle, request, null);
internal static extern SafeUnixHandle IoctlHandle(SafeUnixHandle handle, uint request, void *buffer);