volatile

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2022 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package volatile provides definitions for volatile loads and stores. These are implemented as compiler builtins.

The load operations load a volatile value. The store operations store to a volatile value. The compiler will emit exactly one load or store operation when possible and will not reorder volatile operations. However, the compiler may move other operations across load/store operations, so make sure that all relevant loads/stores are done in a volatile way if this is a problem.

These loads and stores are commonly used to read/write values from memory mapped peripheral devices. They do not provide atomicity, use the sync/atomic package for that.

For more details: https://llvm.org/docs/LangRef.html#volatile-memory-accesses and https://blog.regehr.org/archives/28.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadUint16

func LoadUint16(addr *uint16) (val uint16)

LoadUint16 loads the volatile value *addr.

func LoadUint32

func LoadUint32(addr *uint32) (val uint32)

LoadUint32 loads the volatile value *addr.

func LoadUint64 added in v0.14.0

func LoadUint64(addr *uint64) (val uint64)

LoadUint64 loads the volatile value *addr.

func LoadUint8

func LoadUint8(addr *uint8) (val uint8)

LoadUint8 loads the volatile value *addr.

func StoreUint16

func StoreUint16(addr *uint16, val uint16)

StoreUint16 stores val to the volatile value *addr.

func StoreUint32

func StoreUint32(addr *uint32, val uint32)

StoreUint32 stores val to the volatile value *addr.

func StoreUint64 added in v0.14.0

func StoreUint64(addr *uint64, val uint64)

StoreUint64 stores val to the volatile value *addr.

func StoreUint8

func StoreUint8(addr *uint8, val uint8)

StoreUint8 stores val to the volatile value *addr.

Types

type Register16 added in v0.7.0

type Register16 struct {
	Reg uint16
}

func (*Register16) ClearBits added in v0.7.0

func (r *Register16) ClearBits(value uint16)

ClearBits reads the register, clears the given bits, and writes it back. It is the volatile equivalent of:

r.Reg &^= value

func (*Register16) Get added in v0.7.0

func (r *Register16) Get() uint16

Get returns the value in the register. It is the volatile equivalent of:

*r.Reg

func (*Register16) HasBits added in v0.7.0

func (r *Register16) HasBits(value uint16) bool

HasBits reads the register and then checks to see if the passed bits are set. It is the volatile equivalent of:

(*r.Reg & value) > 0

func (*Register16) ReplaceBits added in v0.13.0

func (r *Register16) ReplaceBits(value uint16, mask uint16, pos uint8)

ReplaceBits is a helper to simplify setting multiple bits high and/or low at once. It is the volatile equivalent of:

r.Reg = (r.Reg & ^(mask << pos)) | value << pos

go:inline

func (*Register16) Set added in v0.7.0

func (r *Register16) Set(value uint16)

Set updates the register value. It is the volatile equivalent of:

*r.Reg = value

func (*Register16) SetBits added in v0.7.0

func (r *Register16) SetBits(value uint16)

SetBits reads the register, sets the given bits, and writes it back. It is the volatile equivalent of:

r.Reg |= value

type Register32 added in v0.7.0

type Register32 struct {
	Reg uint32
}

func (*Register32) ClearBits added in v0.7.0

func (r *Register32) ClearBits(value uint32)

ClearBits reads the register, clears the given bits, and writes it back. It is the volatile equivalent of:

r.Reg &^= value

func (*Register32) Get added in v0.7.0

func (r *Register32) Get() uint32

Get returns the value in the register. It is the volatile equivalent of:

*r.Reg

func (*Register32) HasBits added in v0.7.0

func (r *Register32) HasBits(value uint32) bool

HasBits reads the register and then checks to see if the passed bits are set. It is the volatile equivalent of:

(*r.Reg & value) > 0

func (*Register32) ReplaceBits added in v0.13.0

func (r *Register32) ReplaceBits(value uint32, mask uint32, pos uint8)

ReplaceBits is a helper to simplify setting multiple bits high and/or low at once. It is the volatile equivalent of:

r.Reg = (r.Reg & ^(mask << pos)) | value << pos

go:inline

func (*Register32) Set added in v0.7.0

func (r *Register32) Set(value uint32)

Set updates the register value. It is the volatile equivalent of:

*r.Reg = value

func (*Register32) SetBits added in v0.7.0

func (r *Register32) SetBits(value uint32)

SetBits reads the register, sets the given bits, and writes it back. It is the volatile equivalent of:

r.Reg |= value

type Register64 added in v0.14.0

type Register64 struct {
	Reg uint64
}

func (*Register64) ClearBits added in v0.14.0

func (r *Register64) ClearBits(value uint64)

ClearBits reads the register, clears the given bits, and writes it back. It is the volatile equivalent of:

r.Reg &^= value

func (*Register64) Get added in v0.14.0

func (r *Register64) Get() uint64

Get returns the value in the register. It is the volatile equivalent of:

*r.Reg

func (*Register64) HasBits added in v0.14.0

func (r *Register64) HasBits(value uint64) bool

HasBits reads the register and then checks to see if the passed bits are set. It is the volatile equivalent of:

(*r.Reg & value) > 0

func (*Register64) ReplaceBits added in v0.14.0

func (r *Register64) ReplaceBits(value uint64, mask uint64, pos uint8)

ReplaceBits is a helper to simplify setting multiple bits high and/or low at once. It is the volatile equivalent of:

r.Reg = (r.Reg & ^(mask << pos)) | value << pos

go:inline

func (*Register64) Set added in v0.14.0

func (r *Register64) Set(value uint64)

Set updates the register value. It is the volatile equivalent of:

*r.Reg = value

func (*Register64) SetBits added in v0.14.0

func (r *Register64) SetBits(value uint64)

SetBits reads the register, sets the given bits, and writes it back. It is the volatile equivalent of:

r.Reg |= value

type Register8 added in v0.7.0

type Register8 struct {
	Reg uint8
}

Special types that causes loads/stores to be volatile (necessary for memory-mapped registers).

func (*Register8) ClearBits added in v0.7.0

func (r *Register8) ClearBits(value uint8)

ClearBits reads the register, clears the given bits, and writes it back. It is the volatile equivalent of:

r.Reg &^= value

func (*Register8) Get added in v0.7.0

func (r *Register8) Get() uint8

Get returns the value in the register. It is the volatile equivalent of:

*r.Reg

func (*Register8) HasBits added in v0.7.0

func (r *Register8) HasBits(value uint8) bool

HasBits reads the register and then checks to see if the passed bits are set. It is the volatile equivalent of:

(*r.Reg & value) > 0

func (*Register8) ReplaceBits added in v0.13.0

func (r *Register8) ReplaceBits(value uint8, mask uint8, pos uint8)

ReplaceBits is a helper to simplify setting multiple bits high and/or low at once. It is the volatile equivalent of:

r.Reg = (r.Reg & ^(mask << pos)) | value << pos

go:inline

func (*Register8) Set added in v0.7.0

func (r *Register8) Set(value uint8)

Set updates the register value. It is the volatile equivalent of:

*r.Reg = value

func (*Register8) SetBits added in v0.7.0

func (r *Register8) SetBits(value uint8)

SetBits reads the register, sets the given bits, and writes it back. It is the volatile equivalent of:

r.Reg |= value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL