Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /* Intel x86 GCC specific kernel inline assembler functions and macros */ /* * Copyright (c) 2015, Wind River Systems, Inc. * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _ASM_INLINE_GCC_H #define _ASM_INLINE_GCC_H #ifdef __cplusplus extern "C" { #endif /* * The file must not be included directly * Include asm_inline.h instead */ #ifndef _ASMLANGUAGE /** * * @brief Return the current value of the EFLAGS register * * @return the EFLAGS register. */ static inline unsigned int EflagsGet(void) { unsigned int eflags; /* EFLAGS register contents */ __asm__ volatile( "pushfl;\n\t" "popl %0;\n\t" : "=r"(eflags) : ); return eflags; } #ifdef CONFIG_FP_SHARING /** * * @brief Disallow use of floating point capabilities * * This routine sets CR0[TS] to 1, which disallows the use of FP instructions * by the currently executing thread. * * @return N/A */ static inline void _FpAccessDisable(void) { void *tempReg; __asm__ volatile( "movl %%cr0, %0;\n\t" "orl $0x8, %0;\n\t" "movl %0, %%cr0;\n\t" : "=r"(tempReg) : : "memory"); } /** * * @brief Save non-integer context information * * This routine saves the system's "live" non-integer context into the * specified area. If the specified task or fiber supports SSE then * x87/MMX/SSEx thread info is saved, otherwise only x87/MMX thread is saved. * Function is invoked by _FpCtxSave(struct tcs *tcs) * * @return N/A */ static inline void _do_fp_regs_save(void *preemp_float_reg) { __asm__ volatile("fnsave (%0);\n\t" : : "r"(preemp_float_reg) : "memory"); } #ifdef CONFIG_SSE /** * * @brief Save non-integer context information * * This routine saves the system's "live" non-integer context into the * specified area. If the specified task or fiber supports SSE then * x87/MMX/SSEx thread info is saved, otherwise only x87/MMX thread is saved. * Function is invoked by _FpCtxSave(struct tcs *tcs) * * @return N/A */ static inline void _do_fp_and_sse_regs_save(void *preemp_float_reg) { __asm__ volatile("fxsave (%0);\n\t" : : "r"(preemp_float_reg) : "memory"); } #endif /* CONFIG_SSE */ /** * * @brief Initialize floating point register context information. * * This routine initializes the system's "live" floating point registers. * * @return N/A */ static inline void _do_fp_regs_init(void) { __asm__ volatile("fninit\n\t"); } #ifdef CONFIG_SSE /** * * @brief Initialize SSE register context information. * * This routine initializes the system's "live" SSE registers. * * @return N/A */ static inline void _do_sse_regs_init(void) { __asm__ volatile("ldmxcsr _sse_mxcsr_default_value\n\t"); } #endif /* CONFIG_SSE */ #endif /* CONFIG_FP_SHARING */ #endif /* _ASMLANGUAGE */ #ifdef __cplusplus } #endif #endif /* _ASM_INLINE_GCC_H */ |