/trunk/uspace/lib/libc/include/tls.h |
---|
0,0 → 1,67 |
/* |
* Copyright (c) 2007 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libc |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_TLS_H_ |
#define LIBC_TLS_H_ |
#include <libarch/tls.h> |
#include <sys/types.h> |
/* |
* Symbols defined in the respective linker script. |
*/ |
extern char _tls_alignment; |
extern char _tdata_start; |
extern char _tdata_end; |
extern char _tbss_start; |
extern char _tbss_end; |
extern tcb_t *__make_tls(void); |
extern tcb_t *__alloc_tls(void **, size_t); |
extern void __free_tls(tcb_t *); |
extern void __free_tls_arch(tcb_t *, size_t); |
#ifdef CONFIG_TLS_VARIANT_1 |
extern tcb_t *tls_alloc_variant_1(void **, size_t); |
extern void tls_free_variant_1(tcb_t *, size_t); |
#endif |
#ifdef CONFIG_TLS_VARIANT_2 |
extern tcb_t *tls_alloc_variant_2(void **, size_t); |
extern void tls_free_variant_2(tcb_t *, size_t); |
#endif |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/include/thread.h |
---|
41,20 → 41,14 |
typedef uint64_t thread_id_t; |
extern char _tls_alignment; |
extern void __thread_entry(void); |
extern void __thread_main(uspace_arg_t *uarg); |
extern void __thread_main(uspace_arg_t *); |
extern int thread_create(void (* function)(void *), void *arg, char *name, thread_id_t *tid); |
extern void thread_exit(int status); |
extern void thread_detach(thread_id_t thread); |
extern int thread_join(thread_id_t thread); |
extern int thread_create(void (*)(void *), void *, char *, thread_id_t *); |
extern void thread_exit(int); |
extern void thread_detach(thread_id_t); |
extern int thread_join(thread_id_t); |
extern thread_id_t thread_get_id(void); |
extern tcb_t * __make_tls(void); |
extern tcb_t * __alloc_tls(void **data, size_t size); |
extern void __free_tls(tcb_t *); |
extern void __free_tls_arch(tcb_t *, size_t size); |
#endif |
/trunk/uspace/lib/libc/include/fibril.h |
---|
37,7 → 37,7 |
#include <libarch/fibril.h> |
#include <libadt/list.h> |
#include <libarch/thread.h> |
#include <libarch/tls.h> |
#ifndef context_set |
#define context_set(c, _pc, stack, size, ptls) \ |
/trunk/uspace/lib/libc/generic/tls.c |
---|
0,0 → 1,141 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libc |
* @{ |
*/ |
/** @file |
* |
* Support for thread-local storage, as described in: |
* Drepper U.: ELF Handling For Thread-Local Storage, 2005 |
* |
* Only static model is supported. |
*/ |
#include <tls.h> |
#include <malloc.h> |
#include <string.h> |
#include <align.h> |
/** Create TLS (Thread Local Storage) data structures. |
* |
* The code requires, that sections .tdata and .tbss are adjacent. It may be |
* changed in the future. |
* |
* @return Pointer to TCB. |
*/ |
tcb_t *__make_tls(void) |
{ |
void *data; |
tcb_t *tcb; |
size_t tls_size = &_tbss_end - &_tdata_start; |
tcb = __alloc_tls(&data, tls_size); |
/* |
* Copy thread local data from the initialization image. |
*/ |
memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start); |
/* |
* Zero out the thread local uninitialized data. |
*/ |
memset(data + (&_tbss_start - &_tdata_start), 0, |
&_tbss_end - &_tbss_start); |
return tcb; |
} |
void __free_tls(tcb_t *tcb) |
{ |
size_t tls_size = &_tbss_end - &_tdata_start; |
__free_tls_arch(tcb, tls_size); |
} |
#ifdef CONFIG_TLS_VARIANT_1 |
/** Allocate TLS variant 1 data structures. |
* |
* @param data Start of TLS section. This is an output argument. |
* @param size Size of tdata + tbss section. |
* @return Pointer to tcb_t structure. |
*/ |
tcb_t *tls_alloc_variant_1(void **data, size_t size) |
{ |
tcb_t *result; |
result = malloc(sizeof(tcb_t) + size); |
*data = ((void *)result) + sizeof(tcb_t); |
return result; |
} |
/** Free TLS variant I data structures. |
* |
* @param tcb Pointer to TCB structure. |
* @param size This argument is ignored. |
*/ |
void tls_free_variant_1(tcb_t *tcb, size_t size) |
{ |
free(tcb); |
} |
#endif |
#ifdef CONFIG_TLS_VARIANT_2 |
/** Allocate TLS variant II data structures. |
* |
* @param data Pointer to pointer to thread local data. This is |
* actually an output argument. |
* @param size Size of thread local data. |
* @return Pointer to TCB structure. |
*/ |
tcb_t * tls_alloc_variant_2(void **data, size_t size) |
{ |
tcb_t *tcb; |
size = ALIGN_UP(size, &_tls_alignment); |
*data = memalign(&_tls_alignment, sizeof(tcb_t) + size); |
tcb = (tcb_t *) (*data + size); |
tcb->self = tcb; |
return tcb; |
} |
/** Free TLS variant II data structures. |
* |
* @param tcb Pointer to TCB structure. |
* @param size Size of thread local data. |
*/ |
void tls_free_variant_2(tcb_t *tcb, size_t size) |
{ |
size = ALIGN_UP(size, &_tls_alignment); |
void *start = ((void *) tcb) - size; |
free(start); |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/generic/fibril.c |
---|
35,9 → 35,10 |
#include <libadt/list.h> |
#include <fibril.h> |
#include <thread.h> |
#include <tls.h> |
#include <malloc.h> |
#include <unistd.h> |
#include <thread.h> |
#include <stdio.h> |
#include <libarch/faddr.h> |
#include <futex.h> |
/trunk/uspace/lib/libc/generic/thread.c |
---|
41,54 → 41,10 |
#include <string.h> |
#include <async.h> |
#include <stdio.h> |
#ifndef THREAD_INITIAL_STACK_PAGES_NO |
#define THREAD_INITIAL_STACK_PAGES_NO 1 |
#endif |
static LIST_INITIALIZE(thread_garbage); |
extern char _tdata_start; |
extern char _tdata_end; |
extern char _tbss_start; |
extern char _tbss_end; |
/** Create TLS (Thread Local Storage) data structures. |
* |
* The code requires, that sections .tdata and .tbss are adjacent. It may be |
* changed in the future. |
* |
* @return Pointer to TCB. |
*/ |
tcb_t *__make_tls(void) |
{ |
void *data; |
tcb_t *tcb; |
size_t tls_size = &_tbss_end - &_tdata_start; |
tcb = __alloc_tls(&data, tls_size); |
/* |
* Copy thread local data from the initialization image. |
*/ |
memcpy(data, &_tdata_start, &_tdata_end - &_tdata_start); |
/* |
* Zero out the thread local uninitialized data. |
*/ |
memset(data + (&_tbss_start - &_tdata_start), 0, |
&_tbss_end - &_tbss_start); |
return tcb; |
} |
void __free_tls(tcb_t *tcb) |
{ |
size_t tls_size = &_tbss_end - &_tdata_start; |
__free_tls_arch(tcb, tls_size); |
} |
/** Main thread function. |
* |
* This function is called from __thread_entry() and is used |
/trunk/uspace/lib/libc/generic/libc.c |
---|
40,8 → 40,9 |
#include <libc.h> |
#include <unistd.h> |
#include <malloc.h> |
#include <tls.h> |
#include <thread.h> |
#include <malloc.h> |
#include <fibril.h> |
#include <io/stream.h> |
#include <ipc/ipc.h> |
/trunk/uspace/lib/libc/Makefile |
---|
50,7 → 50,9 |
generic/as.c \ |
generic/cap.c \ |
generic/string.c \ |
generic/fibril.c \ |
generic/thread.c \ |
generic/tls.c \ |
generic/task.c \ |
generic/futex.c \ |
generic/io/io.c \ |
63,7 → 65,6 |
generic/io/vsnprintf.c \ |
generic/io/printf_core.c \ |
malloc/malloc.c \ |
generic/fibril.c \ |
generic/sysinfo.c \ |
generic/ipc.c \ |
generic/async.c \ |
/trunk/uspace/lib/libc/arch/sparc64/include/tls.h |
---|
0,0 → 1,65 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcsparc64 |
* @{ |
*/ |
/** |
* @file |
* @brief sparc64 TLS functions. |
*/ |
#ifndef LIBC_sparc64_TLS_H_ |
#define LIBC_sparc64_TLS_H_ |
#define CONFIG_TLS_VARIANT_2 |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
asm volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7"); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void *retval; |
asm volatile ("mov %%g7, %0\n" : "=r" (retval)); |
return retval; |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/sparc64/include/thread.h |
---|
30,33 → 30,10 |
/** @addtogroup libcsparc64 |
* @{ |
*/ |
/** |
* @file |
* @brief sparc64 TLS functions. |
*/ |
#ifndef LIBC_sparc64_THREAD_H_ |
#define LIBC_sparc64_THREAD_H_ |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
asm volatile ("mov %0, %%g7\n" : : "r" (tcb) : "g7"); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void *retval; |
asm volatile ("mov %%g7, %0\n" : "=r" (retval)); |
return retval; |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/sparc64/Makefile.inc |
---|
33,7 → 33,7 |
TOOLCHAIN_DIR = /usr/local/sparc64/bin |
ARCH_SOURCES += arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
CFLAGS += -mcpu=ultrasparc -m64 |
LFLAGS += -no-check-sections -N |
/trunk/uspace/lib/libc/arch/sparc64/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/sparc64/src/tls.c |
---|
0,0 → 1,51 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcsparc64 sparc64 |
* @ingroup lc |
* @{ |
*/ |
/** @file |
* |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_2(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_2(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ia64/include/tls.h |
---|
0,0 → 1,65 |
/* |
* Copyright (c) 2006 Jakub Jermar |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcia64 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_ia64_TLS_H_ |
#define LIBC_ia64_TLS_H_ |
#define CONFIG_TLS_VARIANT_1 |
#include <sys/types.h> |
/* This structure must be exactly 16 bytes long */ |
typedef struct { |
void *dtv; /* unused in static linking*/ |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
asm volatile ("mov r13 = %0\n" : : "r" (tcb) : "r13"); |
} |
static inline tcb_t *__tcb_get(void) |
{ |
void *retval; |
asm volatile ("mov %0 = r13\n" : "=r" (retval)); |
return retval; |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ia64/include/thread.h |
---|
37,26 → 37,6 |
#define THREAD_INITIAL_STACK_PAGES_NO 2 |
/* This structure must be exactly 16 bytes long */ |
typedef struct { |
void *dtv; /* unused in static linking*/ |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
asm volatile ("mov r13 = %0\n" : : "r" (tcb) : "r13"); |
} |
static inline tcb_t *__tcb_get(void) |
{ |
void *retval; |
asm volatile ("mov %0 = r13\n" : "=r" (retval)); |
return retval; |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/ia64/Makefile.inc |
---|
37,7 → 37,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
BFD_NAME = elf64-little |
BFD_ARCH = ia64-elf64 |
/trunk/uspace/lib/libc/arch/ia64/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/ia64/src/tls.c |
---|
0,0 → 1,51 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcia64 ia64 |
* @brief ia64 architecture dependent parts of libc |
* @ingroup lc |
* @{ |
*/ |
/** @file |
*/ |
#include <tls.h> |
#include <malloc.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_1(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_1(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/arm32/include/tls.h |
---|
0,0 → 1,99 |
/* |
* Copyright (c) 2007 Pavel Jancik |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcarm32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_arm32_TLS_H_ |
#define LIBC_arm32_TLS_H_ |
#include <sys/types.h> |
#define CONFIG_TLS_VARIANT_1 |
/** Offsets for accessing __thread variables are shifted 8 bytes higher. */ |
#define ARM_TP_OFFSET (-8) |
/** TCB (Thread Control Block) struct. |
* |
* TLS starts just after this struct. |
*/ |
typedef struct { |
/** Fibril data. */ |
void *fibril_data; |
} tcb_t; |
/** Sets TLS address to the r9 register. |
* |
* @param tcb TCB (TLS starts behind) |
*/ |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tls = (void *) tcb; |
tls += sizeof(tcb_t) + ARM_TP_OFFSET; |
asm volatile ( |
"mov r9, %0" |
: |
: "r" (tls) |
); |
} |
/** Returns TCB address. |
* |
* @return TCB address (starts before TLS which address is stored |
* in r9 register). |
*/ |
static inline tcb_t *__tcb_get(void) |
{ |
void *ret; |
asm volatile ( |
"mov %0, r9" |
: "=r"(ret) |
); |
return (tcb_t *) (ret - ARM_TP_OFFSET - sizeof(tcb_t)); |
} |
/** Returns TLS address stored. |
* |
* Implemented in assembly. |
* |
* @return TLS address stored in r9 register |
*/ |
extern uintptr_t __aeabi_read_tp(void); |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/arm32/include/thread.h |
---|
1,5 → 1,6 |
/* |
* Copyright (c) 2007 Pavel Jancik, Michal Kebrt |
* Copyright (c) 2007 Pavel Jancik |
* Copyright (c) 2007 Michal Kebrt |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
30,69 → 31,11 |
* @{ |
*/ |
/** @file |
* @brief Uspace threads and TLS. |
*/ |
#ifndef LIBC_arm32_THREAD_H_ |
#define LIBC_arm32_THREAD_H_ |
#include <unistd.h> |
/** Stack initial size. */ |
#define THREAD_INITIAL_STACK_PAGES_NO 1 |
/** Offsets for accessing __thread variables are shifted 8 bytes higher. */ |
#define ARM_TP_OFFSET (-8) |
/** TCB (Thread Control Block) struct. |
* |
* TLS starts just after this struct. |
*/ |
typedef struct { |
/** Fibril data. */ |
void *fibril_data; |
} tcb_t; |
/** Sets TLS address to the r9 register. |
* |
* @param tcb TCB (TLS starts behind) |
*/ |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tls = (void *) tcb; |
tls += sizeof(tcb_t) + ARM_TP_OFFSET; |
asm volatile ( |
"mov r9, %0" |
: |
: "r"(tls) |
); |
} |
/** Returns TCB address. |
* |
* @return TCB address (starts before TLS which address is stored in r9 register). |
*/ |
static inline tcb_t *__tcb_get(void) |
{ |
void *ret; |
asm volatile ( |
"mov %0, r9" |
: "=r"(ret) |
); |
return (tcb_t *) (ret - ARM_TP_OFFSET - sizeof(tcb_t)); |
} |
/** Returns TLS address stored. |
* |
* Implemented in assembly. |
* |
* @return TLS address stored in r9 register |
*/ |
extern uintptr_t __aeabi_read_tp(void); |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/arm32/Makefile.inc |
---|
1,5 → 1,6 |
# |
# Copyright (c) 2007 Michal Kebrt, Pavel Jancik |
# Copyright (c) 2007 Michal Kebrt |
# Copyright (c) 2007 Pavel Jancik |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
37,7 → 38,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c \ |
arch/$(ARCH)/src/tls.c \ |
arch/$(ARCH)/src/eabi.S |
BFD_NAME = elf32-littlearm |
/trunk/uspace/lib/libc/arch/arm32/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/arm32/src/tls.c |
---|
0,0 → 1,51 |
/* |
* Copyright (c) 2007 Pavel Jancik |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcarm32 arm32 |
* @brief arm32 architecture dependent parts of libc |
* @ingroup lc |
* @{ |
*/ |
/** @file |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_1(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_1(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/mips32eb/include/tls.h |
---|
0,0 → 1,0 |
link ../../mips32/include/tls.h |
Property changes: |
Added: svn:special |
+* |
\ No newline at end of property |
/trunk/uspace/lib/libc/arch/mips32eb/Makefile.inc |
---|
35,7 → 35,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
LFLAGS += -N |
/trunk/uspace/lib/libc/arch/ppc32/include/tls.h |
---|
0,0 → 1,73 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcppc32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_ppc32_TLS_H_ |
#define LIBC_ppc32_TLS_H_ |
#define CONFIG_TLS_VARIANT_1 |
#define PPC_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += PPC_TP_OFFSET + sizeof(tcb_t); |
asm volatile ( |
"mr %%r2, %0\n" |
: |
: "r" (tp) |
); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile ( |
"mr %0, %%r2\n" |
: "=r" (retval) |
); |
return (tcb_t *)(retval - PPC_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ppc32/include/thread.h |
---|
35,36 → 35,6 |
#ifndef LIBC_ppc32_THREAD_H_ |
#define LIBC_ppc32_THREAD_H_ |
#define PPC_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += PPC_TP_OFFSET + sizeof(tcb_t); |
asm volatile ( |
"mr %%r2, %0\n" |
: |
: "r" (tp) |
); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile ( |
"mr %0, %%r2\n" |
: "=r" (retval) |
); |
return (tcb_t *)(retval - PPC_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/ppc32/Makefile.inc |
---|
34,7 → 34,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
CFLAGS += -mcpu=powerpc -msoft-float -m32 |
AFLAGS += -a32 |
/trunk/uspace/lib/libc/arch/ppc32/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/ppc32/src/tls.c |
---|
0,0 → 1,49 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcppc32 |
* @{ |
*/ |
/** @file |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_1(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_1(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/amd64/include/tls.h |
---|
0,0 → 1,63 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcamd64 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_amd64_TLS_H_ |
#define LIBC_amd64_TLS_H_ |
#define CONFIG_TLS_VARIANT_2 |
#include <libc.h> |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
__SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm ("movq %%fs:0, %0" : "=r"(retval)); |
return retval; |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/amd64/include/thread.h |
---|
35,26 → 35,6 |
#ifndef LIBC_amd64_THREAD_H_ |
#define LIBC_amd64_THREAD_H_ |
#include <libc.h> |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
__SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm ("movq %%fs:0, %0" : "=r"(retval)); |
return retval; |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/amd64/Makefile.inc |
---|
34,7 → 34,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.S \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
LFLAGS += -N |
/trunk/uspace/lib/libc/arch/amd64/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/amd64/src/tls.c |
---|
0,0 → 1,51 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcamd64 amd64 |
* @ingroup lc |
* @{ |
*/ |
/** @file |
* @ingroup libcia32 |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_2(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_2(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ppc64/include/tls.h |
---|
0,0 → 1,73 |
/* |
* Copyright (c) 2006 Martin Decky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcppc64 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_ppc64_TLS_H_ |
#define LIBC_ppc64_TLS_H_ |
#define CONFIG_TLS_VARIANT_1 |
#define PPC_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += PPC_TP_OFFSET + sizeof(tcb_t); |
asm volatile ( |
"mr %%r2, %0\n" |
: |
: "r" (tp) |
); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile ( |
"mr %0, %%r2\n" |
: "=r" (retval) |
); |
return (tcb_t *)(retval - PPC_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ppc64/include/thread.h |
---|
35,36 → 35,6 |
#ifndef LIBC_ppc64_THREAD_H_ |
#define LIBC_ppc64_THREAD_H_ |
#define PPC_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += PPC_TP_OFFSET + sizeof(tcb_t); |
asm volatile ( |
"mr %%r2, %0\n" |
: |
: "r" (tp) |
); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile ( |
"mr %0, %%r2\n" |
: "=r" (retval) |
); |
return (tcb_t *)(retval - PPC_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/ppc64/Makefile.inc |
---|
34,7 → 34,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
CFLAGS += -mcpu=powerpc64 -msoft-float -m64 |
AFLAGS += -a64 |
/trunk/uspace/lib/libc/arch/ppc64/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/ppc64/src/tls.c |
---|
0,0 → 1,60 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcppc64 |
* @{ |
*/ |
/** @file |
*/ |
#include <thread.h> |
#include <malloc.h> |
/** Allocate TLS & TCB for initial module threads |
* |
* @param data Start of data section |
* @return pointer to tcb_t structure |
* |
*/ |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
tcb_t *tcb; |
*data = malloc(sizeof(tcb_t) + size); |
tcb = (tcb_t *) (*data + size); |
return tcb; |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
void *start = ((void *) tcb) - size; |
free(start); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/mips32/include/tls.h |
---|
0,0 → 1,86 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcmips32 |
* @{ |
*/ |
/** @file |
* @ingroup libcmips32eb |
*/ |
/* TLS for MIPS is described in http://www.linux-mips.org/wiki/NPTL */ |
#ifndef LIBC_mips32_TLS_H_ |
#define LIBC_mips32_TLS_H_ |
/* |
* FIXME: Note that the use of variant I contradicts the observations made in |
* the note below. Nevertheless the scheme we have used for allocating and |
* deallocatin TLS corresponds to TLS variant I. |
*/ |
#define CONFIG_TLS_VARIANT_1 |
/* I did not find any specification (neither MIPS nor PowerPC), but |
* as I found it |
* - it uses Variant II |
* - TCB is at Address(First TLS Block)+0x7000. |
* - DTV is at Address(First TLS Block)+0x8000 |
* - What would happen if the TLS data was larger then 0x7000? |
* - The linker never accesses DTV directly, has the second definition any |
* sense? |
* We will make it this way: |
* - TCB is at TP-0x7000-sizeof(tcb) |
* - No assumption about DTV etc., but it will not have a fixed address |
*/ |
#define MIPS_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += MIPS_TP_OFFSET + sizeof(tcb_t); |
asm volatile ("add $27, %0, $0" : : "r"(tp)); /* Move tls to K1 */ |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile("add %0, $27, $0" : "=r"(retval)); |
return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/mips32/include/thread.h |
---|
33,46 → 33,9 |
* @ingroup libcmips32eb |
*/ |
/* TLS for MIPS is described in http://www.linux-mips.org/wiki/NPTL */ |
#ifndef LIBC_mips32_THREAD_H_ |
#define LIBC_mips32_THREAD_H_ |
/* I did not find any specification (neither MIPS nor PowerPC), but |
* as I found it |
* - it uses Variant II |
* - TCB is at Address(First TLS Block)+0x7000. |
* - DTV is at Address(First TLS Block)+0x8000 |
* - What would happen if the TLS data was larger then 0x7000? |
* - The linker never accesses DTV directly, has the second definition any |
* sense? |
* We will make it this way: |
* - TCB is at TP-0x7000-sizeof(tcb) |
* - No assumption about DTV etc., but it will not have a fixed address |
*/ |
#define MIPS_TP_OFFSET 0x7000 |
typedef struct { |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
void *tp = tcb; |
tp += MIPS_TP_OFFSET + sizeof(tcb_t); |
asm volatile ("add $27, %0, $0" : : "r"(tp)); /* Move tls to K1 */ |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void * retval; |
asm volatile("add %0, $27, $0" : "=r"(retval)); |
return (tcb_t *)(retval - MIPS_TP_OFFSET - sizeof(tcb_t)); |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/mips32/Makefile.inc |
---|
40,7 → 40,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
BFD_ARCH = mips |
/trunk/uspace/lib/libc/arch/mips32/src/thread.c |
---|
File deleted |
/trunk/uspace/lib/libc/arch/mips32/src/tls.c |
---|
0,0 → 1,50 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcmips32 |
* @{ |
*/ |
/** @file |
* @ingroup libcmips32eb |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_1(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_1(tcb, size); |
} |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ia32/include/tls.h |
---|
0,0 → 1,63 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcia32 |
* @{ |
*/ |
/** @file |
*/ |
#ifndef LIBC_ia32_TLS_H_ |
#define LIBC_ia32_TLS_H_ |
#define CONFIG_TLS_VARIANT_2 |
#include <libc.h> |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
__SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void *retval; |
asm ("movl %%gs:0, %0" : "=r"(retval)); |
return retval; |
} |
#endif |
/** @} |
*/ |
/trunk/uspace/lib/libc/arch/ia32/include/thread.h |
---|
35,26 → 35,6 |
#ifndef LIBC_ia32_THREAD_H_ |
#define LIBC_ia32_THREAD_H_ |
#include <libc.h> |
typedef struct { |
void *self; |
void *fibril_data; |
} tcb_t; |
static inline void __tcb_set(tcb_t *tcb) |
{ |
__SYSCALL1(SYS_TLS_SET, (sysarg_t) tcb); |
} |
static inline tcb_t * __tcb_get(void) |
{ |
void *retval; |
asm ("movl %%gs:0, %0" : "=r"(retval)); |
return retval; |
} |
#endif |
/** @} |
/trunk/uspace/lib/libc/arch/ia32/Makefile.inc |
---|
34,7 → 34,7 |
ARCH_SOURCES += arch/$(ARCH)/src/syscall.c \ |
arch/$(ARCH)/src/fibril.S \ |
arch/$(ARCH)/src/thread.c |
arch/$(ARCH)/src/tls.c |
LFLAGS += -N |
/trunk/uspace/lib/libc/arch/ia32/src/thread.c |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:special |
-* |
\ No newline at end of property |
/trunk/uspace/lib/libc/arch/ia32/src/tls.c |
---|
0,0 → 1,51 |
/* |
* Copyright (c) 2006 Ondrej Palkovsky |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup libcamd64 amd64 |
* @ingroup lc |
* @{ |
*/ |
/** @file |
* @ingroup libcia32 |
*/ |
#include <tls.h> |
#include <sys/types.h> |
tcb_t * __alloc_tls(void **data, size_t size) |
{ |
return tls_alloc_variant_2(data, size); |
} |
void __free_tls_arch(tcb_t *tcb, size_t size) |
{ |
tls_free_variant_2(tcb, size); |
} |
/** @} |
*/ |