From fd04e9d460ffb5d5e2c8062433769c7c1ec15a7d Mon Sep 17 00:00:00 2001 From: Bahadir Balban Date: Thu, 5 Nov 2009 01:47:04 +0200 Subject: [PATCH] Added helper to extract raw thread id from fully qualified thread id Currently, the tid returned from kernel contains container id as well, which makes it sufficient to do inter-container syscalls without any preparation. The helpers added are for presentation purposes only. Container id is deleted so that the raw thread id is available for printing or similar. --- conts/libl4/include/l4lib/arch-arm/syslib.h | 19 +++++++++++++++++++ conts/posix/mm0/main.c | 2 +- .../test0/include/test_exec_linker.lds.in | 2 ++ conts/posix/test0/main.c | 2 +- conts/posix/test0/src/test_exec/test_exec.c | 2 +- 5 files changed, 24 insertions(+), 3 deletions(-) diff --git a/conts/libl4/include/l4lib/arch-arm/syslib.h b/conts/libl4/include/l4lib/arch-arm/syslib.h index 5e1c254..3ba9270 100644 --- a/conts/libl4/include/l4lib/arch-arm/syslib.h +++ b/conts/libl4/include/l4lib/arch-arm/syslib.h @@ -144,6 +144,20 @@ static inline void l4_restore_ipcregs(void) l4_set_sender(l4_get_utcb()->saved_sender); } +#define TASK_CID_MASK 0xFF000000 +#define TASK_ID_MASK 0x00FFFFFF +#define TASK_CID_SHIFT 24 + +static inline l4id_t __raw_tid(l4id_t tid) +{ + return tid & TASK_ID_MASK; +} + +static inline l4id_t __cid(l4id_t tid) +{ + return (tid & TASK_CID_MASK) >> TASK_CID_SHIFT; +} + static inline l4id_t self_tid(void) { struct task_ids ids; @@ -152,6 +166,11 @@ static inline l4id_t self_tid(void) return ids.tid; } +static inline l4id_t __raw_self_tid(void) +{ + return __raw_tid(self_tid()); +} + static inline int l4_send_full(l4id_t to, unsigned int tag) { l4_set_tag(tag); diff --git a/conts/posix/mm0/main.c b/conts/posix/mm0/main.c index 5d98c55..e4de096 100644 --- a/conts/posix/mm0/main.c +++ b/conts/posix/mm0/main.c @@ -195,7 +195,7 @@ void handle_requests(void) void main(void) { - printf("\n%s: Started with thread id %x\n", __TASKNAME__, self_tid()); + printf("\n%s: Started with thread id %x\n", __TASKNAME__, __raw_self_tid()); init(); diff --git a/conts/posix/test0/include/test_exec_linker.lds.in b/conts/posix/test0/include/test_exec_linker.lds.in index 2058c1c..001ce21 100644 --- a/conts/posix/test0/include/test_exec_linker.lds.in +++ b/conts/posix/test0/include/test_exec_linker.lds.in @@ -19,5 +19,7 @@ SECTIONS .rodata1 : { *(.rodata1) } . = ALIGN(4K); .data : { *(.data) } + .got : { *(.got) } + .got.plt : { *(.got.plt) } .bss : { *(.bss) } } diff --git a/conts/posix/test0/main.c b/conts/posix/test0/main.c index 51048ff..48845d5 100644 --- a/conts/posix/test0/main.c +++ b/conts/posix/test0/main.c @@ -31,7 +31,7 @@ l4id_t pagerid; int main(int argc, char *argv[]) { - printf("\n%s: Started with thread id %x\n", __TASKNAME__, getpid()); + printf("\n%s: Started with thread id %x\n", __TASKNAME__, __raw_tid(getpid())); parent_of_all = getpid(); diff --git a/conts/posix/test0/src/test_exec/test_exec.c b/conts/posix/test0/src/test_exec/test_exec.c index 845c512..73678c3 100644 --- a/conts/posix/test0/src/test_exec/test_exec.c +++ b/conts/posix/test0/src/test_exec/test_exec.c @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) /* Compare two pid strings. We use strings because we dont have atoi() */ if (!strcmp(pidbuf, parent_of_all)) { printf("EXECVE TEST -- PASSED --\n"); - printf("\nThread (%x): Continues to sync with the pager...\n\n", getpid()); + printf("\nThread (%x): Continues to sync with the pager...\n\n", __raw_tid(getpid())); while (1) wait_pager(pagerid); }