#include #include #include #include #include #include #include "ti_dsp.h" /* ---------------------------------------------------------------------- Boot the input ALTERA ---------------------------------------------------------------------- */ int ti_altera_cfg(ti_dsp_p dsp, ti_bootMode bootMode) { int i; unsigned int n; struct stat fs; /* ---- Buffer to hold the ALTERA configuration data and timestamp */ static unsigned int *data32 = NULL; static int size_altera; /* ---- Check if the ALTERA.dat file needs to be reloaded */ if (stat("ALTERA.dat", &fs) < 0){ perror("ti_altera_cfg:stat()"); return 1; } /* ---- Load the binary file ALTERA.dat in memory */ if (data32 == NULL){ unsigned char *data; int id = open("ALTERA.dat", O_RDONLY); if (id==-1){ perror("ti_altera_cfg:open()"); return 1; } if (fstat(id, &fs)==-1){ perror("ti_altera_cfg:fstat()"); return 1; } size_altera = fs.st_size; data=(unsigned char *)malloc(size_altera); if (data == NULL){ perror("ti_altera_cfg:malloc()"); return 1; } read (id, data, size_altera); close(id); /* Expand to 32-bit words */ data32=(unsigned int *)malloc(size_altera*sizeof(int)); if (data32 == NULL){ perror("ti_altera_cfg:malloc()"); return(1); } for(i=0; icontrolWord &= ~CW_nCONFIG; ti_writeCW(dsp); /* check CONF_DONE=0 and nSTATUS=0 */ n = vme_dsp_read(dsp, TI_STATUS); if((n & TI_nSTATUS) || (n & TI_CONF_DONE)){ fputs("ti_altera_cfg: CONF_DONE or nSTATUS NOT OK after nCONFIG LOW\n", stderr); return 1; } /* send nCONFIG=1 */ dsp->controlWord |= CW_nCONFIG; ti_writeCW(dsp); /* check CONF_DONE=0 and nSTATUS=1 */ n = vme_dsp_read(dsp, TI_STATUS); if(!(n & TI_nSTATUS) || (n & TI_CONF_DONE)){ fputs("ti_altera_cfg: CONF_DONE or nSTATUS NOT OK after nCONFIG HIGH\n", stderr); return 1; } #ifdef SLOW /* send configuration file */ for(i=0; i