RTEMS
Modules | Files | Classes | Macros | Typedefs | Enumerations | Functions | Variables
RTEMS Per CPU Information

Modules

 Flexible Per-CPU Data
 Flexible Per-CPU Data.
 

Files

file  percpu.c
 Allocate and Initialize Per CPU Structures.
 

Classes

struct  Per_CPU_Job_context
 Context for per-processor jobs. More...
 
struct  Per_CPU_Job
 A per-processor job. More...
 
struct  Per_CPU_Stats
 Per-CPU statistics. More...
 
struct  Per_CPU_Control
 Per CPU Core Structure. More...
 
struct  Per_CPU_Control_envelope
 

Macros

#define PER_CPU_JOB_DONE   1
 
#define _Per_CPU_Acquire(cpu, lock_context)   _ISR_lock_Acquire( &( cpu )->Lock, lock_context )
 
#define _Per_CPU_Release(cpu, lock_context)   _ISR_lock_Release( &( cpu )->Lock, lock_context )
 
#define _Per_CPU_Get_snapshot()   ( &_Per_CPU_Information[ _SMP_Get_current_processor() ].per_cpu )
 
#define _Thread_Dispatch_disable_level   _Per_CPU_Get()->thread_dispatch_disable_level
 
#define _Thread_Heir   _Per_CPU_Get()->heir
 
#define _Thread_Executing   _Per_CPU_Get_executing( _Per_CPU_Get() )
 
#define _ISR_Nest_level   _Per_CPU_Get()->isr_nest_level
 
#define _CPU_Interrupt_stack_low   _Per_CPU_Get()->interrupt_stack_low
 
#define _CPU_Interrupt_stack_high   _Per_CPU_Get()->interrupt_stack_high
 
#define _Thread_Dispatch_necessary   _Per_CPU_Get()->dispatch_necessary
 

Typedefs

typedef void(* Per_CPU_Job_handler) (void *arg)
 
typedef struct Per_CPU_Job Per_CPU_Job
 A per-processor job. More...
 
typedef struct Per_CPU_Control Per_CPU_Control
 Per CPU Core Structure. More...
 

Enumerations

enum  Per_CPU_State {
  PER_CPU_STATE_INITIAL, PER_CPU_STATE_READY_TO_START_MULTITASKING, PER_CPU_STATE_REQUEST_START_MULTITASKING, PER_CPU_STATE_UP,
  PER_CPU_STATE_SHUTDOWN
}
 State of a processor. More...
 
enum  Per_CPU_Watchdog_index { PER_CPU_WATCHDOG_TICKS, PER_CPU_WATCHDOG_REALTIME, PER_CPU_WATCHDOG_MONOTONIC, PER_CPU_WATCHDOG_COUNT }
 Per-CPU watchdog header index. More...
 

Functions

static Per_CPU_Control_Per_CPU_Get (void)
 
static Per_CPU_Control_Per_CPU_Get_by_index (uint32_t index)
 
static uint32_t _Per_CPU_Get_index (const Per_CPU_Control *cpu)
 
static struct _Thread_Control_Per_CPU_Get_executing (const Per_CPU_Control *cpu)
 
static bool _Per_CPU_Is_processor_online (const Per_CPU_Control *cpu)
 
static bool _Per_CPU_Is_boot_processor (const Per_CPU_Control *cpu)
 
static __inline__ void _Per_CPU_Acquire_all (ISR_lock_Context *lock_context)
 
static __inline__ void _Per_CPU_Release_all (ISR_lock_Context *lock_context)
 
void _Per_CPU_Initialize (void)
 Allocate and Initialize Per CPU Structures. More...
 
void _Per_CPU_State_change (Per_CPU_Control *cpu, Per_CPU_State new_state)
 
bool _Per_CPU_State_wait_for_non_initial_state (uint32_t cpu_index, uint32_t timeout_in_ns)
 Waits for a processor to change into a non-initial state. More...
 
void _Per_CPU_Perform_jobs (Per_CPU_Control *cpu)
 Performs the jobs of the specified processor in FIFO order. More...
 
void _Per_CPU_Add_job (Per_CPU_Control *cpu, Per_CPU_Job *job)
 Adds the job to the tail of the processing list of the specified processor. More...
 
void _Per_CPU_Wait_for_job (const Per_CPU_Control *cpu, const Per_CPU_Job *job)
 Waits for the job carried out by the specified processor. More...
 
static __inline__ struct _Thread_Control_Thread_Get_executing (void)
 Returns the thread control block of the executing thread. More...
 

Variables

Per_CPU_Control_envelope _Per_CPU_Information [] CPU_STRUCTURE_ALIGNMENT
 Set of Per CPU Core Information. More...
 

Detailed Description

This defines the per CPU state information required by RTEMS and the BSP. In an SMP configuration, there will be multiple instances of this data structure – one per CPU – and the current CPU number will be used as the index.

Typedef Documentation

◆ Per_CPU_Control

Per CPU Core Structure.

This structure is used to hold per core state information.

◆ Per_CPU_Job

typedef struct Per_CPU_Job Per_CPU_Job

A per-processor job.

This structure must be as small as possible due to stack space constraints in _SMP_Multicast_action().

Enumeration Type Documentation

◆ Per_CPU_State

State of a processor.

The processor state controls the life cycle of processors at the lowest level. No multi-threading or other high-level concepts matter here.

State changes must be initiated via _Per_CPU_State_change(). This function may not return in case someone requested a shutdown. The _SMP_Send_message() function will be used to notify other processors about state changes if the other processor is in the up state.

Due to the sequential nature of the basic system initialization one processor has a special role. It is the processor executing the boot_card() function. This processor is called the boot processor. All other processors are called secondary.

dot_inline_dotgraph_1.png
Enumerator
PER_CPU_STATE_INITIAL 

The per CPU controls are initialized to zero.

The boot processor executes the sequential boot code in this state. The secondary processors should perform their basic initialization now and change into the PER_CPU_STATE_READY_TO_START_MULTITASKING state once this is complete.

PER_CPU_STATE_READY_TO_START_MULTITASKING 

Processor is ready to start multitasking.

The secondary processor performed its basic initialization and is ready to receive inter-processor interrupts. Interrupt delivery must be disabled in this state, but requested inter-processor interrupts must be recorded and must be delivered once the secondary processor enables interrupts for the first time. The boot processor will wait for all secondary processors to change into this state. In case a secondary processor does not reach this state the system will not start. The secondary processors wait now for a change into the PER_CPU_STATE_REQUEST_START_MULTITASKING state set by the boot processor once all secondary processors reached the PER_CPU_STATE_READY_TO_START_MULTITASKING state.

PER_CPU_STATE_REQUEST_START_MULTITASKING 

Multitasking start of processor is requested.

The boot processor completed system initialization and is about to perform a context switch to its heir thread. Secondary processors should now issue a context switch to the heir thread. This normally enables interrupts on the processor for the first time.

PER_CPU_STATE_UP 

Normal multitasking state.

PER_CPU_STATE_SHUTDOWN 

This is the terminal state.

Definition at line 128 of file percpu.h.

◆ Per_CPU_Watchdog_index

Per-CPU watchdog header index.

Enumerator
PER_CPU_WATCHDOG_TICKS 

Index for tick clock per-CPU watchdog header.

The reference time point for the tick clock is the system start. The clock resolution is one system clock tick. It is used for the system clock tick based time services.

PER_CPU_WATCHDOG_REALTIME 

Index for realtime clock per-CPU watchdog header.

The reference time point for the realtime clock is the POSIX Epoch. The clock resolution is one nanosecond. It is used for the time of day services and the POSIX services using CLOCK_REALTIME.

PER_CPU_WATCHDOG_MONOTONIC 

Index for monotonic clock per-CPU watchdog header.

The reference time point for the monotonic clock is the system start. The clock resolution is one nanosecond. It is used for the POSIX services using CLOCK_MONOTONIC.

PER_CPU_WATCHDOG_COUNT 

Count of per-CPU watchdog headers.

Definition at line 308 of file percpu.h.

Function Documentation

◆ _Per_CPU_Add_job()

void _Per_CPU_Add_job ( Per_CPU_Control cpu,
Per_CPU_Job job 
)

Adds the job to the tail of the processing list of the specified processor.

This function does not send the SMP_MESSAGE_PERFORM_JOBS message the specified processor.

Parameters
[in,out]cpuThe processor to add the job.
[in,out]jobThe job. The Per_CPU_Job::context member must be initialized by the caller.

Definition at line 64 of file smpmulticastaction.c.

◆ _Per_CPU_Initialize()

void _Per_CPU_Initialize ( void  )

Allocate and Initialize Per CPU Structures.

This method allocates and initialize the per CPU structure.

◆ _Per_CPU_Perform_jobs()

void _Per_CPU_Perform_jobs ( Per_CPU_Control cpu)

Performs the jobs of the specified processor in FIFO order.

Parameters
[in,out]cpuThe jobs of this processor will be performed.

Definition at line 41 of file smpmulticastaction.c.

◆ _Per_CPU_State_wait_for_non_initial_state()

bool _Per_CPU_State_wait_for_non_initial_state ( uint32_t  cpu_index,
uint32_t  timeout_in_ns 
)

Waits for a processor to change into a non-initial state.

This function should be called only in _CPU_SMP_Start_processor() if required by the CPU port or BSP.

bool _CPU_SMP_Start_processor(uint32_t cpu_index)
{
uint32_t timeout = 123456;
start_the_processor(cpu_index);
return _Per_CPU_State_wait_for_non_initial_state(cpu_index, timeout);
}
Parameters
[in]cpu_indexThe processor index.
[in]timeout_in_nsThe timeout in nanoseconds. Use a value of zero to wait forever if necessary.
Return values
trueThe processor is in a non-initial state.
falseThe timeout expired before the processor reached a non-initial state.

Definition at line 22 of file percpustatewait.c.

◆ _Per_CPU_Wait_for_job()

void _Per_CPU_Wait_for_job ( const Per_CPU_Control cpu,
const Per_CPU_Job job 
)

Waits for the job carried out by the specified processor.

This function may result in an SMP_FATAL_WRONG_CPU_STATE_TO_PERFORM_JOBS fatal error.

Parameters
[in]cpuThe processor carrying out the job.
[in]jobThe job to wait for.

Definition at line 105 of file smpmulticastaction.c.

◆ _Thread_Get_executing()

static __inline__ struct _Thread_Control* _Thread_Get_executing ( void  )
static

Returns the thread control block of the executing thread.

This function can be called in any thread context. On SMP configurations, interrupts are disabled to ensure that the processor index is used consistently if no CPU port specific method is available to get the executing thread.

Returns
The thread control block of the executing thread.

Definition at line 878 of file percpu.h.

Variable Documentation

◆ CPU_STRUCTURE_ALIGNMENT

Per_CPU_Control_envelope _Per_CPU_Information [] CPU_STRUCTURE_ALIGNMENT

Set of Per CPU Core Information.

This is an array of per CPU core information.