zytzjx
驱动牛犊
驱动牛犊
  • 注册日期2001-12-24
  • 最后登录2018-05-29
  • 粉丝0
  • 关注0
  • 积分13分
  • 威望41点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
  • 社区居民
阅读:1558回复:1

Windriver DMA

楼主#
更多 发布于:2002-02-22 10:37
春节好
对不起,打搅你一下,我想请教你一个问题,我是用WINDRIVER,想写一个DMA,这儿要设置Register吗?怎么设置?
还有一个问题就是这个DMA怎样写,我写的为什么不行。
void IO_DMATransferBuffer(PVOID pBuffer, DWORD dwBytes, BOOL fIsRead, DWORD dwAddr)
{
    WD_DMA dma;
    DWORD i;
    DWORD dwSumBytes;

    BZERO(dma);
    dma.pUserAddr = pBuffer;
    dma.dwBytes = dwBytes;
    dma.dwOptions = 0;

    // lock region in memory & get page list
    WD_DMALock(hWD,&dma);

    // program page transfer list on PCI bus master card
    dwSumBytes = 0;
    for (i=0; i<dma.dwPages; i++)
    {
        IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 0, (DWORD) dma.Page.pPhysicalAddr);
        IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 4, dwAddr + dwSumBytes);
        IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 8, dma.Page.dwBytes);
        dwSumBytes += dma.Page.dwBytes;
    }
    
    // write the number of pages to transfer and direction of transfer
    IO_Write32BitRegister(MY_REG_DMA_STATUS, dma.dwPages | (fIsRead ? 0x1000 : 0));

    // wait for for status register to indicate transfer compleate here.
    // you can use the interrupt routine for non-busy wait (if the card enables interrupt
    // indication for end of transfer).

    WD_DMAUnlock(hWD,&dma);
}
// performs a single 32 bit write to memory mapped range
void IO_Write32BitRegister(DWORD dwAddr, DWORD dwData)
{
    PDWORD pDW = (PDWORD) (G_baseMemory + dwAddr);
    *pDW = dwData;
}
还有一个问题就是在一个程序中(VC)怎样将一个obj文件连接进去。在Delphi中好象是{L 文件名}就可以了
Wecan
jst7792
论坛版主
论坛版主
  • 注册日期2001-12-10
  • 最后登录2006-11-16
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望1点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-02-22 15:11
如果我没有分析错的话,你是在试图利用windriver提供的user
buffer 的参数初始化一个SGL DMA,我记得典型的SGL DMA的页表项结构是: 当前页物理地址 当前页大小 下一页表存放的物理地址.
for (i=0; i<dma.dwPages; i++)
{
IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 0, (DWORD) dma.Page.pPhysicalAddr);
IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 4, dwAddr + dwSumBytes);
IO_Write32BitRegister(MY_REG_DMA_PAGES + i*12 + 8, dma.Page.dwBytes);
dwSumBytes += dma.Page.dwBytes;
}
这段代码始终不太明白你在做什么.建议再分析一下.
另外注意如果buffer太大,pages会太多,windriver默认的缓冲不够,
需要调用其他的函数,具体看手册吧,我只能说这些了,希望有帮助.
兄弟们,给点分吧
游客

返回顶部