创建Xilinx SDK BSP时,要指定在哪个core上运行,这个选项对源码的影响如下:
xparameters.h里面的宏定义不同:
xscugic_hw.c里面
int XScuGic_DeviceInitialize(u32 DeviceId) { XScuGic_Config *Config; u8 Cpu_Id = XPAR_CPU_ID + 1; Config = &XScuGic_ConfigTable[(u32 )DeviceId]; DistInit(Config, Cpu_Id); CPUInit(Config); return XST_SUCCESS; }
int XScuGic_CfgInitialize(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr, u32 EffectiveAddr) { u32 Int_Id; u8 Cpu_Id = XPAR_CPU_ID + 1; Xil_AssertNonvoid(InstancePtr != NULL); Xil_AssertNonvoid(ConfigPtr != NULL); /* * Set some default values */ InstancePtr->Config->CpuBaseAddress = EffectiveAddr; InstancePtr->IsReady = 0; InstancePtr->Config = ConfigPtr; for (Int_Id = 0; Int_Id<XSCUGIC_MAX_NUM_INTR_INPUTS;Int_Id++) { /* * Initalize the handler to point to a stub to handle an * interrupt which has not been connected to a handler. Only * initialize it if the handler is 0 which means it was not * initialized statically by the tools/user. Set the callback * reference to this instance so that unhandled interrupts * can be tracked. */ if ((InstancePtr->Config->HandlerTable[Int_Id].Handler == 0)) { InstancePtr->Config->HandlerTable[Int_Id].Handler = StubHandler; } InstancePtr->Config->HandlerTable[Int_Id].CallBackRef = InstancePtr; } DistInit(InstancePtr, Cpu_Id); CPUInit(InstancePtr); InstancePtr->IsReady = XIL_COMPONENT_IS_READY; return XST_SUCCESS; }
/* this initializes the various processor modes */ _prestart: _boot: #if XPAR_CPU_ID==0 /* only allow cpu0 through */ mrc p15,0,r1,c0,c0,5 and r1, r1, #0xf cmp r1, #0 beq OKToRun EndlessLoop0: wfe b EndlessLoop0 #elif XPAR_CPU_ID==1 /* only allow cpu1 through */ mrc p15,0,r1,c0,c0,5 and r1, r1, #0xf cmp r1, #1 beq OKToRun EndlessLoop1: wfe b EndlessLoop1 #endif OKToRun: mrc p15, 0, r0, c0, c0, 0 /* Get the revision */ and r5, r0, #0x00f00000 and r6, r0, #0x0000000f orr r6, r6, r5, lsr #20-4从上面的汇编来看,如果实际加测到的CPU_ID和配置的CPU_ID如果不同,BSP将无法启动。