TNeoKernel  v1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Typedefs
tn_arch_example.h File Reference

Detailed Description

Example of architecture-dependent routines.

Definition in file tn_arch_example.h.

Go to the source code of this file.

Macros

#define _TN_FFS(x)   (32 - __builtin_clz((x) & (0 - (x))))
 FFS - find first set bit. More...
 
#define _TN_FATAL_ERROR(error_msg,...)   {__asm__ volatile(" sdbbp 0"); __asm__ volatile ("nop");}
 Used by the kernel as a signal that something really bad happened. More...
 
#define TN_ARCH_STK_ATTR_BEFORE
 Compiler-specific attribute that should be placed before declaration of array used for stack. More...
 
#define TN_ARCH_STK_ATTR_AFTER   __attribute__((aligned(0x8)))
 Compiler-specific attribute that should be placed after declaration of array used for stack. More...
 
#define TN_MIN_STACK_SIZE   36
 Minimum task's stack size, in words, not in bytes; includes a space for context plus for parameters passed to task's body function.
 
#define TN_INT_WIDTH   32
 Width of int type.
 
#define TN_PRIORITIES_CNT   TN_INT_WIDTH
 Number of priorities available, this value usually matches TN_INT_WIDTH. More...
 
#define TN_WAIT_INFINITE   0xFFFFFFFF
 Value for infinite waiting, usually matches UINT_MAX
 
#define TN_FILL_STACK_VAL   0xFEEDFACE
 Value for initializing the task's stack.
 
#define TN_INTSAVE_DATA   int tn_save_status_reg = 0;
 Declares variable that is used by macros TN_INT_DIS_SAVE() and TN_INT_RESTORE() for storing status register value. More...
 
#define TN_INTSAVE_DATA_INT   TN_INTSAVE_DATA
 The same as TN_INTSAVE_DATA but for using in ISR together with TN_INT_IDIS_SAVE(), TN_INT_IRESTORE(). More...
 
#define TN_INT_DIS_SAVE()   tn_save_status_reg = tn_arch_sr_save_int_dis()
 Disable interrupts and return previous value of status register, atomically. More...
 
#define TN_INT_RESTORE()   tn_arch_sr_restore(tn_save_status_reg)
 Restore previously saved status register. More...
 
#define TN_INT_IDIS_SAVE()   TN_INT_DIS_SAVE()
 The same as TN_INT_DIS_SAVE() but for using in ISR. More...
 
#define TN_INT_IRESTORE()   TN_INT_RESTORE()
 The same as TN_INT_RESTORE() but for using in ISR. More...
 
#define TN_IS_INT_DISABLED()   ((__builtin_mfc0(12, 0) & 1) == 0)
 Returns nonzero if interrupts are disabled, zero otherwise.
 

Typedefs

typedef unsigned int TN_UWord
 Unsigned integer type whose size is equal to the size of CPU register. More...
 

Macro Definition Documentation

#define _TN_FFS (   x)    (32 - __builtin_clz((x) & (0 - (x))))

FFS - find first set bit.

Used in _find_next_task_to_run() function.

May be not defined: in this case, naive algorithm will be used.

Definition at line 52 of file tn_arch_example.h.

#define _TN_FATAL_ERROR (   error_msg,
  ... 
)    {__asm__ volatile(" sdbbp 0"); __asm__ volatile ("nop");}

Used by the kernel as a signal that something really bad happened.

Indicates TNeoKernel bugs as well as illegal kernel usage (e.g. sleeping in the idle task callback)

Typically, set to assembler instruction that causes debugger to halt.

Definition at line 61 of file tn_arch_example.h.

#define TN_ARCH_STK_ATTR_BEFORE

Compiler-specific attribute that should be placed before declaration of array used for stack.

It is needed because there are often additional restrictions applied to alignment of stack, so, to meet them, stack arrays need to be declared with these macros.

See also
TN_ARCH_STK_ATTR_AFTER

Definition at line 75 of file tn_arch_example.h.

#define TN_ARCH_STK_ATTR_AFTER   __attribute__((aligned(0x8)))

Compiler-specific attribute that should be placed after declaration of array used for stack.

It is needed because there are often additional restrictions applied to alignment of stack, so, to meet them, stack arrays need to be declared with these macros.

See also
TN_ARCH_STK_ATTR_BEFORE

Definition at line 86 of file tn_arch_example.h.

#define TN_PRIORITIES_CNT   TN_INT_WIDTH

Number of priorities available, this value usually matches TN_INT_WIDTH.

For compatibility with all platforms, it's recommended to use only values from 1 to 14, inclusive.

See also
TN_INT_WIDTH

Definition at line 112 of file tn_arch_example.h.

#define TN_INTSAVE_DATA   int tn_save_status_reg = 0;

Declares variable that is used by macros TN_INT_DIS_SAVE() and TN_INT_RESTORE() for storing status register value.

See also
TN_INT_DIS_SAVE()
TN_INT_RESTORE()

Definition at line 134 of file tn_arch_example.h.

#define TN_INTSAVE_DATA_INT   TN_INTSAVE_DATA

The same as TN_INTSAVE_DATA but for using in ISR together with TN_INT_IDIS_SAVE(), TN_INT_IRESTORE().

See also
TN_INT_IDIS_SAVE()
TN_INT_IRESTORE()

Definition at line 143 of file tn_arch_example.h.

#define TN_INT_DIS_SAVE ( )    tn_save_status_reg = tn_arch_sr_save_int_dis()

Disable interrupts and return previous value of status register, atomically.

Similar tn_arch_sr_save_int_dis(), but implemented as a macro, so it is potentially faster.

Uses TN_INTSAVE_DATA as a temporary storage.

See also
TN_INTSAVE_DATA
tn_arch_sr_save_int_dis()

Definition at line 155 of file tn_arch_example.h.

#define TN_INT_RESTORE ( )    tn_arch_sr_restore(tn_save_status_reg)

Restore previously saved status register.

Similar to tn_arch_sr_restore(), but implemented as a macro, so it is potentially faster.

Uses TN_INTSAVE_DATA as a temporary storage.

See also
TN_INTSAVE_DATA
tn_arch_sr_save_int_dis()

Definition at line 167 of file tn_arch_example.h.

#define TN_INT_IDIS_SAVE ( )    TN_INT_DIS_SAVE()

The same as TN_INT_DIS_SAVE() but for using in ISR.

Uses TN_INTSAVE_DATA_INT as a temporary storage.

See also
TN_INTSAVE_DATA_INT

Definition at line 176 of file tn_arch_example.h.

#define TN_INT_IRESTORE ( )    TN_INT_RESTORE()

The same as TN_INT_RESTORE() but for using in ISR.

Uses TN_INTSAVE_DATA_INT as a temporary storage.

See also
TN_INTSAVE_DATA_INT

Definition at line 185 of file tn_arch_example.h.

Typedef Documentation

typedef unsigned int TN_UWord

Unsigned integer type whose size is equal to the size of CPU register.

Typically it's plain unsigned int.

Definition at line 103 of file tn_arch_example.h.