# MI_Swap*

## C Specification

      #include <nitro/mi.h>

      u32 MI_SwapWord(
              u32             setData,
              volatile u32*   destp );

      u8  MI_SwapByte(
              u32           setData,
              volatile u8*  destp );

## Description

This function swaps `setData` and the data stored at *`destp`. This function implements spinlock to exclusively control resources that are shared between processors or modules. `MI_SwapByte()` swaps byte data. `MI_SwapWord()` swaps word data.

Note that byte access to the main memory is possible only via cache in the TEG environment.

Therefore, `MI_SwapWord()` should be used for main memory.

## Internal Operation

This swaps using the ARM instructions `swp` or `swpb`.

## Arguments

`setData` | The data that is set
`destp` | Pointer to the swap destination

## Return Values

Value stored in the swap destination immediately prior to the swap.

## See Also

None.

## Revision History

10/18/2004 Corrected the description of byte access.
02/10/2004 Initial version.