From c944355198a00e445a205092b8f23bd34cb8af38 Mon Sep 17 00:00:00 2001 From: cvs Date: Thu, 5 Dec 2002 14:28:16 +0000 Subject: [PATCH] - updated simulation --- amortest.tcl | 5 ++--- danu.dat | 2 +- hardsup/sinqhm.c | 2 +- nxamor.c | 9 +++++---- sinqhm/SinqHM_bootParamsConfig.c | 15 +++++++++++++++ sinqhm/SinqHM_gbl.h | 9 +++++++++ sinqhm/SinqHM_srv_main.c | 2 +- sinqhm/SinqHM_srv_routines.c | 28 +++++++++++++++++++++++++++- sinqhm/bldmen | 1 + sinqhmdriv.c | 2 +- 10 files changed, 63 insertions(+), 12 deletions(-) diff --git a/amortest.tcl b/amortest.tcl index 600c3b0e..c26db223 100644 --- a/amortest.tcl +++ b/amortest.tcl @@ -1,4 +1,3 @@ -# # -------------------------------------------------------------------------- # Initialization script for a simulated AMOR instrument # @@ -186,8 +185,8 @@ Motor COX SIM -100. 100. .1 2. # counter x ClientPut "Motors initialized" #======================== histogram memory -#MakeHM hm SinqHM -MakeHM hm SIM +MakeHM hm SinqHM +#MakeHM hm SIM hm configure OverFlowMode Ceil hm configure HistMode PSD hm configure Rank 1 diff --git a/danu.dat b/danu.dat index b6dc33d2..5d94bbff 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 239 + 245 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/hardsup/sinqhm.c b/hardsup/sinqhm.c index 1f384b25..88c389cf 100644 --- a/hardsup/sinqhm.c +++ b/hardsup/sinqhm.c @@ -1021,7 +1021,7 @@ extern int close(int fp); /* initialize the Request data */ Req_buff.bigend = htonl (0x12345678); Req_buff.cmnd = htonl (SQHM_READ); - Req_buff.u.read.n_bins = htonl (iEnd); + Req_buff.u.read.n_bins = htonl (iEnd-iStart); Req_buff.u.read.first_bin = htonl (iStart); Req_buff.u.read.hist_no = htonl (iNum); diff --git a/nxamor.c b/nxamor.c index 9b5f83e7..c258b31f 100644 --- a/nxamor.c +++ b/nxamor.c @@ -394,10 +394,9 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { if( (iDim[1] % i) == 0) { - if(i*chunkSize*sizeof(HistInt) > TOFBLOCK) + if(i*chunkSize*sizeof(HistInt) < TOFBLOCK) { iChunk[1] = i; - break; } } } @@ -422,7 +421,8 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, { memset(lData,0,chunkSize*sizeof(HistInt)); GetHistogramDirect(pHM,pCon, - 0,i*chunkSize,chunkSize,lData,chunkSize*sizeof(HistInt)); + 0,i*chunkSize,(i+1)*chunkSize,lData, + chunkSize*sizeof(HistInt)); /* yield a little in order to allow other clients to receive a response. Also allow for interrupting. @@ -639,7 +639,8 @@ static int WriteTOFDetector(char *name, pHistMem pHM, int *iDim, else { memset(lData,0,MAXSINGLE*iDim[2]*sizeof(HistInt)); - GetHistogramDirect(pHM,pCon,0,iLength,MAXSINGLE*iDim[2], + GetHistogramDirect(pHM,pCon,0,iLength, + iLength + MAXSINGLE*iDim[2], lData, MAXSINGLE*iDim[2]*sizeof(HistInt)); NXDputalias(hfil,hdict,"singleup",lData); NXDaliaslink(hfil,hdict,"singledana","singleup"); diff --git a/sinqhm/SinqHM_bootParamsConfig.c b/sinqhm/SinqHM_bootParamsConfig.c index 8e785959..77eb1d38 100755 --- a/sinqhm/SinqHM_bootParamsConfig.c +++ b/sinqhm/SinqHM_bootParamsConfig.c @@ -166,6 +166,8 @@ #ifdef MV2600 #include "../config/mv2604/config.h" +#elif MEN_A012 +#include "../config/men_824x_ali/config.h" #else #if (CPU == PPC603) #include "../config/mv1603/config.h" @@ -189,6 +191,7 @@ */ #include "SinqHM_def.h" + #define MAX_ACTIONS 8 #define MAX_ARGS 10 #define NIL '\0' @@ -1116,8 +1119,13 @@ taskDelay (1 * sysClkRateGet ()); /* Give lwl_server time to get going */ return True; } + /* **--------------------------------------------------------------------------*/ + +#ifdef MEN_A012 + extern int Hist_base_MEN_alloc; +#endif int sbpc_spawnSinqHM ( /* ================ */ int spnd_flg, /* Suspend flag (arg10) */ @@ -1169,6 +1177,13 @@ return False; } } +#ifdef MEN_A012 + /* + make sure that the memory allocation flag is properly initialized at + the first time + */ + Hist_base_MEN_alloc = 0; +#endif printf ("Spawning SinqHM_srv ..\n TCP/IP port = %d.\n", port); if (use_level_gen == 0) { diff --git a/sinqhm/SinqHM_gbl.h b/sinqhm/SinqHM_gbl.h index d5cce36d..3e0436d3 100755 --- a/sinqhm/SinqHM_gbl.h +++ b/sinqhm/SinqHM_gbl.h @@ -39,6 +39,15 @@ ** by Hist_base_addr. */ void *Hist_base_addr; + /* + ** The MEN board has a divided memory architecture: below 32 MB everything + ** is normal. The area above has to be allocated in a separate memory + ** partition with the partition number stored in sysHighMemPart. This + ** now is a flag which determines if Hist_base_addr has been allocated in + ** such a way in order to be able to free it properly again. + **/ + int Hist_base_MEN_alloc; + /* ** The buffer for holding a frame of data for CERCA type ** interfaces (e.g. HRPT) is pointed to by Frame_base_addr. diff --git a/sinqhm/SinqHM_srv_main.c b/sinqhm/SinqHM_srv_main.c index 622e75d8..6bf8b66d 100755 --- a/sinqhm/SinqHM_srv_main.c +++ b/sinqhm/SinqHM_srv_main.c @@ -151,7 +151,7 @@ Dbg_mask = 0; Dbg_lev0 = 0; - Dbg_lev1 = 1; + Dbg_lev1 = 0; Dbg_lev2 = 0; Dbg_lev3 = 0; Cfgn_done = 0; /* Force a configuration before we can do anything. */ diff --git a/sinqhm/SinqHM_srv_routines.c b/sinqhm/SinqHM_srv_routines.c index e4acd6c1..79fb8dfe 100755 --- a/sinqhm/SinqHM_srv_routines.c +++ b/sinqhm/SinqHM_srv_routines.c @@ -50,6 +50,13 @@ #include #include #include +#ifdef MEN_A012 +/* +#include +#include +*/ +extern PART_ID sysHighMemPart; +#endif #include #include @@ -63,6 +70,8 @@ #include #include #include + + /* **==================== Global Definitions ===================================== */ @@ -1588,12 +1597,20 @@ if (n_extra_bytes != 0) free (my_rqst); +#ifdef MEN_A012 + Hist_base_addr = NULL; + printf("Calling memPartAlloc with %d, %d\n", + (int)sysHighMemPart, Total_bytes); + Hist_base_addr = memPartAlloc(sysHighMemPart,Total_bytes); + Hist_base_MEN_alloc = 1; +#else i = memFindMax (); /* Get size of biggest free memory block */ if (i > Total_bytes) { Hist_base_addr = calloc (Total_bytes, sizeof (char)); }else { Hist_base_addr = NULL; } +#endif printf("Successfully allocated %d bytes\n", Total_bytes); if (Hist_base_addr == NULL) { printf ("\007do_SQHM__PSD_alloc:\n" @@ -3071,7 +3088,16 @@ /* ** Release any allocated histogram buffer */ - free (Hist_base_addr); +#ifdef MEN_A012 + if(Hist_base_MEN_alloc == 1){ + memPartFree(sysHighMemPart, Hist_base_addr); + } else { + free (Hist_base_addr); + } + Hist_base_MEN_alloc = 0; +#else + free(Hist_base_addr); +#endif Hist_base_addr = NULL; free (Frame_base_addr); Frame_base_addr = NULL; diff --git a/sinqhm/bldmen b/sinqhm/bldmen index 0ea067c9..9687216b 100755 --- a/sinqhm/bldmen +++ b/sinqhm/bldmen @@ -45,6 +45,7 @@ alias ccvx 'ccppc ' \ ' -fno-for-scope -Wall -I/h -I$MEN/VXWORKS/INCLUDE/NATIVE '\ ' -I$MEN/VXWORKS/INCLUDE/COM -I$MEN/VXWORKS -I. '\ ' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/all ' \ + ' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/config/men_824x_ali ' \ ' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/h '\ ' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/config '\ ' -I/home/pss123/aco/sinqhm/wind2/2.0.2/target/src/drv -DCPU=PPC603 '\ diff --git a/sinqhmdriv.c b/sinqhmdriv.c index bd36ec15..54faa6d4 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -745,7 +745,7 @@ pCon); pInternal = self->pPriv; /* we do not need to do a lot of copying when datasizes match! */ - iByte = iEnd * self->iBinWidth; + iByte = (iEnd - iStart) * self->iBinWidth; if(self->iBinWidth == sizeof(HistInt)) { /* read HM */