Changes in kernel/arch/ppc32/include/asm.h [da1bafb:d99c1d2] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ppc32/include/asm.h
rda1bafb rd99c1d2 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 }96 40 97 41 /** Enable interrupts. … … 101 45 * 102 46 * @return Old interrupt priority level. 103 *104 47 */ 105 48 static inline ipl_t interrupts_enable(void) 106 49 { 107 ipl_t ipl = msr_read(); 108 msr_write(ipl | MSR_EE); 109 return ipl; 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; 110 61 } 111 62 … … 116 67 * 117 68 * @return Old interrupt priority level. 118 *119 69 */ 120 70 static inline ipl_t interrupts_disable(void) 121 71 { 122 ipl_t ipl = msr_read(); 123 msr_write(ipl & (~MSR_EE)); 124 return ipl; 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; 125 83 } 126 84 … … 130 88 * 131 89 * @param ipl Saved interrupt priority level. 132 *133 90 */ 134 91 static inline void interrupts_restore(ipl_t ipl) 135 92 { 136 msr_write((msr_read() & (~MSR_EE)) | (ipl & MSR_EE)); 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 ); 137 106 } 138 107 … … 142 111 * 143 112 * @return Current interrupt priority level. 144 *145 113 */ 146 114 static inline ipl_t interrupts_read(void) 147 115 { 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); 116 ipl_t v; 117 118 asm volatile ( 119 "mfmsr %0\n" 120 : "=r" (v) 121 ); 122 return v; 159 123 } 160 124 … … 164 128 * The stack is assumed to be STACK_SIZE bytes long. 165 129 * The stack must start on page boundary. 166 *167 130 */ 168 131 static inline uintptr_t get_stack_base(void) 169 132 { 170 uintptr_t base;133 uintptr_t v; 171 134 172 135 asm volatile ( 173 "and % [base], %%sp, %[mask]\n"174 : [base] "=r" (base)175 : [mask]"r" (~(STACK_SIZE - 1))136 "and %0, %%sp, %1\n" 137 : "=r" (v) 138 : "r" (~(STACK_SIZE - 1)) 176 139 ); 177 178 return base; 140 return v; 179 141 } 180 142
Note:
See TracChangeset
for help on using the changeset viewer.