Пример #1
0
BOOL CSerialPDD::Open()
{
    PHYSICAL_ADDRESS	ioPhysicalBase = { S3C6410_BASE_REG_PA_GPIO, 0};
    ULONG				inIoSpace = 0;

    if (InterlockedExchange(&m_lOpenCount,1) !=0)
        return FALSE;
    
    PREFAST_ASSERT(m_PowerHelperHandle!=INVALID_HANDLE_VALUE);
    ASSERT(m_hPowerLock==NULL);
    m_hPowerLock= DDKPwr_RequestLevel( m_PowerHelperHandle, D0 );  
    ASSERT(m_hPowerLock!=NULL);
    
    SetDefaultConfiguration(); 
    InitLine(TRUE);
    InitReceive(TRUE);
    InitXmit(TRUE);

    if(cUart_Index==3)
    {
        if (TranslateBusAddr(m_hParent,Internal,0, ioPhysicalBase,&inIoSpace,&ioPhysicalBase))
    	{
	// Map it if it is Memeory Mapped IO.
	g_pIOPregs = (S3C6410_GPIO_REG *)DrvLib_MapIoSpace(ioPhysicalBase.LowPart , sizeof(S3C6410_GPIO_REG),FALSE);	
	g_pIOPregs->GPCCON &= ~(0xf<<28);	///< Clear Bit
	g_pIOPregs->GPCCON |=  (0x1<<28); 	///< Select UART IP                
	g_pIOPregs->GPCPUD &= ~(0x3<<14);    ///< Pull-Up/Down Disable  
	//g_pIOPregs->GPCDAT |=1<<7;

    	}
    }
    return TRUE;
}
Пример #2
0
PowerState::PowerState (PowerStateManager *pPwrStateMgr, PowerState * pNextPowerState)
    : m_pPwrStateMgr (pPwrStateMgr), m_pNextPowerState (pNextPowerState)
{
	memset (m_dwEventArray, 0, sizeof (m_dwEventArray));
	m_hUnsignaledHandle = CreateEvent (NULL, FALSE, FALSE, NULL);
	PREFAST_ASSERT (pPwrStateMgr != NULL);

	m_dwNumOfEvent = PM_BASE_TOTAL_EVENT;
	for (DWORD dwIndex = 0; dwIndex < PM_BASE_TOTAL_EVENT; dwIndex++)
	{
		m_dwEventArray[dwIndex] = m_hUnsignaledHandle;
	}
}
Пример #3
0
DWORD  CSDWorkItem::ThreadRun()
{
    while (!m_bTerminated) {
        PREFAST_ASSERT(m_psdSlotEvent!=NULL);
        if (!IsEmpty()) {
            // We don't need take lock since only this thread modify the Read Index.
            SD_SLOT_EVENT sdEvent = m_psdSlotEvent [m_dwReadIndex];
            m_dwReadIndex = IncIndex(m_dwReadIndex);
            BOOL fRet = ReleaseSemaphore(m_hEmptySlotSem,1,NULL);
            ASSERT(fRet);
            SlotStatusChangeProcessing(sdEvent);
        }
        else
            ::WaitForSingleObject( m_hWakeupEvent, INFINITE );
    }
    return FALSE;
}
Пример #4
0
///////////////////////////////////////////////////////////////////////////////
//  PostMessage - post a message
//  Input:  pMessage - message to post
//  Output: 
//  Return:
//  Notes:  
//      
///////////////////////////////////////////////////////////////////////////////
BOOL CSDWorkItem::PostEvent(SD_SLOT_EVENT sdEvent, DWORD dwWaitTick)
{
    PREFAST_ASSERT(m_psdSlotEvent!=NULL);
    BOOL fRet = FALSE;
    if (::WaitForSingleObject( m_hEmptySlotSem, dwWaitTick ) == WAIT_OBJECT_0 ) {
        Lock();
        if (!IsFull()) {
            m_psdSlotEvent[m_dwWriteIndex] = sdEvent;
            m_dwWriteIndex = IncIndex(m_dwWriteIndex);
            SetEvent(m_hWakeupEvent);
            fRet = TRUE;
        }
        else
            ASSERT(FALSE);
        Unlock();
    }
    return fRet;
}
Пример #5
0
BOOL CSerialPDD::Close()
{
    if (InterlockedExchange(&m_lOpenCount,0) !=1)
        return FALSE;
    InitXmit(FALSE);
    InitReceive(FALSE);
    InitLine(FALSE);
    
    PREFAST_ASSERT(m_PowerHelperHandle!=INVALID_HANDLE_VALUE);
    ASSERT(m_hPowerLock!=NULL);
    DDKPwr_ReleaseLevel(m_PowerHelperHandle, m_hPowerLock);  
    m_hPowerLock=NULL;
    if(cUart_Index==3)
    {
    	//g_pIOPregs->GPCDAT &=~(1<<7);
	if (g_pIOPregs!=NULL)
	{
		DrvLib_UnmapIoSpace((PVOID)g_pIOPregs);
	}

    }

    return TRUE;
}
Пример #6
0
HRESULT AddLoggingMsg(TCHAR* ptcDeviceName, UCHAR* pucMacAddr, FILETIME ft, TCHAR* ptcMessage)
{
    HRESULT		hr = S_OK;
    SYSTEMTIME  SystemTime;
    FILETIME	LocalTime;

    EnterCriticalSection(&g_LogMsgQueue.Lock);

    // If the list is full
    if(g_LogMsgQueue.dwNewMsgIdx - g_LogMsgQueue.dwOldMsgIdx == -1)
    {
        g_LogMsgQueue.dwNewMsgIdx = g_LogMsgQueue.dwOldMsgIdx;

        // Check if we should wrap around the array
        if(g_LogMsgQueue.dwOldMsgIdx == WZCLOG_ENTRIES - 1)
        {
            g_LogMsgQueue.dwOldMsgIdx = 0;
        }
        else
        {
            g_LogMsgQueue.dwOldMsgIdx++;
        }
    }
    // If the list is empty
    else if(g_LogMsgQueue.dwOldMsgIdx == -1 && g_LogMsgQueue.dwNewMsgIdx == -1)
    {
        g_LogMsgQueue.dwNewMsgIdx = 0;
    }
    // If the list has one entry
    else if(g_LogMsgQueue.dwOldMsgIdx == -1)
    {
        g_LogMsgQueue.dwNewMsgIdx++;
        g_LogMsgQueue.dwOldMsgIdx = 0;
    }
    else
    {
        // Check if we should wrap around the array
        if(g_LogMsgQueue.dwNewMsgIdx == WZCLOG_ENTRIES - 1)
        {
            g_LogMsgQueue.dwOldMsgIdx++;
            g_LogMsgQueue.dwNewMsgIdx = 0;
        }
        else
        {
            g_LogMsgQueue.dwNewMsgIdx++;
        }
    }

    FileTimeToLocalFileTime(&ft, &LocalTime);
    FileTimeToSystemTime(&LocalTime, &SystemTime);

    PREFAST_ASSERT(g_LogMsgQueue.dwNewMsgIdx < WZCLOG_ENTRIES);

    if(pucMacAddr == NULL)
    {
        _sntprintf(g_LogMsgQueue.pszList[g_LogMsgQueue.dwNewMsgIdx], LOG_STATUS_SIZE, TEXT("[%02d:%02d:%02d - %s] %s"),
                   SystemTime.wHour,
                   SystemTime.wMinute,
                   SystemTime.wSecond,
                   ptcDeviceName,
                   ptcMessage);
    }
    else
    {
        _sntprintf(g_LogMsgQueue.pszList[g_LogMsgQueue.dwNewMsgIdx], LOG_STATUS_SIZE, TEXT("[%02d:%02d:%02d - %s] %s - AP [%02x-%02x-%02x-%02x-%02x-%02x]"),
                   SystemTime.wHour,
                   SystemTime.wMinute,
                   SystemTime.wSecond,
                   ptcDeviceName,
                   ptcMessage,
                   pucMacAddr[0],
                   pucMacAddr[1],
                   pucMacAddr[2],
                   pucMacAddr[3],
                   pucMacAddr[4],
                   pucMacAddr[5]);
    }

    // Update dialog if it is visible
    if(g_LogMsgQueue.dwState == WZCLOG_ACTIVE)
    {
        UpdateWZCLogView();
    }

    LeaveCriticalSection(&g_LogMsgQueue.Lock);

    return hr;

} // AddLoggingMsg
Пример #7
0
BOOL
CSDHCBase::Init(
                LPCTSTR pszActiveKey
                )
{
    BOOL fRet = FALSE;
    SD_API_STATUS status;
    HKEY    hkDevice = NULL;

    hkDevice = OpenDeviceKey(pszActiveKey);
    if (!hkDevice || !m_regDevice.Open(hkDevice, _T(""))) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC: Failed to open device key\n")));
        goto EXIT;
    }

    // Get a handle to our parent bus.
    m_hBusAccess = CreateBusAccessHandle(pszActiveKey);
    if (m_hBusAccess == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC: Could not get handle to parent\n")));
        goto EXIT;
    }

    m_cSlots = DetermineSlotCount();
    if (!CheckSlotCount(m_cSlots)) {
        goto EXIT;
    }
    PREFAST_ASSERT(m_cSlots <= SDHC_MAX_SLOTS);

    m_pSlotInfos = (PSDHC_SLOT_INFO) LocalAlloc(LPTR, 
        sizeof(SDHC_SLOT_INFO) * m_cSlots);
    if (m_pSlotInfos == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate slot info objects\n")));
        goto EXIT;
    }

    status = SDHCDAllocateContext(m_cSlots, &m_pHCDContext);
    if (!SD_API_SUCCESS(status)) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate context : 0x%08X \n"),
            status));
        goto EXIT;
    }
    
    // Set our extension 
    m_pHCDContext->pHCSpecificContext = this;

    if (!InitializeHardware()) {
        goto EXIT;
    }

    // Allocate slot objects
    m_pSlots = AllocateSlotObjects(m_cSlots);
    if (m_pSlots == NULL) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to allocate slot objects\n")));
        goto EXIT;
    }

    // Initialize the slots
    for (DWORD dwSlot = 0; dwSlot < m_cSlots; ++dwSlot) {
        PSDHC_SLOT_INFO pSlotInfo = &m_pSlotInfos[dwSlot];
        PCSDHCSlotBase pSlot = GetSlot(dwSlot);

        if (!pSlot->Init(dwSlot, pSlotInfo->pucRegisters, m_pHCDContext, 
            m_dwSysIntr, m_hBusAccess, m_interfaceType, m_dwBusNumber, &m_regDevice)) {
                goto EXIT;
            }
    }

    // set the host controller name
    //SDHCDSetHCName(m_pHCDContext, TEXT("HSMMC"));
   // SDHCDSetHCName(m_pHCDContext, HostControllerName);
    SDHCDSetHCName(m_pHCDContext, TEXT("HostControllerName"));

    // set init handler
    SDHCDSetControllerInitHandler(m_pHCDContext, CSDHCBase::SDHCInitialize);
    // set deinit handler    
    SDHCDSetControllerDeinitHandler(m_pHCDContext, CSDHCBase::SDHCDeinitialize);
    // set the Send packet handler
    SDHCDSetBusRequestHandler(m_pHCDContext, CSDHCBase::SDHCBusRequestHandler);   
    // set the cancel I/O handler
    SDHCDSetCancelIOHandler(m_pHCDContext, CSDHCBase::SDHCCancelIoHandler);   
    // set the slot option handler
    SDHCDSetSlotOptionHandler(m_pHCDContext, CSDHCBase::SDHCSlotOptionHandler);

    // These values must be set before calling SDHCDRegisterHostController()
    // because they are used during that call.
    m_dwPriority = m_regDevice.ValueDW(SDHC_PRIORITY_KEY, 
        SDHC_CARD_CONTROLLER_PRIORITY);

    // now register the host controller 
    status = SDHCDRegisterHostController(m_pHCDContext);

    if (!SD_API_SUCCESS(status)) {
        DEBUGMSG(SDCARD_ZONE_ERROR, (TEXT("SDHC Failed to register host controller: %0x08X \n"), 
            status));
        goto EXIT;
    }

    m_fRegisteredWithBusDriver = TRUE;
    fRet = TRUE;

EXIT:
    if (hkDevice) RegCloseKey(hkDevice);

    return fRet;
}