📄 2413_ohci.c
字号:
pPddObject->lpvMemoryObject = pobMem;
pPddObject->lpvOhcdMddObject = pobOhcd;
_tcsncpy(pPddObject->szDriverRegKey, szDriverRegKey, MAX_PATH);
pPddObject->ioPortBase = ioPortBase;
pPddObject->dwSysIntr = dii.dwSysintr;
// PCI OHCI support suspend and resume
if ( hKey!=NULL) {
DWORD dwCapability;
DWORD dwType;
DWORD dwLength = sizeof(DWORD);
if (RegQueryValueEx(hKey, HCD_CAPABILITY_VALNAME, 0, &dwType, (PUCHAR)&dwCapability, &dwLength) == ERROR_SUCCESS)
HcdMdd_SetCapability (pobOhcd,dwCapability);
RETAILMSG(1,(TEXT("HOST CAP : %d\n"),dwCapability));
RegCloseKey(hKey);
}
return TRUE;
InitializeOHCI_Error:
if (pPddObject->IsrHandle) {
FreeIntChainHandler(pPddObject->IsrHandle);
pPddObject->IsrHandle = NULL;
}
if (pobOhcd)
HcdMdd_DestroyHcdObject(pobOhcd);
if (pobMem)
HcdMdd_DestroyMemoryObject(pobMem);
if(pPddObject->pvVirtualAddress)
HalFreeCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, pPddObject->LogicalAddress, pPddObject->pvVirtualAddress, FALSE);
pPddObject->lpvMemoryObject = NULL;
pPddObject->lpvOhcdMddObject = NULL;
pPddObject->pvVirtualAddress = NULL;
if ( hKey!=NULL)
RegCloseKey(hKey);
return FALSE;
}
/* HcdPdd_Init
*
* PDD Entry point - called at system init to detect and configure OHCI card.
*
* Return Value:
* Return pointer to PDD specific data structure, or NULL if error.
*/
BOOL Init2413Port(void)
{
v_pCLKPWRegs = (volatile S3C2413_CLKPWR_REG*)VirtualAlloc(0, sizeof(S3C2413_CLKPWR_REG), MEM_RESERVE, PAGE_NOACCESS);
if (v_pCLKPWRegs== NULL)
{
RETAILMSG (1,(TEXT("[USBH] Error: v_pCLKPWRegs is not allocated\n")));
goto usbh_fail;
}
if (!VirtualCopy((PVOID)v_pCLKPWRegs, (PVOID)(S3C2413_BASE_REG_PA_CLOCK_POWER >> 8), sizeof(S3C2413_CLKPWR_REG), PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE))
{
RETAILMSG (1,(TEXT("[USBH] Error: v_pCLKPWRegs is not mapped\n")));
goto usbh_fail;
}
return TRUE;
usbh_fail:
if (v_pCLKPWRegs) {
VirtualFree((PVOID)v_pCLKPWRegs, 0, MEM_RELEASE);
}
return FALSE;
}
extern DWORD
HcdPdd_Init(
DWORD dwContext) // IN - Pointer to context value. For device.exe, this is a string
// indicating our active registry key.
{
SOhcdPdd * pPddObject = malloc(sizeof(SOhcdPdd));
BOOL fRet = FALSE;
RETAILMSG(1, (TEXT("+HcdPdd_Init!\n")));
#if 0
RETAILMSG(1, (TEXT("+Init2413Port!\n")));
if(Init2413Port())
{
RETAILMSG(1, (TEXT("...\n")));
RETAILMSG(1, (TEXT("UPLLCON[%xh]\n"), v_pCLKPWRegs->UPLLCON));
RETAILMSG(1, (TEXT("USBH clock setting...\n")));
v_pCLKPWRegs->CLKDIVN |= (1<<6); // set USB48DIV reg.
v_pCLKPWRegs->CLKSRC |= (1<<5); // set SELUPLL=FOUTupll.
}
else
{
RETAILMSG(1, (TEXT("HcdPdd Port Init Error!!!\n")));
}
RETAILMSG(1, (TEXT("-Init2413Port!\n")));
#endif
if (pPddObject) {
pPddObject->pvVirtualAddress = NULL;
InitializeCriticalSection(&pPddObject->csPdd);
pPddObject->IsrHandle = NULL;
pPddObject->hParentBusHandle = CreateBusAccessHandle((LPCWSTR)g_dwContext);
if (pPddObject->hParentBusHandle)
fRet = InitializeOHCI(pPddObject, (LPCWSTR)dwContext);
if(!fRet) {
if (pPddObject->hParentBusHandle)
CloseBusAccessHandle(pPddObject->hParentBusHandle);
DeleteCriticalSection(&pPddObject->csPdd);
free(pPddObject);
pPddObject = NULL;
}
}
RETAILMSG(1, (TEXT("-HcdPdd_Init!\n")));
return (DWORD)pPddObject;
}
/* HcdPdd_CheckConfigPower
*
* Check power required by specific device configuration and return whether it
* can be supported on this platform. For CEPC, this is trivial, just limit to
* the 500mA requirement of USB. For battery powered devices, this could be
* more sophisticated, taking into account current battery status or other info.
*
* Return Value:
* Return TRUE if configuration can be supported, FALSE if not.
*/
extern BOOL HcdPdd_CheckConfigPower(
UCHAR bPort, // IN - Port number
DWORD dwCfgPower, // IN - Power required by configuration
DWORD dwTotalPower) // IN - Total power currently in use on port
{
return ((dwCfgPower + dwTotalPower) > 500) ? FALSE : TRUE;
}
extern void HcdPdd_PowerUp(DWORD hDeviceContext)
{
SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;
//RETAILMSG(1, (TEXT("HcdPdd_PowerUp\n")));
HcdMdd_PowerUp(pPddObject->lpvOhcdMddObject);
return;
}
extern void HcdPdd_PowerDown(DWORD hDeviceContext)
{
SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;
//RETAILMSG(1, (TEXT("HcdPdd_PowerDown\n")));
HcdMdd_PowerDown(pPddObject->lpvOhcdMddObject);
return;
}
extern BOOL HcdPdd_Deinit(DWORD hDeviceContext)
{
SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;
RETAILMSG(1, (TEXT("HcdPdd_Deinit\n")));
if(pPddObject->lpvOhcdMddObject)
HcdMdd_DestroyHcdObject(pPddObject->lpvOhcdMddObject);
if(pPddObject->lpvMemoryObject)
HcdMdd_DestroyMemoryObject(pPddObject->lpvMemoryObject);
if(pPddObject->pvVirtualAddress)
HalFreeCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, pPddObject->LogicalAddress, pPddObject->pvVirtualAddress, FALSE);
if (pPddObject->IsrHandle) {
FreeIntChainHandler(pPddObject->IsrHandle);
pPddObject->IsrHandle = NULL;
}
if (pPddObject->hParentBusHandle)
CloseBusAccessHandle(pPddObject->hParentBusHandle);
free(pPddObject);
FreeVirtualMemory();
return TRUE;
}
extern DWORD HcdPdd_Open(DWORD hDeviceContext, DWORD AccessCode,
DWORD ShareMode)
{
//RETAILMSG(1, (TEXT("HcdPdd_Open\n")));
UnusedParameter(hDeviceContext);
UnusedParameter(AccessCode);
UnusedParameter(ShareMode);
return 1; // we can be opened, but only once!
}
extern BOOL HcdPdd_Close(DWORD hOpenContext)
{
//RETAILMSG(1, (TEXT("HcdPdd_Close\n")));
UnusedParameter(hOpenContext);
return TRUE;
}
extern DWORD HcdPdd_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
UnusedParameter(hOpenContext);
UnusedParameter(pBuffer);
UnusedParameter(Count);
return (DWORD)-1; // an error occured
}
extern DWORD HcdPdd_Write(DWORD hOpenContext, LPCVOID pSourceBytes,
DWORD NumberOfBytes)
{
UnusedParameter(hOpenContext);
UnusedParameter(pSourceBytes);
UnusedParameter(NumberOfBytes);
return (DWORD)-1;
}
extern DWORD HcdPdd_Seek(DWORD hOpenContext, LONG Amount, DWORD Type)
{
UnusedParameter(hOpenContext);
UnusedParameter(Amount);
UnusedParameter(Type);
return (DWORD)-1;
}
extern BOOL HcdPdd_IOControl(DWORD hOpenContext, DWORD dwCode, PBYTE pBufIn,
DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
UnusedParameter(hOpenContext);
UnusedParameter(dwCode);
UnusedParameter(pBufIn);
UnusedParameter(dwLenIn);
UnusedParameter(pBufOut);
UnusedParameter(dwLenOut);
UnusedParameter(pdwActualOut);
return FALSE;
}
// Manage WinCE suspend/resume events
// This gets called by the MDD's IST when it detects a power resume.
// By default it has nothing to do.
extern void HcdPdd_InitiatePowerUp (DWORD hDeviceContext)
{
return;
}
void FreeVirtualMemory(void)
{
if (v_pCLKPWRegs )
{
VirtualFree((PVOID)v_pCLKPWRegs, 0, MEM_RELEASE);
v_pCLKPWRegs = NULL;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -