aboutsummaryrefslogtreecommitdiffstats
path: root/os/ports
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-03-14 09:54:23 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-03-14 09:54:23 +0000
commitc7837bab2ee164d6bb4fb47948ee5fe33162b449 (patch)
tree2754d5fa7d380fa2129a8114fc481ce882aaba52 /os/ports
parent075b89133ec371480bdcf670d3f412b1cf131b0e (diff)
downloadChibiOS-c7837bab2ee164d6bb4fb47948ee5fe33162b449.tar.gz
ChibiOS-c7837bab2ee164d6bb4fb47948ee5fe33162b449.tar.bz2
ChibiOS-c7837bab2ee164d6bb4fb47948ee5fe33162b449.zip
AVR and simulator still missing.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1740 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ports')
-rw-r--r--os/ports/GCC/ARM7/chcore.h2
-rw-r--r--os/ports/GCC/ARMCM3/chcore.h2
-rw-r--r--os/ports/GCC/MSP430/chcore.c47
-rw-r--r--os/ports/GCC/MSP430/chcore.h147
-rw-r--r--os/ports/GCC/PPC/chcore.h2
5 files changed, 128 insertions, 72 deletions
diff --git a/os/ports/GCC/ARM7/chcore.h b/os/ports/GCC/ARM7/chcore.h
index e5aa4c830..fe6a2f885 100644
--- a/os/ports/GCC/ARM7/chcore.h
+++ b/os/ports/GCC/ARM7/chcore.h
@@ -52,7 +52,7 @@
#define CH_CORE_VARIANT_NAME "ARM7TDMI"
/**
- * @brief 32 bit stack and memory alignment enforcement.
+ * @brief 32 bits stack and memory alignment enforcement.
*/
typedef uint32_t stkalign_t;
diff --git a/os/ports/GCC/ARMCM3/chcore.h b/os/ports/GCC/ARMCM3/chcore.h
index f118ba6ef..fbed01054 100644
--- a/os/ports/GCC/ARMCM3/chcore.h
+++ b/os/ports/GCC/ARMCM3/chcore.h
@@ -102,7 +102,7 @@
#define CH_CORE_VARIANT_NAME "Cortex-M3"
/**
- * @brief 32 bit stack and memory alignment enforcement.
+ * @brief 32 bits stack and memory alignment enforcement.
*/
typedef uint32_t stkalign_t;
diff --git a/os/ports/GCC/MSP430/chcore.c b/os/ports/GCC/MSP430/chcore.c
index 369e70987..43528f9c5 100644
--- a/os/ports/GCC/MSP430/chcore.c
+++ b/os/ports/GCC/MSP430/chcore.c
@@ -18,8 +18,9 @@
*/
/**
- * @file MSP430/chcore.c
- * @brief MSP430 architecture port code.
+ * @file MSP430/chcore.c
+ * @brief MSP430 architecture port code.
+ *
* @addtogroup MSP430_CORE
* @{
*/
@@ -27,16 +28,21 @@
#include "ch.h"
/**
- * Performs a context switch between two threads.
- * @param otp the thread to be switched out
- * @param ntp the thread to be switched in
- * @note The function is declared as a weak symbol, it is possible to redefine
- * it in your application code.
+ * @brief Performs a context switch between two threads.
+ * @details 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 <b>directly</b> the context
+ * switch performance so optimize here as much as you can.
+ * @note The function is declared as a weak symbol, it is possible to
+ * redefine it in your application code.
+ *
+ * @param[in] ntp the thread to be switched in
+ * @param[in] otp the thread to be switched out
*/
-/** @cond never */
+#if !defined(__DOXYGEN__)
__attribute__((naked, weak))
-/** @endcond */
-void port_switch(Thread *otp, Thread *ntp) {
+#endif
+void port_switch(Thread *ntp, Thread *otp) {
register struct intctx *sp asm("r1");
asm volatile ("push r11 \n\t" \
@@ -61,13 +67,17 @@ void port_switch(Thread *otp, Thread *ntp) {
}
/**
- * Disables the interrupts and halts the system.
- * @note The function is declared as a weak symbol, it is possible to redefine
- * it in your application code.
+ * @brief Halts the system.
+ * @details 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).
+ * @note The function is declared as a weak symbol, it is possible to
+ * redefine it in your application code.
*/
-/** @cond never */
+#if !defined(__DOXYGEN__)
__attribute__((weak))
-/** @endcond */
+#endif
void port_halt(void) {
port_disable();
@@ -76,10 +86,11 @@ void port_halt(void) {
}
/**
- * Start a thread by invoking its work function.
- * If the work function returns @p chThdExit() is automatically invoked.
+ * @brief Start a thread by invoking its work function.
+ * @details If the work function returns @p chThdExit() is automatically
+ * invoked.
*/
-void threadstart(void) {
+void _port_thread_start(void) {
asm volatile ("eint \n\t" \
"mov r11, r15 \n\t" \
diff --git a/os/ports/GCC/MSP430/chcore.h b/os/ports/GCC/MSP430/chcore.h
index 020096a66..fcf0a7c1e 100644
--- a/os/ports/GCC/MSP430/chcore.h
+++ b/os/ports/GCC/MSP430/chcore.h
@@ -18,8 +18,9 @@
*/
/**
- * @file MSP430/chcore.h
- * @brief MSP430 architecture port macros and structures.
+ * @file MSP430/chcore.h
+ * @brief MSP430 architecture port macros and structures.
+ *
* @addtogroup MSP430_CORE
* @{
*/
@@ -31,19 +32,19 @@
#include <msp430/common.h>
/**
- * If enabled allows the idle thread to enter a low power mode.
+ * @brief Enables the use of a wait state in the idle thread loop.
*/
#ifndef ENABLE_WFI_IDLE
-#define ENABLE_WFI_IDLE 0
+#define ENABLE_WFI_IDLE 0
#endif
/**
- * Macro defining the MSP430 architecture.
+ * @brief Macro defining the MSP430 architecture.
*/
#define CH_ARCHITECTURE_MSP430
/**
- * Name of the implemented architecture.
+ * @brief Name of the implemented architecture.
*/
#define CH_ARCHITECTURE_NAME "MSP430"
@@ -53,18 +54,20 @@
#define CH_CORE_VARIANT_NAME "MSP430"
/**
- * 16 bit stack alignment.
+ * @brief 16 bits stack and memory alignment enforcement.
*/
typedef uint16_t stkalign_t;
/**
- * Generic MSP430 register.
+ * @brief Generic MSP430 register.
*/
typedef void *regmsp_t;
-/** @cond never */
+#if !defined(__DOXYGEN__)
/**
- * Interrupt saved context.
+ * @brief Interrupt saved context.
+ * @details This structure represents the stack frame saved during a
+ * preemption-capable interrupt handler.
*/
struct extctx {
regmsp_t r12;
@@ -74,11 +77,13 @@ struct extctx {
regmsp_t sr;
regmsp_t pc;
};
-/** @endcond */
+#endif
-/** @cond never */
+#if !defined(__DOXYGEN__)
/**
- * This structure represents the inner stack frame during a context switching.
+ * @brief System saved context.
+ * @details This structure represents the inner stack frame during a context
+ * switching.
*/
struct intctx {
regmsp_t r4;
@@ -91,20 +96,23 @@ struct intctx {
regmsp_t r11;
regmsp_t pc;
};
-/** @endcond */
+#endif
-/** @cond never */
+#if !defined(__DOXYGEN__)
/**
- * In the MSP430 port this structure just holds a pointer to the @p intctx
- * structure representing the stack pointer at the time of the context switch.
+ * @brief Platform dependent part of the @p Thread structure.
+ * @details This structure usually contains just the saved stack pointer
+ * defined as a pointer to a @p intctx structure.
*/
struct context {
struct intctx *sp;
};
-/** @endcond */
+#endif
/**
- * Platform dependent part of the @p chThdInit() API.
+ * @brief Platform dependent part of the @p chThdInit() API.
+ * @details This code usually setup the context switching frame represented
+ * by an @p intctx structure.
*/
#define SETUP_CONTEXT(workspace, wsize, pf, arg) { \
tp->p_ctx.sp = (struct intctx *)((uint8_t *)workspace + \
@@ -112,33 +120,39 @@ struct context {
sizeof(struct intctx)); \
tp->p_ctx.sp->r10 = pf; \
tp->p_ctx.sp->r11 = arg; \
- tp->p_ctx.sp->pc = threadstart; \
+ tp->p_ctx.sp->pc = _port_thread_start; \
}
/**
- * The default idle thread implementation requires no extra stack space in
- * this port.
+ * @brief Stack size for the system idle thread.
+ * @details This size depends on the idle thread implementation, usually
+ * the idle thread should take no more space than those reserved
+ * by @p INT_REQUIRED_STACK.
*/
#ifndef IDLE_THREAD_STACK_SIZE
-#define IDLE_THREAD_STACK_SIZE 0
+#define IDLE_THREAD_STACK_SIZE 0
#endif
/**
- * Per-thread stack overhead for interrupts servicing, it is used in the
- * calculation of the correct working area size. In this port the default is
- * 32 bytes per thread.
+ * @brief Per-thread stack overhead for interrupts servicing.
+ * @details 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 @p intctx and
+ * @p extctx is known to be zero.
+ * @note In this port the default is 32 bytes per thread.
*/
#ifndef INT_REQUIRED_STACK
-#define INT_REQUIRED_STACK 32
+#define INT_REQUIRED_STACK 32
#endif
/**
- * Enforces a correct alignment for a stack area size value.
+ * @brief Enforces a correct alignment for a stack area size value.
*/
#define STACK_ALIGN(n) ((((n) - 1) | (sizeof(stkalign_t) - 1)) + 1)
/**
- * Computes the thread working area global size.
+ * @brief Computes the thread working area global size.
*/
#define THD_WA_SIZE(n) STACK_ALIGN(sizeof(Thread) + \
sizeof(struct intctx) + \
@@ -146,20 +160,23 @@ struct context {
(n) + (INT_REQUIRED_STACK))
/**
- * Macro used to allocate a thread working area aligned as both position and
- * size.
+ * @brief Static working area allocation.
+ * @details This macro is used to allocate a static thread working area
+ * aligned as both position and size.
*/
#define WORKING_AREA(s, n) stkalign_t s[THD_WA_SIZE(n) / sizeof(stkalign_t)];
/**
- * IRQ prologue code, inserted at the start of all IRQ handlers enabled to
- * invoke system APIs.
+ * @brief IRQ prologue code.
+ * @details This macro must be inserted at the start of all IRQ handlers
+ * enabled to invoke system APIs.
*/
#define PORT_IRQ_PROLOGUE()
/**
- * IRQ epilogue code, inserted at the end of all IRQ handlers enabled to
- * invoke system APIs.
+ * @brief IRQ epilogue code.
+ * @details This macro must be inserted at the end of all IRQ handlers
+ * enabled to invoke system APIs.
*/
#define PORT_IRQ_EPILOGUE() { \
if (chSchIsRescRequiredExI()) \
@@ -167,56 +184,84 @@ struct context {
}
/**
- * IRQ handler function modifier.
+ * @brief IRQ handler function declaration.
+ * @note @p id can be a function name or a vector number depending on the
+ * port implementation.
*/
#define PORT_IRQ_HANDLER(id) interrupt(id) _vect_##id(void)
/**
- * This function is empty in this port.
+ * @brief Port-related initialization code.
+ * @note This function is empty in this port.
*/
#define port_init()
/**
- * Implemented as global interrupt disable.
+ * @brief Kernel-lock action.
+ * @details Usually this function just disables interrupts but may perform more
+ * actions.
+ * @note Implemented as global interrupt disable.
*/
#define port_lock() asm volatile ("dint")
/**
- * Implemented as global interrupt enable.
+ * @brief Kernel-unlock action.
+ * @details Usually this function just disables interrupts but may perform more
+ * actions.
+ * @note Implemented as global interrupt enable.
*/
#define port_unlock() asm volatile ("eint")
/**
- * This function is empty in this port.
+ * @brief Kernel-lock action from an interrupt handler.
+ * @details This function is invoked before invoking I-class APIs from
+ * interrupt handlers. The implementation is architecture dependent,
+ * in its simplest form it is void.
+ * @note This function is empty in this port.
*/
#define port_lock_from_isr()
/**
- * This function is empty in this port.
+ * @brief Kernel-unlock action from an interrupt handler.
+ * @details This function is invoked after invoking I-class APIs from interrupt
+ * handlers. The implementation is architecture dependent, in its
+ * simplest form it is void.
+ * @note This function is empty in this port.
*/
#define port_unlock_from_isr()
/**
- * Implemented as global interrupt disable.
+ * @brief Disables all the interrupt sources.
+ * @note Of course non maskable interrupt sources are not included.
+ * @note Implemented as global interrupt disable.
*/
#define port_disable() asm volatile ("dint")
/**
- * Same as @p port_disable() in this port, there is no difference between the
- * two states.
+ * @brief Disables the interrupt sources below kernel-level priority.
+ * @note Interrupt sources above kernel level remains enabled.
+ * @note Same as @p port_disable() in this port, there is no difference
+ * between the two states.
*/
#define port_suspend() asm volatile ("dint")
/**
- * Implemented as global interrupt enable.
+ * @brief Enables all the interrupt sources.
+ * @note Implemented as global interrupt enable.
*/
#define port_enable() asm volatile ("eint")
/**
- * This port function is implemented as inlined code for performance reasons.
- * @note The port code does not define a low power mode, this macro has to be
- * defined externally. The default implementation is a "nop", not a
- * real low power mode.
+ * @brief Enters an architecture-dependent IRQ-waiting mode.
+ * @details 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.
+ * @note This port function is implemented as inlined code for performance
+ * reasons.
+ * @note The port code does not define a low power mode, this macro has to
+ * be defined externally. The default implementation is a "nop", not
+ * a real low power mode.
*/
#if ENABLE_WFI_IDLE != 0
#ifndef port_wait_for_interrupt
@@ -231,9 +276,9 @@ struct context {
#ifdef __cplusplus
extern "C" {
#endif
- void port_switch(Thread *otp, Thread *ntp);
+ void port_switch(Thread *ntp, Thread *otp);
void port_halt(void);
- void threadstart(void);
+ void _port_thread_start(void);
#ifdef __cplusplus
}
#endif
diff --git a/os/ports/GCC/PPC/chcore.h b/os/ports/GCC/PPC/chcore.h
index a5466628a..6cc844013 100644
--- a/os/ports/GCC/PPC/chcore.h
+++ b/os/ports/GCC/PPC/chcore.h
@@ -33,7 +33,7 @@
*/
/**
- * @brief Enables the use of the WFI ins.
+ * @brief Enables the use of the @p WFI instruction.
*/
#ifndef ENABLE_WFI_IDLE
#define ENABLE_WFI_IDLE 0