direct-io.hg

changeset 9376:4080ec91a014

Replace evtchn macro maze with static inline functions.
Todo: could replace current irq_info packed format with a bitfield.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 22 16:47:18 2006 +0100 (2006-03-22)
parents ecb99d1ce57d
children 787b39f5fc83
files linux-2.6-xen-sparse/drivers/xen/core/evtchn.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Mar 22 12:21:44 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/core/evtchn.c	Wed Mar 22 16:47:18 2006 +0100
     1.3 @@ -58,17 +58,37 @@ static int evtchn_to_irq[NR_EVENT_CHANNE
     1.4  
     1.5  /* Packed IRQ information: binding type, sub-type index, and event channel. */
     1.6  static u32 irq_info[NR_IRQS];
     1.7 +
     1.8  /* Binding types. */
     1.9  enum { IRQT_UNBOUND, IRQT_PIRQ, IRQT_VIRQ, IRQT_IPI, IRQT_EVTCHN };
    1.10 +
    1.11  /* Constructor for packed IRQ information. */
    1.12 -#define mk_irq_info(type, index, evtchn)				\
    1.13 -	(((u32)(type) << 24) | ((u32)(index) << 16) | (u32)(evtchn))
    1.14 +static inline u32 mk_irq_info(u32 type, u32 index, u32 evtchn)
    1.15 +{
    1.16 +	return ((type << 24) | (index << 16) | evtchn);
    1.17 +}
    1.18 +
    1.19  /* Convenient shorthand for packed representation of an unbound IRQ. */
    1.20  #define IRQ_UNBOUND	mk_irq_info(IRQT_UNBOUND, 0, 0)
    1.21 -/* Accessor macros for packed IRQ information. */
    1.22 -#define evtchn_from_irq(irq) ((u16)(irq_info[irq]))
    1.23 -#define index_from_irq(irq)  ((u8)(irq_info[irq] >> 16))
    1.24 -#define type_from_irq(irq)   ((u8)(irq_info[irq] >> 24))
    1.25 +
    1.26 +/*
    1.27 + * Accessors for packed IRQ information.
    1.28 + */
    1.29 +
    1.30 +static inline unsigned int evtchn_from_irq(int irq)
    1.31 +{
    1.32 +	return (u16)(irq_info[irq]);
    1.33 +}
    1.34 +
    1.35 +static inline unsigned int index_from_irq(int irq)
    1.36 +{
    1.37 +	return (u8)(irq_info[irq] >> 16);
    1.38 +}
    1.39 +
    1.40 +static inline unsigned int type_from_irq(int irq)
    1.41 +{
    1.42 +	return (u8)(irq_info[irq] >> 24);
    1.43 +}
    1.44  
    1.45  /* IRQ <-> VIRQ mapping. */
    1.46  DEFINE_PER_CPU(int, virq_to_irq[NR_VIRQS]);
    1.47 @@ -90,10 +110,13 @@ static unsigned long pirq_needs_unmask_n
    1.48  static u8 cpu_evtchn[NR_EVENT_CHANNELS];
    1.49  static unsigned long cpu_evtchn_mask[NR_CPUS][NR_EVENT_CHANNELS/BITS_PER_LONG];
    1.50  
    1.51 -#define active_evtchns(cpu,sh,idx)		\
    1.52 -	((sh)->evtchn_pending[idx] &		\
    1.53 -	 cpu_evtchn_mask[cpu][idx] &		\
    1.54 -	 ~(sh)->evtchn_mask[idx])
    1.55 +static inline unsigned long active_evtchns(unsigned int cpu, shared_info_t *sh,
    1.56 +					   unsigned int idx)
    1.57 +{
    1.58 +	return (sh->evtchn_pending[idx] &
    1.59 +		cpu_evtchn_mask[cpu][idx] &
    1.60 +		~sh->evtchn_mask[idx]);
    1.61 +}
    1.62  
    1.63  static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
    1.64  {
    1.65 @@ -109,16 +132,31 @@ static void init_evtchn_cpu_bindings(voi
    1.66  	memset(cpu_evtchn_mask[0], ~0, sizeof(cpu_evtchn_mask[0]));
    1.67  }
    1.68  
    1.69 -#define cpu_from_evtchn(evtchn)		(cpu_evtchn[evtchn])
    1.70 +static inline unsigned int cpu_from_evtchn(unsigned int evtchn)
    1.71 +{
    1.72 +	return cpu_evtchn[evtchn];
    1.73 +}
    1.74  
    1.75  #else
    1.76  
    1.77 -#define active_evtchns(cpu,sh,idx)		\
    1.78 -	((sh)->evtchn_pending[idx] &		\
    1.79 -	 ~(sh)->evtchn_mask[idx])
    1.80 -#define bind_evtchn_to_cpu(chn,cpu)	((void)0)
    1.81 -#define init_evtchn_cpu_bindings()	((void)0)
    1.82 -#define cpu_from_evtchn(evtchn)		(0)
    1.83 +static inline unsigned long active_evtchns(unsigned int cpu, shared_info_t *sh,
    1.84 +					   unsigned int idx)
    1.85 +{
    1.86 +	return (sh->evtchn_pending[idx] & ~sh->evtchn_mask[idx]);
    1.87 +}
    1.88 +
    1.89 +static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)
    1.90 +{
    1.91 +}
    1.92 +
    1.93 +static void init_evtchn_cpu_bindings(void)
    1.94 +{
    1.95 +}
    1.96 +
    1.97 +static inline unsigned int cpu_from_evtchn(unsigned int evtchn)
    1.98 +{
    1.99 +	return 0;
   1.100 +}
   1.101  
   1.102  #endif
   1.103