Configuration, Software programming model, Software files – Altera Embedded Peripherals IP User Manual
Page 259: Hardware access routines, Configuration -2, Software programming model -2, Software files -2, Hardware access routines -2
![background image](https://www.manualsdir.com/files/763637/content/doc259.png)
• When the
VALUE
field is
0x0000
, the mutex is unlocked and available. Otherwise, the mutex is locked
and unavailable.
• The
mutex
register is always readable. Avalon-MM master peripherals, such as a processor, can read
the
mutex
register to determine its current state.
• The
mutex
register is writable only under specific conditions. A write operation changes the
mutex
register only if one or both of the following conditions are true:
• The
VALUE
field of the
mutex
register is zero.
• The
OWNER
field of the
mutex
register matches the
OWNER
field in the data to be written.
• A processor attempts to acquire the mutex by writing its ID to the
OWNER
field, and writing a non-zero
value to the
VALUE
field. The processor then checks if the acquisition succeeded by verifying the
OWNER
field.
• After system reset, the
RESET
bit in the
reset
register is high. Writing a one to this bit clears it.
Configuration
The MegaWizard
™
Interface provides the following options:
• Initial Value—the initial contents of the
VALUE
field after reset. If the Initial Value setting is non-zero,
you must also specify Initial Owner.
• Initial Owner—the initial contents of the
OWNER
field after reset. When Initial Owner is specified, this
owner must release the mutex before it can be acquired by another owner.
Software Programming Model
The following sections describe the software programming model for the mutex core. For Nios II
processor users, Altera provides routines to access the mutex core hardware. These functions are specific
to the mutex core and directly manipulate low-level hardware. The mutex core cannot be accessed via the
HAL API or the ANSI C standard library. In Nios II processor systems, a processor locks the mutex by
writing the value of its
cpuid
control register to the OWNER field of the
mutex
register.
Software Files
Altera provides the following software files accompanying the mutex core:
•
altera_avalon_mutex_regs.h
—Defines the core's register map, providing symbolic constants to access the
low-level hardware.
•
altera_avalon_mutex.h
—Defines data structures and functions to access the mutex core hardware.
•
altera_avalon_mutex.c
—Contains the implementations of the functions to access the mutex core
Hardware Access Routines
This section describes the low-level software constructs for manipulating the mutex core. The file
altera_
avalon_mutex.h
declares a structure
alt_mutex_dev
that represents an instance of a mutex device. It also
declares routines for accessing the mutex hardware structure, listed in the table below.
Table 26-2: Hardware Access Routines
Function Name
Description
altera_avalon_mutex_open()
Claims a handle to a mutex, enabling all the other
functions to access the mutex core.
26-2
Configuration
UG-01085
2014.24.07
Altera Corporation
Mutex Core