/************************************************************************* $Archive: /PACS/OnBoard/l_memasm.s $ $Revision: 1.10 $ $Date: 2009/04/23 13:51:12 $ $Author: amazy $ $Log: l_memasm.s,v $ Revision 1.10 2009/04/23 13:51:12 amazy 6.029 ; ; 3 5/23/03 8:21a Pacs Egse ; Added 2 commands to start the link to SPU + writing to EEPROM ; implemented ; ; 2 28/08/02 11:49 Amazy ; Added the header with the history log *************************************************************************/ /***************************************************************************** * * Project name: Plank LFI REBA / Herschel PACS SPU * Product name: LLSW_DRV * Object name: l_memory * Filename: %M% * Language: C (ADSP-21020) * Compiler: G21K - r3.3 * Company: CRISA * Author: F. Torrero * Version: %I% * Creation date: 31/Ago/2001 * Last Modification date: %G% * * Description =============================================================== * * This module defines/implements constants related to the memory map and * functions for memory access * * Change log =============================================================== * * | DATE | NEW VERSION | AUTHOR | REASON FOR CHANGE | * =========================================================================== * * 31/Ago/01 1 F.Torrero Creation * * ****************************************************************************/ /***************************************************************************** INCLUDES *****************************************************************************/ #include #include /***************************************************************************** PRIVATE CONSTANTS *****************************************************************************/ /***************************************************************************** PRIVATE TYPES *****************************************************************************/ /***************************************************************************** PRIVATE VARIABLES *****************************************************************************/ /***************************************************************************** DECLARATION OF PRIVATE FUNCTIONS *****************************************************************************/ /***************************************************************************** IMPLEMENTATION OF FUNCTIONS *****************************************************************************/ .SEGMENT /pm seg_pmco; .GLOBAL _MEM_ReadDMWord; .GLOBAL _MEM_ReadPM32bitMSWord; .GLOBAL _MEM_ReadPM16bitLSWord; .GLOBAL _MEM_WriteDMWord; .GLOBAL _MEM_WritePMWord; .GLOBAL _MEM_CopyPMToPM; /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_ReadDMWord * * DESCRIPTION * Return the value contained in the specified DM address * * INPUT ARGUMENTS: * Data Memory Address * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Value (32bits) * * USED REGISTERS * r4 = Data Memory Address to be read * r0 = Data value read * r5 -> scratch * i0 -> Data Memory Position * * PSEUDOCODE * Save context * Read a DM word * return value * restore context *---------------------------------------------------------------------- $#$ */ _MEM_ReadDMWord: leaf_entry; /* Save registers */ puts = r5; r5 = i0; puts = r5; /* i0*/ /* return dm word*/ i0 = r4; r0 = dm(0, i0); /* Restore used registers*/ r5 = gets(1); /* i0*/ i0 = r5; r5 = gets(2); alter(2); leaf_exit; /* End of _MEM_ReadDMWord */ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_ReadPM32bitMSWord * * DESCRIPTION * Return the value of the MS 32bit word contained in the specified * PM address * * INPUT ARGUMENTS: * Data Memory Address * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Value (32MSbits) * * USED REGISTERS * r4 = Program Memory Address to be read * r0 = Data value read (32MSbits) * r5 -> scratch * px -> To access Program Memory * i10, m10 -> Program Memory Position * * PSEUDOCODE * Save context * Read a PM word * Get the MS 32bit word stored in px2 * return value * restore context *---------------------------------------------------------------------- $#$ */ _MEM_ReadPM32bitMSWord: leaf_entry; /* Save registers */ puts = r5; puts = i10; puts = m10; r5 = px1; puts = r5; /* px1*/ r5 = px2; puts = r5; /* px2*/ /* Return pm high 32 bits*/ i10 = r4; m10 = 0; px = pm(m10, i10); r0 = px2; /* Restore used registers*/ r5 = gets(1); /* px2*/ px2 = r5; r5 = gets(2); /* px1*/ px1 = r5; m10 = gets(3); i10 = gets(4); r5 = gets(5); alter(5); leaf_exit; /* End of _MEM_ReadPM32bitMSWord */ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_ReadPM16bitLSWord * * DESCRIPTION * Return the value of the LS 16bit word contained in the specified * PM address * * INPUT ARGUMENTS: * Data Memory Address * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * Value (16LSbits) * * USED REGISTERS * r4 = Program Memory Address to be read * r0 = Data value read (16LSbits) * r5 -> scratch * px -> To access Program Memory * i10, m10 -> Program Memory Position * * PSEUDOCODE * Save context * Read a PM word * Get the MS 16bit word stored in px1 * return value * restore context *---------------------------------------------------------------------- $#$ */ _MEM_ReadPM16bitLSWord: leaf_entry; /* Save registers */ puts = r5; puts = i10; puts = m10; r5 = px1; puts = r5; /* px1*/ r5 = px2; puts = r5; /* px2*/ /* return pm low 16 bits*/ i10 = r4; m10 = 0; px = pm(m10, i10); r0 = px1; /* Restore used registers*/ r5 = gets(1); /* px2*/ px2 = r5; r5 = gets(2); /* px1*/ px1 = r5; m10 = gets(3); i10 = gets(4); r5 = gets(5); alter(5); leaf_exit; /* End of _MEM_ReadPM16bitLSWord */ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_WriteDMWord * * DESCRIPTION * Writes the provided 32bit value in specified DM address * * INPUT ARGUMENTS: * Data Memory Address * 32bit Value * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * None * * USED REGISTERS * r4 = Data Memory Address * r8 = Value * r5 -> scratch * i0 -> Data Memory Position * * PSEUDOCODE * Save context * Write DM Word * restore context *---------------------------------------------------------------------- $#$ */ _MEM_WriteDMWord: leaf_entry; /* Saving registers */ puts = r5; r5 = i0; puts = r5; /* i0*/ /* Write Dm word */ i0 = r4; dm(0, i0) = r8; /* Restoring used registers*/ r5 = gets(1); /* i0*/ i0 = r5; r5 = gets(2); alter(2); leaf_exit; /* End of _MEM_WriteDMWord */ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_WritePMWord * * DESCRIPTION * Writes the provided 32bit+16bit value in specified PM address * * INPUT ARGUMENTS: * Prgram Memory Address * 32MSbit Value * 16LSbit Value * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * None * * USED REGISTERS * r4 = Program Memory Address * r8 = 32MSbits * r12 = 16LSbits * r5 -> scratch * px -> To access Program Memory * i10,m10 -> Program Memory Position * * PSEUDOCODE * Save context * Write PM Word * restore context *---------------------------------------------------------------------- $#$ */ _MEM_WritePMWord: leaf_entry; /* Saving registers */ puts = r5; puts = i10; puts = m10; r5 = px1; puts = r5; /* px1*/ r5 = px2; puts = r5; /* px2*/ /* Write Pm word*/ i10 = r4; m10 = 0; px2 = r8; px1 = r12; pm(m10, i10) = px; /* Restoring used registers*/ r5 = gets(1); /* px2*/ px2 = r5; r5 = gets(2); /* px1*/ px1 = r5; m10 = gets(3); i10 = gets(4); r5 = gets(5); alter(5); leaf_exit; /* End of _MEM_WritePMWord */ /* #$# ----------------------------------------------------------------------- * FUNCTION NAME: _MEM_CopyPMToPM * * DESCRIPTION * Copy buffer from generic Program memory to generic Program memory (48bit * words) * * INPUT ARGUMENTS: * Program Memory Start Address (source) * Program Memory Start Address (destination) * Number of 48bit words to be copied * * OUTPUT ARGUMENTS: * None * * RETURNED VALUE: * None * * USED REGISTERS * r4 = PM source start address (parameter) * r8 = PM destination Start address (parameter) * r12 = Number of 48bit words to be copied * r5 = Used to perform various operations * px, px1 and px2 = Used to transfer data * i10 = pointer to Program RAM area (source) * i11 = pointer to EEPROM RAM area (destination) * m10 = increment register used for both i10 and i11 * * PSEUDOCODE * Save context * Initialize values of i10 (=r4), i11(=r8) and m10(=1) * Perform writing loop for the number of words specified in r12: * px = PM source value (i10) * PM destination (i11) = px * restore context * * Note: This function is intended to be used for writing to EEPROM, so * the restriction that each word must be written within 150us * of the previous word is taken into account within this function. * However, note that this function does not perform any check on * page boundaries, trying to write into whatever memory area is * specified by the parameters. *---------------------------------------------------------------------- $#$ */ _MEM_CopyPMToPM: leaf_entry; /* Save context */ puts = r5; puts = i10; puts = i11; puts = m10; r5 = px1; puts = r5; /* px1*/ r5 = px2; puts = r5; /* px2*/ /* Initialize values */ i10 = r4; i11 = r8; m10 = 1; /* Perform writing loop */ lcntr = r12, do End_Writing_Loop until lce; px = pm(i10,m10); End_Writing_Loop: pm(i11,m10) = px; /* Restore context */ r5 = gets(1); /* px2*/ px2 = r5; r5 = gets(2); /* px1*/ px1 = r5; m10 = gets(3); i11 = gets(4); i10 = gets(5); r5 = gets(6); alter(6); leaf_exit; /* End of _MEM_CopyPMToPM */ .ENDSEG;