小弟刚开始弄这个不久,希望各位大神能够帮我看看。
下面是我的代码,请帮忙看一下:
/*
* ======== swi Fxn ======== swi deal with PCIE INT
*/
Void PCIEFxn(UArg arg0,UArg arg1 )
{
Dbg_printf("Enter SWI\n");
*((unsigned int *)TI667X_EP_IRQ_SET) = 0x1;
// *((unsigned int *)TI667X_EP_IRQ_CLR) = 0x1;
Dbg_printf("leave SWI\n");
}
/*
Void PCIE_LEGACY_isr(UArg Params)
{
Dbg_printf("enter HWI() LEGACY\n");
Swi_post(mySwiPCIE);
Hwi_Params *hwiParams = (Hwi_Params *)Params;
// if(CpIntc_getEventId(HOST_INT_ID) == hwiParams->eventId)
{
Clear legacy intB
*((unsigned int *)LEGACY_B_IRQ_STATUS) = 0x1;
*((unsigned int *)TI667X_IRQ_EOI) = 0x1;
}
}*/
Void PCIE_MSI_isr(UArg Params)
{
Dbg_printf("enter HWI() \n");
if(Params == 17)
{
Dbg_printf("enter HWI() MSI\n");
/* Clear MSI0 interrupt */
*((unsigned int *)MSI0_IRQ_STATUS) = 0x1;
*((unsigned int *)TI667X_IRQ_EOI) = 0x4; /* end of MSI0, event number=4 */
}
else
return;
*((unsigned int *)MSI0_IRQ_EN_SET) = 0x1;
*((unsigned int *)LEGACY_A_IRQ_ENABLE_SET) = 0x0;
*((unsigned int *)LEGACY_B_IRQ_ENABLE_SET) = 0x0;
*((unsigned int *)LEGACY_C_IRQ_ENABLE_SET) = 0x0;
*((unsigned int *)LEGACY_D_IRQ_ENABLE_SET) = 0x0;
Dbg_printf("leave HWI() then post SWI\n");
Swi_post(mySwiPCIE);
}
/*
* ======== peripheral Fxn ======== CIC init fxn
*/
void CPINTC_config(void)
{
int DSP_ID= get_DSP_id();
Hwi_Params hwiParams;
/* Clear MSI0 interrupt */
*((unsigned int *)MSI0_IRQ_STATUS) = 0x1;
*((unsigned int *)TI667X_IRQ_EOI) = 0x4; /* end of MSI0, event number=4 */
Hwi_Params_init(&hwiParams);
/* set the argument you want passed to your ISR function */
hwiParams.arg = (Int32)17;
/* set the event id of the peripheral assigned to this interrupt */
hwiParams.eventId = 17; /* for MSI interrupt */
/* Enable the Hwi */
hwiParams.enableInt = TRUE;
/* don't allow this interrupt to nest itself */
hwiParams.maskSetting = Hwi_MaskingOption_SELF;
/* Configure interrupt 4 to invoke "demo_irq_handler". */
/* Automatically enables interrupt 4 by default */
/* set params.enableInt = FALSE if you want to control */
/* when the interrupt is enabled using Hwi_enableInterrupt() */
Hwi_create(INTC_VECTID_MSI, PCIE_MSI_isr, &hwiParams, NULL);
Int32 eventId;
}
/*
* ======== task Fxn ======== task creat and init all
*/
Void TaskCreatInit(UArg a0, UArg a1)
{
uint32_t i, j;
uint32_t coreID = CSL_chipReadReg (CSL_CHIP_DNUM);
Swi_Params swiparams;
Dbg_printf("enter TaskCreatInit()\n");
Hwi_disable();
/*
*((unsigned int *)MSI_CAP_REG) |= MSI_EN;
*((unsigned int *)MSI_CAP_REG) |= MSI_EN_64bit;
*/
if (coreID == 0)
{
for(i = 1; i<CORENUM; i++)
{
for (j=0; j<1000; j++)
asm (" NOP 5");
KICK0 = KICK0_UNLOCK;
KICK1 = KICK1_UNLOCK;
*(volatile uint32_t *) iIPCGRInfo[i] |= 1; //设置IPC中断标志,启动IPC中断
KICK0 = KICK_LOCK;
KICK1 = KICK_LOCK;
}
CPINTC_config();
}
Swi_Params_init(&swiparams);
swiparams.arg0 = 1;
swiparams.arg1 = 0;
swiparams.priority = 5;
mySwiPCIE = Swi_create(PCIEFxn, &swiparams, NULL);
for (i = 0; i<BUF_NUM; i++)
{
DEVICE_REG32_W(PC2DSP_READY_ADD(i, coreID), 0);
DEVICE_REG32_W(DSP2PC_READY_ADD(i, coreID), 0);
DEVICE_REG32_W(PC2DSP_SIZE_ADD(i, coreID), 0);
DEVICE_REG32_W(DSP2PC_SIZE_ADD(i, coreID), 0);
}
Hwi_enable();
Swi_post(mySwiPCIE);
Dbg_printf("finish and delete TaskCreatInit()\n");
Task_setPri(task_init, -1);
}
/*
* ======== main ========
*/
Void main()
{ Error_Block eb;
Task_Params taskparams;
/* shared memory uart initialization */
serial_init();
int DSP_ID = get_DSP_id();
Dbg_printf("===========================\n");
Dbg_printf("PCIe Example, this is DSP%d\n", DSP_ID);
Error_init(&eb);
Task_Params_init(&taskparams);
taskparams.priority = 3;
task_init = Task_create(TaskCreatInit, NULL, &eb);
if (task_init == NULL) {
Dbg_printf("Task Init failed\n");
BIOS_exit(0);
}
Dbg_printf("Task Init succeed then bios start\n");
BIOS_start(); /* enable interrupts and start SYS/BIOS */
}
Andy Yin1:
参考MCSDK PCIe boot例子及STK:http://www.deyisupport.com/question_answer/dsp_arm/c6000_multicore/f/53/t/47664.aspx
Gery xia:
请问你的问题解决了吗?我也在SYS/BIOS下调MSI,请问有没有SYS/BIOS下的PCIE MSI例程。KeyStone例程太难移植了。