ChibiOS/RT Logo ChibiOS/RT

Architecture - Reference Manual - Guides

Data Structures | Defines | Typedefs | Functions

Port Templates
[Kernel]

Collaboration diagram for Port Templates:


Description

Non portable code templates.

Data Structures

struct  extctx
 Interrupt saved context. More...
struct  intctx
 System saved context. More...
struct  context
 Platform dependent part of the Thread structure. More...

Defines

#define CH_ARCHITECTURE_XXX
 Unique macro for the implemented architecture.
#define CH_ARCHITECTURE_NAME   ""
 Name of the implemented architecture.
#define CH_ARCHITECTURE_VARIANT_NAME   ""
 Name of the architecture variant (optional).
#define SETUP_CONTEXT(workspace, wsize, pf, arg)
 Platform dependent part of the chThdInit() API.
#define IDLE_THREAD_STACK_SIZE   0
 Stack size for the system idle thread.
#define INT_REQUIRED_STACK   0
 Per-thread stack overhead for interrupts servicing.
#define STACK_ALIGN(n)   ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
 Enforces a correct alignment for a stack area size value.
#define THD_WA_SIZE(n)
 Computes the thread working area global size.
#define WORKING_AREA(s, n)   stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)]
 Static working area allocation.
#define PORT_IRQ_PROLOGUE()
 IRQ prologue code.
#define PORT_IRQ_EPILOGUE()
 IRQ epilogue code.
#define PORT_IRQ_HANDLER(id)   void id(void)
 IRQ handler function declaration.
#define PORT_FAST_IRQ_HANDLER(id)   void id(void)
 Fast IRQ handler function declaration.

Typedefs

typedef uint8_t stkalign_t
 Base type for stack and memory alignment.

Functions

void port_init (void)
 Port-related initialization code.
void port_lock (void)
 Kernel-lock action.
void port_unlock (void)
 Kernel-unlock action.
void port_lock_from_isr (void)
 Kernel-lock action from an interrupt handler.
void port_unlock_from_isr (void)
 Kernel-unlock action from an interrupt handler.
void port_disable (void)
 Disables all the interrupt sources.
void port_suspend (void)
 Disables the interrupt sources below kernel-level priority.
void port_enable (void)
 Enables all the interrupt sources.
void port_wait_for_interrupt (void)
 Enters an architecture-dependent IRQ-waiting mode.
void port_halt (void)
 Halts the system.
void port_switch (Thread *ntp, Thread *otp)
 Performs a context switch between two threads.

Define Documentation

#define CH_ARCHITECTURE_XXX

Unique macro for the implemented architecture.

Definition at line 43 of file kernel/templates/chcore.h.

#define CH_ARCHITECTURE_NAME   ""

Name of the implemented architecture.

Definition at line 48 of file kernel/templates/chcore.h.

#define CH_ARCHITECTURE_VARIANT_NAME   ""

Name of the architecture variant (optional).

Definition at line 53 of file kernel/templates/chcore.h.

#define SETUP_CONTEXT (   workspace,
  wsize,
  pf,
  arg 
)
Value:
{                          \
}

Platform dependent part of the chThdInit() API.

This code usually setup the context switching frame represented by an intctx structure.

Definition at line 90 of file kernel/templates/chcore.h.

Referenced by chThdCreateI().

#define IDLE_THREAD_STACK_SIZE   0

Stack size for the system idle thread.

This size depends on the idle thread implementation, usually the idle thread should take no more space than those reserved by INT_REQUIRED_STACK.

Definition at line 100 of file kernel/templates/chcore.h.

#define INT_REQUIRED_STACK   0

Per-thread stack overhead for interrupts servicing.

This constant is used in the calculation of the correct working area size. This value can be zero on those architecture where there is a separate interrupt stack and the stack space between intctx and extctx is known to be zero.

Definition at line 112 of file kernel/templates/chcore.h.

#define STACK_ALIGN (   n  )     ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)

Enforces a correct alignment for a stack area size value.

Definition at line 118 of file kernel/templates/chcore.h.

#define THD_WA_SIZE (   n  ) 
Value:
STACK_ALIGN(sizeof(Thread) +                         \
                                   sizeof(struct intctx) +                  \
                                   sizeof(struct extctx) +                  \
                                  (n) + (INT_REQUIRED_STACK))

Computes the thread working area global size.

Definition at line 123 of file kernel/templates/chcore.h.

Referenced by chThdCreateI().

#define WORKING_AREA (   s,
  n 
)    stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)]

Static working area allocation.

This macro is used to allocate a static thread working area aligned as both position and size.

Definition at line 133 of file kernel/templates/chcore.h.

#define PORT_IRQ_PROLOGUE (  ) 

IRQ prologue code.

This macro must be inserted at the start of all IRQ handlers enabled to invoke system APIs.

Definition at line 140 of file kernel/templates/chcore.h.

#define PORT_IRQ_EPILOGUE (  ) 

IRQ epilogue code.

This macro must be inserted at the end of all IRQ handlers enabled to invoke system APIs.

Definition at line 147 of file kernel/templates/chcore.h.

#define PORT_IRQ_HANDLER (   id  )     void id(void)

IRQ handler function declaration.

Note:
id can be a function name or a vector number depending on the port implementation.

Definition at line 154 of file kernel/templates/chcore.h.

#define PORT_FAST_IRQ_HANDLER (   id  )     void id(void)

Fast IRQ handler function declaration.

Note:
id can be a function name or a vector number depending on the port implementation.
Not all architectures support fast interrupts, in this case this macro must be omitted.

Definition at line 163 of file kernel/templates/chcore.h.


Typedef Documentation

Base type for stack and memory alignment.

Definition at line 58 of file kernel/templates/chcore.h.


Function Documentation

void port_init ( void   ) 

Port-related initialization code.

Note:
This function is usually empty.

Referenced by chSysInit().

void port_lock ( void   ) 

Kernel-lock action.

Usually this function just disables interrupts but may perform more actions.

void port_unlock ( void   ) 

Kernel-unlock action.

Usually this function just disables interrupts but may perform more actions.

void port_lock_from_isr ( void   ) 

Kernel-lock action from an interrupt handler.

This function is invoked before invoking I-class APIs from interrupt handlers. The implementation is architecture dependent, in its simplest form it is void.

void port_unlock_from_isr ( void   ) 

Kernel-unlock action from an interrupt handler.

This function is invoked after invoking I-class APIs from interrupt handlers. The implementation is architecture dependent, in its simplest form it is void.

Referenced by SVCallVector().

void port_disable ( void   ) 

Disables all the interrupt sources.

Note:
Of course non maskable interrupt sources are not included.

Referenced by port_halt().

void port_suspend ( void   ) 

Disables the interrupt sources below kernel-level priority.

Note:
Interrupt sources above kernel level remains enabled.
void port_enable ( void   ) 

Enables all the interrupt sources.

void port_wait_for_interrupt ( void   ) 

Enters an architecture-dependent IRQ-waiting mode.

The function is meant to return when an interrupt becomes pending. The simplest implementation is an empty function or macro but this would not take advantage of architecture-specific power saving modes.

void port_halt ( void   ) 

Halts the system.

This function is invoked by the operating system when an unrecoverable error is detected (as example because a programming error in the application code that triggers an assertion while in debug mode).

void port_switch ( Thread ntp,
Thread otp 
)

Performs a context switch between two threads.

This is the most critical code in any port, this function is responsible for the context switch between 2 threads.

Note:
The implementation of this code affects directly the context switch performance so optimize here as much as you can.
Parameters:
[in] ntp the thread to be switched in
[in] otp the thread to be switched out

Generated on Sun Oct 24 2010 09:40:46 for ChibiOS/RT by doxygen 1.7.1