view example/get_segment/spe/Hello1.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
line wrap: on
line source

#include "Hello1.h"
#include "Func.h"

/* これは必須 */
SchedDefineDynamicTask(Hello1,1);

static int
rel_offset()
{
    unsigned int pc;
    unsigned int label;
    __asm__ __volatile__(
"         brsl %0,_LLLL\n"
"_LLLL:"
"         ila  %1,_LLLL"
        : "=r" (pc), "=r" (label));
    return  pc-label;
}


static int
run(SchedTask *smanager, void *rbuf, void *wbuf)
{
    long task_id = (long)smanager->get_param(0);

    unsigned int pc;
    __asm__ __volatile__(
"         brsl %0,1f\n"
"1:"
        : "=r" (pc));

    char *fmt = "char [%0x] offset [%0x] 2\n";
    int offset = rel_offset();

    //smanager->fprintf(smanager->stderr_,fmt+offset, fmt, offset);
    //smanager->fprintf(smanager->stderr_,"[%d] Hello, World Seg 2!!\n"+offset, task_id);
    //smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello1);

    smanager->printf(fmt+offset, fmt, offset);
    smanager->printf("[%d] Hello, World Seg 2!!\n"+offset, task_id);
    smanager->printf("pc=0x%0x 0x%0lx\n"+offset,pc, (unsigned long)&runTask_Hello1);

    return 0;
}