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 #ifndef _SYS_ATOM_H_
00040 #error "Do not include this file directly. Use sys/atom.h instead!"
00041 #endif
00042
00043 #if (__GNUC__ && __AVR32__)
00044
00045 #include <avr32/io.h>
00046
00047 #if defined(NUT_CRITICAL_NESTING)
00048
00049 #if defined(NUT_CRITICAL_NESTING_STACK)
00050
00051
00052
00053
00054 #error Not Working
00055 #define NutEnterCritical() \
00056 { \
00057 register int temp_; \
00058 __asm__ volatile ( \
00059 "mfsr r10, %[SR]" "\n\t" \
00060 "pushm r10" "\n\t" \
00061 "ssrf %[SR_GM_OFFSET]" "\n\t" \
00062 : [temp] "=r" (temp_) \
00063 : [SR] "i" (AVR32_SR), \
00064 [SR_GM_OFFSET] "i" (AVR32_SR_GM_OFFSET) \
00065 : "memory", "cc", "r10"); \
00066 }
00067
00068 #define NutExitCritical() \
00069 { \
00070 register int temp_; \
00071 __asm__ volatile ( \
00072 "popm r10" "\n\t" \
00073 "andl r10, LO(%[SR_GM_MASK])" "\n\t" \
00074 "andh r10, HI(%[SR_GM_MASK])" "\n\t" \
00075 "cp.w r10, 0" "\n\t" \
00076 "breq LABEL_INT_SKIP_ENABLE_INTERRUPTS_%[LINE]" "\n\t" \
00077 "csrf %[SR_GM_OFFSET]" "\n\t" \
00078 "LABEL_INT_SKIP_SAVE_CONTEXT_%[LINE]:" "\n\t" \
00079 : [temp] "=r" (temp_) \
00080 : [SR_GM_OFFSET] "i" (AVR32_SR_GM_OFFSET), \
00081 [SR_GM_MASK] "i" (AVR32_SR_GM_MASK), \
00082 [LINE] "i" (__LINE__) \
00083 : "memory", "cc", "r10"); \
00084 }
00085
00086 #else
00087
00088
00089 #error Not implemented
00090 extern unsigned int critical_nesting_level;
00091
00092 #define NutEnterCritical()
00093
00094 #define NutExitCritical()
00095
00096 #endif
00097
00098 #else
00099
00100 #define NutEnterCritical() \
00101 { \
00102 __asm__ __volatile__ ( \
00103 "ssrf\t%0" "\n\t" \
00104 :: "i" (AVR32_SR_GM_OFFSET)); \
00105 }
00106
00107 #define NutExitCritical() \
00108 { \
00109 __asm__ __volatile__ ( \
00110 "csrf\t%0" "\n\t" \
00111 :: "i" (AVR32_SR_GM_OFFSET)); \
00112 }
00113
00114 #endif
00115
00116 #define NutJumpOutCritical() NutExitCritical()
00117
00118 #endif