Mercurial > hg > Game > Cerium
annotate example/get_segment/spe/Hello.cc @ 1615:2c6e9ed9db3b draft
merge
author | Shohei KOKUBO <e105744@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 14 May 2013 13:38:17 +0900 |
parents | d7b0c0f8514c |
children |
rev | line source |
---|---|
354 | 1 #include <stdio.h> |
2 #include "Hello.h" | |
3 #include "Func.h" | |
4 | |
5 /* これは必須 */ | |
441 | 6 SchedDefineDynamicTask(Hello,0); |
354 | 7 |
464
0d64bdb63005
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
462
diff
changeset
|
8 static int |
473
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
9 rel_offset() |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
10 { |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
11 unsigned int pc; |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
12 unsigned int label; |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
13 __asm__ __volatile__( |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
14 " brsl %0,____LLLL\n" |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
15 "____LLLL:" |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
16 " ila %1,____LLLL" |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
17 : "=r" (pc), "=r" (label)); |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
18 return pc-label; |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
19 } |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
20 |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
21 |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
22 static int |
464
0d64bdb63005
task run is mere C function now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
462
diff
changeset
|
23 run(SchedTask *smanager, void *rbuf, void *wbuf) |
354 | 24 { |
626
0e91ddaad798
64bit mode compatibility on Cell
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
473
diff
changeset
|
25 int task_id = (long)smanager->get_param(0); |
354 | 26 |
462
ca987c0beb11
show pc in get_segement.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
27 unsigned int pc; |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
28 __asm__ __volatile__( |
473
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
29 " brsl %0,____LLLL1\n" |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
30 "____LLLL1:" |
467
839e34d0cc3c
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
466
diff
changeset
|
31 : "=r" (pc)); |
462
ca987c0beb11
show pc in get_segement.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
441
diff
changeset
|
32 |
473
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
33 char *fmt = "char [%0x] offset [%0x]\n"; |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
34 int offset = rel_offset(); |
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
35 |
836 | 36 //smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset); |
37 | |
38 //smanager->fprintf(smanager->stderr_,"[%d] Hello, World!! Seg1 \n"+offset, task_id); | |
39 //smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello); | |
473
16f0abb574b7
string offset for get_segment relocation code...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
467
diff
changeset
|
40 |
836 | 41 smanager->printf(fmt+offset, fmt, offset); |
42 | |
872 | 43 smanager->printf("[%d] Hello, World!! Seg1\n"+offset, task_id); |
836 | 44 smanager->printf("pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello); |
354 | 45 |
46 return 0; | |
47 } | |
872 | 48 |