annotate example/get_segment/spe/Hello.cc @ 354:cfd20d609ace draft

add example/get_segment and change spe/DrawSpan.cpp
author koba
date Wed, 15 Jul 2009 17:39:51 +0900
parents
children 208ba3551474
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
354
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
1 #include <stdio.h>
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
2 #include "Hello.h"
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
3 #include "Func.h"
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
4
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
5 /* これは必須 */
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
6 SchedDefineTask(Hello);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
7
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
8 #define PP_STORE 3
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
9 #define SIZE (4096*sizeof(int))
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
10
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
11 int
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
12 Hello::run(void *rbuf, void *wbuf)
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
13 {
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
14 int task_id = get_param(0);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
15 int *ptr = 0;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
16 #if 1
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
17 ptr = (int*)smanager->allocate(SIZE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
18
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
19 smanager->mainMem_alloc(0, SIZE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
20
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
21 int i;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
22 for(i=0;i<4096;i++) {
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
23 ptr[i] = i;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
24 }
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
25 #endif
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
26
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
27 void *next = 0;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
28 #if 1
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
29 smanager->mainMem_wait();
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
30 next = (void *)smanager->mainMem_get(0);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
31
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
32 smanager->dma_wait(PP_STORE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
33 smanager->dma_store(ptr, (uint32)next,
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
34 SIZE, PP_STORE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
35 smanager->dma_wait(PP_STORE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
36 uint32 wait_id = smanager->get_segment(next, SIZE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
37 void* cur = smanager->wait_segment(wait_id);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
38 //smanager->put_segment(wait_id);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
39 //comparePtr *next;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
40 #endif
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
41
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
42
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
43 fprintf(stderr,"sizeof(int) = [%d] sizeof(void*)=[%d]\n", (int)sizeof(int),(int)sizeof(void*));
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
44 fprintf(stderr,"[%d] Main Mem %0x len %d\n", task_id, (unsigned int)next,(int)SIZE);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
45
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
46 free(ptr);
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
47 return 0;
cfd20d609ace add example/get_segment and change spe/DrawSpan.cpp
koba
parents:
diff changeset
48 }