📄 intx20t.c
字号:
/* The content of this file or document is CONFIDENTIAL and PROPRIETARY
* to Jade Technologies Co., Ltd. It is subjected to the terms of a
* License Agreement between Licensee and Jade Technologies Co., Ltd.
* restricting among other things, the use, reproduction, distribution
* and transfer. Each of the embodiments, including this information
* and any derivative work shall retain this copyright notice.
*
* Copyright (c) 2004 - 2005 Jade Technologies Co., Ltd.
* All rights reserved.
* ----------------------------------------------------------------
* File: intx20t.c,v
* Revision: 1.0
* ----------------------------------------------------------------
* $
*
* intx20.c - Z228 interrupt service routines
*/
#include <windows.h>
#include <nkintr.h>
#include <oalintr.h>
#include <oemwake.h>
#include <drv_glob.h>
#include "win_plat.h"
#include <pl190.h> // VIC
#include <pl031.h> // RTC
#include <oalfuncs.h>
#include <dma.h>
#include "dmakern.h"
// External variables
extern DWORD dwReschedTime;
extern DWORD CurMSec;
extern volatile LARGE_INTEGER CurTicks;
extern DWORD dwReschedIncrement;
extern ULONG Logic2SysIntr[LOGINTR_MAX+1];
extern ULONG SysIntr2Logic[SYSINTR_MAXIMUM];
extern DWORD dwIsrTime1, dwIsrTime2;
extern BOOL fIntrTime;
extern WORD wNumInterrupts; /* Reset by a read of the ISR times from the IST */
extern DWORD dwIntrTimeCountdown;
extern DWORD dwIntrTimeCountdownRef;
// External functions
extern int (*PProfileInterrupt)(void);
/* This constant defines how many of the Z228 IC's interrupts to check
* - we are currently only checking up to the keypad as the rest are reserved
* or are vectored.
*/
//const DWORD kVPInterruptSourceBitsToCheck = IRQ_SIC_KEYPAD;
/*
*******************************************************
**
** Function prototypes for ISRs
**
*******************************************************
*/
static DWORD isrWDOG( unsigned int ra ); /* 0 */
static DWORD isrSOFTINT( unsigned int ra );
static DWORD isrCPUINT0( unsigned int ra );
static DWORD isrCPUINT1( unsigned int ra );
static DWORD isrTIMER0( unsigned int ra );
static DWORD isrTIMER1( unsigned int ra ); /* 5 */
static DWORD isrGPIO2( unsigned int ra );
static DWORD isrIIC( unsigned int ra );
static DWORD isrCF( unsigned int ra );
static DWORD isrRTC( unsigned int ra );
static DWORD isrUSB( unsigned int ra ); /* 10 */
static DWORD isrUART0( unsigned int ra );
static DWORD isrUART1( unsigned int ra );
static DWORD isrUART2( unsigned int ra );
static DWORD isrUART3( unsigned int ra );
static DWORD isrSCI( unsigned int ra ); /* 15 */
static DWORD isrCLCD1( unsigned int ra );
static DWORD isrDMA( unsigned int ra );
static DWORD isrPWRFAIL( unsigned int ra );
static DWORD isrSSP( unsigned int ra );
static DWORD isrGPIO7( unsigned int ra ); /* 20 */
static DWORD isrGPIO8( unsigned int ra );
static DWORD isrKBD( unsigned int ra );
static DWORD isrAACI( unsigned int ra );
static DWORD isrCLCD0( unsigned int ra );
static DWORD isrGPIO8_5( unsigned int ra ); /* 25 */
static DWORD isrGPIO0( unsigned int ra );
static DWORD isrVIA( unsigned int ra );
static DWORD isrMP4D( unsigned int ra );
static DWORD isrMP4E( unsigned int ra );
static DWORD isrGPIO8_0( unsigned int ra ); /* 30 */
static DWORD isrGPIO8_1( unsigned int ra );
/*
*******************************************************
**
** Array of function pointers to ISRs
**
*******************************************************
*/
DWORD (*isrFunctionTable[])( unsigned int ra ) =
{
isrWDOG, isrSOFTINT, isrCPUINT0, isrCPUINT1,
isrTIMER0, isrTIMER1, isrGPIO2, isrIIC,
isrCF, isrRTC, isrUSB, isrUART0,
isrUART1, isrUART2, isrUART3, isrSCI,
isrCLCD1, isrDMA, isrPWRFAIL, isrSSP,
isrGPIO7, isrGPIO8, isrKBD, isrAACI,
isrCLCD0, isrGPIO8_5, isrGPIO0, isrVIA,
isrMP4D, isrMP4E, isrGPIO8_0, isrGPIO8_1
};
/*/ Pointer to the DMA controller registers */
static volatile PDMAC_REGS pDMACRegs = (PDMAC_REGS)DMAC_BASE;
/* Called by the kernel whenever an FIQ interrupt is signaled */
void OEMInterruptHandlerFIQ()
{
}
/* Called by the kernel whenever an IRQ interrupt is signaled */
int OEMInterruptHandler(unsigned int ra)
{
/* Local function defintions */
DWORD nSysIntr = SYSINTR_NOP;
DWORD irq;
static DWORD dwStoredInt = 0;
pvstVICRegs Vic = (pvstVICRegs)VA_VIC_BASE;
/* One read of VectAddress */
DWORD VicSource = Vic->VectAddr;
/* Bounds check */
if(VicSource >= 0 && VicSource <= VIC_NONVECT_INTERRUPT )
{
// if we're timing interrupts, keep track of when this one came in
if (fIntrTime)
{
// Subtract off dwReschedIncrment since interrupt hasn't been cleared
dwIsrTime1 = PerfCountSinceTick();
wNumInterrupts++;
}
if(VicSource == VIC_NONVECT_INTERRUPT)
{
/* We have a non-vectored interrupt source active */
DWORD IRQStatus;
IRQStatus = Vic->IRQStatus;
/*
* Scan thorugh the non-vectored irqs for the active interrupt
* NOTE: The non-vectored irqs are currently set-up to be the
* last 16 irqs - see OEMInitInterrupts() for where this is done
*/
for( irq = (VIC_NUM_IRQ_LINES-1); irq >= VIC_NUM_VECTIRQ_LINES; irq-- )
{
if (IRQStatus & (1<<irq)) break;
}
if( irq >= VIC_NUM_VECTIRQ_LINES )
{
/* Non-vectored source - Call local ISR */
nSysIntr = isrFunctionTable[irq](ra);
}
else
{
/* No active interrupts were found */
/* Execution in this block would signify an interrupt that has signaled
* the dispatcher, but has been cleared at the peripheral before it
* could be identified by the dispatcher
*/
}
}
else
{
/* Vectored source - Call local ISR */
nSysIntr = isrFunctionTable[VicSource](ra);
}
/* Clear current VIC interrupt request */
Vic->VectAddr = 0;
}
else
{
/* Value in VectAddress register is incorrect */
/* It is not wise to progress until this problem is fixed */
RETAILMSG (1, (TEXT("Infinite looping in intx20t.c\r\n")));
while(1);
}
/* Return status to OS to determine which (if any) IST is to run */
return(nSysIntr);
}
/*
*******************************************************
**
** ISR Function definitions for VIC
**
** ISR sources not used will have function stubs
** to allow for future expansion when required.
**
*******************************************************
*/
/* Watchdog ISR (Interrupt bit[0]) */
static DWORD isrWDOG( unsigned int ra )
{
DWORD nSysIntr = SYSINTR_NOP;
// DWORD nSysIntr = SYSINTR_WDOG;
/* Disable this interrupt, it will be re-enabled at the end of the IST */
// OEMInterruptDisable(nSysIntr);
// OEMIndicateIntSource(nSysIntr);
return nSysIntr;
}
/* Software Interrupt ISR (Interrupt bit[1]) */
static DWORD isrSOFTINT( unsigned int ra )
{
DWORD nSysIntr = SYSINTR_NOP;
return nSysIntr;
}
/* Comms Received ISR (Interrupt bit[2]) */
static DWORD isrCPUINT0( unsigned int ra )
{
DWORD nSysIntr = SYSINTR_NOP;
return nSysIntr;
}
/* Comms Transmit ISR (Interrupt bit[3]) */
static DWORD isrCPUINT1( unsigned int ra )
{
DWORD nSysIntr = SYSINTR_NOP;
return nSysIntr;
}
/* General Purpose Timers 0 (Tick timer) & 1 ISR (Interrupt bit[4]) */
static DWORD isrTIMER0( unsigned int ra )
{
static BOOL bLED = TRUE;
DWORD nSysIntr = SYSINTR_NOP;
/* update the tick count */
CurTicks.QuadPart += dwReschedIncrement;
/* call the profile ISR if it's enabled */
if (PProfileInterrupt)
{
nSysIntr = PProfileInterrupt();
if(nSysIntr == SYSINTR_RESCHED)
{
/* Update the millisecond counter */
CurMSec += RESCHED_PERIOD;
}
/* Clear the interrupt */
pHALir_ClearTimerInterrupt(OS_TIMER);
/* Return whatever we got back from the profiling ISR */
return nSysIntr;
}
/* Clear the interrupt */
pHALir_ClearTimerInterrupt(OS_TIMER);
/* Not profiling, update the millisecond counter */
CurMSec += RESCHED_PERIOD;
if (fIntrTime)
{
dwIntrTimeCountdown--;
if (dwIntrTimeCountdown == 0)
{
dwIntrTimeCountdown = dwIntrTimeCountdownRef;
wNumInterrupts = 0;
dwIsrTime2 = PerfCountSinceTick();
return (SYSINTR_TIMING);
}
else
{
if((int)(CurMSec - dwReschedTime) >= 0)
return SYSINTR_RESCHED;
}
}
else
{
if ((int) (CurMSec - dwReschedTime) >= 0)
{
bLED = !bLED;
return SYSINTR_RESCHED;
}
}
return SYSINTR_NOP;
}
/* General Purpose Timers 2 and 3 ISR (Interrupt bit[5]) */
static DWORD isrTIMER1( unsigned int ra )
{
/* DWORD nSysIntr = OEMTranslateIrq(LOGINTR_TIMER2);
if( nSysIntr != SYSINTR_NOP )
{
OEMInterruptDisable(nSysIntr);
OEMIndicateIntSource(nSysIntr);
}
*/
DWORD nSysIntr = OEMTranslateIrq(LOGINTR_TIMER1);
RETAILMSG(0, (_T("Timer2 Intr!!!\r\n")));
if( nSysIntr != SYSINTR_NOP )
{
OEMInterruptDisable(nSysIntr);
OEMIndicateIntSource(nSysIntr);
}
return nSysIntr;
}
/* General Purpose Input/Output port0 ISR (Interrupt bit[6]) */
static DWORD isrGPIO2( unsigned int ra )
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -