本帖最后由 一只耳朵怪 于 2018-6-25 11:30 编辑
参考开发包的pcieboot interrupt的例子,里面使用的CSL方式配置中断,而sys/bios下无法使用该方法,如果采用此方式直接导致系统挂掉,可能是对系统定时器中断造成影响,所以改为bios下的HWI方式配置中断,没有成功进入中断函数,而CSL方式是可以的。代码如下
CSL方式
write_uart("Debug: GEM-INTC Configura
tion...nr");
/* INTC module initialization */
intcContext.eventhandlerRecord = EventHandler;
intcContext.numEvtEntries = 10;
if (
CSL_intcInit(&intcContext) != CSL_SOK)
[ write_uart("Error: GEM-INTC initialization failed nr");
return;
]
/* Enable NMIs */
if (
CSL_intcGlobalNmiEnable() != CSL_SOK)
[ write_uart("Error: GEM-INTC global NMI enable failed nr");
return;
]
/* Enable global interrupts */
if (
CSL_intcGlobalEnable(&state) != CSL_SOK) [
write_uart("Error: GEM-INTC global enable failed nr");
return; ]
/* Open the INTC Module for Vector ID: 4 and Event ID: 63 (C6678) 59 (C6670) * Refer to the interrupt architecture and mapping document for the Event ID (INTC0_OUT3)*/
vectId = CSL_INTC_VECTID_4;
hTest = CSL_intcOpen (&intcObj, INTC0_OUT8, &vectId , NULL);
if (hTest == NULL)
[ write_uart("Error: GEM-INTC Open failednr");
return;
]
/* Register an call-back handler which is invoked when the event occurs. */
EventRecord.handler = &test_isr_handler;
EventRecord.arg = 0;
if (
CSL_intcPlugEventHandler(hTest,&EventRecord) != CSL_SOK)
[
write_uart("Error: GEM-INTC Plug event handler failednr");
return;
]
/* Enabling the events. */
if (
CSL_intcHwControl(hTest,CSL_INTC_CMD_EVTENABLE, NULL) != CSL_SOK)
[ write_uart("Error: GEM-INTC CSL_INTC_CMD_EVTENABLE command failednr");
return;
]
write_uart("Debug: GEM-INTC Configuration Completed nr");
/************************************************** ************* CPINTC-0 Configuration ************* **************************************************/
write_uart("Debug: CPINTC-0 Configuration...nr");
/* Open the handle to the CPINT Instance */
hnd = CSL_CPINTC_open(0);
if (hnd == 0)
[
write_uart("Error: Unable to open CPINTC-0nr");
return;
]
/* Disable all host interrupts. */
CSL_CPINTC_disableAllHostInterrupt(hnd);
/* Configure no nesting support in the CPINTC Module. */
CSL_CPINTC_setNestingMode (hnd, CPINTC_NO_NESTING);
/* We now map System Interrupt 50 to channel 8*/
CSL_CPINTC_mapSystemIntrToChannel (hnd, PCIEXpress_Legacy_INTA, 8);
/* We now enable system interrupt 50 */
CSL_CPINTC_enableSysInterrupt (hnd, PCIEXpress_Legacy_INTA);
/* We enable host interrupts. */
CSL_CPINTC_enableHostInterrupt (hnd, 8);
/* Enable all host interrupts also. */
CSL_CPINTC_enableAllHostInterrupt(hnd);
write_uart("Debug: CPINTC-0 Configuration Completednr");
HWI方式
Uint32 hostIntr =8;
Uint32 sysIntr = PCIEXpress_Legacy_INTA;
DEVICE_REG32_W(MAGIC_ADDR, 0);
DEVICE_REG32_W(PCIE_LEGACY_A_IRQ_STATUS, 0x1);
/************************************************ *************** INTC Configuration ************* ************************************************/
write_uart("Debug: GEM-INTC Configuration...nr");
/* Map the System Interrupt i.e. the Interrupt Destination 0 interrupt to the DIO ISR Handler. */
CpIntc_dispatchPlug(sysIntr, (CpIntc_FuncPtr)test_isr_handler, (UArg)0, TRUE);
/* The configuration is for CPINTC0. We map system interrupt 112 to Host Interrupt 8. */
CpIntc_mapSysIntToHostInt(0, sysIntr, hostIntr);
/* Enable the Host Interrupt. */
CpIntc_enableHostInt(0, hostIntr);
/* Enable the System Interrupt */
CpIntc_enableSysInt(0, sysIntr);
/* Get the event id associated with the host interrupt. */
int eventId = CpIntc_getEventId(hostIntr); // will get eventid = 104
Hwi_Params params;
Hwi_Params_init(¶ms);
/* Host interrupt value*/
params.arg = hostIntr;
/* Event id is 74 for your host interrupt */
params.eventId = eventId;
/* Enable the Hwi */
params.enableInt = TRUE;
/* This plugs the interrupt vector 4 and the ISR function. */ /* When using CpIntc, you must plug the Hwi fxn with CpIntc_dispatch */ /* so it knows how to process the CpIntc interrupts.*/
Hwi_create(4, &CpIntc_dispatch, ¶ms, NULL);
write_uart("Debug: CPINTC-0 Configuration Completednr");
配置完成后使能中断,接着触发中断
*(volatile UInt32*)(0x21800188)=1; //LEGACY_A_IRQ_ENABLE_SET
*(volatile UInt32*)(0x21800180)=1; //LEGACY_A_IRQ_STATUS_RAW
CSL方式可以,而HWI方式不行,不知道什么原因,是配置不对,还是有其他地方需要设置,希望大家能给点思路,谢谢。