|
ChibiOS/RT
2.5.1 |
|
ARMv6-M specific port code, structures and macros.
Data Structures | |
| struct | context |
Platform dependent part of the Thread structure. More... | |
Functions | |
| CH_IRQ_HANDLER (SysTickVector) | |
| System Timer vector. | |
| void | NMIVector (void) |
| NMI vector. | |
| void | PendSVVector (void) |
| PendSV vector. | |
| void | _port_irq_epilogue (regarm_t lr) |
| IRQ epilogue code. | |
| void | port_halt (void) |
| Halts the system. | |
| void | _port_switch_from_isr (void) |
| Post-IRQ switch code. | |
| void | _port_switch (Thread *ntp, Thread *otp) |
| Performs a context switch between two threads. | |
| void | _port_thread_start (void) |
| Thread start code. | |
Defines | |
| #define | CORTEX_PRIORITY_PENDSV 0 |
| PendSV priority level. | |
| #define | PORT_IDLE_THREAD_STACK_SIZE 16 |
| Stack size for the system idle thread. | |
| #define | PORT_INT_REQUIRED_STACK 32 |
| Per-thread stack overhead for interrupts servicing. | |
| #define | CORTEX_ENABLE_WFI_IDLE FALSE |
| Enables the use of the WFI instruction in the idle thread loop. | |
| #define | CORTEX_PRIORITY_SYSTICK (CORTEX_PRIORITY_LEVELS >> 1) |
| SYSTICK handler priority. | |
| #define | CORTEX_ALTERNATE_SWITCH FALSE |
| Alternate preemption method. | |
| #define | CORTEX_MAX_KERNEL_PRIORITY 1 |
| Maximum usable priority for normal ISRs. | |
| #define | CH_ARCHITECTURE_ARM_v6M |
| Macro defining the specific ARM architecture. | |
| #define | CH_ARCHITECTURE_NAME "ARMv6-M" |
| Name of the implemented architecture. | |
| #define | CH_CORE_VARIANT_NAME "Cortex-M0" |
| Name of the architecture variant. | |
| #define | CH_PORT_INFO "Preemption through NMI" |
| Port-specific information string. | |
| #define | SETUP_CONTEXT(workspace, wsize, pf, arg) |
Platform dependent part of the chThdCreateI() API. | |
| #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() regarm_t _saved_lr = (regarm_t)__get_LR() |
| IRQ prologue code. | |
| #define | PORT_IRQ_EPILOGUE() _port_irq_epilogue(_saved_lr) |
| 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. | |
| #define | port_init() |
| Port-related initialization code. | |
| #define | port_lock() __disable_interrupt() |
| Kernel-lock action. | |
| #define | port_unlock() __enable_interrupt() |
| Kernel-unlock action. | |
| #define | port_lock_from_isr() port_lock() |
| Kernel-lock action from an interrupt handler. | |
| #define | port_unlock_from_isr() port_unlock() |
| Kernel-unlock action from an interrupt handler. | |
| #define | port_disable() __disable_interrupt() |
| Disables all the interrupt sources. | |
| #define | port_suspend() __disable_interrupt() |
| Disables the interrupt sources below kernel-level priority. | |
| #define | port_enable() __enable_interrupt() |
| Enables all the interrupt sources. | |
| #define | port_wait_for_interrupt() asm ("wfi") |
| Enters an architecture-dependent IRQ-waiting mode. | |
| #define | port_switch(ntp, otp) _port_switch(ntp, otp) |
| Performs a context switch between two threads. | |
Typedefs | |
| typedef void * | regarm_t |
| Generic ARM register. | |
| typedef uint64_t | stkalign_t |
| Stack and memory alignment enforcement. | |
| CH_IRQ_HANDLER | ( | SysTickVector | ) |
System Timer vector.
This interrupt is used as system tick.
Definition at line 40 of file IAR/ARMCMx/chcore_v6m.c.
References CH_IRQ_EPILOGUE, CH_IRQ_PROLOGUE, chSysLockFromIsr, chSysTimerHandlerI(), and chSysUnlockFromIsr.

| void NMIVector | ( | void | ) |
NMI vector.
The NMI vector is used for exception mode re-entering after a context switch.
Definition at line 57 of file IAR/ARMCMx/chcore_v6m.c.
References port_unlock_from_isr.
| void PendSVVector | ( | void | ) |
PendSV vector.
The PendSV vector is used for exception mode re-entering after a context switch.
Definition at line 75 of file IAR/ARMCMx/chcore_v6m.c.
| void _port_irq_epilogue | ( | regarm_t | lr | ) |
IRQ epilogue code.
| [in] | lr | value of the LR register on ISR entry |
Definition at line 95 of file IAR/ARMCMx/chcore_v6m.c.
References chSchIsPreemptionRequired(), and port_lock_from_isr.

| void port_halt | ( | void | ) |
Halts the system.
This function is invoked by the operating system when an unrecoverable error is detected (for example because a programming error in the application code that triggers an assertion while in debug mode).
This function is invoked by the operating system when an unrecoverable error is detected (for example because a programming error in the application code that triggers an assertion while in debug mode).
Definition at line 114 of file kernel/templates/chcore.c.
| void _port_switch_from_isr | ( | void | ) |
Post-IRQ switch code.
The switch is performed in thread context then an NMI exception is enforced in order to return to the exact point before the preemption.
Exception handlers return here for context switching.
Definition at line 134 of file GCC/ARMCMx/chcore_v6m.c.
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.
| [in] | ntp | the thread to be switched in |
| [in] | otp | the thread to be switched out |
Definition at line 165 of file GCC/ARMCMx/chcore_v6m.c.
| void _port_thread_start | ( | void | ) |
Thread start code.
Thread start code.
If the work function returns chThdExit() is automatically invoked.
Definition at line 51 of file ports/cosmic/STM8/chcore.c.
| #define CORTEX_PRIORITY_PENDSV 0 |
PendSV priority level.
0, this handler always has the highest priority that cannot preempt the kernel. Definition at line 42 of file IAR/ARMCMx/chcore_v6m.h.
| #define PORT_IDLE_THREAD_STACK_SIZE 16 |
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 PORT_INT_REQUIRED_STACK.
Definition at line 62 of file IAR/ARMCMx/chcore_v6m.h.
| #define PORT_INT_REQUIRED_STACK 32 |
Per-thread stack overhead for interrupts servicing.
This constant is used in the calculation of the correct working area size.
chSchDoReschedule() can have a stack frame, especially with compiler optimizations disabled. The value can be reduced when compiler optimizations are enabled. Definition at line 75 of file IAR/ARMCMx/chcore_v6m.h.
| #define CORTEX_ENABLE_WFI_IDLE FALSE |
Enables the use of the WFI instruction in the idle thread loop.
Definition at line 82 of file IAR/ARMCMx/chcore_v6m.h.
| #define CORTEX_PRIORITY_SYSTICK (CORTEX_PRIORITY_LEVELS >> 1) |
SYSTICK handler priority.
Definition at line 91 of file IAR/ARMCMx/chcore_v6m.h.
| #define CORTEX_ALTERNATE_SWITCH FALSE |
Alternate preemption method.
Activating this option will make the Kernel use the PendSV handler for preemption instead of the NMI handler.
Definition at line 103 of file IAR/ARMCMx/chcore_v6m.h.
| #define CORTEX_MAX_KERNEL_PRIORITY 1 |
Maximum usable priority for normal ISRs.
Definition at line 114 of file IAR/ARMCMx/chcore_v6m.h.
| #define CH_ARCHITECTURE_ARM_v6M |
Macro defining the specific ARM architecture.
Definition at line 126 of file IAR/ARMCMx/chcore_v6m.h.
| #define CH_ARCHITECTURE_NAME "ARMv6-M" |
Name of the implemented architecture.
Definition at line 131 of file IAR/ARMCMx/chcore_v6m.h.
| #define CH_CORE_VARIANT_NAME "Cortex-M0" |
Name of the architecture variant.
Definition at line 137 of file IAR/ARMCMx/chcore_v6m.h.
| #define CH_PORT_INFO "Preemption through NMI" |
Port-specific information string.
Definition at line 146 of file IAR/ARMCMx/chcore_v6m.h.
| #define SETUP_CONTEXT | ( | workspace, | |
| wsize, | |||
| pf, | |||
| arg | |||
| ) |
{ \
tp->p_ctx.r13 = (struct intctx *)((uint8_t *)workspace + \
wsize - \
sizeof(struct intctx)); \
tp->p_ctx.r13->r4 = (regarm_t)pf; \
tp->p_ctx.r13->r5 = (regarm_t)arg; \
tp->p_ctx.r13->lr = (regarm_t)_port_thread_start; \
}
Platform dependent part of the chThdCreateI() API.
This code usually setup the context switching frame represented by an intctx structure.
Definition at line 213 of file IAR/ARMCMx/chcore_v6m.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 225 of file IAR/ARMCMx/chcore_v6m.h.
| #define THD_WA_SIZE | ( | n | ) |
STACK_ALIGN(sizeof(Thread) + \ sizeof(struct intctx) + \ sizeof(struct extctx) + \ (n) + (PORT_INT_REQUIRED_STACK))
Computes the thread working area global size.
Definition at line 230 of file IAR/ARMCMx/chcore_v6m.h.
| #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 240 of file IAR/ARMCMx/chcore_v6m.h.
IRQ prologue code.
This macro must be inserted at the start of all IRQ handlers enabled to invoke system APIs.
Definition at line 247 of file IAR/ARMCMx/chcore_v6m.h.
| #define PORT_IRQ_EPILOGUE | ( | ) | _port_irq_epilogue(_saved_lr) |
IRQ epilogue code.
This macro must be inserted at the end of all IRQ handlers enabled to invoke system APIs.
Definition at line 254 of file IAR/ARMCMx/chcore_v6m.h.
| #define PORT_IRQ_HANDLER | ( | id | ) | void id(void) |
IRQ handler function declaration.
id can be a function name or a vector number depending on the port implementation. Definition at line 261 of file IAR/ARMCMx/chcore_v6m.h.
| #define PORT_FAST_IRQ_HANDLER | ( | id | ) | void id(void) |
Fast IRQ handler function declaration.
id can be a function name or a vector number depending on the port implementation. Definition at line 268 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_init | ( | void | ) |
{ \
SCB_AIRCR = AIRCR_VECTKEY | AIRCR_PRIGROUP(0); \
nvicSetSystemHandlerPriority(HANDLER_PENDSV, \
CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_PENDSV)); \
nvicSetSystemHandlerPriority(HANDLER_SYSTICK, \
CORTEX_PRIORITY_MASK(CORTEX_PRIORITY_SYSTICK)); \
}
Port-related initialization code.
Definition at line 273 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_lock | ( | void | ) | __disable_interrupt() |
Kernel-lock action.
Usually this function just disables interrupts but may perform more actions.
Definition at line 286 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_unlock | ( | void | ) | __enable_interrupt() |
Kernel-unlock action.
Usually this function just enables interrupts but may perform more actions.
Definition at line 293 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_lock_from_isr | ( | void | ) | port_lock() |
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.
port_lock() in this port. Definition at line 302 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_unlock_from_isr | ( | void | ) | port_unlock() |
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.
port_lock() in this port. Definition at line 311 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_disable | ( | void | ) | __disable_interrupt() |
Disables all the interrupt sources.
Definition at line 316 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_suspend | ( | void | ) | __disable_interrupt() |
Disables the interrupt sources below kernel-level priority.
Definition at line 321 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_enable | ( | void | ) | __enable_interrupt() |
Enables all the interrupt sources.
Definition at line 326 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_wait_for_interrupt | ( | void | ) | asm ("wfi") |
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.
WFI instruction. Definition at line 337 of file IAR/ARMCMx/chcore_v6m.h.
| #define port_switch | ( | ntp, | |
| otp | |||
| ) | _port_switch(ntp, 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.
| [in] | ntp | the thread to be switched in |
| [in] | otp | the thread to be switched out |
Definition at line 353 of file IAR/ARMCMx/chcore_v6m.h.
| typedef void* regarm_t |
Generic ARM register.
Definition at line 160 of file IAR/ARMCMx/chcore_v6m.h.
| typedef uint64_t stkalign_t |
Stack and memory alignment enforcement.
Definition at line 168 of file IAR/ARMCMx/chcore_v6m.h.