Changeset 2086948a in rtems


Ignore:
Timestamp:
May 11, 2018, 4:54:59 AM (17 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
fe2cd01
Parents:
853c5ef
git-author:
Sebastian Huber <sebastian.huber@…> (05/11/18 04:54:59)
git-committer:
Sebastian Huber <sebastian.huber@…> (06/28/18 13:02:12)
Message:

riscv: Add dummy SMP support

Update #3433.

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • bsps/riscv/riscv/start/start.S

    r853c5ef r2086948a  
    5353        .option pop
    5454
     55#ifdef RTEMS_SMP
     56        csrr    s0, mhartid
     57        bnez    s0, .Lloop_forever
     58#endif
     59
    5560        la      t0, ISR_Handler
    5661        csrw    mtvec, t0
     
    7075
    7176        j       boot_card
     77
     78#ifdef RTEMS_SMP
     79.Lloop_forever:
     80        j       .Lloop_forever
     81#endif
    7282
    7383        .align  4
  • c/src/lib/libbsp/riscv/riscv/Makefile.am

    r853c5ef r2086948a  
    6262librtemsbsp_a_SOURCES += ../../../../../../bsps/riscv/riscv/console/console-io.c
    6363
     64if HAS_SMP
     65librtemsbsp_a_SOURCES += ../../../../../../bsps/shared/start/bspsmp-dummy.c
     66endif
    6467
    6568include $(top_srcdir)/../../../../automake/local.am
  • cpukit/score/cpu/riscv/include/rtems/score/cpu.h

    r853c5ef r2086948a  
    8181  unsigned long mepc;
    8282#ifdef RTEMS_SMP
    83   /**
    84    * @brief On SMP configurations the thread context must contain a boolean
    85    * indicator to signal if this context is executing on a processor.
    86    *
    87    * This field must be updated during a context switch.  The context switch
    88    * to the heir must wait until the heir context indicates that it is no
    89    * longer executing on a processor.  The context switch must also check if
    90    * a thread dispatch is necessary to honor updates of the heir thread for
    91    * this processor.  This indicator must be updated using an atomic test and
    92    * set operation to ensure that at most one processor uses the heir
    93    * context at the same time.
    94    *
    95    * @code
    96    * void _CPU_Context_switch(
    97    *   Context_Control *executing,
    98    *   Context_Control *heir
    99    * )
    100    * {
    101    *   save( executing );
    102    *
    103    *   executing->is_executing = false;
    104    *   memory_barrier();
    105    *
    106    *   if ( test_and_set( &heir->is_executing ) ) {
    107    *     do {
    108    *       Per_CPU_Control *cpu_self = _Per_CPU_Get_snapshot();
    109    *
    110    *       if ( cpu_self->dispatch_necessary ) {
    111    *         heir = _Thread_Get_heir_and_make_it_executing( cpu_self );
    112    *       }
    113    *     } while ( test_and_set( &heir->is_executing ) );
    114    *   }
    115    *
    116    *   restore( heir );
    117    * }
    118    * @endcode
    119    */
    12083  volatile bool is_executing;
    12184#endif
     
    481444
    482445#ifdef RTEMS_SMP
    483 /**
    484  * @brief Performs CPU specific SMP initialization in the context of the boot
    485  * processor.
    486  *
    487  * This function is invoked on the boot processor during system
    488  * initialization.  All interrupt stacks are allocated at this point in case
    489  * the CPU port allocates the interrupt stacks.  This function is called
    490  * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is
    491  * used.
    492  *
    493  * @return The count of physically or virtually available processors.
    494  * Depending on the configuration the application may use not all processors.
    495  */
     446
    496447uint32_t _CPU_SMP_Initialize( void );
    497448
    498 /**
    499  * @brief Starts a processor specified by its index.
    500  *
    501  * This function is invoked on the boot processor during system
    502  * initialization.
    503  *
    504  * This function will be called after _CPU_SMP_Initialize().
    505  *
    506  * @param[in] cpu_index The processor index.
    507  *
    508  * @retval true Successful operation.
    509  * @retval false Unable to start this processor.
    510  */
    511449bool _CPU_SMP_Start_processor( uint32_t cpu_index );
    512450
    513 /**
    514  * @brief Performs final steps of CPU specific SMP initialization in the
    515  * context of the boot processor.
    516  *
    517  * This function is invoked on the boot processor during system
    518  * initialization.
    519  *
    520  * This function will be called after all processors requested by the
    521  * application have been started.
    522  *
    523  * @param[in] cpu_count The minimum value of the count of processors
    524  * requested by the application configuration and the count of physically or
    525  * virtually available processors.
    526  */
    527451void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    528452
    529 /**
    530  * @brief Returns the index of the current processor.
    531  *
    532  * An architecture specific method must be used to obtain the index of the
    533  * current processor in the system.  The set of processor indices is the
    534  * range of integers starting with zero up to the processor count minus one.
    535  */
    536 uint32_t _CPU_SMP_Get_current_processor( void );
    537 
    538 /**
    539  * @brief Sends an inter-processor interrupt to the specified target
    540  * processor.
    541  *
    542  * This operation is undefined for target processor indices out of range.
    543  *
    544  * @param[in] target_processor_index The target processor index.
    545  */
     453void _CPU_SMP_Prepare_start_multitasking( void );
     454
     455static inline uint32_t _CPU_SMP_Get_current_processor( void )
     456{
     457  unsigned long mhartid;
     458
     459  __asm__ volatile ( "csrr %0, mhartid" : "=&r" ( mhartid ) );
     460
     461  return (uint32_t) mhartid;
     462}
     463
    546464void _CPU_SMP_Send_interrupt( uint32_t target_processor_index );
    547465
    548 /**
    549  * @brief Broadcasts a processor event.
    550  *
    551  * Some architectures provide a low-level synchronization primitive for
    552  * processors in a multi-processor environment.  Processors waiting for this
    553  * event may go into a low-power state and stop generating system bus
    554  * transactions.  This function must ensure that preceding store operations
    555  * can be observed by other processors.
    556  *
    557  * @see _CPU_SMP_Processor_event_receive().
    558  */
    559 void _CPU_SMP_Processor_event_broadcast( void );
    560 
    561 /**
    562  * @brief Receives a processor event.
    563  *
    564  * This function will wait for the processor event and may wait forever if no
    565  * such event arrives.
    566  *
    567  * @see _CPU_SMP_Processor_event_broadcast().
    568  */
     466static inline void _CPU_SMP_Processor_event_broadcast( void )
     467{
     468  __asm__ volatile ( "" : : : "memory" );
     469}
     470
    569471static inline void _CPU_SMP_Processor_event_receive( void )
    570472{
     
    572474}
    573475
    574 /**
    575  * @brief Gets the is executing indicator of the thread context.
    576  *
    577  * @param[in] context The context.
    578  */
    579476static inline bool _CPU_Context_Get_is_executing(
    580477  const Context_Control *context
     
    584481}
    585482
    586 /**
    587  * @brief Sets the is executing indicator of the thread context.
    588  *
    589  * @param[in] context The context.
    590  * @param[in] is_executing The new value for the is executing indicator.
    591  */
    592483static inline void _CPU_Context_Set_is_executing(
    593484  Context_Control *context,
     
    597488  context->is_executing = is_executing;
    598489}
     490
    599491#endif /* RTEMS_SMP */
    600492
  • cpukit/score/cpu/riscv/include/rtems/score/cpuimpl.h

    r853c5ef r2086948a  
    66
    77/*
    8  * Copyright (c) 2013 embedded brains GmbH
     8 * Copyright (c) 2013, 2018 embedded brains GmbH
    99 *
    1010 * Redistribution and use in source and binary forms, with or without
     
    3737#define CPU_PER_CPU_CONTROL_SIZE 0
    3838
     39#if __riscv_xlen == 32
     40
     41#define CPU_INTERRUPT_FRAME_SIZE 144
     42
     43#elif __riscv_xlen == 64
     44
     45#define CPU_INTERRUPT_FRAME_SIZE 288
     46
     47#endif /* __riscv_xlen */
     48
    3949#ifndef ASM
    4050
  • testsuites/smptests/smpfatal08/init.c

    r853c5ef r2086948a  
    7272
    7373#if defined(RTEMS_PARAVIRT) \
    74   || (!defined(__leon__) && !defined(__PPC__) && !defined(__arm__))
     74  || (!defined(__leon__) && !defined(__PPC__) \
     75    && !defined(__arm__) && !defined(__riscv))
    7576uint32_t _CPU_SMP_Get_current_processor(void)
    7677{
Note: See TracChangeset for help on using the changeset viewer.