summaryrefslogtreecommitdiffstats
path: root/schedsim/shell/schedsim_smpsimple/smp_stub.c
blob: 7f8f2d44d44613cbacb0697b982aba1bc5f5a6d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
 *  RTEMS SMP Support for Single Core
 *
 *  COPYRIGHT (c) 1989-2013.
 *  On-Line Applications Research Corporation (OAR).
 *
 *  The license and distribution terms for this file may be
 *  found in the file LICENSE in this distribution or at
 *  http://www.rtems.com/license/LICENSE.
 */

#include <rtems.h>
#include <rtems/bspIo.h>
#include <stdlib.h>

uint32_t Schedsim_Current_cpu;
extern uint32_t Schedsim_Maximum_CPUs_From_Command_Line;

uint32_t _CPU_SMP_Initialize( void )
{
  if ( configured_cpu_count < Schedsim_Maximum_CPUs_From_Command_Line ) {
    printf(
      "ERROR - Maximum cores per confdefs.h is %d\n",
      configured_cpu_count
    );
    exit( 1 );
  }

  /* return the number of CPUs */
  return Schedsim_Maximum_CPUs_From_Command_Line;
}

bool _CPU_SMP_Start_processor( uint32_t cpu_index )
{
  return true;
}

void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
{
}

void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
{
} 

void _CPU_SMP_Processor_event_broadcast( void )
{
  Per_CPU_Control  *cpu = _Per_CPU_Get();
  uint32_t         cpu_count = _SMP_Get_processor_count();
  uint32_t         cpu_index;
  Per_CPU_State    state = cpu->state;

  if (state == PER_CPU_STATE_REQUEST_START_MULTITASKING) {
    for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
      cpu = _Per_CPU_Get_by_index( cpu_index );
      state = cpu->state;
      if (state == PER_CPU_STATE_INITIAL )
         cpu->state = PER_CPU_STATE_READY_TO_START_MULTITASKING;
    }
  }
}


void _CPU_SMP_Processor_event_receive( void )
{
}

uint32_t _CPU_SMP_Get_current_processor( void )
{
  return Schedsim_Current_cpu;
}