|
分配虚拟地址,并映射到指定物理地址
m_IOPreg = (volatile IOPreg *)VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE,PAGE_READWRITE|PAGE_NOCACHE);
if(m_IOPreg ==NULL)
{
ERR = GetLastError();
RETAILMSG(1,(TEXT("ALLOC IOreg failed for %d!\n"),ERR));
}
if(!VirtualCopy((LPVOID)m_IOPreg,(LPVOID)(IOP_BASE>>8),sizeof(IOPreg),PAGE_READWRITE|PAGE_PHYSICAL))
{
ERR = GetLastError();
RETAILMSG(1,(TEXT("IOPreg COPY TO PHICICAL failed for the error %d\n"),ERR));
}
m_PWMreg = (volatile PWMreg *)VirtualAlloc(0,sizeof(PWMreg),MEM_RESERVE,PAGE_READWRITE|PAGE_NOCACHE);
if(m_PWMreg ==NULL)
{
ERR = GetLastError();
RETAILMSG(1,(TEXT("ALLOC PWMreg FAILED for the Error %d\n"),ERR));
}
if(!VirtualCopy((LPVOID)m_PWMreg,(LPVOID)(PWM_BASE>>8),sizeof(PWMreg),PAGE_READWRITE|PAGE_PHYSICAL))
{
ERR = GetLastError();
RETAILMSG(1,(TEXT("PWMreg COPY TO PHICICAL failed for the error %d\n"),ERR));
}
问题是:VirtualAlloc分配虚拟地址,指定成指定成MEM_RESERVE没有问题,但指定成MEM_COMMIT就出错,GetLastError = 87
还有,即便是指定成MEM_RESERVE,对寄存器设置也没有效果,这是为何?
|
|