?? hfctldevcfgfunc.c
字號:
/* file number */
/*
modification history
-, 2004, October, 1th Release
*/
/****************************************************************
Module: hfCtlDevCfgFunc.c
Author:
Description:
****************************************************************/
/* Included Files */
#include <vxWorks.h>
#include <stdio.h>
#include <logLib.h>
#include <taskLib.h>
#include <memLib.h>
#include <stdlib.h>
#include <string.h>
#include <cacheLib.h>
#include "../../../include/drv/hF1394Pmc/hFCtlPmc.h"
#include "../../../include/drv/hF1394Pmc/HFCtlPmcLow.h"
#include "../../../include/drv/hF1394Pmc/plx9656.h"
#include "rs60x.h"
/* define some macro */
/* Global Variables */
extern HFCTL_DEV HFCtlPmcDev;
/* Forward Declaration */
/******************************************************************************
TITLE: hfCtlDevLAS0Config
DESC: routine to config access to HFCtl device's Local address space 0
PARAM: fd - file descriptor
RETURN: OK - operation was successful
ERROR - operation Failed
******************************************************************************/
STATUS hfCtlDevLAS0Config(int fd)
{
int i;
int iStatus;
unsigned long ulRegData;
unsigned char ucRegCharData;
unsigned long *pTempData;
/* get Local configuration register LAS0BA */
iStatus = HFCtlPmcGetRegLocalAdrsSpace0BaseAdrs(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register LAS0BA bit 0 */
ulRegData = (*pTempData) | 0x1;
iStatus = HFCtlPmcSetRegLocalAdrsSpace0BaseAdrs(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register MARBR */
ulRegData = 0x00210010;
iStatus = HFCtlPmcSetRegModeArbitration(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register BIGEND */
ucRegCharData = 0xee;
iStatus = HFCtlPmcSetRegBigEndianDesc(fd, ucRegCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register LMISC1 */
ucRegCharData = 0x05;
iStatus = HFCtlPmcSetRegLocalMisc1(fd, ucRegCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register LMISC2 */
ucRegCharData = 0x01;
iStatus = HFCtlPmcSetRegLocalMisc2(fd, ucRegCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local configuration register LBRD0 */
ulRegData = 0x80430343; /* enable READY */
iStatus = HFCtlPmcSetRegLocalBusSpace0RegionDesc(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
return(OK);
}
/******************************************************************************
TITLE: hfCtlDevLAS0ConfigList
DESC: routine to list HFCtl device's Local address space 0 configuration
PARAM: fd - file descriptor
RETURN: OK - operation was successful
ERROR - operation Failed
******************************************************************************/
STATUS hfCtlDevLAS0ConfigList(int fd)
{
int iStatus;
unsigned long ulRegData;
unsigned char ucRegCharData;
unsigned char *pTempCharData;
unsigned long *pTempData;
/* get Local configuration register LAS0RR */
iStatus = HFCtlPmcGetRegLAS0Range(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: LAS0RR = 0x%.8x\n", *pTempData);
/* get Local configuration register LAS0BA */
iStatus = HFCtlPmcGetRegLocalAdrsSpace0BaseAdrs(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: LAS0BA = 0x%.8x\n", *pTempData);
/* get Local configuration register MARBR */
iStatus = HFCtlPmcGetRegModeArbitration(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: MARBR = 0x%.8x\n", *pTempData);
/* get Local configuration register BIGEND */
iStatus = HFCtlPmcGetRegBigEndianDesc(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: BIGEND = 0x%.2x\n", *pTempCharData);
/* get Local configuration register LMISC1 */
iStatus = HFCtlPmcGetRegLocalMisc1(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: LMISC1 = 0x%.2x\n", *pTempCharData);
/* get Local configuration register PROT_AREA */
iStatus = HFCtlPmcGetRegPROT_AREA(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: PROT_AREA = 0x%.2x\n", *pTempCharData);
/* get Local configuration register LMISC2 */
iStatus = HFCtlPmcGetRegLocalMisc2(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: LMISC2 = 0x%.2x\n", *pTempCharData);
/* get Local configuration register LBRD0 */
iStatus = HFCtlPmcGetRegLocalBusSpace0RegionDesc(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevLAS0ConfigList: LBRD0 = 0x%.8x\n", *pTempData);
return(OK);
}
/******************************************************************************
TITLE: hfCtlDevDMA0FuncConfig
DESC: routine to perform an DMA operation
PARAM: fd - file descriptor
pDmaPci - pointer to structure HFCTL_PCIDMA
RETURN: OK - operation was successful
ERROR - operation Failed
NOTE:
BEFORE PERFORM A DMA write operation,
if we read the source buffer, then the first Dword in the target memory
is DMA right,
if we don't read the source buffer, then the first Dword in the target memory
is DMA with the value of register DMAMODE0.
if we read the DMAMODE0's value, then the first Dword in the target memory
is DMA right as first Dword in the source buffer.
******************************************************************************/
STATUS hfCtlDevDMA0FuncConfig(int fd, HFCTL_PCIDMA *pDmaPci)
{
int i;
int iStatus;
int iCount;
int iWaitCount;
unsigned char ucTemp;
unsigned long ulRegData;
unsigned char ucRegCharData;
unsigned char *pTempCharData;
unsigned long *pTempData;
unsigned long *pSrcData;
#if 0
printf("hfCtlDevDMA0FuncConfig: pDmaPci = 0x%.8x\n", pDmaPci);
pSrcData = (unsigned long *)(pDmaPci->pciAddress - 0x40000000);
printf("hfCtlDevDMA0FuncConfig: pSrcData = 0x%.8x\n", pSrcData);
iCount = pDmaPci->count;
printf("hfCtlDevDMA0FuncConfig: iCount = 0x%d\n", iCount);
#endif /* if 0 */
/* get DMA register DMAMODE0 */
iStatus = HFCtlPmcGetRegDmaChannel0Mode(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
if ((pDmaPci->lockAdrs) == TRUE)
{
ulRegData = (*pTempData) | DATA_BIT11;
}
else
{
ulRegData = (*pTempData) & (~DATA_BIT11);
}
/* lock Local address */
iStatus = HFCtlPmcSetRegDmaChannel0Mode(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/****************************************************
VERY IMPORTANT!
BEFORE PERFORM A DMA write operation,
should read the value of register DMAMODE0 once
conclusion:
BEFORE PERFORM A DMA write operation,
if we read the source buffer, then the first Dword in the target memory
is DMA right,
if we don't read the source buffer, then the first Dword in the target memory
is DMA with the value of register DMAMODE0.
if we read the DMAMODE0's value, then the first Dword in the target memory
is DMA right as first Dword in the source buffer.
*****************************************************/
/* get DMA register DMAMODE0 */
iStatus = HFCtlPmcGetRegDmaChannel0Mode(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
#if 0
if (1)
{
printf("hfCtlDevDMA0FuncConfig: after set DMAMODE0, DMAMODE0 = 0x%.8x\n", *pTempData);
}
#endif /* if 0 */
/* set PCI address */
ulRegData = pDmaPci->pciAddress;
iStatus = HFCtlPmcSetRegDmaChannel0PciAdrs(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set Local address */
ulRegData = pDmaPci->LocalAddress;
iStatus = HFCtlPmcSetRegDmaChannel0LocalAdrs(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
if ((pDmaPci->count) >= 0x800000)
{
printf("hfCtlDevDMA0FuncConfig: dma size too large.\n");
return(ERROR);
}
/* set DMA transfer size */
ulRegData = (pDmaPci->count) & 0x7fffff;
iStatus = HFCtlPmcSetRegDmaChannel0TransferSize(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set DMA transfer direction */
if ((pDmaPci->Read) == TRUE)
{
ulRegData = 0x00000008;
}
else
{
ulRegData = 0x0;
}
iStatus = HFCtlPmcSetRegDmaChannel0DescPointer(fd, ulRegData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* get DMA register DMACSR0 */
iStatus = HFCtlPmcGetRegDmaChannel0CmdStatus(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* set DMA register DMACSR0 */
ucRegCharData = (*pTempCharData) | DATA_BIT0; /* enable DMA channel 0 */
iStatus = HFCtlPmcSetRegDmaChannel0CmdStatus(fd, ucRegCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* get DMA register DMACSR0 */
iStatus = HFCtlPmcGetRegDmaChannel0CmdStatus(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/****************************************************
VERY IMPORTANT!
BEFORE PERFORM A DMA write operation,
if we read the source buffer, then the first Dword in the target memory
is DMA right,
if we don't read the source buffer, then the first Dword in the target memory
is DMA with the value of register DMAMODE0.
if we read the DMAMODE0's value, then the first Dword in the target memory
is DMA right as first Dword in the source buffer.
*****************************************************/
#if 0
for(i = 0; i < (iCount / 4); i++)
{
printf("hfCtlDevDMA0FuncConfig: pSrcData[%d] = 0x%.8x\n", i, pSrcData[i]);
}
cacheFlush(DATA_CACHE, pSrcData, iCount);
#endif /* if 0 */
/* start DMA channel 0 */
ucRegCharData = (*pTempCharData) | DATA_BIT1; /* start DMA channel 0 */
iStatus = HFCtlPmcSetRegDmaChannel0CmdStatus(fd, ucRegCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
/* wait DMA to end */
ucTemp = 0;
iWaitCount = 0;
while((!ucTemp) && (iWaitCount < 30))
{
taskDelay(1);
iStatus = HFCtlPmcGetRegDmaChannel0CmdStatus(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
ucTemp = (*pTempCharData) & DATA_BIT4;
iWaitCount++;
}
if ((!ucTemp) && (iWaitCount == 30))
{
printf("hfCtlDevDMA0FuncConfig: DMA WAIT TIME OUT.\n");
return(ERROR);
}
return(OK);
}
/******************************************************************************
TITLE: hfCtlDevDMA0FuncConfigList
DESC: routine to list HFCtl device's DMA0 configuration
PARAM: fd - file descriptor
RETURN: OK - operation was successful
ERROR - operation Failed
******************************************************************************/
STATUS hfCtlDevDMA0FuncConfigList(int fd)
{
int iStatus;
unsigned long ulRegData;
unsigned char ucRegCharData;
unsigned char *pTempCharData;
unsigned long *pTempData;
/* get DMA register DMAMODE0 */
iStatus = HFCtlPmcGetRegDmaChannel0Mode(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevDMA0FuncConfigList: DMAMODE0 = 0x%.8x\n", *pTempData);
/* get DMA register DMAPADR0 */
iStatus = HFCtlPmcGetRegDmaChannel0PciAdrs(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevDMA0FuncConfigList: DMAPADR0 = 0x%.8x\n", *pTempData);
/* get DMA register DMALADR0 */
iStatus = HFCtlPmcGetRegDmaChannel0LocalAdrs(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevDMA0FuncConfigList: DMALADR0 = 0x%.8x\n", *pTempData);
/* get DMA register DMASIZ0 */
iStatus = HFCtlPmcGetRegDmaChannel0TransferSize(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevDMA0FuncConfigList: DMASIZ0 = 0x%.8x\n", *pTempData);
/* get DMA register DMADPR0 */
iStatus = HFCtlPmcGetRegDmaChannel0DescPointer(fd, pTempData);
if (iStatus == ERROR)
{
return(ERROR);
}
printf("hfCtlDevDMA0FuncConfigList: DMADPR0 = 0x%.8x\n", *pTempData);
/* get DMA register DMACSR0 */
iStatus = HFCtlPmcGetRegDmaChannel0CmdStatus(fd, pTempCharData);
if (iStatus == ERROR)
{
return(ERROR);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -