📄 mu.c
字号:
/* ===========================================================================
* TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
*
* Property of Texas Instruments -- For Unrestricted Internal Use Only
* Unauthorized reproduction and/or distribution is strictly prohibited. This
* product is protected under copyright law and trade secret law as an
* unpublished work. Created 2002, (C) Copyright 2002 Texas Instruments. All
* rights reserved.
*
* Filename : mu.c
*
* Description : Memory Utilities
* Project : omap1610
*
* Author : Rajko
*
* ===========================================================================*/
#include "global_types.h"
#ifdef DSP_ACCESS
#define DSP_ADJUST >> 1
#else
#define DSP_ADJUST
#endif
/*----------------------------------------------------------------------------
* NAME : MU_Mem32ConstFill
*
* DESCRIPTION : Fill memory with constant data
*
* PARAMETERS : StartAddress - pointer to start address
* Length - Number of UWORD32 to write
* Pattern - Value
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem32ConstFill( UWORD32 *StartAddress,
UWORD32 Length,
UWORD32 Pattern )
{
UWORD32 count;
UWORD32 *addr;
UWORD32 tmp_l;
tmp_l = (UWORD32)StartAddress;
for ( count = 0; count < Length; count++ ) {
addr = (UWORD32 *)tmp_l;
*addr = Pattern;
tmp_l += (4 DSP_ADJUST);
}
} /* MU_Mem32ConstFill() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem32RampFill
*
* DESCRIPTION : Fill memory with ramp data ored with pattern
*
* PARAMETERS : StartAddress - pointer to start address
* Length - Number of UWORD32 to write
* Pattern - Value ORed with ramp data
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem32RampFill( UWORD32 *StartAddress,
UWORD32 Length,
UWORD32 Pattern )
{
UWORD32 count;
UWORD32 *addr;
UWORD32 tmp_l;
tmp_l = (UWORD32)StartAddress;
for ( count = 0; count < Length; count++ ) {
addr = (UWORD32 *)tmp_l;
*addr = count | Pattern;
tmp_l += (4 DSP_ADJUST);
}
} /* MU_Mem32RampFill() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem32Compare
*
* DESCRIPTION : Compare two buffers
*
* PARAMETERS : B1Address - pointer to start address of Buff 1
* B2Address - pointer to start address of Buff 1
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : UWORD32
* 0 - Buffers are same
* n - Number of values not identical in two buffers
*
*----------------------------------------------------------------------------*/
UWORD32 MU_Mem32Compare( UWORD32 *B1Address,
UWORD32 *B2Address,
UWORD32 Length )
{
UWORD32 count;
UWORD32 *b1;
UWORD32 *b2;
UWORD32 tmp_l1;
UWORD32 tmp_l2;
UWORD32 error_count;
tmp_l1 = (UWORD32)B1Address;
tmp_l2 = (UWORD32)B2Address;
error_count = 0L;
for ( count = 0; count < Length; count++ ) {
b1 = (UWORD32 *)tmp_l1;
b2 = (UWORD32 *)tmp_l2;
if ( *b1 != *b2 )
error_count ++;
tmp_l1 += (4 DSP_ADJUST);
tmp_l2 += (4 DSP_ADJUST);
}
return error_count;
} /* MU_Mem32Compare() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem32CompareValue
*
* DESCRIPTION : Compare two buffers
*
* PARAMETERS : B1Address - pointer to start address of Buffer
* value - Value to compare with
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : UWORD32
* 0 - Buffers are same
* n - Number of values not identical in two buffers
*
*----------------------------------------------------------------------------*/
UWORD32 MU_Mem32CompareValue( UWORD32 *B1Address,
UWORD32 value,
UWORD32 Length )
{
UWORD32 count;
UWORD32 *b1;
UWORD32 tmp_l1;
UWORD32 error_count;
tmp_l1 = (UWORD32)B1Address;
error_count = 0L;
for ( count = 0; count < Length; count++ ) {
b1 = (UWORD32 *)tmp_l1;
if ( *b1 != value )
error_count ++;
tmp_l1 += (4 DSP_ADJUST);
}
return error_count;
} /* MU_Mem32CompareValue() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem32Copy
*
* DESCRIPTION : Copy 32 bit buffers
*
* PARAMETERS : Destination - pointer to where to Buffer
* Source - pointer to where from Buffer
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem32Copy( UWORD32 *Destination,
UWORD32 *Source,
UWORD32 Length )
{
UWORD32 count;
UWORD32 *dst;
UWORD32 *src;
UWORD32 tmp_l1;
UWORD32 tmp_l2;
tmp_l1 = (UWORD32)Destination;
tmp_l2 = (UWORD32)Source;
for ( count = 0; count < Length; count++ ) {
dst = (UWORD32 *)tmp_l1;
src = (UWORD32 *)tmp_l2;
*dst = *src;
tmp_l1 += (4 DSP_ADJUST);
tmp_l2 += (4 DSP_ADJUST);
}
} /* MU_Mem32Copy() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem16ConstFill
*
* DESCRIPTION : Fill memory with constant data
*
* PARAMETERS : StartAddress - pointer to start address
* Length - Number of UWORD16 to write
* Pattern - Value
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem16ConstFill( UWORD16 *StartAddress,
UWORD32 Length,
UWORD16 Pattern )
{
UWORD32 count;
UWORD16 *addr;
UWORD32 tmp_l;
tmp_l = (UWORD32)StartAddress;
for ( count = 0; count < Length; count++ ) {
addr = (UWORD16 *)tmp_l;
*addr = Pattern;
tmp_l += (2 DSP_ADJUST);
}
} /* MU_Mem16ConstFill() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem16RampFill
*
* DESCRIPTION : Fill memory with ramp data ored with pattern
*
* PARAMETERS : StartAddress - pointer to start address
* Length - Number of UWORD16 to write
* Pattern - Value ORed with ramp data
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem16RampFill( UWORD16 *StartAddress,
UWORD32 Length,
UWORD16 Pattern )
{
UWORD32 count;
UWORD16 *addr;
UWORD32 tmp_l;
tmp_l = (UWORD32)StartAddress;
for ( count = 0; count < Length; count++ ) {
addr = (UWORD16 *)tmp_l;
*addr = (UWORD16)count | Pattern;
tmp_l += (2 DSP_ADJUST);
}
} /* MU_Mem16RampFill() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem16Compare
*
* DESCRIPTION : Compare two buffers
*
* PARAMETERS : B1Address - pointer to start address of Buff 1
* B2Address - pointer to start address of Buff 1
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : UWORD32
* 0 - Buffers are same
* n - Number of values not identical in two buffers
*
*----------------------------------------------------------------------------*/
UWORD16 MU_Mem16Compare( UWORD16 *B1Address,
UWORD16 *B2Address,
UWORD32 Length )
{
UWORD32 count;
UWORD16 *b1;
UWORD16 *b2;
UWORD32 tmp_l1;
UWORD32 tmp_l2;
UWORD32 error_count;
tmp_l1 = (UWORD32)B1Address;
tmp_l2 = (UWORD32)B2Address;
error_count = 0L;
for ( count = 0; count < Length; count++ ) {
b1 = (UWORD16 *)tmp_l1;
b2 = (UWORD16 *)tmp_l2;
if ( *b1 != *b2 )
error_count ++;
tmp_l1 += (2 DSP_ADJUST);
tmp_l2 += (2 DSP_ADJUST);
}
return error_count;
} /* MU_Mem16Compare() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem16CompareValue
*
* DESCRIPTION : Compare two buffers
*
* PARAMETERS : B1Address - pointer to start address of Buffer
* value - Value to compare with
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : UWORD32
* 0 - Buffers are same
* n - Number of values not identical in two buffers
*
*----------------------------------------------------------------------------*/
UWORD32 MU_Mem16CompareValue( UWORD16 *B1Address,
UWORD32 value,
UWORD32 Length )
{
UWORD32 count;
UWORD16 *b1;
UWORD32 tmp_l1;
UWORD32 error_count;
tmp_l1 = (UWORD32)B1Address;
error_count = 0L;
for ( count = 0; count < Length; count++ ) {
b1 = (UWORD16 *)tmp_l1;
if ( *b1 != value )
error_count ++;
tmp_l1 += (2 DSP_ADJUST);
}
return error_count;
} /* mem16_coompare_value() */
/*----------------------------------------------------------------------------
* NAME : MU_Mem16Copy
*
* DESCRIPTION : Copy 16 bit buffers
*
* PARAMETERS : Destination - pointer to where to Buffer
* Source - pointer to where from Buffer
* Length - Number of UWORD32 to compare
*
* RETURN VALUE : None
*
*----------------------------------------------------------------------------*/
void MU_Mem16Copy( UWORD16 *Destination,
UWORD16 *Source,
UWORD32 Length )
{
UWORD32 count;
UWORD16 *dst;
UWORD16 *src;
UWORD32 tmp_l1;
UWORD32 tmp_l2;
tmp_l1 = (UWORD32)Destination;
tmp_l2 = (UWORD32)Source;
for ( count = 0; count < Length; count++ ) {
dst = (UWORD16 *)tmp_l1;
src = (UWORD16 *)tmp_l2;
*dst = *src;
tmp_l1 += (2 DSP_ADJUST);
tmp_l2 += (2 DSP_ADJUST);
}
} /* MU_Mem16Copy() */
/* Nothing past this point */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -