atom.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _SYS_ATOM_H_
00050 #error "Do not include this file directly. Use sys/atom.h instead!"
00051 #endif
00052
00053 #if (__GNUC__ && __AVR32__)
00054
00055 #include <avr32/io.h>
00056
00057 #if defined(NUT_CRITICAL_NESTING)
00058
00059 #if defined(NUT_CRITICAL_NESTING_STACK)
00060
00061
00062
00063
00064 #error Not Working
00065 #define NutEnterCritical() \
00066 { \
00067 register int temp_; \
00068 __asm__ volatile ( \
00069 "mfsr r10, %[SR]" "\n\t" \
00070 "pushm r10" "\n\t" \
00071 "ssrf %[SR_GM_OFFSET]" "\n\t" \
00072 : [temp] "=r" (temp_) \
00073 : [SR] "i" (AVR32_SR), \
00074 [SR_GM_OFFSET] "i" (AVR32_SR_GM_OFFSET) \
00075 : "memory", "cc", "r10"); \
00076 }
00077
00078 #define NutExitCritical() \
00079 { \
00080 register int temp_; \
00081 __asm__ volatile ( \
00082 "popm r10" "\n\t" \
00083 "andl r10, LO(%[SR_GM_MASK])" "\n\t" \
00084 "andh r10, HI(%[SR_GM_MASK])" "\n\t" \
00085 "cp.w r10, 0" "\n\t" \
00086 "breq LABEL_INT_SKIP_ENABLE_INTERRUPTS_%[LINE]" "\n\t" \
00087 "csrf %[SR_GM_OFFSET]" "\n\t" \
00088 "LABEL_INT_SKIP_SAVE_CONTEXT_%[LINE]:" "\n\t" \
00089 : [temp] "=r" (temp_) \
00090 : [SR_GM_OFFSET] "i" (AVR32_SR_GM_OFFSET), \
00091 [SR_GM_MASK] "i" (AVR32_SR_GM_MASK), \
00092 [LINE] "i" (__LINE__) \
00093 : "memory", "cc", "r10"); \
00094 }
00095
00096 #else
00097
00098
00099 #error Not implemented
00100 extern unsigned int critical_nesting_level;
00101
00102 #define NutEnterCritical()
00103
00104 #define NutExitCritical()
00105
00106 #endif
00107
00108 #else
00109
00110 #define NutEnterCritical() \
00111 { \
00112 __asm__ __volatile__ ( \
00113 "ssrf\t%0" "\n\t" \
00114 "nop" "\n\t" \
00115 "nop" "\n\t" \
00116 :: "i" (AVR32_SR_GM_OFFSET) \
00117 : "memory"); \
00118 }
00119
00120 #define NutExitCritical() \
00121 { \
00122 __asm__ __volatile__ ( \
00123 "csrf\t%0" "\n\t" \
00124 :: "i" (AVR32_SR_GM_OFFSET) \
00125 : "memory"); \
00126 }
00127
00128 #endif
00129
00130 #define NutJumpOutCritical() NutExitCritical()
00131
00132 #endif