wct4xxp: Reduce stack usage in oct612x API.

Reduce the stack usage by replacing the mOCT6100_RETRIEVE_NLP_CONF_DWORD
and mOCT6100_SAVE_NLP_CONF_DWORD macros with functions. Some compilers
do a better job of optimizing the local variables declared in those
macros than others.

For example, with gcc 4.3.0, running

]# make stackcheck | grep Oct6100 | head -n 20 | sed -e 's/^0\S* //g' | uniq

Before:
Oct6100ApiWriteVqeNlpMemory [wct4xxp]:  1112
Oct6100ApiInvalidateChanPlayoutStructs [wct4xxp]:520
Oct6100ApiSetChannelLevelControl [wct4xxp]:     392
Oct6100ApiBridgeEventRemove [wct4xxp]:  344
Oct6100ApiDebugChannelOpen [wct4xxp]:   312
Oct6100ApiWriteVqeAfMemory [wct4xxp]:   296
Oct6100ApiSetChannelTailConfiguration [wct4xxp]:264
Oct6100ApiRandomMemoryWrite [wct4xxp]:  248
Oct6100ApiTransferToneEvents [wct4xxp]: 248
Oct6100ApiModifyChannelStructs [wct4xxp]:       232

After:
Oct6100ApiBridgeEventRemove [wct4xxp]:  344
Oct6100ApiDebugChannelOpen [wct4xxp]:   312
Oct6100ApiRandomMemoryWrite [wct4xxp]:  248
Oct6100ApiTransferToneEvents [wct4xxp]: 248
Oct6100ApiInvalidateChanPlayoutStructs [wct4xxp]:248
Oct6100ApiModifyChannelStructs [wct4xxp]:       232
Oct6100ApiBridgeRemoveParticipantFromChannel [wct4xxp]:216
Oct6100ApiWriteVqeNlpMemory [wct4xxp]:  200
Oct6100ApiInitChannels [wct4xxp]:               168
Oct6100ApiProgramNLP [wct4xxp]:         168

Signed-off-by: Shaun Ruffell <sruffell@digium.com>

Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=9751

git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/branches/2.4@9754 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
Shaun Ruffell
2011-02-10 16:29:47 +00:00
parent 5c039eea69
commit 02fe6beeb4
9 changed files with 271 additions and 383 deletions

View File

@@ -47,6 +47,7 @@ $Octasic_Revision: 89 $
#include "oct6100api/oct6100_remote_debug_inst.h"
#include "oct6100api/oct6100_debug_inst.h"
#include "oct6100api/oct6100_api_inst.h"
#include "oct6100api/oct6100_channel_inst.h"
#include "oct6100api/oct6100_interrupts_pub.h"
#include "oct6100api/oct6100_chip_open_pub.h"

View File

@@ -2703,11 +2703,10 @@ UINT32 Oct6100ApiBridgeEventAdd(
UINT32 ulFeatureBitOffset = pSharedInfo->MemoryMap.RinLevelControlOfst.byBitOffset;
UINT32 ulFeatureFieldLength = pSharedInfo->MemoryMap.RinLevelControlOfst.byFieldSize;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChanEntry,
ulBaseAddress + ulFeatureBytesOffset,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -2720,11 +2719,10 @@ UINT32 Oct6100ApiBridgeEventAdd(
ulTempData |= ( cOCT6100_PASS_THROUGH_LEVEL_CONTROL << ulFeatureBitOffset );
/* First read the DWORD where the field is located. */
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChanEntry,
ulBaseAddress + ulFeatureBytesOffset,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
@@ -7583,11 +7581,10 @@ UINT32 Oct6100ApiBridgeSetDominantSpeaker(
ulFeatureFieldLength = f_pApiInstance->pSharedInfo->MemoryMap.DominantSpeakerFieldOfst.byFieldSize;
/* Retrieve the current configuration. */
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChanEntry,
ulBaseAddress + ulFeatureBytesOffset,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -7598,11 +7595,10 @@ UINT32 Oct6100ApiBridgeSetDominantSpeaker(
ulTempData |= ( ( f_usDominantSpeakerIndex ) << ulFeatureBitOffset );
/* Save the new dominant speaker. */
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChanEntry,
ulBaseAddress + ulFeatureBytesOffset,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;

View File

@@ -1241,11 +1241,10 @@ UINT32 Oct6100BufferPlayoutCheckForSpecificEvent(
}
/* Retrieve the current write pointer. */
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulPlayoutBaseAddress + ulWritePtrBytesOfst,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;

View File

@@ -51,6 +51,7 @@ $Octasic_Revision: 81 $
#include "oct6100api/oct6100_events_pub.h"
#include "oct6100api/oct6100_channel_pub.h"
#include "oct6100api/oct6100_interrupts_pub.h"
#include "oct6100api/oct6100_channel_inst.h"
#include "oct6100_chip_open_priv.h"
#include "oct6100_miscellaneous_priv.h"

View File

@@ -52,6 +52,7 @@ $Octasic_Revision: 46 $
#include "oct6100api/oct6100_chip_open_pub.h"
#include "oct6100api/oct6100_channel_pub.h"
#include "oct6100api/oct6100_phasing_tsst_pub.h"
#include "oct6100api/oct6100_channel_inst.h"
#include "oct6100_chip_open_priv.h"
#include "oct6100_miscellaneous_priv.h"

View File

@@ -2398,11 +2398,10 @@ UINT32 Oct6100ApiWriteChanPlayoutStructs(
/* Cleared! */
ulTempData &= ( ~ulMask );
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -2422,11 +2421,10 @@ UINT32 Oct6100ApiWriteChanPlayoutStructs(
/* Cleared! */
ulTempData &= ( ~ulMask );
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
@@ -2471,11 +2469,10 @@ UINT32 Oct6100ApiWriteChanPlayoutStructs(
ulTempData &= ( ~ulMask );
ulTempData |= *pulSkipPtr << ulSkipPtrBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -2501,11 +2498,10 @@ UINT32 Oct6100ApiWriteChanPlayoutStructs(
ulTempData &= ( ~ulMask );
ulTempData |= ulWritePtr << ulWritePtrBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -2912,7 +2908,7 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
/* Get the write pointer in the chip. */
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulReadData, ulResult );
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance, pEchoChannel, ulAddress, &ulReadData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -2984,11 +2980,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
{
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3000,11 +2995,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
ulTempData |= 0x1 << ulIgnoreBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}
@@ -3017,7 +3011,7 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
ulAddress = ulPlayoutBaseAddress + ulWritePtrBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance, pEchoChannel, ulAddress, &ulTempData, ulResult );
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance, pEchoChannel, ulAddress, &ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3026,11 +3020,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
ulTempData &= ( ~ulMask );
ulTempData |= ulWritePtr << ulWritePtrBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3042,11 +3035,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
ulAddress = ulPlayoutBaseAddress + ulSkipPtrBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3055,11 +3047,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
ulTempData &= ( ~ulMask );
ulTempData |= ulSkipPtr << ulSkipPtrBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3076,11 +3067,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
{
ulAddress = ulPlayoutBaseAddress + ulHardSkipBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3092,22 +3082,20 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
if ( f_pBufferPlayoutStop->fStopCleanly == FALSE )
ulTempData |= 0x1 << ulHardSkipBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
/* Now is the appropriate time to skip! */
ulAddress = ulPlayoutBaseAddress + ulIgnoreBytesOfst;
mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_retrieve_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
&ulTempData,
ulResult );
&ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
@@ -3118,11 +3106,10 @@ UINT32 Oct6100ApiInvalidateChanPlayoutStructs(
/* Set the skip bit. */
ulTempData |= 0x1 << ulIgnoreBitOfst;
mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInstance,
ulResult = oct6100_save_nlp_conf_dword(f_pApiInstance,
pEchoChannel,
ulAddress,
ulTempData,
ulResult );
ulTempData);
if ( ulResult != cOCT6100_ERR_OK )
return ulResult;
}

View File

@@ -51,6 +51,7 @@ $Octasic_Revision: 113 $
#include "oct6100api/oct6100_channel_pub.h"
#include "oct6100api/oct6100_chip_open_pub.h"
#include "oct6100api/oct6100_channel_inst.h"
#include "oct6100_chip_open_priv.h"
#include "oct6100_miscellaneous_priv.h"

View File

@@ -208,101 +208,6 @@ $Octasic_Revision: 20 $
#define mOCT6100_ASSIGN_USER_READ_WRITE_OBJ( f_pApiInst, Params )
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: mOCT6100_RETRIEVE_NLP_CONF_DWORD
Description: This function is used by the API to store on a per channel basis
the various confguration DWORD from the device. The API performs
less read to the chip that way since it is always in synch
with the chip.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
IN f_pApiInst Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
IN f_pChanEntry Pointer to an API channel structure..
IN f_ulAddress Address that needs to be modified..
IN f_pulConfigDword Pointer to the content stored in the API located at the
desired address.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#define mOCT6100_RETRIEVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_pulConfigDword, f_ulResult ) \
{ \
tOCT6100_READ_PARAMS _ReadParams; \
UINT16 _usReadData; \
f_ulResult = cOCT6100_ERR_FATAL_8E; \
(*f_pulConfigDword) = cOCT6100_INVALID_VALUE; \
\
_ReadParams.pProcessContext = f_pApiInst->pProcessContext; \
mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _ReadParams); \
_ReadParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \
_ReadParams.pusReadData = &_usReadData; \
\
/* Read the first 16 bits.*/ \
_ReadParams.ulReadAddress = f_ulAddress; \
mOCT6100_DRIVER_READ_API(_ReadParams, f_ulResult); \
if (f_ulResult == cOCT6100_ERR_OK) { \
/* Save data.*/ \
(*f_pulConfigDword) = _usReadData << 16; \
\
/* Read the last 16 bits .*/ \
_ReadParams.ulReadAddress += 2; \
mOCT6100_DRIVER_READ_API(_ReadParams, f_ulResult); \
if (f_ulResult == cOCT6100_ERR_OK) { \
/* Save data.*/ \
(*f_pulConfigDword) |= _usReadData; \
f_ulResult = cOCT6100_ERR_OK; \
} \
} \
} \
/*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\
Function: mOCT6100_SAVE_NLP_CONF_DWORD
Description: This function stores a configuration Dword within an API channel
structure and then writes it into the chip.
-------------------------------------------------------------------------------
| Argument | Description
-------------------------------------------------------------------------------
IN f_pApiInst Pointer to API instance. This memory is used to keep
the present state of the chip and all its resources.
IN f_pChanEntry Pointer to an API channel structure..
IN f_ulAddress Address that needs to be modified..
IN f_pulConfigDword content to be stored in the API located at the
desired address.
\*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
#define mOCT6100_SAVE_NLP_CONF_DWORD( f_pApiInst, f_pChanEntry, f_ulAddress, f_ulConfigDword, f_ulResult ) \
{ \
/* Write the config DWORD. */ \
tOCT6100_WRITE_PARAMS _WriteParams; \
\
_WriteParams.pProcessContext = f_pApiInst->pProcessContext; \
mOCT6100_ASSIGN_USER_READ_WRITE_OBJ(f_pApiInst, _WriteParams) \
_WriteParams.ulUserChipId = f_pApiInst->pSharedInfo->ChipConfig.ulUserChipId; \
\
/* Write the first 16 bits. */ \
_WriteParams.ulWriteAddress = f_ulAddress; \
_WriteParams.usWriteData = (UINT16)((f_ulConfigDword >> 16) & 0xFFFF); \
mOCT6100_DRIVER_WRITE_API(_WriteParams, f_ulResult); \
\
if (f_ulResult == cOCT6100_ERR_OK) { \
/* Write the last word. */ \
_WriteParams.ulWriteAddress = f_ulAddress + 2; \
_WriteParams.usWriteData = (UINT16)(f_ulConfigDword & 0xFFFF); \
mOCT6100_DRIVER_WRITE_API(_WriteParams, f_ulResult); \
} \
}
#define mOCT6100_CREATE_FEATURE_MASK( f_ulFieldSize, f_ulFieldBitOffset, f_pulFieldMask ) \
{ \
(*f_pulFieldMask) = ( 1 << f_ulFieldSize ); \
@@ -361,4 +266,14 @@ UINT8 Oct6100ApiHexToAscii(
UINT32 Oct6100ApiRand(
IN UINT32 f_ulRange );
UINT32 oct6100_retrieve_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
tPOCT6100_API_CHANNEL f_pChanEntry,
UINT32 f_ulAddress,
UINT32 *f_pulConfigDword);
UINT32 oct6100_save_nlp_conf_dword(tPOCT6100_INSTANCE_API f_pApiInst,
tPOCT6100_API_CHANNEL f_pChanEntry,
UINT32 f_ulAddress,
UINT32 f_ulConfigDword);
#endif /* __OCT6100_MISCELLANEOUS_PRIV_H__ */