ia64/xen-unstable

changeset 4631:2fdf5cc2b79b

bitkeeper revision 1.1357.1.1 (42681e7b7KG-juYnPnNfse4HYMkaMw)

Make find_highest_irq() work for both 32 and 64 bit.

Signed-off-by: Xin B Li <xin.b.li@intel.com>
Signed-off-by: ian@xensource.com
author iap10@freefall.cl.cam.ac.uk
date Thu Apr 21 21:43:23 2005 +0000 (2005-04-21)
parents caaf9d543bc5
children 1caa83c98dee
files xen/arch/x86/vmx_io.c
line diff
     1.1 --- a/xen/arch/x86/vmx_io.c	Thu Apr 21 15:39:08 2005 +0000
     1.2 +++ b/xen/arch/x86/vmx_io.c	Thu Apr 21 21:43:23 2005 +0000
     1.3 @@ -282,7 +282,7 @@ void vmx_io_assist(struct exec_domain *e
     1.4      }
     1.5  }
     1.6  
     1.7 -#ifdef __i386__
     1.8 +#if defined(__i386__) || defined(__x86_64__)
     1.9  static inline int __fls(u32 word)
    1.10  {
    1.11      int bit;
    1.12 @@ -296,53 +296,52 @@ static inline int __fls(u32 word)
    1.13  #define __fls(x) 	generic_fls(x)
    1.14  static __inline__ int generic_fls(u32 x)
    1.15  {
    1.16 -	int r = 32;
    1.17 +    int r = 31;
    1.18  
    1.19 -	if (!x)
    1.20 -		return 0;
    1.21 -	if (!(x & 0xffff0000u)) {
    1.22 -		x <<= 16;
    1.23 -		r -= 16;
    1.24 -	}
    1.25 -	if (!(x & 0xff000000u)) {
    1.26 -		x <<= 8;
    1.27 -		r -= 8;
    1.28 -	}
    1.29 -	if (!(x & 0xf0000000u)) {
    1.30 -		x <<= 4;
    1.31 -		r -= 4;
    1.32 -	}
    1.33 -	if (!(x & 0xc0000000u)) {
    1.34 -		x <<= 2;
    1.35 -		r -= 2;
    1.36 -	}
    1.37 -	if (!(x & 0x80000000u)) {
    1.38 -                x <<= 1;
    1.39 -                r -= 1;
    1.40 -	}
    1.41 -	return r;
    1.42 +    if (!x)
    1.43 +        return -1;
    1.44 +    if (!(x & 0xffff0000u)) {
    1.45 +        x <<= 16;
    1.46 +        r -= 16;
    1.47 +    }
    1.48 +    if (!(x & 0xff000000u)) {
    1.49 +        x <<= 8;
    1.50 +        r -= 8;
    1.51 +    }
    1.52 +    if (!(x & 0xf0000000u)) {
    1.53 +        x <<= 4;
    1.54 +        r -= 4;
    1.55 +    }
    1.56 +    if (!(x & 0xc0000000u)) {
    1.57 +        x <<= 2;
    1.58 +        r -= 2;
    1.59 +    }
    1.60 +    if (!(x & 0x80000000u)) {
    1.61 +        x <<= 1;
    1.62 +        r -= 1;
    1.63 +    }
    1.64 +    return r;
    1.65  }
    1.66  #endif
    1.67  
    1.68 -
    1.69  /* Simple minded Local APIC priority implementation. Fix later */
    1.70  static __inline__ int find_highest_irq(u32 *pintr)
    1.71  {
    1.72      if (pintr[7])
    1.73 -        return __fls(pintr[7]) + (255-32*1);
    1.74 +        return __fls(pintr[7]) + (256-32*1);
    1.75      if (pintr[6])
    1.76 -        return __fls(pintr[6]) + (255-32*2);
    1.77 +        return __fls(pintr[6]) + (256-32*2);
    1.78      if (pintr[5])
    1.79 -        return __fls(pintr[5]) + (255-32*3);
    1.80 +        return __fls(pintr[5]) + (256-32*3);
    1.81      if (pintr[4])
    1.82 -        return __fls(pintr[4]) + (255-32*4);
    1.83 +        return __fls(pintr[4]) + (256-32*4);
    1.84      if (pintr[3])
    1.85 -        return __fls(pintr[3]) + (255-32*5);
    1.86 +        return __fls(pintr[3]) + (256-32*5);
    1.87      if (pintr[2])
    1.88 -        return __fls(pintr[2]) + (255-32*6);
    1.89 +        return __fls(pintr[2]) + (256-32*6);
    1.90      if (pintr[1])
    1.91 -        return __fls(pintr[1]) + (255-32*7);
    1.92 -    return (__fls(pintr[0])-1);
    1.93 +        return __fls(pintr[1]) + (256-32*7);
    1.94 +    return __fls(pintr[0]);
    1.95  }
    1.96  
    1.97  /*