Beispiel #1
0
void*
osl_dma_map(void *dev, void *va, uint size, uint direction)
{
	if (direction == DMA_TX)
		cacheFlush(DATA_CACHE, va, size);
	else
		cacheInvalidate(DATA_CACHE, va, size);

	return ((void*)CACHE_DMA_VIRT_TO_PHYS(va));
}
Beispiel #2
0
void*
osl_dma_map(osl_t *osh, void *va, unsigned int size, unsigned int direction)
{
    if (((uint)va & 0x20000000) == 0)
    {
	if (direction == DMA_TX)
		cacheFlush(DATA_CACHE, va, size);
	else
		cacheInvalidate(DATA_CACHE, va, size);
    }

	return ((void*)CACHE_DMA_VIRT_TO_PHYS(va));
}
* 函 数 名  : bsp_om_socp_clean_rd_buf
*
* 功能描述  :清理SOCP的RD缓存
*
* 输入参数  :chan_id :socp 的通道ID
*                       rd_stru: 入参
*
* 输出参数  :无
*
* 返 回 值  : BSP_OK 成功; 其他 失败
*****************************************************************************/

u32 bsp_om_socp_clean_rd_buf(u32 chan_id,SOCP_BUFFER_RW_STRU *rd_stru)
{
    u32             ret;
    SOCP_BUFFER_RW_STRU    rd_buf_stru = {0};

    osl_sem_down(&socp_opt_sem);

    ret = (u32)bsp_socp_get_rd_buffer(chan_id,&rd_buf_stru);

    if(BSP_OK != ret)
    {
        ret  = BSP_ERR_OMS_SOCP_GET_RD_ERR;

        goto fail;
    }

    /* 无RD需要释放*/
    if( (0 ==rd_buf_stru.u32Size)&&(0 == rd_buf_stru.u32RbSize))
    {
         ret  = BSP_OK;
         goto successful;
    }

    /* 获取到的RD数据异常*/
    if((rd_buf_stru.u32Size + rd_buf_stru.u32RbSize) > BSP_OM_CODER_SRC_RDSIZE)
    {
        ret  = BSP_ERR_OMS_SOCP_CLEAN_RD_ERR;
        goto fail;
    }

    if(0 != (rd_buf_stru.u32Size / sizeof(SOCP_RD_DATA_STRU)))
    {
        rd_stru->pBuffer = rd_buf_stru.pBuffer;
        rd_stru->u32Size = rd_buf_stru.u32Size;
        (void)cacheInvalidate(DATA_CACHE, rd_buf_stru.pBuffer, rd_buf_stru.u32Size);
    }
    else
    {
        ret  = BSP_ERR_OMS_SOCP_CLEAN_RD_ERR;

        goto fail;
    }

    ret = (u32)bsp_socp_read_rd_done(chan_id, rd_buf_stru.u32Size);  /* 释放rd缓存 */
    if( BSP_OK !=ret)
    {
        goto fail;
    }
    else
    {
        ret  = BSP_OK;
        goto successful;
    }

fail:
    osl_sem_up(&socp_opt_sem);
    return ret;
successful:
    osl_sem_up(&socp_opt_sem);
    return ret;
}
Beispiel #4
0
/*
 ***************************************************************************
 *Function:     acquire
 *Description:  This routine is the ACQUIRE example program.
 ***************************************************************************
 */
void acquire(void)
{
    char                sbTopName[20],sbBotName[20];
    FILE                *ptrTopFile=0,*ptrBotFile=0;
    unsigned int        p6256RegBaseAddr[4];  /* For ALL 4 VIM sites */
    P6256_BOARD_PARAMS  p6256BoardParams[4];
    P6256_REG_ADDR      p6256Regs[4];        
    volatile int        wdCount,wdCtrlWord;
    unsigned int        clockRate;
    unsigned int        numCyclesDelay,bifoClock;

    printf("[acquire]:\tstarting\n");

    /* Turn all led's off */                           
    sysLED_Off(0);          
    sysLED_Off(1);         
    sysLED_Off(2);        
    sysLED_Off(3);  

    top_outData=(int *)cacheDmaMalloc(BUFFER_SIZE*sizeof(int));
    bot_outData=(int *)cacheDmaMalloc(BUFFER_SIZE*sizeof(int));
    top_iData=  (int *)cacheDmaMalloc(BUFFER_SIZE*sizeof(int));
    bot_iData=  (int *)cacheDmaMalloc(BUFFER_SIZE*sizeof(int));
    if(top_outData==0||top_iData==0||bot_outData==0||bot_iData==0)
        {
        sysLED_On(0);
        fprintf(stderr,"[acquire] Unable to allocate data buffers\n");
        return;
        }

    /* get module id; if module is not a 6256, exit */
    if(sysVimGetModuleId(TOP_VIM_ID)!=P6256_MODULE_ID)
        {
        sysLED_On(0);
        fprintf(stderr,"[acquire] unable to id 6256\n");
        return;
        }

    /* Reset and Release All VIM sites */
    *P4205_RESET_REG=P4205_RESET_VIM_ALL; 
    taskDelay(4);
    *P4205_RESET_REG=0;

    /* Assign the 6256 register base addresses For the selected Vim Site */
    p6256RegBaseAddr[TOP_VIM_ID]=sysVimCtrlBase(TOP_VIM_ID);
    p6256RegBaseAddr[BOT_VIM_ID]=sysVimCtrlBase(BOT_VIM_ID);

    /* Initialize the 6256 using library routines ------------------ */

    /* Initialize Table of 6256 Addresses for Top and Bottom VIMs */
    P6256InitRegAddr(p6256RegBaseAddr[TOP_VIM_ID],&p6256Regs[TOP_VIM_ID]);
    P6256InitRegAddr(p6256RegBaseAddr[BOT_VIM_ID],&p6256Regs[BOT_VIM_ID]);

    /* Reset Board Registers for Top and Bottom VIMs */
    P6256ResetRegs(&p6256Regs[TOP_VIM_ID]);
    P6256ResetRegs(&p6256Regs[BOT_VIM_ID]);

    /* Load board parameters with default values for Top and Bottom VIMs */
    P6256SetBoardDefaults(&p6256BoardParams[TOP_VIM_ID]);
    P6256SetBoardDefaults(&p6256BoardParams[BOT_VIM_ID]);

    /* 
     *Apply program parameters to board parameters Parameters for both will
     *be set in this local function
     */
    P6256SetBoardParams(&p6256BoardParams[0]); 

    /*
     * If the onboard clock is used, set clock rate for the default internal
     * clock rate.  If not, use the locally defined external clock rate.
     * The external clock rate is also used when the clock is obtained from
     * the sync bus, even if the sync bus is driven from the onboard clock.
     * Note that the SAME Clock source will be used for BOTH Top and Bottom
     * VIM Sites.
     */
    if((p6256BoardParams[TOP_VIM_ID].clockSourceSelect==P6256_CLK_SRC_SEL_BYPASS)&&(p6256BoardParams[TOP_VIM_ID].clockSelect==P6256_ONBOARD_CLOCK))
        clockRate = P6256_INT_OSC_STANDARD;    /* defined in 6256.h */
    else 
        clockRate = EXTERNAL_CLOCK_RATE;       /* local define */
  
    /* Initialize Board Registers */
    P6256InitBoardRegs(&p6256BoardParams[TOP_VIM_ID],&p6256Regs[TOP_VIM_ID]);
    P6256InitBoardRegs(&p6256BoardParams[BOT_VIM_ID],&p6256Regs[BOT_VIM_ID]);

    /* 
     *******************************************************************
     * DATA COLLECTION AND PROCESSING STAGE
     *
     * the data is channeled into buffers based on the data routing mode
     * as set in the channel control register.
     *******************************************************************
     */
    /* Disable Fifo Writes */
    P6256_DISABLE_FIFO_WRITE(p6256Regs[TOP_VIM_ID].syncGateGenerator);      
    P6256_DISABLE_FIFO_WRITE(p6256Regs[BOT_VIM_ID].syncGateGenerator);      

    wdCtrlWord=func_initialize_9656_dma_controller();

    /* Calculate Slowest Bifo Clock */
    bifoClock=25000000;
    numCyclesDelay=sysGetCpuRate()/(bifoClock>>2);

    /* Flush the Bifo */
    sysVimFlushBifo(Delay,numCyclesDelay,512,16,512,16,TOP_VIM_ID);
    sysVimFlushBifo(Delay,numCyclesDelay,512,16,512,16,BOT_VIM_ID);

    /*fetch the data*/

    /* Enable Fifo Writes */
    P6256_ENABLE_FIFO_WRITE(p6256Regs[TOP_VIM_ID].syncGateGenerator);
    P6256_ENABLE_FIFO_WRITE(p6256Regs[BOT_VIM_ID].syncGateGenerator);

    /* Start both DMAs */
    PLX9656_REG_WRITE(plx9656Base,PLX9656_PCI_DMACSR0_DMACSR1,wdCtrlWord);

    /* Wait until done */
    if(TOP_VIM_ID==P4205_VIM_A)     /* upper VIM location, sites A & B */
        {
        while (!(GT_GPP_POLL_CAUSE(PLX_1_INT)))
                ;
        GT_GPP_CLEAR_CAUSE(PLX_1_INT);
        }
    else
        {
        while (!(GT_GPP_POLL_CAUSE(PLX_2_INT)))
                ;
        GT_GPP_CLEAR_CAUSE(PLX_2_INT);
        }

    /*sync with cache ... maybe unnecessary*/
    cacheInvalidate(DATA_CACHE,(void *)top_outData,BUFFER_SIZE*sizeof(int));
    cacheInvalidate(DATA_CACHE,(void *)bot_outData,BUFFER_SIZE*sizeof(int));
    cacheInvalidate(DATA_CACHE,(void *)top_iData,  BUFFER_SIZE*sizeof(int));
    cacheInvalidate(DATA_CACHE,(void *)bot_iData,  BUFFER_SIZE*sizeof(int));

    /* strip out inphase/quadrature components*/
    func_process_collected_data();

    cacheFlush(DATA_CACHE,(void *)top_iData,BUFFER_SIZE*sizeof(int));
    cacheFlush(DATA_CACHE,(void *)bot_iData,BUFFER_SIZE*sizeof(int));

    /*create unique name for output files*/
    sprintf(sbTopName,"./top%d.dat",TOP_VIM_ID);
    sprintf(sbBotName,"./bot%d.dat",BOT_VIM_ID);
    sbTopName[12]=0;
    sbBotName[12]=0;

    /*open/create file*/
    ptrTopFile=fopen(sbTopName,"w");
    ptrBotFile=fopen(sbBotName,"w");
    if(ptrTopFile<=0||ptrBotFile<=0)
        fprintf(stdout,"unable to create/open output file(s)\n");
    else 
        {
        /*write to file*/
        for(wdCount=0;wdCount<BUFFER_SIZE;wdCount++)
                {
                fprintf(ptrTopFile,"%d\n",top_iData[wdCount]);
                fprintf(ptrBotFile,"%d\n",bot_iData[wdCount]);
                }

        fclose(ptrTopFile);
        fclose(ptrBotFile);
        }

    sysLED_On(1);
    sysLED_On(2);
    sysLED_On(3);
    printf("[acquire]:\tconcluding\n");

    /*free allocated resources and exit*/
    cacheDmaFree((void *)top_outData);
    cacheDmaFree((void *)bot_outData);
    cacheDmaFree((void *)top_iData);
    cacheDmaFree((void *)bot_iData);
}