/************************************************************************* $Archive: /PACS/OnBoard/m_smcsin.c $ $Revision: 1.10 $ $Date: 2009/04/23 13:51:12 $ $Author: amazy $ $Log: m_smcsin.c,v $ Revision 1.10 2009/04/23 13:51:12 amazy 6.029 * * 4 28/08/02 11:49 Amazy * Added the header with the history log *************************************************************************/ /***************************************************************************** * * Project name: Herschel PACS DEC-MEC * Product name: DM_LLDRV * Object name: m_smcsin * Filename: %M% * Language: C (ADSP-21020) * Compiler: G21K - r3.3 * Company: CRISA * Author: F. Torrero * Version: %I% * Creation date: 25/Mar/2002 * Last Modification date: %G% * * Description =============================================================== * * This module implements SMCS sub-interrupts management functions for two * SMCS chips * * Change log =============================================================== * * | DATE | NEW VERSION | AUTHOR | REASON FOR CHANGE | * =========================================================================== * * 25/Mar/02 1 F.Torrero Creation * * ****************************************************************************/ /***************************************************************************** INCLUDES *****************************************************************************/ #include "l_gendef.h" #include "l_errcod.h" #include "m_smcsge.h" #include "m_smcsin.h" /***************************************************************************** PRIVATE CONSTANTS *****************************************************************************/ /***************************************************************************** PRIVATE TYPES *****************************************************************************/ /***************************************************************************** PRIVATE VARIABLES *****************************************************************************/ /***************************************************************************** DECLARATION OF PRIVATE FUNCTIONS *****************************************************************************/ /***************************************************************************** IMPLEMENTATION OF FUNCTIONS *****************************************************************************/ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_MaskUnmaskSMCSSubInt * * DESCRIPTION * In the specified SMCS chip, Mask/Unmask the interrupts specified by the * input Bit-mask. If bit in Bit-mask =1 then Mask/Unmask appropriate * interrupt, interrupts corresponding to bits that are =0 in Bit-mask are * unaffected. * * INPUT ARGUMENTS: * SMCSChip * Interrupt BitMask * Mask/Unmask flag * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Status Return * * PSEUDOCODE * Calculate IMR address depending on SMCS chip * Read current value of SMCS/IMR * If Flag=Mask then * New IMR value = current value AND BitMask * else (unmask) * New IMR value = current value OR (NOT BitMask) * Write New value to SMCS/IMR * Return OK *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_MaskUnmaskSMCSSubInt(T_UNSIGNED_32 SMCSChip, T_UNSIGNED_32 InterruptBitMask, T_UNSIGNED_32 MaskUnmaskFlag) { T_UNSIGNED_32 IMRCurrentValue=0; T_UNSIGNED_32 IMRNewValue=0; T_UNSIGNED_32 IMRAddress=0; /* Calculate IMR address depending on SMCS chip */ if (SMCSChip==K_SMCS_1) { IMRAddress = K_DMADD_SMCS1_IMR; } else { /* SMCSchip is 2 */ IMRAddress = K_DMADD_SMCS2_IMR; } DSMCS_ReadSMCSReg(IMRAddress,&IMRCurrentValue); if(MaskUnmaskFlag==K_MASK) { IMRNewValue= IMRCurrentValue & (~InterruptBitMask); } else { /* Unmask */ IMRNewValue= IMRCurrentValue | InterruptBitMask; } DSMCS_WriteSMCSReg(IMRAddress,IMRNewValue); return(K_SR_OK); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_GetSMCSIMR * * DESCRIPTION * Read the Interrupt mask register of specified SMCS * * INPUT ARGUMENTS: * None * * OUTPUT ARGUMENTS: * Interrupt mask register value * * RETURNED VALUE: * Status Return * * PSEUDOCODE * Calculate IMR address depending on SMCS chip * Read IMR and store value in output argument * Return OK *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_GetSMCSIMR(T_UNSIGNED_32 SMCSChip, T_UNSIGNED_32 *InterruptMaskRegValue) { T_UNSIGNED_32 IMRAddress=0; /* Calculate IMR address depending on SMCS chip */ if (SMCSChip==K_SMCS_1) { IMRAddress = K_DMADD_SMCS1_IMR; } else { /* SMCSchip is 2 */ IMRAddress = K_DMADD_SMCS2_IMR; } DSMCS_ReadSMCSReg(IMRAddress,InterruptMaskRegValue); return(K_SR_OK); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_GetSMCSIPR * * DESCRIPTION * Read the Interrupt pending register of specified SMCS * * INPUT ARGUMENTS: * None * * OUTPUT ARGUMENTS: * Interrupt pending register value * * RETURNED VALUE: * Status Return * * PSEUDOCODE * Calculate IPR address and dummy writing address depending on SMCS chip * Read IPR and store value in output argument * Perform workaround, i.e dummy writing in 7F * Return OK * * Note: ISR will be automatically cleared after reading. *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_GetSMCSIPR(T_UNSIGNED_32 SMCSChip, T_UNSIGNED_32 *InterruptPendingRegValue) { T_UNSIGNED_32 IPRAddress=0; T_UNSIGNED_32 DummyWritingAddress=0; /* Calculate IPR address and dummy writing address depending on SMCS chip */ if (SMCSChip==K_SMCS_1) { IPRAddress = K_DMADD_SMCS1_ISR; DummyWritingAddress=K_DMADD_SMCS1_DUMMY; } else { /* SMCSchip is 2 */ IPRAddress = K_DMADD_SMCS2_ISR; DummyWritingAddress=K_DMADD_SMCS2_DUMMY; } DSMCS_ReadSMCSReg(IPRAddress,InterruptPendingRegValue); /* Workaround (dummy writing) */ DSMCS_WriteSMCSReg(DummyWritingAddress,0); return(K_SR_OK); } /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: DSMCS_ClearSMCSIPR * * DESCRIPTION * Clear the Interrupt pending register of SMCS * * INPUT ARGUMENTS: * None * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Status Return * * PSEUDOCODE * Read ISR in order to clear it * Return OK *---------------------------------------------------------------------- $#$ */ T_SR DSMCS_ClearSMCSIPR(T_UNSIGNED_32 SMCSChip) { T_UNSIGNED_32 ISRValue=0; /* Used just to perform the reading */ DSMCS_GetSMCSIPR(SMCSChip, &ISRValue); return(K_SR_OK); }