comparison example/get_segment/spe/Hello.cc @ 0:04e28d8d3c6f

first commit
author Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp>
date Mon, 08 Nov 2010 01:23:25 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:04e28d8d3c6f
1 #include <stdio.h>
2 #include "Hello.h"
3 #include "Func.h"
4
5 /* これは必須 */
6 SchedDefineDynamicTask(Hello,0);
7
8 static int
9 rel_offset()
10 {
11 unsigned int pc;
12 unsigned int label;
13 __asm__ __volatile__(
14 " brsl %0,____LLLL\n"
15 "____LLLL:"
16 " ila %1,____LLLL"
17 : "=r" (pc), "=r" (label));
18 return pc-label;
19 }
20
21
22 static int
23 run(SchedTask *smanager, void *rbuf, void *wbuf)
24 {
25 int task_id = (long)smanager->get_param(0);
26
27 unsigned int pc;
28 __asm__ __volatile__(
29 " brsl %0,____LLLL1\n"
30 "____LLLL1:"
31 : "=r" (pc));
32
33 char *fmt = "char [%0x] offset [%0x]\n";
34 int offset = rel_offset();
35
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);
40
41 smanager->printf(fmt+offset, fmt, offset);
42
43 smanager->printf("[%d] Hello, World!! Seg1\n"+offset, task_id);
44 smanager->printf("pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello);
45
46 return 0;
47 }
48