Changes in kernel/arch/ppc32/include/asm.h [d99c1d2:da1bafb] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ppc32/include/asm.h
rd99c1d2 rda1bafb 38 38 #include <typedefs.h> 39 39 #include <config.h> 40 #include <arch/cpu.h> 41 #include <arch/mm/asid.h> 42 43 static inline uint32_t msr_read(void) 44 { 45 uint32_t msr; 46 47 asm volatile ( 48 "mfmsr %[msr]\n" 49 : [msr] "=r" (msr) 50 ); 51 52 return msr; 53 } 54 55 static inline void msr_write(uint32_t msr) 56 { 57 asm volatile ( 58 "mtmsr %[msr]\n" 59 :: [msr] "r" (msr) 60 ); 61 } 62 63 static inline void sr_set(uint32_t flags, asid_t asid, uint32_t sr) 64 { 65 asm volatile ( 66 "mtsrin %[value], %[sr]\n" 67 :: [value] "r" ((flags << 16) + (asid << 4) + sr), 68 [sr] "r" (sr << 28) 69 ); 70 } 71 72 static inline uint32_t sr_get(uint32_t vaddr) 73 { 74 uint32_t vsid; 75 76 asm volatile ( 77 "mfsrin %[vsid], %[vaddr]\n" 78 : [vsid] "=r" (vsid) 79 : [vaddr] "r" (vaddr) 80 ); 81 82 return vsid; 83 } 84 85 static inline uint32_t sdr1_get(void) 86 { 87 uint32_t sdr1; 88 89 asm volatile ( 90 "mfsdr1 %[sdr1]\n" 91 : [sdr1] "=r" (sdr1) 92 ); 93 94 return sdr1; 95 } 40 96 41 97 /** Enable interrupts. … … 45 101 * 46 102 * @return Old interrupt priority level. 103 * 47 104 */ 48 105 static inline ipl_t interrupts_enable(void) 49 106 { 50 ipl_t v; 51 ipl_t tmp; 52 53 asm volatile ( 54 "mfmsr %0\n" 55 "mfmsr %1\n" 56 "ori %1, %1, 1 << 15\n" 57 "mtmsr %1\n" 58 : "=r" (v), "=r" (tmp) 59 ); 60 return v; 107 ipl_t ipl = msr_read(); 108 msr_write(ipl | MSR_EE); 109 return ipl; 61 110 } 62 111 … … 67 116 * 68 117 * @return Old interrupt priority level. 118 * 69 119 */ 70 120 static inline ipl_t interrupts_disable(void) 71 121 { 72 ipl_t v; 73 ipl_t tmp; 74 75 asm volatile ( 76 "mfmsr %0\n" 77 "mfmsr %1\n" 78 "rlwinm %1, %1, 0, 17, 15\n" 79 "mtmsr %1\n" 80 : "=r" (v), "=r" (tmp) 81 ); 82 return v; 122 ipl_t ipl = msr_read(); 123 msr_write(ipl & (~MSR_EE)); 124 return ipl; 83 125 } 84 126 … … 88 130 * 89 131 * @param ipl Saved interrupt priority level. 132 * 90 133 */ 91 134 static inline void interrupts_restore(ipl_t ipl) 92 135 { 93 ipl_t tmp; 94 95 asm volatile ( 96 "mfmsr %1\n" 97 "rlwimi %0, %1, 0, 17, 15\n" 98 "cmpw 0, %0, %1\n" 99 "beq 0f\n" 100 "mtmsr %0\n" 101 "0:\n" 102 : "=r" (ipl), "=r" (tmp) 103 : "0" (ipl) 104 : "cr0" 105 ); 136 msr_write((msr_read() & (~MSR_EE)) | (ipl & MSR_EE)); 106 137 } 107 138 … … 111 142 * 112 143 * @return Current interrupt priority level. 144 * 113 145 */ 114 146 static inline ipl_t interrupts_read(void) 115 147 { 116 ipl_t v; 117 118 asm volatile ( 119 "mfmsr %0\n" 120 : "=r" (v) 121 ); 122 return v; 148 return msr_read(); 149 } 150 151 /** Check whether interrupts are disabled. 152 * 153 * @return True if interrupts are disabled. 154 * 155 */ 156 static inline bool interrupts_disabled(void) 157 { 158 return ((msr_read() & MSR_EE) == 0); 123 159 } 124 160 … … 128 164 * The stack is assumed to be STACK_SIZE bytes long. 129 165 * The stack must start on page boundary. 166 * 130 167 */ 131 168 static inline uintptr_t get_stack_base(void) 132 169 { 133 uintptr_t v; 134 135 asm volatile ( 136 "and %0, %%sp, %1\n" 137 : "=r" (v) 138 : "r" (~(STACK_SIZE - 1)) 139 ); 140 return v; 170 uintptr_t base; 171 172 asm volatile ( 173 "and %[base], %%sp, %[mask]\n" 174 : [base] "=r" (base) 175 : [mask] "r" (~(STACK_SIZE - 1)) 176 ); 177 178 return base; 141 179 } 142 180
Note:
See TracChangeset
for help on using the changeset viewer.