Changeset 03e4d1e9 in rtems


Ignore:
Timestamp:
06/29/22 12:37:47 (6 weeks ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
eefaf068
Parents:
9dd4bd3
git-author:
Sebastian Huber <sebastian.huber@…> (06/29/22 12:37:47)
git-committer:
Sebastian Huber <sebastian.huber@…> (07/04/22 06:30:42)
Message:

score: Add _CPU_Use_thread_local_storage()

At some point during system initialization, the idle threads are created.
Afterwards, the boot processor basically executes within the context of an idle
thread with thread dispatching disabled. On some architectures, the
thread-local storage area of the associated thread must be set in dedicated
processor registers. Add the new CPU port function to do this:

void _CPU_Use_thread_local_storage( const Context_Control *context )

Close #4672.

Files:
21 edited

Legend:

Unmodified
Added
Removed
  • cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    163163}
    164164
     165RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     166  const Context_Control *context
     167)
     168{
     169  __asm__ volatile (
     170    "msr TPIDR_EL0, %0" : : "r" ( context->thread_id ) : "memory"
     171  );
     172}
     173
    165174#ifdef __cplusplus
    166175}
  • cpukit/score/cpu/arm/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    161161}
    162162
     163RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     164  const Context_Control *context
     165)
     166{
     167#ifdef ARM_MULTILIB_HAS_THREAD_ID_REGISTER
     168  __asm__ volatile (
     169    "mcr p15, 0, %0, c13, c0, 3" : : "r" ( context->thread_id ) : "memory"
     170  );
     171#else
     172  (void) context;
     173#endif
     174}
     175
    163176#ifdef __cplusplus
    164177}
  • cpukit/score/cpu/bfin/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    6060}
    6161
     62RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     63  const Context_Control *context
     64)
     65{
     66  (void) context;
     67}
     68
    6269#ifdef __cplusplus
    6370}
  • cpukit/score/cpu/i386/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    8181}
    8282
     83RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     84  const Context_Control *context
     85)
     86{
     87  uint32_t tmp;
     88  uint32_t cpu_index;
     89
     90#ifdef RTEMS_SMP
     91  cpu_index = _CPU_SMP_Get_current_processor();
     92#else
     93  cpu_index = 0;
     94#endif
     95
     96  __asm__ volatile (
     97    "movl " RTEMS_XSTRING( I386_CONTEXT_CONTROL_GS_0_OFFSET ) "(%2), %0\n"
     98    "movl %0, _Global_descriptor_table+24(,%1,8)\n"
     99    "movl " RTEMS_XSTRING( I386_CONTEXT_CONTROL_GS_1_OFFSET ) "(%2), %0\n"
     100    "movl %0, _Global_descriptor_table+28(,%1,8)\n"
     101    "leal 24(,%1,8), %0\n"
     102    "movl %0, %%gs\n"
     103    : "=&r" ( tmp )
     104    : "r" ( cpu_index ), "r" ( context )
     105    : "memory"
     106  );
     107}
     108
    83109#ifdef __cplusplus
    84110}
  • cpukit/score/cpu/lm32/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    5959}
    6060
     61RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     62  const Context_Control *context
     63)
     64{
     65  (void) context;
     66}
     67
    6168#ifdef __cplusplus
    6269}
  • cpukit/score/cpu/m68k/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7979}
    8080
     81RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     82  const Context_Control *context
     83)
     84{
     85  /*
     86   * There is nothing to do since the thread-local storage area is obtained by
     87   * calling __m68k_read_tp().
     88   */
     89  (void) context;
     90}
     91
    8192#ifdef __cplusplus
    8293}
  • cpukit/score/cpu/microblaze/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    8787}
    8888
     89RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     90  const Context_Control *context
     91)
     92{
     93  /*
     94   * There is nothing to do since the thread-local storage area is obtained by
     95   * calling __tls_get_addr().
     96   */
     97  (void) context;
     98}
     99
    89100#ifdef __cplusplus
    90101}
  • cpukit/score/cpu/mips/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7979}
    8080
     81RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     82  const Context_Control *context
     83)
     84{
     85  (void) context;
     86}
     87
    8188#ifdef __cplusplus
    8289}
  • cpukit/score/cpu/moxie/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7979}
    8080
     81RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     82  const Context_Control *context
     83)
     84{
     85  (void) context;
     86}
     87
    8188#ifdef __cplusplus
    8289}
  • cpukit/score/cpu/nios2/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7171}
    7272
     73RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     74  const Context_Control *context
     75)
     76{
     77   register uint32_t r23 __asm__( "r23" );
     78
     79   r23 = context->r23;
     80
     81   /* Make sure that the register assignment is not optimized away */
     82   __asm__ volatile ( "" : : "r" ( r23 ) );
     83}
     84
    7385#ifdef __cplusplus
    7486}
  • cpukit/score/cpu/no_cpu/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    167167}
    168168
     169/**
     170 * @brief Uses the thread-local storage area of the context.
     171 *
     172 * Some architectures may use dedicated registers to reference the thread-local
     173 * storage area of the associated thread.  This function should set these
     174 * registers to the values defined by the specified processor context.
     175 *
     176 * @param context is the processor context defining the thread-local storage
     177 *   area to use.
     178 */
     179RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     180  const Context_Control *context
     181)
     182{
     183  (void) context;
     184}
     185
    169186#ifdef __cplusplus
    170187}
  • cpukit/score/cpu/or1k/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7171}
    7272
     73RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     74  const Context_Control *context
     75)
     76{
     77  (void) context;
     78}
     79
    7380#ifdef __cplusplus
    7481}
  • cpukit/score/cpu/powerpc/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    284284}
    285285
     286RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     287  const Context_Control *context
     288)
     289{
     290#ifdef __powerpc64__
     291   register uintptr_t tp __asm__( "13" );
     292#else
     293   register uintptr_t tp __asm__( "2" );
     294#endif
     295
     296   tp = ppc_get_context( context )->tp;
     297
     298   /* Make sure that the register assignment is not optimized away */
     299   __asm__ volatile ( "" : : "r" ( tp ) );
     300}
     301
    286302#ifdef __cplusplus
    287303}
  • cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    431431}
    432432
     433RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     434  const Context_Control *context
     435)
     436{
     437   register uintptr_t tp __asm__( "tp" );
     438
     439   tp = context->tp;
     440
     441   /* Make sure that the register assignment is not optimized away */
     442   __asm__ volatile ( "" : : "r" ( tp ) );
     443}
     444
    433445#ifdef __cplusplus
    434446}
  • cpukit/score/cpu/sh/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    6060}
    6161
     62RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     63  const Context_Control *context
     64)
     65{
     66  (void) context;
     67}
     68
    6269#ifdef __cplusplus
    6370}
  • cpukit/score/cpu/sparc/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    235235}
    236236
     237RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     238  const Context_Control *context
     239)
     240{
     241   register uint32_t g7 __asm__( "g7" );
     242
     243   g7 = context->g7;
     244
     245   /* Make sure that the register assignment is not optimized away */
     246   __asm__ volatile ( "" : : "r" ( g7 ) );
     247}
     248
    237249#ifdef __cplusplus
    238250}
  • cpukit/score/cpu/sparc64/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7979}
    8080
     81RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     82  const Context_Control *context
     83)
     84{
     85  (void) context;
     86}
     87
    8188#ifdef __cplusplus
    8289}
  • cpukit/score/cpu/v850/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    7979}
    8080
     81RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     82  const Context_Control *context
     83)
     84{
     85  (void) context;
     86}
     87
    8188#ifdef __cplusplus
    8289}
  • cpukit/score/cpu/x86_64/include/rtems/score/cpuimpl.h

    r9dd4bd3 r03e4d1e9  
    6363}
    6464
     65RTEMS_INLINE_ROUTINE void _CPU_Use_thread_local_storage(
     66  const Context_Control *context
     67)
     68{
     69  (void) context;
     70}
     71
    6572#ifdef __cplusplus
    6673}
  • cpukit/score/src/threadcreateidle.c

    r9dd4bd3 r03e4d1e9  
    4141
    4242#include <rtems/score/threadidledata.h>
     43#include <rtems/score/cpuimpl.h>
    4344#include <rtems/score/threadimpl.h>
    4445#include <rtems/score/assert.h>
     
    125126    }
    126127  }
     128
     129  _CPU_Use_thread_local_storage(
     130    &_Per_CPU_Get_executing( _Per_CPU_Get() )->Registers
     131  );
    127132}
  • testsuites/sptests/sptls01/init.c

    r9dd4bd3 r03e4d1e9  
    22
    33/*
    4  * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
     4 * Copyright (C) 2014, 2022 embedded brains GmbH
    55 *
    66 * Redistribution and use in source and binary forms, with or without
     
    3030#endif
    3131
    32 #include <stdio.h>
     32#include <rtems/bspIo.h>
     33#include <rtems/sysinit.h>
    3334
    3435#include "tmacros.h"
     
    4647static void check_tls_item(uint32_t expected)
    4748{
    48   printf("TLS item = %i\n", tls_item);
     49  printk("TLS item = %i\n", tls_item);
    4950  rtems_test_assert(tls_item == expected);
    5051}
     
    9899}
    99100
    100 static void Init(rtems_task_argument arg)
     101static void test_idle_during_system_init(void)
    101102{
    102103  TEST_BEGIN();
    103104
     105  check_tls_item(123);
     106}
     107
     108static void Init(rtems_task_argument arg)
     109{
    104110  test();
    105111
     
    108114  rtems_test_exit(0);
    109115}
     116
     117RTEMS_SYSINIT_ITEM(
     118  test_idle_during_system_init,
     119  RTEMS_SYSINIT_IDLE_THREADS,
     120  RTEMS_SYSINIT_ORDER_LAST
     121);
    110122
    111123#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
Note: See TracChangeset for help on using the changeset viewer.