Changes in kernel/arch/sparc64/include/barrier.h [c8e99bb:7a0359b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/include/barrier.h
rc8e99bb r7a0359b 27 27 */ 28 28 29 /** @addtogroup sparc64 29 /** @addtogroup sparc64 30 30 * @{ 31 31 */ … … 36 36 #define KERN_sparc64_BARRIER_H_ 37 37 38 #include <trace.h> 39 38 40 #ifdef KERNEL 41 39 42 #include <typedefs.h> 43 40 44 #else 45 41 46 #include <stdint.h> 47 42 48 #endif 43 49 … … 45 51 * Our critical section barriers are prepared for the weakest RMO memory model. 46 52 */ 47 #define CS_ENTER_BARRIER() \ 48 asm volatile ( \ 49 "membar #LoadLoad | #LoadStore\n" \ 50 ::: "memory" \ 51 ) 52 #define CS_LEAVE_BARRIER() \ 53 asm volatile ( \ 54 "membar #StoreStore\n" \ 55 "membar #LoadStore\n" \ 56 ::: "memory" \ 53 #define CS_ENTER_BARRIER() \ 54 asm volatile ( \ 55 "membar #LoadLoad | #LoadStore\n" \ 56 ::: "memory" \ 57 57 ) 58 58 59 #define memory_barrier()\60 asm volatile ( "membar #LoadLoad | #StoreStore\n" ::: "memory")61 #define read_barrier()\62 asm volatile ("membar #LoadLoad\n" ::: "memory")63 #define write_barrier()\64 asm volatile ("membar #StoreStore\n" ::: "memory")59 #define CS_LEAVE_BARRIER() \ 60 asm volatile ( \ 61 "membar #StoreStore\n" \ 62 "membar #LoadStore\n" \ 63 ::: "memory" \ 64 ) 65 65 66 #define flush(a) \ 67 asm volatile ("flush %0\n" :: "r" ((a)) : "memory") 66 #define memory_barrier() \ 67 asm volatile ( \ 68 "membar #LoadLoad | #StoreStore\n" \ 69 ::: "memory" \ 70 ) 71 72 #define read_barrier() \ 73 asm volatile ( \ 74 "membar #LoadLoad\n" \ 75 ::: "memory" \ 76 ) 77 78 #define write_barrier() \ 79 asm volatile ( \ 80 "membar #StoreStore\n" \ 81 ::: "memory" \ 82 ) 83 84 #define flush(a) \ 85 asm volatile ( \ 86 "flush %[reg]\n" \ 87 :: [reg] "r" ((a)) \ 88 : "memory" \ 89 ) 68 90 69 91 /** Flush Instruction pipeline. */ 70 static inline void flush_pipeline(void)92 NO_TRACE static inline void flush_pipeline(void) 71 93 { 72 94 uint64_t pc; 73 95 74 96 /* 75 97 * The FLUSH instruction takes address parameter. … … 80 102 * the %pc register will always be in the range mapped by 81 103 * DTLB. 104 * 82 105 */ 83 84 85 "rd %%pc, % 0\n"86 "flush % 0\n"87 : "=&r" (pc)106 107 asm volatile ( 108 "rd %%pc, %[pc]\n" 109 "flush %[pc]\n" 110 : [pc] "=&r" (pc) 88 111 ); 89 112 } 90 113 91 114 /** Memory Barrier instruction. */ 92 static inline void membar(void)115 NO_TRACE static inline void membar(void) 93 116 { 94 asm volatile ("membar #Sync\n"); 117 asm volatile ( 118 "membar #Sync\n" 119 ); 95 120 } 96 121 97 122 #if defined (US) 98 123 99 #define smc_coherence(a) \ 100 { \ 101 write_barrier(); \ 102 flush((a)); \ 103 } 124 #define FLUSH_INVAL_MIN 4 104 125 105 #define FLUSH_INVAL_MIN 4 106 #define smc_coherence_block(a, l) \ 107 { \ 108 unsigned long i; \ 109 write_barrier(); \ 110 for (i = 0; i < (l); i += FLUSH_INVAL_MIN) \ 111 flush((void *)(a) + i); \ 112 } 126 #define smc_coherence(a) \ 127 do { \ 128 write_barrier(); \ 129 flush((a)); \ 130 } while (0) 131 132 #define smc_coherence_block(a, l) \ 133 do { \ 134 unsigned long i; \ 135 write_barrier(); \ 136 \ 137 for (i = 0; i < (l); i += FLUSH_INVAL_MIN) \ 138 flush((void *)(a) + i); \ 139 } while (0) 113 140 114 141 #elif defined (US3) 115 142 116 #define smc_coherence(a) 117 {\118 write_barrier();\119 flush_pipeline();\120 } 143 #define smc_coherence(a) \ 144 do { \ 145 write_barrier(); \ 146 flush_pipeline(); \ 147 } while (0) 121 148 122 #define smc_coherence_block(a, l) 123 {\124 write_barrier();\125 flush_pipeline();\126 } 149 #define smc_coherence_block(a, l) \ 150 do { \ 151 write_barrier(); \ 152 flush_pipeline(); \ 153 } while (0) 127 154 128 #endif 155 #endif /* defined(US3) */ 129 156 130 157 #endif
Note:
See TracChangeset
for help on using the changeset viewer.