Changeset 100193 in vbox for trunk/include
- Timestamp:
- Jun 16, 2023 8:13:55 AM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/asm-arm.h
r99978 r100193 49 49 * @{ 50 50 */ 51 52 53 #if 0 /* figure out arm64 */54 55 /**56 * Get the CPSR (Current Program Status) register.57 * @returns CPSR.58 */59 #if RT_INLINE_ASM_EXTERNAL60 DECLASM(RTCCUINTREG) ASMGetFlags(void);61 #else62 DECLINLINE(RTCCUINTREG) ASMGetFlags(void)63 {64 RTCCUINTREG uFlags;65 # if RT_INLINE_ASM_GNU_STYLE66 # ifdef RT_ARCH_ARM6467 __asm__ __volatile__("mrs %0, nzcv\n\t" : "=r" (uFlags));68 # else69 __asm__ __volatile__("mrs %0, cpsr\n\t" : "=r" (uFlags));70 # endif71 # else72 # error "Unsupported compiler"73 # endif74 return uFlags;75 }76 #endif77 78 79 /**80 * Set the CPSR register.81 * @param uFlags The new CPSR value.82 */83 #if RT_INLINE_ASM_EXTERNAL84 DECLASM(void) ASMSetFlags(RTCCUINTREG uFlags);85 #else86 DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags)87 {88 # if RT_INLINE_ASM_GNU_STYLE89 __asm__ __volatile__("msr cpsr_c, %0\n\t"90 : : "r" (uFlags));91 # else92 # error "Unsupported compiler"93 # endif94 }95 #endif96 97 #endif98 99 51 100 52 /** … … 169 121 170 122 171 #if 0 /* port to arm64, armv7 and check */172 173 123 /** 174 124 * Enables interrupts (IRQ and FIQ). … … 179 129 DECLINLINE(void) ASMIntEnable(void) 180 130 { 131 # if RT_INLINE_ASM_GNU_STYLE 132 # ifdef RT_ARCH_ARM64 133 __asm__ __volatile__("msr daifclr, #0xf\n\t"); 134 # else 181 135 RTCCUINTREG uFlags; 182 # if RT_INLINE_ASM_GNU_STYLE183 136 __asm__ __volatile__("mrs %0, cpsr\n\t" 184 137 "bic %0, %0, #0xc0\n\t" 185 138 "msr cpsr_c, %0\n\t" 186 139 : "=r" (uFlags)); 140 # endif 187 141 # else 188 142 # error "Unsupported compiler" … … 200 154 DECLINLINE(void) ASMIntDisable(void) 201 155 { 156 # if RT_INLINE_ASM_GNU_STYLE 157 # ifdef RT_ARCH_ARM64 158 __asm__ __volatile__("msr daifset, #0xf\n\t"); 159 # else 202 160 RTCCUINTREG uFlags; 203 # if RT_INLINE_ASM_GNU_STYLE204 161 __asm__ __volatile__("mrs %0, cpsr\n\t" 205 162 "orr %0, %0, #0xc0\n\t" 206 163 "msr cpsr_c, %0\n\t" 207 164 : "=r" (uFlags)); 165 # endif 208 166 # else 209 167 # error "Unsupported compiler" … … 223 181 RTCCUINTREG uFlags; 224 182 # if RT_INLINE_ASM_GNU_STYLE 183 # ifdef RT_ARCH_ARM64 184 __asm__ __volatile__("mrs %[uRet], daif\n\t" 185 "msr daifset, #0xf\n\t" 186 : [uRet] "=r" (uFlags)); 187 # else 225 188 RTCCUINTREG uNewFlags; 226 189 __asm__ __volatile__("mrs %0, cpsr\n\t" … … 229 192 : "=r" (uFlags) 230 193 , "=r" (uNewFlags)); 194 # endif 231 195 # else 232 196 # error "Unsupported compiler" … … 234 198 return uFlags; 235 199 } 200 201 202 /** 203 * Get the CPSR/PSTATE register. 204 * @returns CPSR/PSTATE. 205 */ 206 #if RT_INLINE_ASM_EXTERNAL 207 DECLASM(RTCCUINTREG) ASMGetFlags(void); 208 #else 209 DECLINLINE(RTCCUINTREG) ASMGetFlags(void) 210 { 211 RTCCUINTREG uFlags; 212 # if RT_INLINE_ASM_GNU_STYLE 213 # ifdef RT_ARCH_ARM64 214 __asm__ __volatile__("isb\n\t" 215 "mrs %0, daif\n\t" 216 : "=r" (uFlags)); 217 # else 218 # error "Implementation required for arm32" 219 # endif 220 # else 221 # error "Unsupported compiler" 222 # endif 223 return uFlags; 224 } 225 #endif 226 227 228 /** 229 * Get the CPSR/PSTATE register. 230 * @returns CPSR/PSTATE. 231 */ 232 #if RT_INLINE_ASM_EXTERNAL 233 DECLASM(void) ASMSetFlags(RTCCUINTREG uFlags); 234 #else 235 DECLINLINE(void) ASMSetFlags(RTCCUINTREG uFlags) 236 { 237 # if RT_INLINE_ASM_GNU_STYLE 238 # ifdef RT_ARCH_ARM64 239 __asm__ __volatile__("isb\n\t" 240 "msr daif, %[uFlags]\n\t" 241 : : [uFlags] "r" (uFlags)); 242 # else 243 # error "Implementation required for arm32" 244 # endif 245 # else 246 # error "Unsupported compiler" 247 # endif 248 } 236 249 #endif 237 250 … … 244 257 DECLINLINE(bool) ASMIntAreEnabled(void) 245 258 { 246 /** @todo r=bird: reversed, but does both need to be enabled? */247 259 return ASMGetFlags() & 0xc0 /* IRQ and FIQ bits */ ? true : false; 248 260 }
Note:
See TracChangeset
for help on using the changeset viewer.