github.com/usbarmory/tamago@v0.0.0-20240508072735-8612bbe1e454/internal/reg/reg64.go (about) 1 // https://github.com/usbarmory/tamago 2 // 3 // Copyright (c) WithSecure Corporation 4 // https://foundry.withsecure.com 5 // 6 // Use of this source code is governed by the license 7 // that can be found in the LICENSE file. 8 9 package reg 10 11 import ( 12 "sync/atomic" 13 "unsafe" 14 ) 15 16 func IsSet64(addr uint64, pos int) bool { 17 reg := (*uint64)(unsafe.Pointer(uintptr(addr))) 18 r := atomic.LoadUint64(reg) 19 20 return (int(r) >> pos) & 1 == 1 21 } 22 23 func Read64(addr uint64) uint64 { 24 reg := (*uint64)(unsafe.Pointer(uintptr(addr))) 25 return atomic.LoadUint64(reg) 26 } 27 28 func Write64(addr uint64, val uint64) { 29 reg := (*uint64)(unsafe.Pointer(uintptr(addr))) 30 atomic.StoreUint64(reg, val) 31 }