本文整理匯總了Golang中C.__u32函數的典型用法代碼示例。如果您正苦於以下問題:Golang __u32函數的具體用法?Golang __u32怎麽用?Golang __u32使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了__u32函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: MapUserMemory
func (vm *Vm) MapUserMemory(
start Paddr,
size uint64,
mmap []byte) error {
// See NOTE above about read-only memory.
// As we will not support it for the moment,
// we do not expose it through the interface.
// Leveraging that feature will likely require
// a small amount of re-architecting in any case.
var region C.struct_kvm_userspace_memory_region
region.slot = C.__u32(vm.mem_region)
region.flags = C.__u32(0)
region.guest_phys_addr = C.__u64(start)
region.memory_size = C.__u64(size)
region.userspace_addr = C.__u64(uintptr(unsafe.Pointer(&mmap[0])))
// Execute the ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vm.fd),
uintptr(C.IoctlSetUserMemoryRegion),
uintptr(unsafe.Pointer(®ion)))
if e != 0 {
return e
}
// We're set, bump our slot.
vm.mem_region += 1
return nil
}
示例2: Interrupt
func (vm *Vm) Interrupt(
irq Irq,
level bool) error {
// Prepare the IRQ.
var irq_level C.struct_irq_level
irq_level.irq = C.__u32(irq)
if level {
irq_level.level = C.__u32(1)
} else {
irq_level.level = C.__u32(0)
}
// Execute the ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vm.fd),
uintptr(C.IoctlIrqLine),
uintptr(unsafe.Pointer(&irq_level)))
if e != 0 {
return e
}
return nil
}
示例3: SetAttr
// sched_setattr(2)
func SetAttr(pid int, attr SchedAttr) error {
cAttr := C.struct_sched_attr{
C.__u32(C.SCHED_ATTR_SIZE),
C.__u32(attr.Policy),
C.__u64(attr.Flags),
C.__s32(attr.Nice),
C.__u32(attr.Priority),
C.__u64(attr.Runtime.Nanoseconds()),
C.__u64(attr.Deadline.Nanoseconds()),
C.__u64(attr.Period.Nanoseconds()),
}
_, err := C.sched_setattr(C.pid_t(pid), &cAttr, C.uint(0))
return err
}
示例4: GetQuota
// GetQuota - get the quota limits of a directory that was configured with SetQuota
func (q *QuotaCtl) GetQuota(targetPath string, quota *Quota) error {
projectID, ok := q.quotas[targetPath]
if !ok {
return fmt.Errorf("quota not found for path : %s", targetPath)
}
//
// get the quota limit for the container's project id
//
var d C.fs_disk_quota_t
var cs = C.CString(q.backingFsBlockDev)
defer C.free(unsafe.Pointer(cs))
_, _, errno := syscall.Syscall6(syscall.SYS_QUOTACTL, C.Q_XGETPQUOTA,
uintptr(unsafe.Pointer(cs)), uintptr(C.__u32(projectID)),
uintptr(unsafe.Pointer(&d)), 0, 0)
if errno != 0 {
return fmt.Errorf("Failed to get quota limit for projid %d on %s: %v",
projectID, q.backingFsBlockDev, errno.Error())
}
quota.Size = uint64(d.d_blk_hardlimit) * 512
return nil
}
示例5: SetStepping
func (vcpu *Vcpu) SetStepping(step bool) error {
var guest_debug C.struct_kvm_guest_debug
if step == vcpu.is_stepping {
// Already set.
return nil
} else if step {
guest_debug.control = C.__u32(C.IoctlGuestDebugEnable)
} else {
guest_debug.control = 0
}
// Execute our debug ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetGuestDebug),
uintptr(unsafe.Pointer(&guest_debug)))
if e != 0 {
return e
}
// We're okay.
vcpu.is_stepping = step
return nil
}
示例6: SetFpuState
func (vcpu *Vcpu) SetFpuState(state Fpu) error {
// Prepare our data.
var kvm_fpu C.struct_kvm_fpu
for i := 0; i < len(state.FPR); i += 1 {
for j := 0; j < len(state.FPR[i]); j += 1 {
kvm_fpu.fpr[i][j] = C.__u8(state.FPR[i][j])
}
}
kvm_fpu.fcw = C.__u16(state.FCW)
kvm_fpu.fsw = C.__u16(state.FSW)
kvm_fpu.ftwx = C.__u8(state.FTWX)
kvm_fpu.last_opcode = C.__u16(state.LastOpcode)
kvm_fpu.last_ip = C.__u64(state.LastIp)
kvm_fpu.last_dp = C.__u64(state.LastDp)
for i := 0; i < len(state.XMM); i += 1 {
for j := 0; j < len(state.XMM[i]); j += 1 {
kvm_fpu.xmm[i][j] = C.__u8(state.XMM[i][j])
}
}
kvm_fpu.mxcsr = C.__u32(state.MXCSR)
// Execute the ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetFpu),
uintptr(unsafe.Pointer(&kvm_fpu)))
if e != 0 {
return e
}
return nil
}
示例7: SetCpuid
func (vcpu *Vcpu) SetCpuid(cpuids []Cpuid) error {
// Initialize our cpuid data.
cpuidData := make([]byte, PageSize, PageSize)
for i, cpuid := range cpuids {
e := C.cpuid_set(
unsafe.Pointer(&cpuidData[0]),
C.int(PageSize),
C.int(i),
C.__u32(cpuid.Function),
C.__u32(cpuid.Index),
C.__u32(cpuid.Flags),
C.__u32(cpuid.EAX),
C.__u32(cpuid.EBX),
C.__u32(cpuid.ECX),
C.__u32(cpuid.EDX))
if e != 0 {
return syscall.Errno(e)
}
}
// Set our vcpuid.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetCpuid),
uintptr(unsafe.Pointer(&cpuidData[0])))
if e != 0 {
return e
}
// We're good.
vcpu.cpuid = cpuids
return nil
}
示例8: SetXcrs
func (vcpu *Vcpu) SetXcrs(xcrs []Xcr) error {
// Build our parameter.
var kvm_xcrs C.struct_kvm_xcrs
kvm_xcrs.nr_xcrs = C.__u32(len(xcrs))
for i, xcr := range xcrs {
kvm_xcrs.xcrs[i].xcr = C.__u32(xcr.Id)
kvm_xcrs.xcrs[i].value = C.__u64(xcr.Value)
}
// Execute the ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetXcrs),
uintptr(unsafe.Pointer(&kvm_xcrs)))
if e != 0 {
return e
}
return nil
}
示例9: SetEventFd
func (vm *Vm) SetEventFd(
eventfd *EventFd,
paddr Paddr,
size uint,
is_pio bool,
unbind bool,
has_value bool,
value uint64) error {
var ioeventfd C.struct_kvm_ioeventfd
ioeventfd.addr = C.__u64(paddr)
ioeventfd.len = C.__u32(size)
ioeventfd.fd = C.__s32(eventfd.Fd())
ioeventfd.datamatch = C.__u64(value)
if is_pio {
ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagPio)
}
if unbind {
ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagDeassign)
}
if has_value {
ioeventfd.flags |= C.__u32(C.IoctlIoEventFdFlagDatamatch)
}
// Bind / unbind the eventfd.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vm.fd),
uintptr(C.IoctlIoEventFd),
uintptr(unsafe.Pointer(&ioeventfd)))
if e != 0 {
return e
}
// Success.
return nil
}
示例10: SignalMSI
func (vm *Vm) SignalMSI(
addr Paddr,
data uint32,
flags uint32) error {
// Prepare the MSI.
var msi C.struct_kvm_msi
msi.address_lo = C.__u32(addr & 0xffffffff)
msi.address_hi = C.__u32(addr >> 32)
msi.data = C.__u32(data)
msi.flags = C.__u32(flags)
// Execute the ioctl.
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vm.fd),
uintptr(C.IoctlSignalMsi),
uintptr(unsafe.Pointer(&msi)))
if e != 0 {
return e
}
return nil
}
示例11: SetMpState
func (vcpu *Vcpu) SetMpState(state MpState) error {
// Execute the ioctl.
var kvm_state C.struct_kvm_mp_state
kvm_state.mp_state = C.__u32(state)
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetMpState),
uintptr(unsafe.Pointer(&kvm_state)))
if e != 0 {
return e
}
return nil
}
示例12: SetClock
func (vm *Vm) SetClock(clock Clock) error {
// Execute the ioctl.
var kvm_clock_data C.struct_kvm_clock_data
kvm_clock_data.clock = C.__u64(clock.Time)
kvm_clock_data.flags = C.__u32(clock.Flags)
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vm.fd),
uintptr(C.IoctlSetClock),
uintptr(unsafe.Pointer(&kvm_clock_data)))
if e != 0 {
return e
}
return nil
}
示例13: nativeCpuid
func nativeCpuid(function uint32) Cpuid {
var eax C.__u32
var ebx C.__u32
var ecx C.__u32
var edx C.__u32
// Query our native function.
C.cpuid_native(C.__u32(function), &eax, &ebx, &ecx, &edx)
// Transform.
return Cpuid{
Function: function,
EAX: uint32(eax),
EBX: uint32(ebx),
ECX: uint32(ecx),
EDX: uint32(edx)}
}
示例14: SetXSave
func (vcpu *Vcpu) SetXSave(state XSave) error {
// Execute the ioctl.
var kvm_xsave C.struct_kvm_xsave
for i := 0; i < len(state.Region); i += 1 {
kvm_xsave.region[i] = C.__u32(state.Region[i])
}
_, _, e := syscall.Syscall(
syscall.SYS_IOCTL,
uintptr(vcpu.fd),
uintptr(C.IoctlSetXSave),
uintptr(unsafe.Pointer(&kvm_xsave)))
if e != 0 {
return e
}
return nil
}
示例15: ProcessOutgoing
func (vchannel *VirtioChannel) ProcessOutgoing() error {
for buf := range vchannel.outgoing {
// The device is active.
vchannel.VirtioDevice.Acquire()
// Put in the virtqueue.
vchannel.Debug(
"vqueue#%d outgoing slot [%d]",
vchannel.Channel,
buf.index)
var evt_interrupt C.int
var no_interrupt C.int
C.vring_put_buf(
&vchannel.vring,
C.__u16(buf.index),
C.__u32(buf.length),
&evt_interrupt,
&no_interrupt)
if vchannel.HasFeatures(VirtioRingFEventIdx) {
// This is used the event index.
if evt_interrupt != C.int(0) {
// Interrupt the guest.
vchannel.Interrupt(true)
}
} else {
// We have no event index.
if no_interrupt == C.int(0) {
// Interrupt the guest.
vchannel.Interrupt(true)
}
}
// Remove from our outstanding list.
delete(vchannel.Outstanding, uint16(buf.index))
// We can release until the next buffer comes back.
vchannel.VirtioDevice.Release()
}
return nil
}