引用: 引用 4 楼 firefly123 的回复:
应该是访问方式错误.
看一下驱动程序,readfile到底干了些什么事,有可能指定地址是在seek中指定的
seek直接返回0 不可能是seek spi_read的驱动程序代码如下
DWORD
SPI_Read(
DWORD hOpenContext,
LPVOID pBuffer,
DWORD Count)
{
PSPI_PRIVATE_CONTEXT pSpiPrivate = (PSPI_PRIVATE_CONTEXT)hOpenContext;
PSPI_PUBLIC_CONTEXT pSpiPublic = pSpiPrivate->pSpiPublic;
// DWORD dwReadSize;
HRESULT hr;
PBYTE g_pMappedEmbedded;
PBYTE g_pMarshalled;
RETAILMSG(SPI_INIT,(TEXT("[SPI] SPI_Read : pSpiPrivate->State=%d\n"),pSpiPrivate->State));
//param check
if(pSpiPrivate->State != STATE_IDLE)
{
RETAILMSG(SPI_INIT,(TEXT("[SPI] READ ERROR : STATE IS NOT IDLE\n")));
return 0;
}
RETAILMSG(SPI_INIT,(TEXT("+[SPI] SPI_READ...\n")));
RETAILMSG(SPI_INIT,(TEXT("[SPI] pBuffer : 0x%X, Count : %d\n"), pBuffer, Count));
hr = CeOpenCallerBuffer((PVOID*) &g_pMappedEmbedded, pBuffer, Count, ARG_IO_PTR, FALSE);
hr = CeAllocAsynchronousBuffer((PVOID*) &g_pMarshalled, g_pMappedEmbedded, Count, ARG_IO_PTR);
if(pSpiPrivate->bUseRxDMA)
{
pSpiPrivate->pRxBuffer = pVirtDmaDstBufferAddr;
pSpiPrivate->pRxDMABuffer = (LPVOID)DmaDstAddress;
}
else
{
pSpiPrivate->pRxBuffer = g_pMarshalled;
}
RETAILMSG(SPI_MSG,(TEXT("[SPI] g_pMappedEmbedded 0x%x\n"),g_pMappedEmbedded));
RETAILMSG(SPI_MSG,(TEXT("[SPI] g_pMarshalled 0x%x\n"),g_pMarshalled));
pSpiPrivate->dwRxCount = Count;
pSpiPublic->pSpiPrivate = pSpiPrivate;
SetEvent(pSpiPublic->hRxEvent);
//Thread call
WaitForSingleObject(pSpiPublic->hRxDoneEvent, INFINITE);
pSpiPrivate->State = STATE_IDLE;
if(pSpiPrivate->bUseRxDMA)
{
memcpy(g_pMarshalled, pVirtDmaDstBufferAddr,Count);
}
hr = CeFreeAsynchronousBuffer((PVOID)g_pMarshalled, g_pMappedEmbedded, Count, ARG_IO_PTR);
hr = CeCloseCallerBuffer((PVOID) g_pMappedEmbedded, pBuffer, Count, ARG_IO_PTR);
RETAILMSG(SPI_INIT,(TEXT("[SPI] SPI_Read : Return Value : %d\n\n"),pSpiPrivate->dwRxCount));
return pSpiPrivate->dwRxCount ;
}
根本看不出来如何操作的