mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-29 16:37:03 +00:00
Make codebase more CPU-agnostic + MacOS disclaimer (#559)
This commit is contained in:
parent
445b0afa95
commit
2c81d240a5
26 changed files with 416 additions and 272 deletions
|
|
@ -10,6 +10,7 @@
|
|||
/* Includes: */
|
||||
/*****************************************************************************/
|
||||
#include "aes128.h"
|
||||
#include "Common/cpu_features.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Defines: */
|
||||
|
|
@ -23,8 +24,6 @@
|
|||
// The number of rounds in AES Cipher.
|
||||
#define Nr 10
|
||||
|
||||
bool useAESNI = false;
|
||||
|
||||
typedef uint8 state_t[4][4];
|
||||
|
||||
typedef struct
|
||||
|
|
@ -601,6 +600,7 @@ void AES128_CBC_decrypt_updateIV(uint8* output, uint8* input, uint32 length, con
|
|||
memcpy(iv, newIv, KEYLEN);
|
||||
}
|
||||
|
||||
#if defined(ARCH_X86_64)
|
||||
inline __m128i AESNI128_ASSIST(
|
||||
__m128i temp1,
|
||||
__m128i temp2)
|
||||
|
|
@ -792,6 +792,7 @@ void __aesni__AES128_ECB_encrypt(uint8* input, const uint8* key, uint8* output)
|
|||
feedback = _mm_aesenclast_si128(feedback, ((__m128i*)expandedKey)[10]);
|
||||
_mm_storeu_si128(&((__m128i*)output)[0], feedback);
|
||||
}
|
||||
#endif
|
||||
|
||||
void(*AES128_ECB_encrypt)(uint8* input, const uint8* key, uint8* output);
|
||||
void (*AES128_CBC_decrypt)(uint8* output, uint8* input, uint32 length, const uint8* key, const uint8* iv) = nullptr;
|
||||
|
|
@ -836,10 +837,8 @@ void AES128_init()
|
|||
lookupTable_multiply[i] = (vE << 0) | (v9 << 8) | (vD << 16) | (vB << 24);
|
||||
}
|
||||
// check if AES-NI is available
|
||||
int v[4];
|
||||
cpuid(v, 1);
|
||||
useAESNI = (v[2] & 0x2000000) != 0;
|
||||
if (useAESNI)
|
||||
#if defined(ARCH_X86_64)
|
||||
if (g_CPUFeatures.x86.aesni)
|
||||
{
|
||||
// AES-NI implementation
|
||||
AES128_CBC_decrypt = __aesni__AES128_CBC_decrypt;
|
||||
|
|
@ -851,9 +850,8 @@ void AES128_init()
|
|||
AES128_CBC_decrypt = __soft__AES128_CBC_decrypt;
|
||||
AES128_ECB_encrypt = __soft__AES128_ECB_encrypt;
|
||||
}
|
||||
#else
|
||||
AES128_CBC_decrypt = __soft__AES128_CBC_decrypt;
|
||||
AES128_ECB_encrypt = __soft__AES128_ECB_encrypt;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AES128_useAESNI()
|
||||
{
|
||||
return useAESNI;
|
||||
}
|
||||
|
|
@ -2,7 +2,6 @@
|
|||
#define _AES_H_
|
||||
|
||||
void AES128_init();
|
||||
bool AES128_useAESNI();
|
||||
|
||||
extern void(*AES128_ECB_encrypt)(uint8* input, const uint8* key, uint8* output);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ public:
|
|||
{
|
||||
if (!m_lockBool.exchange(true, std::memory_order_acquire))
|
||||
break;
|
||||
while (m_lockBool.load(std::memory_order_relaxed)) _mm_pause();
|
||||
while (m_lockBool.load(std::memory_order_relaxed))
|
||||
_mm_pause();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -36,4 +37,4 @@ public:
|
|||
private:
|
||||
|
||||
mutable std::atomic<bool> m_lockBool = false;
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue