File indexing completed on 2025-05-11 08:24:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #include <bsp/bootcard.h>
0027 #include <bsp/irq.h>
0028 #include <amba.h>
0029
0030 #include <rtems/score/riscv-utility.h>
0031 #include <rtems/score/smpimpl.h>
0032
0033 static rtems_isr bsp_inter_processor_interrupt( void *v )
0034 {
0035 _SMP_Inter_processor_interrupt_handler(_Per_CPU_Get());
0036 }
0037
0038 void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
0039 {
0040 uint32_t cpu_index_self;
0041
0042 cpu_index_self = _Per_CPU_Get_index(cpu_self);
0043 GRLIB_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << GRLIB_mp_irq;
0044
0045 if (
0046 cpu_index_self < rtems_configuration_get_maximum_processors()
0047 && _SMP_Should_start_processor(cpu_index_self)
0048 ) {
0049 set_csr(mie, MIP_MEIP);
0050 _SMP_Start_multitasking_on_secondary_processor(cpu_self);
0051 } else {
0052 _CPU_Thread_Idle_body(0);
0053 }
0054 }
0055
0056 uint32_t _CPU_SMP_Initialize(void)
0057 {
0058 GRLIB_Cpu_Unmask_interrupt(GRLIB_mp_irq, _CPU_SMP_Get_current_processor());
0059
0060 rtems_interrupt_handler_install(
0061 GRLIB_mp_irq,
0062 "IPI",
0063 RTEMS_INTERRUPT_SHARED,
0064 bsp_inter_processor_interrupt,
0065 NULL
0066 );
0067
0068 return grlib_get_cpu_count(GRLIB_IrqCtrl_Regs);
0069 }
0070
0071 bool _CPU_SMP_Start_processor(uint32_t cpu_index)
0072 {
0073 GRLIB_IrqCtrl_Regs->mpstat = 1U << cpu_index;
0074
0075 return true;
0076 }
0077
0078 void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
0079 {
0080 (void) cpu_count;
0081
0082 }
0083
0084 void _CPU_SMP_Prepare_start_multitasking(void)
0085 {
0086
0087 }
0088
0089 void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
0090 {
0091
0092 GRLIB_IrqCtrl_Regs->force[target_processor_index] = 1 << GRLIB_mp_irq;
0093
0094 }