|
ChibiOS/RT
2.6.0 |
|
AVR specific port code, structures and macros.
Data Structures | |
| struct | extctx |
| Interrupt saved context. More... | |
| struct | intctx |
| System saved context. More... | |
| struct | context |
Platform dependent part of the Thread structure. More... | |
Functions | |
| void | port_switch (Thread *ntp, Thread *otp) |
| Performs a context switch between two threads. | |
| void | port_halt (void) |
| Halts the system. | |
| void | _port_thread_start (void) |
| Start a thread by invoking its work function. | |
Defines | |
| #define | ENABLE_WFI_IDLE 0 |
| If enabled allows the idle thread to enter a low power mode. | |
| #define | CH_ARCHITECTURE_AVR |
| Macro defining the AVR architecture. | |
| #define | CH_ARCHITECTURE_NAME "AVR" |
| Name of the implemented architecture. | |
| #define | CH_CORE_VARIANT_NAME "MegaAVR" |
| Name of the architecture variant (optional). | |
| #define | CH_COMPILER_NAME "GCC " __VERSION__ |
| Name of the compiler supported by this port. | |
| #define | CH_PORT_INFO "None" |
| Port-specific information string. | |
| #define | SETUP_CONTEXT(workspace, wsize, pf, arg) |
Platform dependent part of the chThdCreateI() API. | |
| #define | PORT_IDLE_THREAD_STACK_SIZE 8 |
| Stack size for the system idle thread. | |
| #define | PORT_INT_REQUIRED_STACK 32 |
| 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) ISR(id) |
| IRQ handler function declaration. | |
| #define | port_init() |
| Port-related initialization code. | |
| #define | port_lock() asm volatile ("cli" : : : "memory") |
| Kernel-lock action. | |
| #define | port_unlock() asm volatile ("sei" : : : "memory") |
| Kernel-unlock action. | |
| #define | port_lock_from_isr() |
| Kernel-lock action from an interrupt handler. | |
| #define | port_unlock_from_isr() |
| Kernel-unlock action from an interrupt handler. | |
| #define | port_disable() asm volatile ("cli" : : : "memory") |
| Disables all the interrupt sources. | |
| #define | port_suspend() asm volatile ("cli" : : : "memory") |
| Disables the interrupt sources below kernel-level priority. | |
| #define | port_enable() asm volatile ("sei" : : : "memory") |
| Enables all the interrupt sources. | |
| #define | port_wait_for_interrupt() |
| Enters an architecture-dependent IRQ-waiting mode. | |
| #define | INLINE inline |
| Inline function modifier. | |
| #define | ROMCONST const |
| ROM constant modifier. | |
| #define | PACK_STRUCT_STRUCT __attribute__((packed)) |
| Packed structure modifier (within). | |
| #define | PACK_STRUCT_BEGIN |
| Packed structure modifier (before). | |
| #define | PACK_STRUCT_END |
| Packed structure modifier (after). | |
Typedefs | |
| typedef uint8_t | stkalign_t |
| 8 bits stack and memory alignment enforcement. | |
| typedef bool | bool_t |
| typedef uint8_t | tmode_t |
| typedef uint8_t | tstate_t |
| typedef uint8_t | trefs_t |
| typedef uint8_t | tslices_t |
| typedef uint8_t | tprio_t |
| typedef int16_t | msg_t |
| typedef uint8_t | eventid_t |
| typedef uint8_t | eventmask_t |
| typedef uint8_t | flagsmask_t |
| typedef uint16_t | systime_t |
| typedef int8_t | cnt_t |
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 53 of file ports/GCC/AVR/chcore.c.
| 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).
Definition at line 119 of file ports/GCC/AVR/chcore.c.
References port_disable(), and TRUE.

| void _port_thread_start | ( | void | ) |
Start a thread by invoking its work function.
If the work function returns chThdExit() is automatically invoked.
Definition at line 131 of file ports/GCC/AVR/chcore.c.
References chSysUnlock.
| #define ENABLE_WFI_IDLE 0 |
If enabled allows the idle thread to enter a low power mode.
Definition at line 50 of file ports/GCC/AVR/chcore.h.
| #define CH_ARCHITECTURE_AVR |
Macro defining the AVR architecture.
Definition at line 56 of file ports/GCC/AVR/chcore.h.
| #define CH_ARCHITECTURE_NAME "AVR" |
Name of the implemented architecture.
Definition at line 61 of file ports/GCC/AVR/chcore.h.
| #define CH_CORE_VARIANT_NAME "MegaAVR" |
Name of the architecture variant (optional).
Definition at line 66 of file ports/GCC/AVR/chcore.h.
| #define CH_COMPILER_NAME "GCC " __VERSION__ |
Name of the compiler supported by this port.
Definition at line 71 of file ports/GCC/AVR/chcore.h.
| #define CH_PORT_INFO "None" |
Port-specific information string.
Definition at line 76 of file ports/GCC/AVR/chcore.h.
| #define SETUP_CONTEXT | ( | workspace, | |
| wsize, | |||
| pf, | |||
| arg | |||
| ) |
{ \
tp->p_ctx.sp = (struct intctx*)((uint8_t *)workspace + wsize - \
sizeof(struct intctx)); \
tp->p_ctx.sp->r2 = (int)pf; \
tp->p_ctx.sp->r3 = (int)pf >> 8; \
tp->p_ctx.sp->r4 = (int)arg; \
tp->p_ctx.sp->r5 = (int)arg >> 8; \
tp->p_ctx.sp->pcl = (int)_port_thread_start >> 8; \
tp->p_ctx.sp->pch = (int)_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 156 of file ports/GCC/AVR/chcore.h.
| #define PORT_IDLE_THREAD_STACK_SIZE 8 |
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 175 of file ports/GCC/AVR/chcore.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. 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 188 of file ports/GCC/AVR/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 194 of file ports/GCC/AVR/chcore.h.
| #define THD_WA_SIZE | ( | n | ) |
STACK_ALIGN(sizeof(Thread) + \ (sizeof(struct intctx) - 1) + \ (sizeof(struct extctx) - 1) + \ (n) + (PORT_INT_REQUIRED_STACK))
Computes the thread working area global size.
Definition at line 199 of file ports/GCC/AVR/chcore.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 209 of file ports/GCC/AVR/chcore.h.
| #define PORT_IRQ_PROLOGUE | ( | ) |
{ \
asm ("" : : : "r18", "r19", "r20", "r21", "r22", "r23", "r24", \
"r25", "r26", "r27", "r30", "r31"); \
}
IRQ prologue code.
This macro must be inserted at the start of all IRQ handlers enabled to invoke system APIs.
Definition at line 218 of file ports/GCC/AVR/chcore.h.
| #define PORT_IRQ_EPILOGUE | ( | ) |
{ \
dbg_check_lock(); \
if (chSchIsPreemptionRequired()) \
chSchDoReschedule(); \
dbg_check_unlock(); \
}
IRQ epilogue code.
This macro must be inserted at the end of all IRQ handlers enabled to invoke system APIs.
Definition at line 228 of file ports/GCC/AVR/chcore.h.
| #define PORT_IRQ_HANDLER | ( | id | ) | ISR(id) |
IRQ handler function declaration.
id can be a function name or a vector number depending on the port implementation. Definition at line 240 of file ports/GCC/AVR/chcore.h.
| #define port_init | ( | void | ) |
Port-related initialization code.
Definition at line 246 of file ports/GCC/AVR/chcore.h.
| #define port_lock | ( | void | ) | asm volatile ("cli" : : : "memory") |
Kernel-lock action.
Usually this function just disables interrupts but may perform more actions.
Definition at line 254 of file ports/GCC/AVR/chcore.h.
| #define port_unlock | ( | void | ) | asm volatile ("sei" : : : "memory") |
Kernel-unlock action.
Usually this function just enables interrupts but may perform more actions.
Definition at line 262 of file ports/GCC/AVR/chcore.h.
| #define 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.
Definition at line 271 of file ports/GCC/AVR/chcore.h.
| #define 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.
Definition at line 280 of file ports/GCC/AVR/chcore.h.
| #define port_disable | ( | void | ) | asm volatile ("cli" : : : "memory") |
Disables all the interrupt sources.
Definition at line 287 of file ports/GCC/AVR/chcore.h.
| #define port_suspend | ( | void | ) | asm volatile ("cli" : : : "memory") |
Disables the interrupt sources below kernel-level priority.
port_disable() in this port, there is no difference between the two states. Definition at line 295 of file ports/GCC/AVR/chcore.h.
| #define port_enable | ( | void | ) | asm volatile ("sei" : : : "memory") |
Enables all the interrupt sources.
Definition at line 301 of file ports/GCC/AVR/chcore.h.
| #define 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.
Definition at line 317 of file ports/GCC/AVR/chcore.h.
| #define INLINE inline |
Inline function modifier.
Definition at line 59 of file ports/GCC/AVR/chtypes.h.
| #define ROMCONST const |
ROM constant modifier.
Definition at line 65 of file ports/GCC/AVR/chtypes.h.
| #define PACK_STRUCT_STRUCT __attribute__((packed)) |
Packed structure modifier (within).
Definition at line 71 of file ports/GCC/AVR/chtypes.h.
| #define PACK_STRUCT_BEGIN |
Packed structure modifier (before).
Definition at line 77 of file ports/GCC/AVR/chtypes.h.
| #define PACK_STRUCT_END |
Packed structure modifier (after).
Definition at line 83 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t stkalign_t |
8 bits stack and memory alignment enforcement.
Definition at line 81 of file ports/GCC/AVR/chcore.h.
| typedef bool bool_t |
Fast boolean type.
Definition at line 43 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t tmode_t |
Thread flags.
Definition at line 44 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t tstate_t |
Thread state.
Definition at line 45 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t trefs_t |
Thread references counter.
Definition at line 46 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t tslices_t |
Thread time slices counter.
Definition at line 47 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t tprio_t |
Thread priority.
Definition at line 48 of file ports/GCC/AVR/chtypes.h.
| typedef int16_t msg_t |
Inter-thread message.
Definition at line 49 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t eventid_t |
Event Id.
Definition at line 50 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t eventmask_t |
Event mask.
Definition at line 51 of file ports/GCC/AVR/chtypes.h.
| typedef uint8_t flagsmask_t |
Event flags.
Definition at line 52 of file ports/GCC/AVR/chtypes.h.
| typedef uint16_t systime_t |
System time.
Definition at line 53 of file ports/GCC/AVR/chtypes.h.
| typedef int8_t cnt_t |
Resources counter.
Definition at line 54 of file ports/GCC/AVR/chtypes.h.