diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2015-04-22 01:49:56 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-22 01:49:56 +0000 |
commit | e6403c6a048bdec5a7fc7c6c0cc149fc5f098f80 (patch) | |
tree | 1f5871ed574c6c7b67b25316dac14246e75121d7 | |
parent | 504561e31250b05cc8831f3f8f4ec2f7d5f37635 (diff) | |
parent | e4f17c1301d2499c578b311eb9539cb42cc5af16 (diff) | |
download | ndk-android-6.0.1_r61.tar.gz |
Merge "Add Mips MSA feature to android_getCpuFeatures"android-m-preview-2android-m-preview-1android-m-previewandroid-cts-6.0_r9android-cts-6.0_r8android-cts-6.0_r7android-cts-6.0_r6android-cts-6.0_r5android-cts-6.0_r4android-cts-6.0_r32android-cts-6.0_r31android-cts-6.0_r30android-cts-6.0_r3android-cts-6.0_r29android-cts-6.0_r28android-cts-6.0_r27android-cts-6.0_r26android-cts-6.0_r25android-cts-6.0_r24android-cts-6.0_r23android-cts-6.0_r22android-cts-6.0_r21android-cts-6.0_r20android-cts-6.0_r2android-cts-6.0_r19android-cts-6.0_r18android-cts-6.0_r17android-cts-6.0_r16android-cts-6.0_r15android-cts-6.0_r14android-cts-6.0_r13android-cts-6.0_r12android-cts-6.0_r1android-6.0.1_r9android-6.0.1_r81android-6.0.1_r80android-6.0.1_r8android-6.0.1_r79android-6.0.1_r78android-6.0.1_r77android-6.0.1_r74android-6.0.1_r73android-6.0.1_r72android-6.0.1_r70android-6.0.1_r7android-6.0.1_r69android-6.0.1_r68android-6.0.1_r67android-6.0.1_r66android-6.0.1_r65android-6.0.1_r63android-6.0.1_r62android-6.0.1_r61android-6.0.1_r60android-6.0.1_r59android-6.0.1_r58android-6.0.1_r57android-6.0.1_r56android-6.0.1_r55android-6.0.1_r54android-6.0.1_r53android-6.0.1_r52android-6.0.1_r51android-6.0.1_r50android-6.0.1_r5android-6.0.1_r49android-6.0.1_r48android-6.0.1_r47android-6.0.1_r46android-6.0.1_r45android-6.0.1_r43android-6.0.1_r42android-6.0.1_r41android-6.0.1_r40android-6.0.1_r4android-6.0.1_r33android-6.0.1_r32android-6.0.1_r31android-6.0.1_r30android-6.0.1_r3android-6.0.1_r28android-6.0.1_r27android-6.0.1_r26android-6.0.1_r25android-6.0.1_r24android-6.0.1_r22android-6.0.1_r21android-6.0.1_r20android-6.0.1_r18android-6.0.1_r17android-6.0.1_r16android-6.0.1_r13android-6.0.1_r12android-6.0.1_r11android-6.0.1_r10android-6.0.1_r1android-6.0.0_r7android-6.0.0_r6android-6.0.0_r5android-6.0.0_r41android-6.0.0_r4android-6.0.0_r3android-6.0.0_r26android-6.0.0_r25android-6.0.0_r24android-6.0.0_r23android-6.0.0_r2android-6.0.0_r13android-6.0.0_r12android-6.0.0_r11android-6.0.0_r1master-soongmarshmallow-releasemarshmallow-mr3-releasemarshmallow-mr2-releasemarshmallow-mr1-releasemarshmallow-mr1-devmarshmallow-dr1.6-releasemarshmallow-dr1.5-releasemarshmallow-dr1.5-devmarshmallow-dr-releasemarshmallow-dr-dragon-releasemarshmallow-dr-devmarshmallow-devmarshmallow-cts-release
-rw-r--r-- | sources/android/cpufeatures/cpu-features.c | 27 | ||||
-rw-r--r-- | sources/android/cpufeatures/cpu-features.h | 21 |
2 files changed, 43 insertions, 5 deletions
diff --git a/sources/android/cpufeatures/cpu-features.c b/sources/android/cpufeatures/cpu-features.c index d75eebcb5..75bb9fc17 100644 --- a/sources/android/cpufeatures/cpu-features.c +++ b/sources/android/cpufeatures/cpu-features.c @@ -28,7 +28,9 @@ /* ChangeLog for this library: * - * NDK r9?: Support for 64-bit CPUs (Intel, ARM & MIPS). + * NDK r10e?: Add MIPS MSA feature. + * + * NDK r10: Support for 64-bit CPUs (Intel, ARM & MIPS). * * NDK r8d: Add android_setCpu(). * @@ -471,7 +473,13 @@ cpulist_read_from(CpuList* list, const char* filename) HWCAP_IDIVT ) #endif -#if defined(__arm__) || defined(__aarch64__) +#if defined(__mips__) +// see <uapi/asm/hwcap.h> kernel header +#define HWCAP_MIPS_R6 (1 << 0) +#define HWCAP_MIPS_MSA (1 << 1) +#endif + +#if defined(__arm__) || defined(__aarch64__) || defined(__mips__) #define AT_HWCAP 16 #define AT_HWCAP2 26 @@ -993,6 +1001,21 @@ android_cpuInit(void) g_cpuFeatures |= ANDROID_CPU_X86_FEATURE_MOVBE; } #endif +#if defined( __mips__) + { /* MIPS and MIPS64 */ + /* Extract the list of CPU features from ELF hwcaps */ + uint32_t hwcaps = 0; + hwcaps = get_elf_hwcap_from_getauxval(AT_HWCAP); + if (hwcaps != 0) { + int has_r6 = (hwcaps & HWCAP_MIPS_R6); + int has_msa = (hwcaps & HWCAP_MIPS_MSA); + if (has_r6) + g_cpuFeatures |= ANDROID_CPU_MIPS_FEATURE_R6; + if (has_msa) + g_cpuFeatures |= ANDROID_CPU_MIPS_FEATURE_MSA; + } + } +#endif /* __mips__ */ free(cpuinfo); } diff --git a/sources/android/cpufeatures/cpu-features.h b/sources/android/cpufeatures/cpu-features.h index e86cba882..d93f11a8e 100644 --- a/sources/android/cpufeatures/cpu-features.h +++ b/sources/android/cpufeatures/cpu-features.h @@ -65,10 +65,7 @@ extern AndroidCpuFamily android_getCpuFamily(void); * NOTE: This will return 0 for the following architectures that don't have * optional features listed at the moment: * - * ANDROID_CPU_FAMILY_MIPS - * ANDROID_CPU_FAMILY_ARM64 * ANDROID_CPU_FAMILY_X86_64 - * ANDROID_CPU_FAMILY_MIPS64 */ extern uint64_t android_getCpuFeatures(void); @@ -260,6 +257,7 @@ enum { ANDROID_CPU_ARM64_FEATURE_SHA2 = (1 << 5), ANDROID_CPU_ARM64_FEATURE_CRC32 = (1 << 6), }; + /* The bit flags corresponding to the output of android_getCpuFeatures() * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_X86. */ @@ -269,6 +267,23 @@ enum { ANDROID_CPU_X86_FEATURE_MOVBE = (1 << 2), }; +/* The bit flags corresponding to the output of android_getCpuFeatures() + * when android_getCpuFamily() returns ANDROID_CPU_FAMILY_MIPS + * or ANDROID_CPU_FAMILY_MIPS64. Values are: + * + * R6: + * CPU executes MIPS Release 6 instructions natively, and + * supports obsoleted R1..R5 instructions only via kernel traps. + * + * MSA: + * CPU supports Mips SIMD Architecture instructions. + */ +enum { + ANDROID_CPU_MIPS_FEATURE_R6 = (1 << 0), + ANDROID_CPU_MIPS_FEATURE_MSA = (1 << 1), +}; + + /* Return the number of CPU cores detected on this device. */ extern int android_getCpuCount(void); |