[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] Make find_highest_irq() work for both 32 and 64 bit.



ChangeSet 1.1357.1.1, 2005/04/21 22:43:23+01:00, iap10@xxxxxxxxxxxxxxxxxxxxx

        Make find_highest_irq() work for both 32 and 64 bit.
        
        Signed-off-by: Xin B Li <xin.b.li@xxxxxxxxx>
        Signed-off-by: ian@xxxxxxxxxxxxx



 vmx_io.c |   67 +++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 33 insertions(+), 34 deletions(-)


diff -Nru a/xen/arch/x86/vmx_io.c b/xen/arch/x86/vmx_io.c
--- a/xen/arch/x86/vmx_io.c     2005-04-21 21:08:28 -04:00
+++ b/xen/arch/x86/vmx_io.c     2005-04-21 21:08:28 -04:00
@@ -282,7 +282,7 @@
     }
 }
 
-#ifdef __i386__
+#if defined(__i386__) || defined(__x86_64__)
 static inline int __fls(u32 word)
 {
     int bit;
@@ -296,53 +296,52 @@
 #define __fls(x)       generic_fls(x)
 static __inline__ int generic_fls(u32 x)
 {
-       int r = 32;
+    int r = 31;
 
-       if (!x)
-               return 0;
-       if (!(x & 0xffff0000u)) {
-               x <<= 16;
-               r -= 16;
-       }
-       if (!(x & 0xff000000u)) {
-               x <<= 8;
-               r -= 8;
-       }
-       if (!(x & 0xf0000000u)) {
-               x <<= 4;
-               r -= 4;
-       }
-       if (!(x & 0xc0000000u)) {
-               x <<= 2;
-               r -= 2;
-       }
-       if (!(x & 0x80000000u)) {
-                x <<= 1;
-                r -= 1;
-       }
-       return r;
+    if (!x)
+        return -1;
+    if (!(x & 0xffff0000u)) {
+        x <<= 16;
+        r -= 16;
+    }
+    if (!(x & 0xff000000u)) {
+        x <<= 8;
+        r -= 8;
+    }
+    if (!(x & 0xf0000000u)) {
+        x <<= 4;
+        r -= 4;
+    }
+    if (!(x & 0xc0000000u)) {
+        x <<= 2;
+        r -= 2;
+    }
+    if (!(x & 0x80000000u)) {
+        x <<= 1;
+        r -= 1;
+    }
+    return r;
 }
 #endif
 
-
 /* Simple minded Local APIC priority implementation. Fix later */
 static __inline__ int find_highest_irq(u32 *pintr)
 {
     if (pintr[7])
-        return __fls(pintr[7]) + (255-32*1);
+        return __fls(pintr[7]) + (256-32*1);
     if (pintr[6])
-        return __fls(pintr[6]) + (255-32*2);
+        return __fls(pintr[6]) + (256-32*2);
     if (pintr[5])
-        return __fls(pintr[5]) + (255-32*3);
+        return __fls(pintr[5]) + (256-32*3);
     if (pintr[4])
-        return __fls(pintr[4]) + (255-32*4);
+        return __fls(pintr[4]) + (256-32*4);
     if (pintr[3])
-        return __fls(pintr[3]) + (255-32*5);
+        return __fls(pintr[3]) + (256-32*5);
     if (pintr[2])
-        return __fls(pintr[2]) + (255-32*6);
+        return __fls(pintr[2]) + (256-32*6);
     if (pintr[1])
-        return __fls(pintr[1]) + (255-32*7);
-    return (__fls(pintr[0])-1);
+        return __fls(pintr[1]) + (256-32*7);
+    return __fls(pintr[0]);
 }
 
 /*

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.