mpu

package
v0.0.0-...-168ccc2 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package mpu provides interface to configure Cortex-M Memory Protection Unit.

Index

Constants

View Source
const VALID = 1 << 4

Variables

This section is empty.

Functions

func Clear

func Clear(fl Flags)

Clear clears flags specified by fl.

func Select

func Select(n int)

Select selects region number n.

func Set

func Set(fl Flags)

Set sets flags specified by fl.

func SetRegion

func SetRegion(base uintptr, attr Attr)

func Type

func Type() (i, d int, s bool)

Type returns information about MPU unit: i - number of supported instruction regions, d - number of supported data regions. s - true if separate instruction and data regions are supported.

Types

type Attr

type Attr uint32
const (
	ENA Attr = 1 << 0 // Enables region

	B Attr = 1 << 16 // Bufferable.
	C Attr = 1 << 17 // Cacheable.
	S Attr = 1 << 18 // Shareable.

	// Access permissons.
	Amask Attr = 7 << 24 // Use to extract access permission bits.
	A____ Attr = 0 << 24 // No access.
	Ar___ Attr = 5 << 24 // Priv-RO.
	Arw__ Attr = 1 << 24 // Priv-RW.
	Ar_r_ Attr = 6 << 24 // Priv-RO, Unpriv-RO.
	Arwr_ Attr = 2 << 24 // Priv-RW, Unpriv-RO.
	Arwrw Attr = 3 << 24 // Priv-RW, Unpriv-RW.

	XN Attr = 1 << 28 // Instruction access disable.
)

func Region

func Region() (base uintptr, attr Attr)

func SIZE

func SIZE(exp int) Attr

func SRD

func SRD(srd int) Attr

func TEX

func TEX(tex int) Attr

func (Attr) SIZE

func (a Attr) SIZE() (exp int)

func (Attr) SRD

func (a Attr) SRD() int

func (Attr) TEX

func (a Attr) TEX() int

type Flags

type Flags uint32
const (
	// If ENABLE is set MPU is enabled.
	ENABLE Flags = 1 << 0
	// If HFNMIENA is not set the MPU will be disabled during HardFault, NMI
	// and FAULTMASK handlers.
	HFNMIENA Flags = 1 << 1
	// If PRIVDEF is set the default memory map is used as background region for
	// privileged software access.
	PRIVDEFENA Flags = 1 << 2
)

func State

func State() Flags

Jump to

Keyboard shortcuts

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