📄 system.c
字号:
dwHPPhysicalMemSize = pPddObject->dwPhysicalMemSize/4;
// Align with page size.
pPddObject->dwPhysicalMemSize = (pPddObject->dwPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1);
dwHPPhysicalMemSize = ((dwHPPhysicalMemSize + PAGE_SIZE -1) & ~(PAGE_SIZE -1));
}
else
pPddObject->dwPhysicalMemSize=0;
if (pPddObject->dwPhysicalMemSize<gcTotalAvailablePhysicalMemory) { // Setup Minimun requirement.
pPddObject->dwPhysicalMemSize = gcTotalAvailablePhysicalMemory;
dwHPPhysicalMemSize = gcHighPriorityPhysicalMemory;
}
pPddObject->AdapterObject.ObjectSize = sizeof(DMA_ADAPTER_OBJECT);
pPddObject->AdapterObject.InterfaceType = dwi.dwInterfaceType;
pPddObject->AdapterObject.BusNumber = dwi.dwBusNumber;
if ((pPddObject->pvVirtualAddress = HalAllocateCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, &pPddObject->LogicalAddress, FALSE)) == NULL) {
goto InitializeEHCI_Error;
}
if (!(pobMem = HcdMdd_CreateMemoryObject(pPddObject->dwPhysicalMemSize, dwHPPhysicalMemSize, (PUCHAR) pPddObject->pvVirtualAddress, (PUCHAR) pPddObject->LogicalAddress.LowPart))) {
goto InitializeEHCI_Error;
}
if (!(pobEHCD = HcdMdd_CreateHcdObject(pPddObject, pobMem, szDriverRegKey, ioPortBase, dii.dwSysintr))) {
goto InitializeEHCI_Error;
}
pPddObject->lpvMemoryObject = pobMem;
pPddObject->lpvEHCDMddObject = pobEHCD;
_tcsncpy(pPddObject->szDriverRegKey, szDriverRegKey, MAX_PATH);
pPddObject->ioPortBase = ioPortBase;
pPddObject->dwSysIntr = dii.dwSysintr;
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 (pobEHCD,dwCapability);
RegCloseKey(hKey);
}
return TRUE;
InitializeEHCI_Error:
if (pPddObject->IsrHandle) {
FreeIntChainHandler(pPddObject->IsrHandle);
pPddObject->IsrHandle = NULL;
}
if (pobEHCD)
HcdMdd_DestroyHcdObject(pobEHCD);
if (pobMem)
HcdMdd_DestroyMemoryObject(pobMem);
if(pPddObject->pvVirtualAddress)
HalFreeCommonBuffer(&pPddObject->AdapterObject, pPddObject->dwPhysicalMemSize, pPddObject->LogicalAddress, pPddObject->pvVirtualAddress, FALSE);
pPddObject->lpvMemoryObject = NULL;
pPddObject->lpvEHCDMddObject = NULL;
pPddObject->pvVirtualAddress = NULL;
if ( hKey!=NULL)
RegCloseKey(hKey);
return FALSE;
}
/* HcdPdd_Init
*
* PDD Entry point - called at system init to detect and configure EHCI card.
*
* Return Value:
* Return pointer to PDD specific data structure, or NULL if error.
*/
extern DWORD
HcdPdd_Init(
DWORD dwContext) // IN - Pointer to context value. For device.exe, this is a string
// indicating our active registry key.
{
SEHCDPdd * pPddObject = malloc(sizeof(SEHCDPdd));
BOOL fRet = FALSE;
if (pPddObject) {
pPddObject->pvVirtualAddress = NULL;
InitializeCriticalSection(&pPddObject->csPdd);
pPddObject->IsrHandle = NULL;
pPddObject->hParentBusHandle = CreateBusAccessHandle((LPCWSTR)g_dwContext);
fRet = InitializeEHCI(pPddObject, (LPCWSTR)dwContext);
if(!fRet)
{
if (pPddObject->hParentBusHandle)
CloseBusAccessHandle(pPddObject->hParentBusHandle);
DeleteCriticalSection(&pPddObject->csPdd);
free(pPddObject);
pPddObject = NULL;
}
}
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)
{
SEHCDPdd * pPddObject = (SEHCDPdd *)hDeviceContext;
HcdMdd_PowerUp(pPddObject->lpvEHCDMddObject);
return;
}
extern void HcdPdd_PowerDown(DWORD hDeviceContext)
{
SEHCDPdd * pPddObject = (SEHCDPdd *)hDeviceContext;
HcdMdd_PowerDown(pPddObject->lpvEHCDMddObject);
return;
}
extern BOOL HcdPdd_Deinit(DWORD hDeviceContext)
{
SEHCDPdd * pPddObject = (SEHCDPdd *)hDeviceContext;
if(pPddObject->lpvEHCDMddObject)
HcdMdd_DestroyHcdObject(pPddObject->lpvEHCDMddObject);
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);
return TRUE;
}
extern DWORD HcdPdd_Open(DWORD hDeviceContext, DWORD AccessCode,
DWORD ShareMode)
{
UnusedParameter(hDeviceContext);
UnusedParameter(AccessCode);
UnusedParameter(ShareMode);
return 1; // we can be opened, but only once!
}
extern BOOL HcdPdd_Close(DWORD hOpenContext)
{
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;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -