AN2345 Freescale Semiconductor / Motorola, AN2345 Datasheet - Page 14

no-image

AN2345

Manufacturer Part Number
AN2345
Description
Real-Time Memory Manager for StarCore DSPs
Manufacturer
Freescale Semiconductor / Motorola
Datasheet
VSMM Distribution
3.6 VSMM Critical Methods
14
2
See Section 8.2, Configuration ‘C’ Source File, VSMM_cfg.c, on page 29 for a listing of this file.
Many VSMM routines have critical sections, in which the program is vulnerable to undesirable
interruption or corruption and therefore requires interrupts to be disabled during execution of these
sections. The VSMM release provides several default critical methods associated with disabling and
re-enabling interrupts upon entry and exit of critical sections or the use of a binary semaphore, also
referred to as a spin-lock. Most of the VSMM critical methods are defined in the VSMM_cfg.c source
file.
VSMMEnterCritical.asm and VSMMExitCritical.asm assembly files provide the entry and
exit routines for critical method 2. These two files must be included in your application project file if you
have set the #define constant VSMM_CRITICAL_METHOD to a value of 2 within the VSMM_cfg.h
header file and the OSE_RTOS #define constant is defined as 0. A developer may also create his or her
own critical methods. The critical methods are as follows:
• Critical Method 1. Two available options are determined by the OSE_RTOS constant. Upon exit of a
• Critical Method 2. Two available options are determined by the OSE_RTOS constant. Both options
• Critical Method 3. This method disables interrupts, adjusts the interrupt priority mask (IPM), and
• Critical Method 4. This method can be used only with the OSE Systems OSEck RTOS because it uses
critical section, both options always re-enable interrupts even if they are disabled before entry into the
critical section. If the OSE_RTOS constant is set to 1 within the VSMM_cfg.h header file, the OSEck
RTOS LOCK macro disables interrupts, and the OSEck RTOS RESTORE macro re-enables interrupts.
If OSE_RTOS is set to 0, the StarCore DSP assembly di instruction disables interrupts and the ei
instruction re-enables interrupts.
save the current interrupt state before interrupts are disabled upon entry into critical sections and
restore the interrupts to their saved state when critical sections are exited. If the OSE_RTOS constant is
set to 1, the OSEck RTOS LOCK_SAVE macro stores the interrupt state and disables interrupts, and
the OSEck RTOS LOCK_RESTORE macro restores the saved interrupt state. If OSE_RTOS is set to
0, the critical method assembly routine in the VSMMEnterCritical.asm file: saves the interrupt
state into a global variable named: guliDSPSR and disables the interrupts. The assembly routine in the
VSMMExitCritical.asm file restores the interrupt state by testing the saved status register
interrupt bit within the guliDSPSR global variable, and, if the bit is cleared, re-enables the interrupts.
Otherwise, the interrupts remain disabled. Note that critical method 2 consumes the most cycles of all
the default methods provided.
re-enables interrupts when a critical section is entered. When a critical section is exited, interrupts are
disabled, the IPM is restored, and interrupts are re-enabled. This method is useful when you want to
allow higher-priority processes, such as an OS kernel, the ability to continue to generate and service
interrupts. It is extremely important that these higher-priority processes do not access any VSMM
routines since doing so could potentially interrupt one of these routines while it is within a critical
section. If you are using VSMM within an unmasked priority process, it is highly recommended that
you either use an alternate critical method or place an access function around the VSMM function call
to ensure mutual exclusivity.
the OSE spin-lock mechanism. This mechanism is a binary semaphore that can be shared across cores
on a DSP such as the MSC8102. To use this critical method, the VSMM_CRITICAL_METHOD
#define constant must be set to 4, and the OSE_RTOS #define constant must be set to 1. You must also
initialize a spin-lock for VSMM critical sections. Using OSEck, add the following code snippet to your
start handler 2 routine. If you are not using a start handler, simply add this code snippet to a module so
that it executes only once, for the life of the program and at program start-up.
2
The exception is the enter and exit critical methods associated with critical method 2. The
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com

Related parts for AN2345