⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 system.c

📁 WinCE5.0BSP for Renesas SH7770
💻 C
📖 第 1 页 / 共 2 页
字号:
    address = (DWORD)pvUsbRegister;

    DEBUGMSG(ZONE_INIT, (TEXT("Revision %08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));
    DEBUGMSG(ZONE_INIT, (TEXT("%08x \r\n"), (ULONG)READ_REGISTER_ULONG((PULONG)address+=1) ));

//    pvUsbRegister = (PVOID)(
//       (DWORD)pPddObject->pvVirtualAddress + dwOffset);

    // Allocate and map vertual address for USB shared memory
    // Shared memory address is not adjusted so it must be aligned in 4kB.
    pPddObject->pvMemBase = VirtualAlloc(
        0, dwTotalMemSize, MEM_RESERVE, PAGE_NOACCESS);
	if (pPddObject->pvMemBase == NULL) {
        RETAILMSG(1,
            (TEXT("InitializeOHCI: VirtualAlloc (memory) failed!\r\n")));
        goto error_return;
    }
    if (!VirtualCopy(pPddObject->pvMemBase,
        (LPVOID)dwMemAddr, dwTotalMemSize, PAGE_READWRITE|PAGE_NOCACHE)) {
        RETAILMSG(1,
            (TEXT("InitializeOHCI: VirtualCopy (memory) failed!\r\n")));
        goto error_return;
    }

    g_dwTotalAvailablePhysicalMemory = dwTotalMemSize;
    g_dwHighPriorityPhysicalMemory = dwHiPrioMemSize;

    // Shared memory base address for host controller hardware may take the
    // value 0 but this causes problem. If this is set to 0, replaced it with
    // 0x10000000. These higher bits are ignored by hardware.
    if (dwHWMemBase == 0) dwHWMemBase = 0x10000000;

    // The PDD can supply a buffer of contiguous physical memory here, or can
    // let the MDD try to allocate the memory from system RAM.
    // In our case, PDD supplies it.
    pvUsbHcca = pPddObject->pvMemBase;
    pobMem = HcdMdd_CreateMemoryObject(dwTotalMemSize,
        dwHiPrioMemSize, pvUsbHcca, (PVOID)dwHWMemBase); 

    if (pobMem) {
        pobOhcd = HcdMdd_CreateHcdObject(pPddObject, pobMem,
            szDriverRegKey, pvUsbRegister, dwSysIntr);
        if (!pobOhcd) {
            RETAILMSG(1,
                (TEXT("InitializeOHCI: HcdMdd_CreateHcdObject failed!\r\n")));
            goto error_return;
        }
    }

    pPddObject->pvMemoryObject = pobMem;
    pPddObject->pvOhcdMddObject = pobOhcd;

    return TRUE;

error_return:

    if (pobOhcd) HcdMdd_DestroyHcdObject(pobOhcd);
    if (pobMem) HcdMdd_DestroyMemoryObject(pobMem);

    if (pPddObject->pvMemBase)
        VirtualFree(pPddObject->pvMemBase, 0, MEM_RELEASE);
    if (pPddObject->pvVirtualAddress)
        VirtualFree(pPddObject->pvVirtualAddress, 0, MEM_RELEASE);

    pPddObject->pvMemoryObject = NULL;
    pPddObject->pvOhcdMddObject = NULL;
    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.
 */
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;

    if (pPddObject) {
        pPddObject->pvVirtualAddress = NULL;
        InitializeCriticalSection(&pPddObject->csPdd);
        fRet = InitializeOHCI(pPddObject, (LPCWSTR)dwContext);

        if(!fRet)
        {
            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)
{
    SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;
    HcdMdd_PowerUp(pPddObject->pvOhcdMddObject);

    return;
}

extern void HcdPdd_PowerDown(DWORD hDeviceContext)
{
    SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;

    HcdMdd_PowerDown(pPddObject->pvOhcdMddObject);

    return;
}


extern BOOL HcdPdd_Deinit(DWORD hDeviceContext)
{
    SOhcdPdd * pPddObject = (SOhcdPdd *)hDeviceContext;

    if(pPddObject->pvOhcdMddObject)
        HcdMdd_DestroyHcdObject(pPddObject->pvOhcdMddObject);
    if(pPddObject->pvMemoryObject)
        HcdMdd_DestroyMemoryObject(pPddObject->pvMemoryObject);
    if(pPddObject->pvVirtualAddress)
        VirtualFree(pPddObject->pvVirtualAddress, 0, MEM_RELEASE);
    
    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 + -