/****************************************************************************** * * Title : primFunc_copyMemory.c * Version 0.0 * * Description: copy memory primitive function. * Related files: * * Author: Lukas Tomasek, tomasekl@fzu.cz * ******************************************************************************/ /****************************************************************************** * Header files * ******************************************************************************/ #include #include "primFunc_copyMemory.h" #include "globalDefinitions.h" #include "primParamsUir.h" #include "uirUtility.h" #include #include "primFunctionInit.h" /****************************************************************************** * Global functions * ******************************************************************************/ /*============================================================================= * primFunction_copyMemory() *============================================================================= * * * */ ERROR_ID primFunction_copyMemory(PRIM_FUNC_OPTION funcOption, struct PRIM_TABLE *primTable, void *primitive, UINT32 inputParameter, UINT8 slotNumber){ FILE *file; struct MSG_HEAD* primHeader=(struct MSG_HEAD*) primitive; UINT32 *primDataPtr=(UINT32*)((UINT32)primHeader+sizeof(struct MSG_HEAD)); ERROR_ID errorId=SUCCESS; int status; struct COPY_MEMORY_IN *copyMemory=&primTable->params.copyMemory; const int panel=global.panel.primEdit[getPrimArrayId(COPY_MEMORY)]; if(R_COPY_MEMORY!=R_COPY_MEMORY_HOST){ // ERROR_CHECK(PROGRAM_ERROR, primitive COPY_MEMORY - wrong revision number); return(PROGRAM_ERROR); } switch(funcOption){ case PRIM_PANEL_TO_TABLE: GetCtrlVal(panel, CPY_MEMP_SOURCE, (UINT32*)©Memory->source); GetCtrlVal(panel, CPY_MEMP_DESTINATION, (UINT32*)©Memory->destination); GetCtrlVal(panel, CPY_MEMP_SIZE, ©Memory->size); /* NO BREAK HERE!!!*/ case PRIM_PARAMS_TO_TABLE: /* add table headers - don't set indexes!!! */ primTable->inPrimHeader.length=SIZEOF(struct COPY_MEMORY_IN)+SIZEOF(struct MSG_HEAD); primTable->inPrimHeader.id=COPY_MEMORY; primTable->inPrimHeader.primRevision=R_COPY_MEMORY; primTable->replyLength=0; /* no reply data */ break; case PRIM_TABLE_TO_PANEL: if(primTable->inPrimHeader.primRevision!=R_COPY_MEMORY){ ERROR_CHECK(PROGRAM_ERROR, primitive COPY_MEMORY - wrong revision number); return(PROGRAM_ERROR); } SetCtrlVal(panel, CPY_MEMP_SOURCE, (unsigned int)copyMemory->source); SetCtrlVal(panel, CPY_MEMP_DESTINATION, (unsigned int)copyMemory->destination); SetCtrlVal(panel, CPY_MEMP_SIZE, copyMemory->size); break; case PRIM_BUILD: /* copy data */ *(struct COPY_MEMORY_IN*)(primDataPtr)=*copyMemory; break; case REP_DATA_PROCESS: /* no reply */ break; case WRITE_TO_FILE: file=(FILE*)inputParameter; fprintf(file, "*source= 0x%X, *destination= 0x%X, size= 0x%X\n", (UINT32)copyMemory->source, (UINT32)copyMemory->destination, copyMemory->size); break; case READ_FROM_FILE: file=(FILE*)inputParameter; status=fscanf(file, "*source= 0x%X, *destination= 0x%X, size= 0x%X\n", (UINT32*)©Memory->source, (UINT32*)©Memory->destination, ©Memory->size); if(status==-1) {ERROR_CHECK(FATAL_ERROR, Read from prim file error!); return(FATAL_ERROR);} break; default: ; } return(SUCCESS); } /******************************************************************************/