volatile.mx raw

   1  // Package volatile provides definitions for volatile loads and stores. These
   2  // are implemented as compiler builtins.
   3  //
   4  // The load operations load a volatile value. The store operations store to a
   5  // volatile value. The compiler will emit exactly one load or store operation
   6  // when possible and will not reorder volatile operations. However, the compiler
   7  // may move other operations across load/store operations, so make sure that all
   8  // relevant loads/stores are done in a volatile way if this is a problem.
   9  //
  10  // These loads and stores are commonly used to read/write values from memory
  11  // mapped peripheral devices. They do not provide atomicity, use the sync/atomic
  12  // package for that.
  13  //
  14  // For more details: https://llvm.org/docs/LangRef.html#volatile-memory-accesses
  15  // and https://blog.regehr.org/archives/28.
  16  package volatile
  17  
  18  // LoadUint8 loads the volatile value *addr.
  19  func LoadUint8(addr *uint8) (val uint8)
  20  
  21  // LoadUint16 loads the volatile value *addr.
  22  func LoadUint16(addr *uint16) (val uint16)
  23  
  24  // LoadUint32 loads the volatile value *addr.
  25  func LoadUint32(addr *uint32) (val uint32)
  26  
  27  // LoadUint64 loads the volatile value *addr.
  28  func LoadUint64(addr *uint64) (val uint64)
  29  
  30  // StoreUint8 stores val to the volatile value *addr.
  31  func StoreUint8(addr *uint8, val uint8)
  32  
  33  // StoreUint16 stores val to the volatile value *addr.
  34  func StoreUint16(addr *uint16, val uint16)
  35  
  36  // StoreUint32 stores val to the volatile value *addr.
  37  func StoreUint32(addr *uint32, val uint32)
  38  
  39  // StoreUint64 stores val to the volatile value *addr.
  40  func StoreUint64(addr *uint64, val uint64)
  41