WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

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

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Make find_highest_irq() work for both 32 and 64 bit.
From: BitKeeper Bot <riel@xxxxxxxxxxx>
Date: Thu, 21 Apr 2005 21:43:23 +0000
Delivery-date: Fri, 22 Apr 2005 01:08:09 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: Xen Development List <xen-devel@xxxxxxxxxxxxxxxxxxx>
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Make find_highest_irq() work for both 32 and 64 bit., BitKeeper Bot <=