0. 写在前面
1. 多核之间通信交互
var SHAREDMEM = 0x0C000000;
var SHAREDMEMSIZE = 0x40000;
var SDDR3_BASE = 0x80000000;
var SDDR3_SIZE = 0x50000;
/*
* Need to define the shared region. The IPC modules use this
* to make portable pointers. All processors need to add this
* call with their base address of the shared memory region.
* If the processor cannot access the memory, do not add it.
*/
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.numEntries = 2;
SharedRegion.translate = false;
SharedRegion.setEntryMeta(0,
{ base: SHAREDMEM,
len: SHAREDMEMSIZE,
ownerProcId: 0,
isValid: true,
cacheEnable: true,
cacheLineSize: 64,
createHeap: true,
name: "MSMC_SHARED",
});
SharedRegion.setEntryMeta(1,
{ base: SDDR3_BASE,
len: SDDR3_SIZE,
ownerProcId: 0,
isValid: true,
cacheEnable: true,
cacheLineSize: 128,
createHeap: true,
name: "DDR3_SHARED",
}); 1.1 情况 1
// IPC_Struct
typedef struct tag_imgIRLmp
{
ListMP_Elem header;
ImgIR ir; // 红外图像结构体
Int InitFlag; // 0:代表跟踪状态,1:代表初始化帧
} ImgIRLMP;
typedef struct tag_ImgIR
{
UInt8 *pImg;
int width;
int height;
} ImgIR;/* CORE 0 */ ImgIRLMP *pImgIRLMP; // Allocation pImgIRLMP = (ImgIRLMP *)Memory_alloc(0, sizeof(ImgIRLMP), L1_CACHELINE_SIZE, &eb); // Fill Data pImgIRLMP->InitFlag = 10086; // ...省略其它赋值 // Put Elem ListMP_putHead(lmpIR_handle, (ListMP_Elem *)pImgIRLMP);
/* CORE 1 */ ImgIRLMP *pImgIRLMP; while((pImgIRLMP = (ImgIRLMP *)ListMP_getTail(lmpIR_handle)) == NULL);
1.2 情况 2
// IPC_Struct
typedef struct tag_imgIRLmp
{
ListMP_Elem header;
ImgIR *pir; // 这里是指针,和情况 1 不同
Int InitFlag;
} ImgIRLMP;
typedef struct tag_ImgIR
{
UInt8 *pImg;
int width;
int height;
} ImgIR;2. 单核的核内交互
var SMSMC_BASE = 0x0C000000;
var SMSMC_SIZE = 0x00040000;
var SDDR3_BASE = 0x80000000;
var SDDR3_SIZE = 0x40000000;
var SharedRegion = xdc.useModule('ti.sdo.ipc.SharedRegion');
SharedRegion.numEntries = 2;
SharedRegion.translate = false;
SharedRegion.setEntryMeta(0,
{ base: SHAREDMEM,
len: SHAREDMEMSIZE,
ownerProcId: 0,
isValid: true,
cacheEnable: true,
cacheLineSize: 64,
createHeap: true,
name: "MSMC_SHARED",
});
SharedRegion.setEntryMeta(1,
{ base: SDDR3_BASE,
len: SDDR3_SIZE,
ownerProcId: 0,
isValid: true,
cacheEnable: true,
cacheLineSize: 128,
createHeap: true,
name: "DDR3_SHARED",
}); typedef struct tag_DataPtQueElem
{
Queue_Elem header;
void *pIr;
void *pImg2;
void *pImg2;
int frame_id;
} DataPtQueElem;/*
send.cpp
*/
// global variables
#pragma DATA_SECTION(hw_image_data,".image");
uint8_t hw_image_data[HW_IMAGE_DATA_SIZE];
#pragma DATA_SECTION(my_image2, ".image")
uint8_t my_image2[MY_IMAGE_DATA_SIZE2];
#pragma DATA_SECTION(my_image3, ".image")
uint8_t my_image3[MY_IMAGE_DATA_SIZE3];
void send_func()
{
DataPtQueElem *pElem;
pElem = (DataPtQueElem*)Memory_alloc(0, sizeof(DataPtQueElem), L1_CACHELINE_SIZE, NULL);
pElem->pIr = hw_image_data;
pElem->pImg2 = my_image2;
pElem->pImg3 = my_image3;
pElem->frame_id = 10086;
Queue_enqueue(hDataPtQue, (Queue_Elem *)pElem);
}/* recv.cpp */ DataPtQueElem *pElem; pElem = (DataPtQueElem *)Queue_dequeue(hDataPtQue);