summaryrefslogtreecommitdiffstats
path: root/src/lib/syscall_task.C
blob: a6b575b5eaac43265ec1221da86324c7799d2de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <sys/task.h>
#include <sys/syscall.h>
#include <kernel/task.H>
#include <kernel/taskmgr.H>
#include <kernel/cpu.H>

using namespace Systemcalls;

void task_yield()
{
    _syscall0(TASK_YIELD);
    return;
}

tid_t task_create(void(*fn)(void*), void* ptr)
{
    return (tid_t)(uint64_t) _syscall2(TASK_START, (void*)fn, ptr);
}

void task_end()
{
    _syscall0(TASK_END); // no return.
    return;
}

tid_t task_gettid()
{
    // Even though we have a syscall for GETTID, we also have the task in 
    // GRP13.

    register task_t* task;
    asm volatile("addi %0, 13, 0" : "=r"(task));
    return task->tid;
    //return (tid_t)_syscall0(TASK_GETTID);
}

cpuid_t task_getcpuid()
{
    register task_t* task;
    asm volatile("addi %0, 13, 0" : "=r"(task));
    return task->cpu->cpu;
}
OpenPOWER on IntegriCloud