Sebastian Huber 55f0bb55fe cpukit/score/cpu/or1k: Implement TLS
The port declared a thread-local storage variant and implemented none
of it.  _CPU_Context_Initialize() discarded the thread-local storage
area, _CPU_Get_TLS_thread_pointer() returned NULL, and the context
switch skipped r10, so every thread shared whatever value that register
held.

r10 is the thread pointer of the OpenRISC ABI.  The compiler emits an
access as an offset added to it and treats it as a fixed register, so a
register variable cannot name it.

Initialize it from _TLS_Initialize_area(), restore it in the context
switch, return it from _CPU_Get_TLS_thread_pointer(), and set it in
_CPU_Use_thread_local_storage().  The storage then also works during
system initialization, before the first context is restored.

The linker computes the offsets relative to a 16 byte thread control
block and reserves an aligned block of that size before the data:

  base = align_power( TCB_SIZE, alignment ) - TCB_SIZE

See tpoff() in bfd/elf32-or1k.c.  Variant 10 places the data right
after the block and hands out its address as the thread pointer, so
every offset is too large by the padding, and an object with an
alignment above 16 bytes reads as zero.  Use variant 11, which reserves
an aligned block, and point the thread pointer at the first byte after
the block.  Give the block the 16 bytes which the linker of this
architecture assumes.  It is 8 on a 32 bit target otherwise.

sptls01, sptls02, sptls04, ts-validation-tls-0 and ts-validation-tls-1
pass with this change.

Close #5685.

Assisted-by: Claude:claude-opus-5 claude-code
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2026-08-20 18:14:29 -05:00
…
…
…
…
…
…
…

Real-Time Executive for Multiprocessing Systems

RTEMS is a real-time executive (kernel) which provides a high performance environment for embedded applications with the following features:

  • Standards based user interfaces.
  • Multitasking capabilities.
  • Homogeneous and heterogeneous multiprocessor systems.
  • Symmetric Multiprocessing (SMP):
    • Cluster scheduling: Job-level fixed prority scheduler (EDF) with support for one-to-one and one-to-all thread to processor affinities.
    • Locking protocols with transitive priority inheritance, priority ceiling, MRsP and OMIP.
  • Event-driven, priority-based, preemptive scheduling.
  • Scalable timer and timeout support.
  • Optional rate monotonic scheduling.
  • Intertask communication and synchronisation.
  • Priority inheritance.
  • Responsive interrupt management.
  • Dynamic memory allocation.
  • Dynamic code loading using run-time link editing.
  • File systems, IMFS, FAT, RFS, JFFS, NSFv4 (with LibBSD)
  • High level of user configurability.
  • Link-time configurable schedulers.
  • Linker-set based initialization (similar to global C++ constructors).
  • Drivers for I2C, SPI and LibBSD has NIC, USB, SD/MMC and Framebuffer.
  • Open source with a friendly user license.

RTEMS Project:

Project git repositories are located at:

Online documentation is available at:

RTEMS Doxygen for CPUKit:

RTEMS POSIX 1003.1 Compliance Guide:

RTEMS Discourse User forum for questions, answers and examples:

RTEMS Discord for support:

RTEMS Mailing Lists for general purpose use the users list and for developers use the devel list.

The version number for this software in releases is located in the VERSION file if present.

S
Description
RTEMS is a ​real-time executive in use by embedded systems applications around the world and beyond
Readme
141 MiB
0 Stars 1 Watchers 0 Forks
Languages
C 93.9%
Assembly 3.4%
Ada 1.4%
Python 0.3%
HTML 0.3%
Other 0.4%