port.h
来自「picoos源码。The RTOS and the TCP/IP stack 」· C头文件 代码 · 共 422 行 · 第 1/2 页
H
422 行
* If your processor has enough general purpose register, you may define
* the variable as register variable for fastest possible access. This is
* truly better than pushing the flags to the stack.<br>
*
* @b Hint: @n
* Sometimes it is not possible to disable interrupts globally. Then
* you will set ::POS_SCHED_LOCK to disable only the timer interrupt.
* If you wish to use pico]OS software interrupts, you will then
* also need to configure ::POS_IRQ_DISABLE_ALL to disable
* interrupts globally.
* @{
*/
/** Enable local flags variable.
* When this define is set to 1, a user defined variable will be
* generated for storing the current processor state before
* disabling interrupts. Then the define ::POSCFG_LOCK_FLAGSTYPE
* must be set to the type of variable to be used for the flags.
*/
#define POSCFG_LOCK_USEFLAGS 0
/** Define variable type for the processor flags.
* If ::POSCFG_LOCK_USEFLAGS is set to 1, this define must be
* set to the variable type that shall be used for the
* processor flags. In this example, the variable definition
* "register VAR_t flags;" would be added to each function
* using the macros ::POS_SCHED_LOCK, ::POS_SCHED_UNLOCK,
* ::POS_IRQ_DISABLE_ALL and ::POS_IRQ_ENABLE_ALL.
*/
#define POSCFG_LOCK_FLAGSTYPE register VAR_t
/** Scheduler locking.
* Locking the scheduler for a short time is done by
* disabling the interrupts on the processor. This macro
* can contain a subroutine call or a piece of assembler
* code that stores the processor state and disables
* the interrupts. See ::POSCFG_LOCK_FLAGSTYPE for more details.
*/
#ifdef GCC
#define POS_SCHED_LOCK asm volatile("pushf\n" "cli\n"::)
#else
#define POS_SCHED_LOCK asm { PUSHF; CLI }
#endif
/** Scheduler unlocking.
* This is the counterpart macro of ::POS_SCHED_LOCK. It restores
* the saved processor flags and reenables the interrupts this way.
*/
#ifdef GCC
#define POS_SCHED_UNLOCK asm volatile("popf\n"::)
#else
#define POS_SCHED_UNLOCK asm POPF
#endif
/** Optional scheduler locking: Disable all interrupts.
* In some environments it is not possible to disable all interrupts
* for a longer period of time. In such an environment you will need to
* implement ::POS_SCHED_LOCK to only disable the timer interrupt and
* the interrupts that are directly connected to pico]OS. All other
* interrupts can be interfaced with the pico]OS software interrupt
* system to the pico]OS core. Only the interface functions need then
* to disable interrupts globally. Set this macro to a function that
* globally disables interrupts, including the interrupts that are
* also disabled by the usual ::POS_SCHED_LOCK macro.
* @note If your system timing is not critical, you can set
* this macro to ::POS_SCHED_LOCK
* @sa POS_IRQ_ENABLE_ALL, POS_SCHED_LOCK, POSCFG_LOCK_USEFLAGS
*/
#define POS_IRQ_DISABLE_ALL POS_SCHED_LOCK
/** Optional scheduler locking: Enable all interrupts.
* This is the counterpart macro of ::POS_IRQ_DISABLE_ALL.
* It enables all interrupts again.
*/
#define POS_IRQ_ENABLE_ALL POS_SCHED_UNLOCK
/** @} */
/*---------------------------------------------------------------------------
* FINDBIT - DEFINITIONS FOR GENERIC FILE fbit_gen.c
*-------------------------------------------------------------------------*/
/** @defgroup findbit Generic Findbit
* @ingroup configp
* The pico]OS is shipped with a generic file that implements variouse
* methods for finding the first and least significant bit set.
* This section contains switches for configuring the file fbit_gen.c.
* Please see the section <b>pico]OS Porting Information</b> for details
* about findbit.
* @{
*/
/** Generic finbit configuration, look-up table support.
* The findbit mechanism can be implemented as look-up table.<br>
*
* POSCFG_FBIT_USE_LUTABLE = 0:<br>
* Do not use look up tables. "findbit" is implemented as a function.
* (This does not increase code size through tables. Also
* some CPUs may execute program code faster from their caches
* than fetching data from big lookup tables.)
* Note: This is the only possible setting for
* systems with ::MVAR_BITS != 8 <br>
*
* POSCFG_FBIT_USE_LUTABLE = 1:<br>
* - When round robin scheduling is disabled, findbit is done
* by use of a 256 byte sized lookup table.
* - When round robin scheduling is enabled, findbit is implemented
* as a function and uses a 256 byte sized lookup table.<br>
*
* POSCFG_FBIT_USE_LUTABLE = 2:<br>
* This is only applicable for round robin scheduling.
* "findbit" is implemented as a two dimensional lookup table.
* This blows code size very much.
*/
#define POSCFG_FBIT_USE_LUTABLE 0
/** Generic finbit configuration, machine bit-shift ability.
* Some machines are very slow in doing bit-shifts. If your
* target is such a machine, you can define this parameter to
* zero to prevent findbit of doing excessive bitshifts.
*/
#define POSCFG_FBIT_BITSHIFT 1
/** @} */
/*---------------------------------------------------------------------------
* PORT DEPENDENT NANO LAYER CONFIGURATION
*-------------------------------------------------------------------------*/
/** @defgroup portnlcfg Nano Layer Port
* @ingroup configp
* This section is used to configure port dependent
* settings for the nano layer. (file port.h)
* @{
*/
/** Set the direction the stack grows.
* When the processor stack grows from bottom to top, this define
* must be set to 1. On platforms where the stack grows from
* top to bottom, this define must be set to 0.
*/
#define NOSCFG_STACK_GROWS_UP 0
/** Set the default stack size.
* If the functions ::nosTaskCreate or ::nosInit are called with
* a stack size of zero, this value is taken as the default stack size.
*/
#define NOSCFG_DEFAULT_STACKSIZE 2048
/** Enable generic console output handshake.
* Please see description of function ::c_nos_putcharReady for details.
*/
#define NOSCFG_CONOUT_HANDSHAKE 0
/** Set the size of the console output FIFO.
* If ::NOSCFG_CONOUT_HANDSHAKE is enabled, a FIFO buffer can be used
* to speed up console output and to reduce CPU usage. This option is
* useful when console output is done through a serial line that does
* not have a hardware FIFO. To enable the FIFO, set this define to
* the FIFO size in bytes. A zero will disable the FIFO buffer.
*/
#define NOSCFG_CONOUT_FIFOSIZE 256
/** @} */
/*---------------------------------------------------------------------------
* USER DEFINED CONTENT OF TASK ENVIRONMENT
*-------------------------------------------------------------------------*/
#if DOX!=0
/** @def POS_USERTASKDATA
* Add user defined data elements to the global task structure.
* Please see detailed description of ::POSTASK_t.
* @sa POSTASK_t
*/
#define POS_USERTASKDATA void *stackptr;
#else
/* Here is an example for different memory handling types:
*/
#if POSCFG_TASKSTACKTYPE == 0
#define POS_USERTASKDATA \
void *stackptr;
#elif POSCFG_TASKSTACKTYPE == 1
#define POS_USERTASKDATA \
void *stackptr; \
void *stackroot;
#elif POSCFG_TASKSTACKTYPE == 2
#define FIXED_STACK_SIZE 0x0600
#define POS_USERTASKDATA \
void *stackptr; \
unsigned short stack[FIXED_STACK_SIZE];
#endif
#endif /* DOX */
#endif /* _PORT_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?