Skip to main content

[jpcm~jpcm-commit:4b720cef] Ensure that ecx is set to zero when using CPUID instruction

  • From:
  • To:
  • Subject: [jpcm~jpcm-commit:4b720cef] Ensure that ecx is set to zero when using CPUID instruction
  • Date: Thu, 19 Apr 2012 20:49:12 +0000

Project:    jpcm
Repository: jpcm-commit
Revision:   4b720cef6bee64af977f4f527fbbe1afd1be8b0c
Author:     mikeb2701
Date:       2012-04-19 20:49:06 UTC
Link:       

Log Message:
------------
Ensure that ecx is set to zero when using CPUID instruction


Revisions:
----------
4b720cef6bee64af977f4f527fbbe1afd1be8b0c


Modified Paths:
---------------
jpcm-os-services-darwin/src/main/java/net/jpcm/cpuid/CPUIDDarwinService.java
jpcm-os-services-darwin/src/main/java/net/jpcm/msr/DarwinMsrJni.java
jpcm-os-services-darwin/src/main/native/DarwinMsrJni.cpp
jpcm-os-services-darwin/src/main/native/DarwinMsrJni.h


Diffs:
------
diff --git 
a/jpcm-os-services-darwin/src/main/java/net/jpcm/cpuid/CPUIDDarwinService.java
 
b/jpcm-os-services-darwin/src/main/java/net/jpcm/cpuid/CPUIDDarwinService.java
index f9c2f0c..ecb8701 100644
--- 
a/jpcm-os-services-darwin/src/main/java/net/jpcm/cpuid/CPUIDDarwinService.java
+++ 
b/jpcm-os-services-darwin/src/main/java/net/jpcm/cpuid/CPUIDDarwinService.java
@@ -5,6 +5,6 @@ import net.jpcm.msr.DarwinMsrJni;
 public class CPUIDDarwinService implements CPUIDService {
     @Override
     public int[] read(int inputEAX) {
-        return DarwinMsrJni.readCpuid(inputEAX);
+        return DarwinMsrJni.readCpuid(inputEAX, 0);
     }
 }
diff --git 
a/jpcm-os-services-darwin/src/main/java/net/jpcm/msr/DarwinMsrJni.java 
b/jpcm-os-services-darwin/src/main/java/net/jpcm/msr/DarwinMsrJni.java
index 703f3c9..06e53f3 100644
--- a/jpcm-os-services-darwin/src/main/java/net/jpcm/msr/DarwinMsrJni.java
+++ b/jpcm-os-services-darwin/src/main/java/net/jpcm/msr/DarwinMsrJni.java
@@ -11,5 +11,5 @@ public class DarwinMsrJni {
     public static native void write(long ioConnectT, int cpuId, long 
register, long value);
     public static native void close(long ioConnectT);
     public static native CpuTopology getCpuTopology(long ioConnectT, int 
cpuId);
-    public static native int[] readCpuid(int eax);
+    public static native int[] readCpuid(int eax, int ecx);
 }
diff --git a/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.cpp 
b/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.cpp
index 9a794f0..ab58131 100644
--- a/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.cpp
+++ b/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.cpp
@@ -167,12 +167,12 @@ JNIEXPORT jobject JNICALL 
Java_net_jpcm_msr_DarwinMsrJni_getCpuTopology
 }
 
 JNIEXPORT jintArray JNICALL Java_net_jpcm_msr_DarwinMsrJni_readCpuid
-  (JNIEnv * env, jclass clazz, jint eax)
+  (JNIEnv * env, jclass clazz, jint eax, jint ecx)
 {
        jint values[4];
     asm volatile("cpuid" :
                  "=a" (values[0]), "=b" (values[1]), "=c" (values[2]), "=d" 
(values[3]) :
-                 "a" (eax));
+                 "a" (eax), "c" (ecx));
 
     jintArray result = env->NewIntArray(4);
     env->SetIntArrayRegion(result, 0, 4, values);
diff --git a/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.h 
b/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.h
index 6ce1392..d0b240b 100644
--- a/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.h
+++ b/jpcm-os-services-darwin/src/main/native/DarwinMsrJni.h
@@ -53,7 +53,7 @@ JNIEXPORT jobject JNICALL 
Java_net_jpcm_msr_DarwinMsrJni_getCpuTopology
  * Signature: (I)[I
  */
 JNIEXPORT jintArray JNICALL Java_net_jpcm_msr_DarwinMsrJni_readCpuid
-  (JNIEnv *, jclass, jint);
+  (JNIEnv *, jclass, jint, jint);
 
 #ifdef __cplusplus
 }




[jpcm~jpcm-commit:4b720cef] Ensure that ecx is set to zero when using CPUID instruction

mikeb2701 04/19/2012
 
 
Close
loading
Please Confirm
Close