@@ -44,12 +44,13 @@ # include #endif #ifdef __QNX__ # include #endif -#ifdef OF_PPC_ASM +#if defined(OF_PPC_ASM) || defined(OF_MIPS_ASM) # include +# include #endif #if defined(OF_X86_64_ASM) || defined(OF_X86_ASM) struct x86_regs { uint32_t eax, ebx, ecx, edx; @@ -56,13 +57,17 @@ }; #endif static size_t pageSize; static size_t numberOfCPUs; -#ifdef OF_PPC_ASM -static sig_atomic_t altiVecSupported; -static sigjmp_buf altiVecJumpBuffer; +#if defined(OF_PPC_ASM) +static sig_atomic_t supportsAltiVec = 0; +#elif defined(OF_MIPS_ASM) +static sig_atomic_t supportsMXU = 0; +#endif +#if defined(OF_PPC_ASM) || defined(OF_MIPS_ASM) +static sigjmp_buf SIGILLJumpBuffer; #endif #if defined(OF_X86_64_ASM) static OF_INLINE struct x86_regs OF_CONST_FUNC x86_cpuid(uint32_t eax, uint32_t ecx) @@ -100,29 +105,40 @@ return regs; } #endif -#ifdef OF_PPC_ASM +#if defined(OF_PPC_ASM) || defined(OF_MIPS_ASM) static void -altiVecSIGILLHandler(int signal) +SIGILLHandler(int signal) { - altiVecSupported = 0; - siglongjmp(altiVecJumpBuffer, 1); + siglongjmp(SIGILLJumpBuffer, 1); } #endif @implementation OFSystemInfo -#ifdef OF_PPC_ASM +#if defined(OF_PPC_ASM) || defined(OF_MIPS_ASM) + (void)load { - altiVecSupported = 1; - if (sigsetjmp(altiVecJumpBuffer, 1) == 0) { - signal(SIGILL, altiVecSIGILLHandler); + if (sigsetjmp(SIGILLJumpBuffer, 1) == 0) { + signal(SIGILL, SIGILLHandler); +# if defined(OF_PPC_ASM) __asm__ __volatile__ ( "vor v0, v0, v0" ); + supportsAltiVec = 1; +# elif defined(OF_MIPS_ASM) + /* This also enables the MXU */ + __asm__ __volatile__ ( + "li $t0, 1\n\t" + ".word 0x7008042f /* s32i2m xr16, $t0 */" + : + : + : "$8" /* $t0 */ + ); + supportsMXU = 1; +# endif } signal(SIGILL, SIG_DFL); } #endif @@ -403,9 +419,16 @@ #endif #ifdef OF_PPC_ASM + (bool)supportsAltiVec { - return altiVecSupported; + return supportsAltiVec; +} +#endif + +#ifdef OF_MIPS_ASM ++ (bool)supportsMXU +{ + return supportsMXU; } #endif @end