|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
一、cfg文件
- w$ R6 a& e0 U* ]* B$ o* H1 W
" M6 q% p7 D% C8 R" q6 a1 u; v- /* Create the stack Thread Task for our application. */
- var tskSlaveThread = Task.create("&slave_main");
- tskSlaveThread.stackSize = 0x2000;
- tskSlaveThread.priority = 0x5;
- tskSlaveThread.instance.name = "slave_main";* s7 E* I# @3 w/ ]5 q
: y! b9 g7 S2 D/ S
1 f6 g; s% |$ W, u3 U+ r# e. i4 |创建slave_main进程。
5 L, d& ]: R: _9 O+ U4 ~" s/ U2 B
二、main函数, c& J1 t1 o" R$ I; f
$ g" b" h2 H( `8 o2 B* y- Mmain函数很简单,只是打开IPC以及BIOS1 X2 _+ A6 T2 z, s
: D- A$ v4 J1 ]1 Y0 v2 Q三、slave_main进程/ E" {* @8 }0 b/ H" H
6 v6 y" y4 P/ H( n6 C2 _5 m3.1 创建heapBuf, V/ s4 P2 j( E9 @- F/ H& }
D2 R0 z9 h# w; \8 z0 j- /* Open the heap created by the other processor. Loop until opened. */
- do {
- status = HeapBufMP_open(IMAGE_PROCESSING_HEAP_NAME, &heapHandle); //"image_processing_heap"
- if (status < 0) {
- Task_sleep(1);
- }
- //printf("HeapBufMP_open failed\n" );
- } while (status < 0);
' d3 _/ |2 k* F/ V3 @' x3 n
/ H8 f' H( j5 w" W& F
3 G3 D: M$ a2 t3.2 创建messageQ( slave )/ k4 _6 w. Y& r, d1 h8 [
$ g7 ^9 j, D! N& M
- /* Register this heap with MessageQ */
- MessageQ_registerHeap((IHeap_Handle)heapHandle, IMAGE_PROCESSING_HEAPID);
- /* Create the local message queue */
- //从核创建MessageQ 根据MessageQ名字 主核在MessageQ_open打开 MessageQ名字在mc_process_init中设置
- h_receive_queue = MessageQ_create(receive_queue_name, NULL);
- if (h_receive_queue == NULL)
- {
- printf("MessageQ_create failed\n" );
- goto close_n_exit;
- }
. ~8 b. b; i) o; ?$ h % o6 j+ |& g8 w4 o! p
5 X f% [( j, j! _- ?. z3 X3 w
3.3 接收messageQ( slave )6 O- N# @5 B1 X5 Z& i' l2 j
9 ^; l9 e2 Y4 l- if (MessageQ_get(h_receive_queue, (MessageQ_Msg *)&p_msg, MessageQ_FOREVER) < 0) //接收MessageQ信息 通过p_msg结构体传输来 该结构体包含着 MessageQ头 核ID 图像处理参数
- {
- printf("%s: This should not happen since timeout is forever\n", receive_queue_name);
- goto close_n_exit;
- }
- reply_queue_id = MessageQ_getReplyQueue(p_msg); //获得回复队列的ID号 reply_queue_id 然后通过MessageQ_put发送出去
- if (reply_queue_id == MessageQ_INVALIDMESSAGEQ)
- {
- printf("receive_queue_name: Ignoring the message as reply queue is not set.\n", receive_queue_name);
- continue;
- }: f6 p1 E, a3 F# n, u
% m" }; Q* n; p' V
% O' v* o' t q$ t3.4 sobel图像处理* |, U5 t( {3 ~* x( s% ~
4 i; J' e/ L$ f3 d$ f9 oprocess_rgb(&(p_msg->info));
; ^/ h. a/ u* M( ^& Jp_msg->info是该核需要处理的图像的指针,处理之后的结果也在这里* d" Q% v7 O% k* E3 k
2 @" d8 V+ _8 }0 N' c+ v" Q8 m3.5 发送messageQ( master)9 R; n& b! r' j6 E3 e
) X6 u) h2 M* j- /*============== 向主核发送MessageQ信息===========*/
- if (MessageQ_put(reply_queue_id, (MessageQ_Msg)p_msg) < 0)
- {
- printf("%s: MessageQ_put had a failure error\n", receive_queue_name);
- }
- if (MultiProc_self() != 0)
- {
- Cache_inv(p_msg->info.scratch_buf[0], p_msg->info.scratch_buf_len[0], Cache_Type_ALL, FALSE);
- if (p_msg->info.scratch_buf[1])
- {
- Cache_inv(p_msg->info.scratch_buf[1], p_msg->info.scratch_buf_len[1], Cache_Type_ALL, FALSE);
- }
- Cache_inv(p_msg, sizeof(process_message_t), Cache_Type_ALL, FALSE);
- }9 s- c) x' G. b
3 e9 j1 ]- b: h
至此,大功告成/ V( a$ A+ f4 l# T( E# }- I+ D9 P
. ~6 a4 N5 z1 [( P0 w
2 q" v- Q4 d- K: j$ K; Z1 o
8 Q# j+ ~' a9 g
0 q0 C6 p8 a/ ~* i/ T
6 x, Q1 @$ @. P4 v' }1 B
$ ~3 z+ Y+ b; T$ j
. P2 |. D7 r" W |
|