Пример #1
0
BOOL GetARM2Version(UCHAR *pOutBuffer,DWORD outSize,DWORD *pOutSize)
{
	UINT32	g_u4Param1,g_u4Param2,g_u4Param3;
    DWORD dwRet;
	UINT32 u4ModuleID,u4MessageID,u4offset = sizeof(SHAREMEM);
    DWORD dwPhyAddr = 0;
    SHAREMEM *pShareM = NULL;


	
	pShareM = AllocateShareMem(4*20,&dwPhyAddr);
	pShareM->u4Size = sizeof(SHAREMEM);
	pShareM->ShareMemT = SHAREMEM_ARM2_VERSION;
	pShareM->u4ResponeStatus = 0;
	pShareM->u4BufferSize= 4*20 - (sizeof(SHAREMEM));

	
	HWSendMessage(MSG_COMBINE(MODULE_BCAR, MSG_GET_ARM2_VERSION),dwPhyAddr, u4offset, 0);

	dwRet = WaitForSingleObject(g_hBackCarIntrEvt, INFINITE);
	HWGetMessage(MODULE_BCAR, &u4ModuleID, &g_u4Param1, &g_u4Param2, &g_u4Param3);
	u4MessageID = GETMESSAGEID(u4ModuleID);
	if(u4MessageID == MSG_ARM2_RESPONSE)
	   RETAILMSG(TRUE, (TEXT("[FSC][INFO]Rev ARM2 Responese\r\n")));
			
	memcpy(pOutBuffer,(const void *)(0xAC000000+dwPhyAddr+u4offset),g_u4Param1);
	*pOutSize = g_u4Param1;
	InterruptDone(g_dwBackCarSysIntr);
	FreeShareMem(pShareM,4*20,dwPhyAddr);
	
	return TRUE;
}
Пример #2
0
BOOL
CRomiDisk::WaitForInterrupt(
    DWORD dwTimeOut
    )
{
    BYTE bStatus;
    BOOL fRet = TRUE;
    DWORD dwRet;

    // wait for interrupt
    dwRet = WaitForSingleObject(m_pPort->m_hIRQEvent, dwTimeOut);
    if (dwRet == WAIT_TIMEOUT) {
        fRet = FALSE;
    }
    else {
        if (dwRet != WAIT_OBJECT_0) {
            if (!WaitForDisc(WAIT_TYPE_DRQ, dwTimeOut, 10)) {
                fRet = FALSE;
            }
        }
    }

    // read status; acknowledge interrupt
    bStatus = GetBaseStatus();
    if (bStatus & ATA_STATUS_ERROR) {
        bStatus = GetError();
        fRet = FALSE;
    }

    // signal interrupt done
    InterruptDone(m_pPort->m_dwSysIntr);

    return fRet;
}
Пример #3
0
VOID 
CSDHCBase::HandleInterrupt(
                           ) 
{
    Lock();

	RETAILMSG(0,(TEXT("+CSDHCBase::HandleInterrupt\r\n")));
    // Use slot zero to get the shared global interrupt register
    PCSDHCSlotBase pSlotZero = GetSlot(0);
    DWORD dwIntStatus = pSlotZero->ReadControllerInterrupts();

    do {
        DEBUGMSG(SDHC_INTERRUPT_ZONE, (TEXT("CSDHCBase::HandleInterrupt: Slot Interrupt_Status=0x%X\n"), 
            dwIntStatus));

        for (DWORD dwSlot = 0; dwSlot < m_cSlots; ++dwSlot) {
            PCSDHCSlotBase pSlot = GetSlot(dwSlot);

            //if ( ((1 << dwSlot) & dwIntStatus) || pSlot->NeedsServicing() ) {
                pSlot->HandleInterrupt();
            //}
        }

        dwIntStatus = pSlotZero->ReadControllerInterrupts();
	/*
		if(dwIntStatus == 0x2 )
			RETAILMSG(1,(TEXT("dwIntStatus=0x%08X\n"),dwIntStatus));
        */
		if(dwIntStatus && pSlotZero->IsOnlySDIOInterrupt()) break;
    } while (dwIntStatus);

    InterruptDone(m_dwSysIntr);
	RETAILMSG(0,(TEXT("-CSDHCBase::HandleInterrupt\r\n")));
    Unlock();
}
Пример #4
0
BOOL GetMCUInfo(UCHAR *pOutBuffer,DWORD outSize,DWORD *pOutSize)
{
	UINT32	g_u4Param1,g_u4Param2,g_u4Param3;
    DWORD dwRet;
	UINT32 u4ModuleID,u4MessageID;
    DWORD dwPhyAddr = 0;
    SHAREMEM *pShareM = NULL;


	
	pShareM = AllocateShareMem(4*1024,&dwPhyAddr);
	pShareM->u4Size = sizeof(SHAREMEM);
	pShareM->ShareMemT = SHAREMEM_MCU_INFO;
	pShareM->u4ResponeStatus = 0;
	pShareM->u4BufferSize= 4*1024 - (sizeof(SHAREMEM));

	
	HWSendMessage(MSG_COMBINE(MODULE_BCAR, MSG_WINCE_GET_MCU_INFO),dwPhyAddr, 0, 0);

	dwRet = WaitForSingleObject(g_hBackCarIntrEvt, INFINITE);
	HWGetMessage(MODULE_BCAR, &u4ModuleID, &g_u4Param1, &g_u4Param2, &g_u4Param3);
	u4MessageID = GETMESSAGEID(u4ModuleID);
	if(u4MessageID == MSG_ARM2_RESPONSE)
	   RETAILMSG(TRUE, (TEXT("[FSC][INFO]Rev ARM2 Responese\r\n")));
			
			
	memcpy(pOutBuffer,(UCHAR *)pShareM->Data,4);
	*pOutSize = 4;
	InterruptDone(g_dwBackCarSysIntr);
	FreeShareMem(pShareM,4*1024,dwPhyAddr);

	return TRUE;
}
Пример #5
0
INT WINAPI ResetButtonThread(void)
{
	PWRBTN_INF((_T("[PWR:INF] ++ResetButtonThread()\r\n")));

	while(!g_bExitThread)
	{
		WaitForSingleObject(g_hEventResetBtn, INFINITE);

		if(g_bExitThread)
		{
			break;
		}

		Button_rstbtn_disable_interrupt();			// Mask EINT
		Button_rstbtn_clear_interrupt_pending();		// Clear Interrupt Pending

		InterruptDone(g_dwSysIntrResetBtn);

		PWRBTN_INF((_T("[PWR] Reset Button Event\r\n")));

		SetSystemPowerState(NULL, POWER_STATE_RESET, POWER_FORCE);
		//KernelIoControl(IOCTL_HAL_REBOOT, NULL, 0, NULL, 0, NULL);

		PWRBTN_ERR((_T("[PWR:ERR] Soft Reset Failed\r\n")));

		Button_rstbtn_enable_interrupt();				// UnMask EINT
	}

	PWRBTN_INF((_T("[PWR:INF] --ResetButtonThread()\r\n")));

	return 0;
}
Пример #6
0
static DWORD MFC_IntrThread(void)
{
    unsigned int intr_reason;

    while (1)
    {
        // Wait for MFC Interrupt
        WaitForSingleObject(gMfcIntrEvent, INFINITE);

        // Only SEQ_INIT, SEQ_END, PIC_RUN and BUFFER EMPTY/FULL interrupts
        // will be processed.
        intr_reason = MfcIntrReason();
        RETAILMSG(0, (L"(( MFC Interrupt ) reason = 0x%X\n", intr_reason));

        if (intr_reason & MFC_INTR_ENABLE_RESET) {
            // On the MFC Interrupt,
            // MFC command completion event will be sent.
            // This event wakes up the task in WaitInterruptNotification() function.
            SendInterruptNotification(intr_reason);
        }

        // Clearing MFC interrupt bit
        MfcClearIntr();

        // Notify to Kernel that MFC Interrupt processing is completed.
        InterruptDone(g_MfcSysIntr);
    }

}
Пример #7
0
void
CPCIDisk::EnableInterrupt(
    )
{
    GetBaseStatus(); // acknowledge interrupt, if pending

    // signal interrupt done
    InterruptDone(m_pPort->m_dwSysIntr);
}
Пример #8
0
void
busDriverIsr (BUS_DRIVER_HANDLE busDriverHandle,A_BOOL *callDsr)
{
    CF_DEVICE *cfDevice;

    cfDevice = (CF_DEVICE *)busDriverHandle;
#ifdef DEBUG
    printMask = FALSE;
#endif
    if (cfDevice->interruptRegistered == FALSE) {
        InterruptDone(cfDevice->sysIntr);
        *callDsr = FALSE;
    } else {
	    cfFunction.pIsr((CF_DEVICE_HANDLE)cfDevice,callDsr);
    }
#ifdef DEBUG
    printMask = TRUE;
#endif
    return;
}
Пример #9
0
// New function to Card detect thread of HSMMC ch1 on SMDK6410.
DWORD CSDHControllerCh1::CardDetectThread() {
    BOOL  bSlotStateChanged = FALSE;
    DWORD dwWaitResult  = WAIT_TIMEOUT;
    PCSDHCSlotBase pSlotZero = GetSlot(0);

    CeSetThreadPriority(GetCurrentThread(), 100);

    while(1) {
        // Wait for the next insertion/removal interrupt
        dwWaitResult = WaitForSingleObject(m_hevCardDetectEvent, INFINITE);

        Lock();
        pSlotZero->HandleInterrupt(SDSLOT_INT_CARD_DETECTED);
        Unlock();
        InterruptDone(m_dwSDDetectSysIntr);

        EnableCardDetectInterrupt();
    }

    return TRUE;
}
Пример #10
0
INT WINAPI PowerButtonThread(void)
{
	DWORD nBtnCount = 0;

	PWRBTN_INF((_T("[PWR:INF] ++PowerButtonThread()\r\n")));

	while(!g_bExitThread)
	{
		WaitForSingleObject(g_hEventPowerBtn, INFINITE);

		if(g_bExitThread)
		{
			break;
		}

		Button_pwrbtn_disable_interrupt();			// Mask EINT
		Button_pwrbtn_clear_interrupt_pending();		// Clear Interrupt Pending

		InterruptDone(g_dwSysIntrPowerBtn);

		while(Button_pwrbtn_is_pushed())
		{
			// Wait for Button Released...
			Sleep(10);
		}

		nBtnCount++;
		PWRBTN_INF((_T("[PWR] Power Button Event [%d]\r\n"), nBtnCount));

		//PowerPolicyNotify(PPN_POWERBUTTONPRESSED,0);
		SetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);

		Button_pwrbtn_enable_interrupt();			// UnMask EINT
	}

	PWRBTN_INF((_T("[PWR:INF] --PowerButtonThread()\r\n")));

	return 0;
}
Пример #11
0
BOOL GetARM2BackCarStatus(UCHAR *pOutBuffer,DWORD outSize,DWORD *pOutSize)
{
	UINT32	g_u4Param1,g_u4Param2,g_u4Param3;
    DWORD dwRet;
	UINT32 u4ModuleID,u4MessageID;
	HWSendMessage(MSG_COMBINE(MODULE_BCAR, MSG_WINCE_APP_READY),0, 0, 0);
			
			
	dwRet = WaitForSingleObject(g_hBackCarIntrEvt, INFINITE);
			
	HWGetMessage(MODULE_BCAR, &u4ModuleID, &g_u4Param1, &g_u4Param2, &g_u4Param3);
			
	u4MessageID = GETMESSAGEID(u4ModuleID);
	if(u4MessageID == MSG_ARM2_RESPONSE)
	   RETAILMSG(TRUE, (TEXT("[FSC][INFO]Rev ARM2 Responese\r\n")));
			
			
	memcpy(pOutBuffer,(UCHAR *)&g_u4Param1,4);
	memcpy(pOutBuffer+4,(UCHAR *)&g_u4Param2,4);
	*pOutSize = 8;
	InterruptDone(g_dwBackCarSysIntr);
	return TRUE;
}
Пример #12
0
static DWORD SpiGpioIRQInterruptThread(LPVOID pContext)
{
    PSDHCD_HW_DEVICE pHWDevice = (PSDHCD_HW_DEVICE)pContext;

    DBG_PRINT(SDDBG_TRACE, ("SpiGpioIRQInterruptThread: Initializing. Context 0x%X \n",pContext));
    
    CeSetThreadPriority(GetCurrentThread(), SPI_IRQ_THREAD_PRIORITY);
    
    while (TRUE) {
        WaitForSingleObject(pHWDevice->hIstEventSPIGpioIRQ,INFINITE); 
        if (pHWDevice->ShutDown) {
            DBG_PRINT(SDDBG_TRACE, ("SpiGpioIRQInterruptThread: Shutting down \n"));            
            break;
        }
        
        HcdSpiInterrupt(pHWDevice->pDevice);
            
            /* ack kernel/OAL that interrupt has been acknowledged */
        InterruptDone(pHWDevice->SysIntrSPIGpioIRQ); 
    }

    return 0;
}
Пример #13
0
VOID
DdsiTouchPanelGetPoint(TOUCH_PANEL_SAMPLE_FLAGS *pTipState, INT *pUncalX, INT *pUncalY)
{
	static int PrevX=0;
	static int PrevY=0;
	int TmpX = 0;
	int TmpY = 0;

	//TSPMSG((_T("[TSP] ++DdsiTouchPanelGetPoint()\r\n")));

	if (g_pVIC1Reg->VICRAWINTR & (1<<(PHYIRQ_PENDN-VIC1_BIT_OFFSET)))		// gIntrTouch Interrupt Case
	{
		//TSPMSG((_T("[TSP] gIntrTouch(PHYIRQ_PENDN) Case\r\n")));

		*pTipState = TouchSampleValidFlag;

		if ((g_pADCReg->ADCDAT0 & D_UPDOWN_UP)
			|| (g_pADCReg->ADCDAT1 & D_UPDOWN_UP))
		{
			//TSPMSG((_T("[TSP] Pen Up\r\n")));

			g_bTSP_DownFlag = FALSE;

			g_pADCReg->ADCTSC = ADCTSC_WAIT_PENDOWN;

			*pUncalX = PrevX;
			*pUncalY = PrevY;

			TSP_SampleStop();
		}
		else
		{
			//TSPMSG((_T("[TSP] Pen Down\r\n")));

			g_bTSP_DownFlag = TRUE;

			g_pADCReg->ADCTSC = ADCTSC_WAIT_PENUP;

			*pTipState |= TouchSampleIgnore;

			*pUncalX = PrevX;
			*pUncalY = PrevY;

			*pTipState |= TouchSampleDownFlag;

			TSP_SampleStart();
		}

		g_pADCReg->ADCCLRWK = CLEAR_ADCWK_INT;

		InterruptDone(gIntrTouch);		// Not handled in MDD
	}
	else// if (g_pVIC0Reg->VICRAWINTR & (1<<(PHYIRQ_TIMER3)))		// gIntrTouchTimer Interrupt Case
	{
		//TSPMSG((_T("[TSP] gIntrTouchChanged(PHYIRQ_TIMER3) Case\r\n")));

		// Check for Pen-Up case on the event of timer3 interrupt
		if ((g_pADCReg->ADCDAT0 & D_UPDOWN_UP)
			|| (g_pADCReg->ADCDAT1 & D_UPDOWN_UP))
		{
			//TSPMSG((_T("[TSP] Pen Up +\r\n")));

			g_bTSP_DownFlag = FALSE;

			g_pADCReg->ADCTSC = ADCTSC_WAIT_PENDOWN;

			*pUncalX = PrevX;
			*pUncalY = PrevY;

			*pTipState = TouchSampleValidFlag;

			TSP_SampleStop();
		}
		else if (g_bTSP_DownFlag)
		{
			if (TSP_GetXY(&TmpX, &TmpY) == TRUE)
			{
				//TSP_TransXY(&TmpX, &TmpY);

				if(Touch_Pen_Filtering(&TmpX, &TmpY))
				{
					*pTipState = TouchSampleValidFlag | TouchSampleDownFlag;
					*pTipState &= ~TouchSampleIgnore;
				}
				else		// Invalid touch pen
				{
					*pTipState = TouchSampleValidFlag;
					*pTipState |= TouchSampleIgnore;
				}

				*pUncalX = PrevX = TmpX;
				*pUncalY = PrevY = TmpY;

				g_pADCReg->ADCTSC = ADCTSC_WAIT_PENUP;

				//TSPMSG((_T("[TSP] UncalX = %d, UncalY = %d\r\n"), *pUncalX,*pUncalY));
			}
			else
			{
				*pTipState = TouchSampleIgnore;
			}
		}
		else
		{
			TSPERR((_T("[TSP] Unknown State\r\n")));

			*pTipState = TouchSampleIgnore;
			TSP_SampleStop();
		}

		// timer3 interrupt status clear
		//g_pPWMReg->TINT_CSTAT |= (1<<8);		// Do not use OR/AND operation on TINTC_CSTAT
		g_pPWMReg->TINT_CSTAT = TINT_CSTAT_INTMASK(g_pPWMReg->TINT_CSTAT) | TIMER3_PENDING_CLEAR;

		InterruptDone(gIntrTouchChanged);		// Not Handled in MDD
	}

	//TSPMSG((_T("[TSP] --DdsiTouchPanelGetPoint()\r\n")));
}
Пример #14
0
INT WINAPI PowerButtonThread(void)
{
	DWORD nBtnCount = 0;
	WCHAR  state[1024] = {0};
	LPWSTR pState = &state[0];
	DWORD dwBufChars = (sizeof(state) / sizeof(state[0]));
	DWORD  dwStateFlags = 0;
	DWORD dwErr;

	PWRBTN_INF((_T("[PWR:INF] ++PowerButtonThread()\r\n")));

	while(!g_bExitThread)
	{
		WaitForSingleObject(g_hEventPowerBtn, INFINITE);

		if(g_bExitThread)
		{
			break;
		}

		Button_pwrbtn_disable_interrupt();			// Mask EINT
		Button_pwrbtn_clear_interrupt_pending();		// Clear Interrupt Pending

		dwErr = GetSystemPowerState(pState, dwBufChars, &dwStateFlags);
		if (ERROR_SUCCESS != dwErr)
		{
			RETAILMSG(1, (TEXT("PMGET!GetSystemPowerState:ERROR:%d\n"), dwErr));
		}
		else
		{
			RETAILMSG(1, (TEXT("PMGET! System Power state is '%s', flags 0x%08x\n"), state, dwStateFlags));
		}

		InterruptDone(g_dwSysIntrPowerBtn);

#ifndef    SLEEP_AGING_TEST
		while(Button_pwrbtn_is_pushed())
		{
			// Wait for Button Released...
			Sleep(10);
		}
#endif

		nBtnCount++;
		PWRBTN_INF((_T("[PWR] Power Button Event [%d]\r\n"), nBtnCount));

		//SetSystemPowerState(NULL, POWER_STATE_SUSPEND, POWER_FORCE);
		//PowerPolicyNotify(PPN_POWERBUTTONPRESSED,0);

		if ( wcscmp(state,TEXT("screenoff")) == 0 )
		{
			RETAILMSG(1,(TEXT("setsystempowerstate to ON from screen off\r\n")));
			SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE );
		}
		else if ( wcscmp(state,TEXT("backlightoff")) == 0 )
		{

		#ifdef WPC
			RETAILMSG(1,(TEXT("setsystempowerstate to ON from backlight off\r\n")));
			SetSystemPowerState( NULL, POWER_STATE_ON, POWER_FORCE );
		#endif
		#ifdef SMARTFON
		  	 RETAILMSG(1,(TEXT("setsystempowerstate to IDLE from backlight off\r\n")));
			SetSystemPowerState( TEXT("useridle"), POWER_STATE_IDLE, POWER_FORCE );
		#endif
		}
		else
		{
		#ifdef WPC
			//SetSystemPowerState( NULL, POWER_STATE_SUSPEND, POWER_FORCE );
			PowerPolicyNotify(PPN_POWERBUTTONPRESSED,0);
		#endif
		#ifdef SMARTFON
			RETAILMSG(1,(TEXT("setsystempowerstate to IDLE from on\r\n")));
			SetSystemPowerState( TEXT("useridle"), POWER_STATE_IDLE, POWER_FORCE );
		#endif
		}

		Button_pwrbtn_enable_interrupt();			// UnMask EINT
#ifdef    SLEEP_AGING_TEST
        Sleep(2000);
        SetEvent(g_hEventPowerBtn);
#endif
	}

	PWRBTN_INF((_T("[PWR:INF] --PowerButtonThread()\r\n")));

	return 0;
}
Пример #15
0
DWORD CPdd6410Uart::ThreadRun()
{
    DWORD dwData;
    DWORD interrupts;
    
    while ( m_hISTEvent!=NULL && !IsTerminated() )
    {
        if ( WaitForSingleObject( m_hISTEvent, m_dwISTTimeout) == WAIT_OBJECT_0)
        {
            m_HardwareLock.Lock();    
        
            while ( !IsTerminated() )
            {
                dwData = ( GetInterruptStatus() & (S6410UART_INT_RXD | S6410UART_INT_TXD | S6410UART_INT_ERR | S6410UART_INT_MODEM) );
                if (dwData)
                {
                    DEBUGMSG(ZONE_THREAD, (TEXT(" CPdd6410Uart::ThreadRun Active INT=%x\r\n"), dwData));

                    // Clear the interrupt value to notify to MDD
                    interrupts=NULL;
                    DEBUGCHK(interrupts==NULL);

                    if ((dwData & S6410UART_INT_RXD)!=0)
                    {
                        interrupts |= INTR_RX;
                    }
                    if ((dwData & S6410UART_INT_TXD)!=0)
                    {
                        interrupts |= INTR_TX;
                    }
                    if ((dwData & S6410UART_INT_ERR)!=0)
                    {
                        interrupts |= INTR_LINE | INTR_RX;
                    }
                    if ((dwData & S6410UART_INT_MODEM)!=0)
                    {
                        interrupts |=INTR_MODEM;
                    }
                    
                    NotifyPDDInterrupt( (INTERRUPT_TYPE)interrupts );
                    
                    ClearInterrupt(dwData);
                }
                else
                {
                    break;
                }
            }

            m_HardwareLock.Unlock();   

            InterruptDone(m_dwSysIntr);
        }
        else
        {
            DEBUGMSG(ZONE_THREAD,(TEXT(" CPdd6410Uart::ThreadRun timeout INT=%x,MASK=%d\r\n"),m_pReg6410Uart->Read_UINTP()/*m_pReg6410Uart->Read_UINTSP()*/, m_pReg6410Uart->Read_UINTM()) );
            ASSERT(FALSE);
        }
    }

    return 1;
}
Пример #16
0
void S3C2450DISP::SetVisibleSurface( GPESurf *pTempSurf, BOOL bWaitForVBlank)
{
	static int timeoutcnt=0;
    DWORD we;
#ifdef	HIGH_PRIORITY_INTR
	int iPriority;
	HANDLE hThread;

	hThread = GetCurrentThread();
	iPriority = CeGetThreadPriority(hThread);
	CeSetThreadPriority(hThread, DISPDRV_IST_PRIORITY);
#endif	
	S3C2450Surf *pSurf = (S3C2450Surf *) pTempSurf;
	EnterCriticalSection(&m_CS);
	// assume Synchronous to VSYNC

	EnableInterrupt();
	we = WaitForSingleObject(m_hVSYNCInterruptEvent,1000/*INFINITE*/);
	DisableInterrupt();
	InterruptDone(m_dwVSYNCSysIntr);

	if(we != WAIT_OBJECT_0)
	{
		timeoutcnt++;
		RETAILMSG(1,(TEXT("Surface Flipping Time Out  %d !!!\n"), timeoutcnt));
		for(int i=0;i<78;i++)
			RETAILMSG(1,(TEXT("0x%08X = 0x%08X\n"),(DWORD*)((DWORD*)m_pLCDReg + i),*(DWORD*)((DWORD*)m_pLCDReg + i)));
			
		RETAILMSG(1,(TEXT("saved_x=%d"),saved_x));
		RETAILMSG(1,(TEXT("saved_y=%d"),saved_y));
		RETAILMSG(1,(TEXT("saved_width=%d"),saved_width));
		RETAILMSG(1,(TEXT("saved_height=%d"),saved_height));				
		while(1);
	}

	if(pSurf->m_bIsOverlay == FALSE)
	{
		//RETAILMSG(1,(TEXT("pSurf->OffsetInVideoMemory()=0x%08X\n"),pSurf->OffsetInVideoMemory()));
		m_pVisibleSurface = pSurf;
		m_pLCDReg->VIDW00ADD0B0 = (UINT32)(pSurf->OffsetInVideoMemory() + IMAGE_FRAMEBUFFER_DMA_BASE);		
				// buffer end address
		m_pLCDReg->VIDW00ADD1B0 = (UINT32)(pSurf->OffsetInVideoMemory() + IMAGE_FRAMEBUFFER_DMA_BASE) + (LCD_XSIZE_TFT*LCD_YSIZE_TFT*2);
				// buffer size 
		m_pLCDReg->VIDW00ADD2B0 = (0<<VIDWxADD2_OFFSET_SIZE_S)|(LCD_XSIZE_TFT*2);
	}
	else
	{

		m_pLCDReg->VIDW01ADD0 = (UINT32)(pSurf->OffsetInVideoMemory() + IMAGE_FRAMEBUFFER_DMA_BASE);		
				// buffer end address
		m_pLCDReg->VIDW01ADD1 = (UINT32)(pSurf->OffsetInVideoMemory() + IMAGE_FRAMEBUFFER_DMA_BASE) + 
														(pSurf->Width()*pSurf->Height()*2);
				// buffer size 
		m_pLCDReg->VIDW01ADD2 = (0<<VIDWxADD2_OFFSET_SIZE_S)|(pSurf->Width()*2);		
	}
	RETAILMSG(DBGLCD, (TEXT("S3C2450DISP::SetVisibleSurface\r\n")));
	LeaveCriticalSection(&m_CS);

#ifdef	HIGH_PRIORITY_INTR
	CeSetThreadPriority(hThread, iPriority);
#endif	
}
Пример #17
0
BOOL KeyMatrix::IsrThreadProc()
{
    DWORD dwPriority;
    DWORD i, step;

    DWORD   rguiScanCode[SIZE_KEY];
    BOOL    rgfKeyUp[SIZE_KEY];
    UINT    cEvents;
    DWORD ret;
    DWORD timeout;
    HANDLE gEventIntr;
    DWORD irq, sysintr;

    ReadRegDWORD( TEXT("HARDWARE\\DEVICEMAP\\KEYBD"), _T("Priority256"), &dwPriority );
    if(dwPriority == 0)
    {
        dwPriority = DEFAULT_PRIORITY;
    }

    DEBUGMSG(ZONE_INIT, (TEXT("+[KEYBD]IsrThreadProc\r\n")));
    // update the IST priority
    CeSetThreadPriority(GetCurrentThread(), (int)dwPriority);

    irq = IRQ_KEYPAD;
    if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &irq, sizeof(UINT32), &sysintr, sizeof(UINT32), NULL))
    {
        ERRORMSG( 1, (TEXT("ERROR: Failed to request the IRQ_KEY sysintr.\r\n")));
        sysintr = SYSINTR_UNDEFINED;
        return(FALSE);
    }

    gEventIntr = CreateEvent(NULL, FALSE, FALSE, NULL);
    if( NULL == gEventIntr )
    {
        ERRORMSG( 1, (TEXT("Event is not created\r\n")));
        return(FALSE);
    }

    if( InterruptInitialize(sysintr, gEventIntr, NULL, 0) == FALSE )
    {
        ERRORMSG( 1, (TEXT("interrupt is not initialized\n\r")));
        return(FALSE);
    }


    timeout = INFINITE;
    DEBUGMSG(ZONE_INIT, (TEXT("+[KEYBD]Enter Infinite Loop\r\n")));
    while(1)    // INFINITE LOOP ____________________________________________________________________
    {
        ret = WaitForSingleObject(gEventIntr, timeout); // Wait for Interrupt Event ________________________

        if( ret == WAIT_OBJECT_0 )
        {
            RETAILMSG( FALSE,(TEXT("Object : WAIT_OBJECT_0\r\n")));
            timeout = TIME_KEYSCAN;
        }

        // Clear Pressed/Released Interrupt
        KEYIF_Status_Clear();
        // Read the Matrix
        KScan_ProcIO();

        for( i=0, step=0; i< SIZE_COLS; i++, step+=SIZE_ROWS)
        {
            cEvents = KScan_ProcState( i, step, rguiScanCode, rgfKeyUp);

            if( cEvents )
            {
                for (UINT iEvent = 0; iEvent < cEvents; ++iEvent)
                {
                    v_pfnKeybdEvent(v_uiPddId, rguiScanCode[iEvent], rgfKeyUp[iEvent]);
                    RETAILMSG(FALSE,(TEXT("PddID : %x, ScanCode : %x, KeyUp : %d\r\n"),v_uiPddId, rguiScanCode[iEvent], rgfKeyUp[iEvent]));
                }
            }
        }

        if( TRUE == AreAllKeysUp() )
        {
            RETAILMSG(0,(TEXT("Key all up\r\n")));
            timeout = INFINITE;
        }
        InterruptDone(sysintr);
    }// INFINITE LOOP ____________________________________________________________________
}
Пример #18
0
static DWORD
I2C_IST(
    LPVOID Context
    )
{
    PI2C_CONTEXT pI2C = (PI2C_CONTEXT)Context;
    DWORD i2cSt;
    BOOL bDone = FALSE;
#ifdef DEBUG
    DWORD r = 0;
#endif

    if ( !pI2C ) {
        TEST_TRAP;
        return ERROR_INVALID_PARAMETER;
    }

    //DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("+I2C_IST[%u, %u, %d] \r\n"), pI2C->Mode, pI2C->State, pI2C->DataCount));

    do  {
        
        if (pI2C->Mode == INTERRUPT) {
            
            DWORD we;

            bDone = FALSE;
            
            we = WaitForSingleObject(pI2C->ISTEvent, INFINITE);
            
            //DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("I2C_IST[%u, %d] \r\n"), pI2C->State, pI2C->DataCount));

            // clear the interrupt here because we re-arm another below
            InterruptDone(gIntrIIC);

            //
            // Ensure correct state initiated by Read/Write
            //
            DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("I2C_IST[%u, %d] \r\n"), 
                pI2C->State, pI2C->DataCount));

            switch(pI2C->State)
            {
                case OFF:
                    DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("I2C_IST: ExitThread \r\n")));
                    ExitThread(ERROR_SUCCESS);
                    break;

                case IDLE:
                    DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("I2C_IST: IDLE \r\n")));
                    continue;
                    break;

                default:
                    if (pI2C->State != WRITE_ACK && 
                        pI2C->State != RESUME &&
                        pI2C->DataCount == INVALID_DATA_COUNT) {
                        DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("I2C_IST: INVALID_DATA_COUNT\r\n")));
                        continue;
                    }
                    break;
            }
        }

//        EnterCriticalSection(&pI2C->RegCS);
        
        i2cSt = rIICSTAT; 

        if (i2cSt & 0x8) {
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_IST[%u, %d]: bus arbitration failed \r\n"), 
                pI2C->State, pI2C->DataCount));
//           RETAILMSG(1, (TEXT("I2C_IST[%u, %d]: bus arbitration failed \r\n"), 
//                pI2C->State, pI2C->DataCount));
        } 

        if (i2cSt & 0x4) {
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_IST[%u, %d]: slave address matches IICADD \r\n"), 
                pI2C->State, pI2C->DataCount));
//            RETAILMSG(1, (TEXT("I2C_IST[%u, %d]: slave address matches IICADD \r\n"), 
//                pI2C->State, pI2C->DataCount));
        }
        
        if (i2cSt & 0x2) {
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_IST[%u, %d]: received slave address 0x0 \r\n"), 
                pI2C->State, pI2C->DataCount));
//            RETAILMSG(1, (TEXT("I2C_IST[%u, %d]: received slave address 0x0 \r\n"), 
//                pI2C->State, pI2C->DataCount));
        }

        if (i2cSt & 0x1) {
            DEBUGMSG(ZONE_READ|ZONE_WRITE,(TEXT("I2C_IST[%u, %d]: ACK NOT received \r\n"), 
                pI2C->State, pI2C->DataCount));
	     RETAILMSG(1, (TEXT("I2C_IST[%u, %d]: ACK NOT received \r\n"), 
               pI2C->State, pI2C->DataCount));
        }

        __try {
                
            switch(pI2C->State)
            {
                case IDLE:
                case SUSPEND:
                    continue;
                    break;
                    
                case RESUME:
                    DEBUGMSG(ZONE_WRN, (TEXT("I2C_IST: RESUME \r\n")));
//                  RETAILMSG(1,  (TEXT("I2C_IST: RESUME \r\n")));
                    InitRegs(pI2C);
                    pI2C->LastError = ERROR_OPERATION_ABORTED;
                    SetEvent(pI2C->DoneEvent);
                    break;

                case SET_READ_ADDR:
                    if ( (pI2C->DataCount--) == 0 )
                    {
                        DEBUGMSG(ZONE_READ|ZONE_TRACE, (TEXT("A2[%d] \r\n"), 
                            pI2C->DataCount ));
//                        RETAILMSG(1, (TEXT("A2[%d] \r\n"), 
//           		 pI2C->DataCount ));
                        bDone = TRUE;
                        break;
                    }

                    DEBUGMSG(ZONE_READ|ZONE_TRACE, (TEXT("A1[%d]: 0x%X \r\n"), 
                        pI2C->DataCount, pI2C->WordAddr));
//                    RETAILMSG(1, (TEXT("A1[%d]: 0x%X \r\n"), 
//                        pI2C->DataCount, pI2C->WordAddr));                    
                    // write word address
                    // For setup time of SDA before SCL rising edge, rIICDS must be written 
                    // before clearing the interrupt pending bit.
                    if (pI2C->Flags.WordAddr) {
                        rIICDS = pI2C->WordAddr;
                        // clear interrupt pending bit (resume)
                        rIICCON = RESUME_ACK;
                        pI2C->Flags.WordAddr = FALSE;
                    }
                    break;


                case READ_DATA:                    
                    ASSERT(pI2C->Data);
                    if ( (pI2C->DataCount--) == 0 )
                    {
                        bDone = TRUE;
                    
                        *pI2C->Data = (UCHAR)rIICDS;
#ifdef DEBUG                        
                        r = *pI2C->Data;
                        
                        //RETAILMSG(1,(TEXT("R3_1:0x%X, pI2C->Data(0x%X) \r\n"), r, pI2C->Data));
                        //RETAILMSG(1,(_T("pI2C->Data(0x%X)\r\n"), pI2C->Data));
#endif
                        pI2C->Data++;
                        
                        rIICSTAT = MRX_STOP;    
                        rIICCON  = RESUME_ACK;  // resume operation.
                        
                        //RETAILMSG(1,(_T("pI2C->Data(0x%X)\r\n"), pI2C->Data));
                        //RETAILMSG(1,(TEXT("R3_2:0x%X, pI2C->Data(0x%X) \r\n"), r, pI2C->Data));
                        //DEBUGMSG(ZONE_READ|ZONE_TRACE,(TEXT("R3:0x%X \r\n"), r));
                                    
                        //The pending bit will not be set after issuing stop condition.
                        break;    
                    }

                    // Drop the returned Slave WordAddr?
                    if ( pI2C->Flags.DropRxAddr )
                    {
                        pI2C->RxRetAddr = (UCHAR)rIICDS;
                        pI2C->Flags.DropRxAddr = FALSE;
                        DEBUGMSG(ZONE_READ|ZONE_TRACE,(TEXT("Drop: 0x%X \r\n"), 
                            pI2C->RxRetAddr));
                        
                    } else {
                        *pI2C->Data = (UCHAR)rIICDS;
#ifdef DEBUG
                        r = *pI2C->Data;
#endif
                        pI2C->Data++;
                    }

					//RETAILMSG(1,(TEXT("R3_3:0x%X, pI2C->Data(0x%X) \r\n"), r, pI2C->Data));
					
                    // The last data is read with no ack.
                    if ( pI2C->DataCount == 0 ) {
                        rIICCON = RESUME_NO_ACK;    // resume operation with NOACK.  
                        DEBUGMSG(ZONE_READ|ZONE_TRACE,(TEXT("R1:0x%X \r\n"), r));
                    } else {
                        rIICCON = RESUME_ACK;       // resume operation with ACK
                        DEBUGMSG(ZONE_READ|ZONE_TRACE,(TEXT("R2:0x%X \r\n"), r));
                    }
                    break;


                case WRITE_DATA:                        
                    ASSERT(pI2C->Data);
                    if ( (pI2C->DataCount--) == 0 )
                    {
                        DEBUGMSG(ZONE_WRITE|ZONE_TRACE,(TEXT("W3[%d] \r\n"), pI2C->DataCount));
                        //RETAILMSG(1,(TEXT("W3[%d] \r\n"), pI2C->DataCount));
                        
                        bDone = TRUE;

                        rIICSTAT = MTX_STOP;    
                        rIICCON  = RESUME_ACK;  // resume operation.

                        //The pending bit will not be set after issuing stop condition.
                        break;    
                    }
                    
                    if (pI2C->Flags.WordAddr) {
                        rIICDS = pI2C->WordAddr;
                        DEBUGMSG(ZONE_WRITE|ZONE_TRACE,(TEXT("W1[%d]: 0x%X \r\n"), 
                            pI2C->DataCount, pI2C->WordAddr));
                        pI2C->Flags.WordAddr = FALSE;
                    } else {
                        DEBUGMSG(ZONE_WRITE|ZONE_TRACE,(TEXT("W2[%d]: 0x%X \r\n"), 
                            pI2C->DataCount, *pI2C->Data));
                        
                        rIICDS = (UCHAR)*pI2C->Data;
                        pI2C->Data++;
                    }

                    rIICCON = RESUME_ACK;   // resume operation.
                    break;


                case WRITE_ACK:
                    DEBUGMSG(ZONE_WRITE|ZONE_TRACE,(TEXT("WRITE_ACK \r\n") ));
                    //RETAILMSG(1,(TEXT("WRITE_ACK \r\n") ));
                    pI2C->Status = i2cSt;
                    bDone = TRUE;
                    break;


                case IO_COMPLETE:
                    DEBUGMSG(ZONE_IST, (TEXT("IO_COMPLETE \r\n")));
                    bDone = TRUE;
                    break;


                case IO_ABANDONED:
                    DEBUGMSG(ZONE_ERR|ZONE_WRN,(TEXT("IO_ABANDONED \r\n") ));
                    bDone = TRUE;
                    break;


                default:
                    DEBUGMSG(ZONE_ERR,(TEXT("!!! I2C_IST ERROR: Invalid State: %u !!!\r\n"), 
                        pI2C->State));
                    bDone = TRUE;
                    break;    
            }
        
        } _except(EXCEPTION_EXECUTE_HANDLER) {
            
            rIICSTAT = (pI2C->State == READ_DATA) ? MRX_STOP : MTX_STOP;
            rIICCON  = RESUME_ACK;

            pI2C->DataCount = INVALID_DATA_COUNT;
        
            pI2C->LastError = GetExceptionCode();
//            RETAILMSG(1,(TEXT("!!! I2C_IST EXCEPTION: 0x%X !!!\r\n"), pI2C->LastError ));
        }

            
        if (bDone) {
            DEBUGMSG(ZONE_IST, (TEXT("SetEvent DONE\r\n")));
            SetEvent(pI2C->DoneEvent);
        }            

//        LeaveCriticalSection(&pI2C->RegCS);
                    
    } while (pI2C->Mode == INTERRUPT);


    //DEBUGMSG(ZONE_IST|ZONE_TRACE,(TEXT("-I2C_IST[%u] \r\n"), pI2C->Mode));

    return ERROR_SUCCESS;
}
Пример #19
0
DWORD
HW_Init(
    PI2C_CONTEXT pI2C
    )
{
    DWORD dwErr = ERROR_SUCCESS;
	UINT32 Irq;
    
//    RETAILMSG(1,(TEXT("I2C Init\r\n")));
    if ( !pI2C ) {
        return ERROR_INVALID_PARAMETER;
    }
    
    DEBUGMSG(ZONE_TRACE,(TEXT("+I2C_Init: %u, 0x%x, 0x%x \r\n"), 
        pI2C->Mode, pI2C->SlaveAddress));

    InitializeCriticalSection(&pI2C->RegCS);
    
    pI2C->Status    = 0;
    pI2C->Data      = NULL;
    pI2C->DataCount = INVALID_DATA_COUNT;
    pI2C->Flags.DropRxAddr = FALSE;

    pI2C->hProc = (HANDLE)GetCurrentProcessId();

    InitRegs(pI2C);

    // create I/O Done Event
    if ( (pI2C->DoneEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL)
    {
        dwErr = GetLastError();
        DEBUGMSG(ZONE_ERR,(TEXT("I2C_Init ERROR: Unable to create Done event: %u \r\n"), dwErr));
        goto _init_error;
    }

    // setup Operating Mode
    if ( pI2C->Mode == INTERRUPT ) {
        // create IST event
        if ( (pI2C->ISTEvent = CreateEvent(NULL, FALSE, FALSE, NULL)) == NULL)
        {
            dwErr = GetLastError();
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_Init ERROR: Unable to create IST event: %u \r\n"), dwErr));
            goto _init_error;
        }

	// Obtain sysintr values from the OAL for the camera interrupt.
	//
	Irq = IRQ_I2C;
	if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &Irq, sizeof(UINT32), &gIntrIIC, sizeof(UINT32), NULL))
	{
		DEBUGMSG(ZONE_ERR, (TEXT("ERROR: Failed to request the IIC sysintr.\r\n")));
		gIntrIIC = SYSINTR_UNDEFINED;
		return(FALSE);
	}
//	RETAILMSG(1, (TEXT("IIC IRQ mapping: [IRQ:%d->sysIRQ:%d].\r\n"), Irq, gIntrIIC));

        // initialize the interrupt
        if( !InterruptInitialize(gIntrIIC, pI2C->ISTEvent, NULL, 0) ) 
        {
            dwErr = GetLastError();
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_Init ERROR: Unable to initialize interrupt: %u\r\n"), dwErr));
            goto _init_error;
        }

        InterruptDone(gIntrIIC);

        // create the IST
        if ( (pI2C->IST = CreateThread(NULL, 0, I2C_IST, (LPVOID)pI2C, 0, NULL)) == NULL)
        {
            dwErr = GetLastError();
            DEBUGMSG(ZONE_ERR,(TEXT("I2C_Init ERROR: Unable to create IST: %u\r\n"), dwErr));
            goto _init_error;
        }

        // TODO: registry override
        if ( !CeSetThreadPriority(pI2C->IST, I2C_THREAD_PRIORITY)) {
            dwErr = GetLastError();
            DEBUGMSG(ZONE_ERR, (TEXT("I2C_Init ERROR: CeSetThreadPriority ERROR:%d\n"), dwErr));
            goto _init_error;
        }
    }

    DEBUGMSG(ZONE_TRACE,(TEXT("-I2C_Init \r\n")));

    return dwErr;

_init_error:
    HW_Deinit(pI2C);

    return dwErr;
}
Пример #20
0
DWORD CST202T_SATA::InterruptThread(
    IN PVOID lParam
    )
{
    CST202T_SATA        *pDisk = (CST202T_SATA *)lParam;

    while(TRUE) {
        WaitForSingleObject(pDisk->m_pPort->m_hIRQEvent, INFINITE);

        // We have three interrupts of interest: the ATA interrupt, the
        // DMA block transfer complete interrupt, and the SATA error
        // interrupt.
        //
        // NOTE: We have no indicatior of the ATA interrupt being active.
        //       Thus, we must assume the ATA interrupt is the interrupt
        //       being triggered if none of the other interrupts is
        //       detected.  Note that some versions of the SATA host
        //       document provided by ST describe bit 31 of INTPR
        //       as the "IPF" bit, which would indicate the state
        //       of the ATA interrupt.  However, this bit is not
        //       present in this part.
        ////////////////////////////////////////////////////////////////


        // First, determine if a SATA error condition has been detected.
        if (IsSErrorIntActive())
            {
            // Simply acknowledge the interrupt here to unblock any pending
            // read or write operation.  The GetSATAError function will
            // handle the SATA error at the appropriate time and re-enable
            // the interrupt.
            EnableSErrorInt(FALSE);

            // Get ATA status and clear pending ATA interrupt condition.
            pDisk->m_pPort->m_bStatus = GetBaseStatus();

//            DEBUGMSG(ZONE_IO, (_T(
//                "Atapi!CST202T_SATA::InterruptThread> Got SError Interrupt!\r\n"
//                )));

            SetEvent(pDisk->m_pPort->m_hErrorEvent);
            }
        else if (IsDMACTfrIntActive())
            {
                // If we're operating in DMA mode, the DMA controller may have
                // generated the interrupt. The only DMA interrupt we are interested
                // in is the transfer complete interrupt.  ACK it here.
                ClearDMACTfrInt();

                // Get ATA status and clear pending ATA interrupt condition.
                pDisk->m_pPort->m_bStatus = GetBaseStatus();

//                DEBUGMSG(ZONE_IO, (_T(
//                    "Atapi!CST202T_SATA::InterruptThread> Got DMA Interrupt!\r\n"
//                    )));

                SetEvent(pDisk->m_pPort->m_hDMAEvent);
            }
        else // ATA interrupt
            {
            // SATA interrupt condition.
            pDisk->m_pPort->m_bStatus = GetBaseStatus();

//            DEBUGMSG(ZONE_IO, (_T(
//                "Atapi!CST202T_SATA::InterruptThread> Got SATA Interrupt!\r\n"
//                )));

            SetEvent(pDisk->m_pPort->m_hSATAEvent);
            }

        InterruptDone(pDisk->m_pPort->m_dwSysIntr);
    }

    return(0);
}