ia64/xen-unstable

changeset 10442:811c02dbe595

[IA64] optionally enable xen console with irq/input.

Makes xen serial console working in input.
You need to add 'xencons' option to xen command line, and you need
to disable serial on linux (unfortunatly).
Remove unused functions in irq.c
Add a ia64_xen_vector bitmask of vectors used exclusively by Xen.

Signed-off-by: Tristan Gingold <tristan.gingold@bull.net>
author awilliam@xenbuild.aw
date Wed Jun 21 11:15:08 2006 -0600 (2006-06-21)
parents f771bbaa93ce
children 0e5635d68de3
files xen/arch/ia64/linux-xen/iosapic.c xen/arch/ia64/linux-xen/irq_ia64.c xen/arch/ia64/xen/acpi.c xen/arch/ia64/xen/irq.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/linux-xen/asm/iosapic.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/iosapic.c	Wed Jun 21 10:40:20 2006 -0600
     1.2 +++ b/xen/arch/ia64/linux-xen/iosapic.c	Wed Jun 21 11:15:08 2006 -0600
     1.3 @@ -1185,6 +1185,7 @@ int iosapic_guest_write(unsigned long ph
     1.4  
     1.5  	/* Sanity check. Vector should be allocated before this update */
     1.6  	if ((rte_index > ios->num_rte) ||
     1.7 +	    test_bit(vec, ia64_xen_vector) ||
     1.8  	    ((vec > IA64_FIRST_DEVICE_VECTOR) &&
     1.9  	     (vec < IA64_LAST_DEVICE_VECTOR) &&
    1.10  	     (!test_bit(vec - IA64_FIRST_DEVICE_VECTOR, ia64_vector_mask))))
     2.1 --- a/xen/arch/ia64/linux-xen/irq_ia64.c	Wed Jun 21 10:40:20 2006 -0600
     2.2 +++ b/xen/arch/ia64/linux-xen/irq_ia64.c	Wed Jun 21 11:15:08 2006 -0600
     2.3 @@ -233,6 +233,10 @@ static struct irqaction ipi_irqaction = 
     2.4  };
     2.5  #endif
     2.6  
     2.7 +#ifdef XEN
     2.8 +extern void setup_vector (unsigned int vec, struct irqaction *action);
     2.9 +#endif
    2.10 +
    2.11  void
    2.12  register_percpu_irq (ia64_vector vec, struct irqaction *action)
    2.13  {
    2.14 @@ -245,7 +249,11 @@ register_percpu_irq (ia64_vector vec, st
    2.15  			desc->status |= IRQ_PER_CPU;
    2.16  			desc->handler = &irq_type_ia64_lsapic;
    2.17  			if (action)
    2.18 +#ifdef XEN
    2.19 +				setup_vector(irq, action);
    2.20 +#else
    2.21  				setup_irq(irq, action);
    2.22 +#endif
    2.23  		}
    2.24  }
    2.25  
     3.1 --- a/xen/arch/ia64/xen/acpi.c	Wed Jun 21 10:40:20 2006 -0600
     3.2 +++ b/xen/arch/ia64/xen/acpi.c	Wed Jun 21 11:15:08 2006 -0600
     3.3 @@ -50,7 +50,7 @@
     3.4  #include <asm/system.h>
     3.5  #include <asm/numa.h>
     3.6  #include <asm/sal.h>
     3.7 -//#include <asm/cyclone.h>
     3.8 +#include <asm/hw_irq.h>
     3.9  
    3.10  #define BAD_MADT_ENTRY(entry, end) (                                        \
    3.11  		(!entry) || (unsigned long)entry + sizeof(*entry) > end ||  \
    3.12 @@ -650,7 +650,7 @@ acpi_boot_init (void)
    3.13  	printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus);
    3.14  	return 0;
    3.15  }
    3.16 -#if 0
    3.17 +
    3.18  int
    3.19  acpi_gsi_to_irq (u32 gsi, unsigned int *irq)
    3.20  {
    3.21 @@ -667,7 +667,7 @@ acpi_gsi_to_irq (u32 gsi, unsigned int *
    3.22  	}
    3.23  	return 0;
    3.24  }
    3.25 -
    3.26 +#if 0
    3.27  int
    3.28  acpi_register_irq (u32 gsi, u32 polarity, u32 trigger)
    3.29  {
     4.1 --- a/xen/arch/ia64/xen/irq.c	Wed Jun 21 10:40:20 2006 -0600
     4.2 +++ b/xen/arch/ia64/xen/irq.c	Wed Jun 21 11:15:08 2006 -0600
     4.3 @@ -125,17 +125,6 @@ inline void synchronize_irq(unsigned int
     4.4  EXPORT_SYMBOL(synchronize_irq);
     4.5  #endif
     4.6  
     4.7 -static int noirqdebug;
     4.8 -
     4.9 -static int __init noirqdebug_setup(char *str)
    4.10 -{
    4.11 -	noirqdebug = 1;
    4.12 -	printk("IRQ lockup detection disabled\n");
    4.13 -	return 1;
    4.14 -}
    4.15 -
    4.16 -__setup("noirqdebug", noirqdebug_setup);
    4.17 -
    4.18  /*
    4.19   * Generic enable/disable code: this just calls
    4.20   * down into the PIC-specific version for the actual
    4.21 @@ -232,122 +221,6 @@ out:
    4.22  	return 1;
    4.23  }
    4.24  
    4.25 -/**
    4.26 - *	request_irq - allocate an interrupt line
    4.27 - *	@irq: Interrupt line to allocate
    4.28 - *	@handler: Function to be called when the IRQ occurs
    4.29 - *	@irqflags: Interrupt type flags
    4.30 - *	@devname: An ascii name for the claiming device
    4.31 - *	@dev_id: A cookie passed back to the handler function
    4.32 - *
    4.33 - *	This call allocates interrupt resources and enables the
    4.34 - *	interrupt line and IRQ handling. From the point this
    4.35 - *	call is made your handler function may be invoked. Since
    4.36 - *	your handler function must clear any interrupt the board 
    4.37 - *	raises, you must take care both to initialise your hardware
    4.38 - *	and to set up the interrupt handler in the right order.
    4.39 - *
    4.40 - *	Dev_id must be globally unique. Normally the address of the
    4.41 - *	device data structure is used as the cookie. Since the handler
    4.42 - *	receives this value it makes sense to use it.
    4.43 - *
    4.44 - *	If your interrupt is shared you must pass a non NULL dev_id
    4.45 - *	as this is required when freeing the interrupt.
    4.46 - *
    4.47 - *	Flags:
    4.48 - *
    4.49 - *	SA_SHIRQ		Interrupt is shared
    4.50 - *
    4.51 - *	SA_INTERRUPT		Disable local interrupts while processing
    4.52 - *
    4.53 - *	SA_SAMPLE_RANDOM	The interrupt can be used for entropy
    4.54 - *
    4.55 - */
    4.56 -
    4.57 -int request_irq(unsigned int irq,
    4.58 -		irqreturn_t (*handler)(int, void *, struct pt_regs *),
    4.59 -		unsigned long irqflags,
    4.60 -		const char * devname,
    4.61 -		void *dev_id)
    4.62 -{
    4.63 -	int retval;
    4.64 -	struct irqaction * action;
    4.65 -
    4.66 -	/*
    4.67 -	 * Sanity-check: shared interrupts should REALLY pass in
    4.68 -	 * a real dev-ID, otherwise we'll have trouble later trying
    4.69 -	 * to figure out which interrupt is which (messes up the
    4.70 -	 * interrupt freeing logic etc).
    4.71 -	 */
    4.72 -	if (irqflags & SA_SHIRQ) {
    4.73 -		if (!dev_id)
    4.74 -			printk(KERN_ERR "Bad boy: %s called us without a dev_id!\n", devname);
    4.75 -	}
    4.76 -
    4.77 -	if (irq >= NR_IRQS)
    4.78 -		return -EINVAL;
    4.79 -	if (!handler)
    4.80 -		return -EINVAL;
    4.81 -
    4.82 -	action = xmalloc(struct irqaction);
    4.83 -	if (!action)
    4.84 -		return -ENOMEM;
    4.85 -
    4.86 -	action->handler = (void *) handler;
    4.87 -	action->name = devname;
    4.88 -	action->dev_id = dev_id;
    4.89 -
    4.90 -	retval = setup_irq(irq, action);
    4.91 -	if (retval)
    4.92 -		xfree(action);
    4.93 -	return retval;
    4.94 -}
    4.95 -
    4.96 -EXPORT_SYMBOL(request_irq);
    4.97 -
    4.98 -/**
    4.99 - *	free_irq - free an interrupt
   4.100 - *	@irq: Interrupt line to free
   4.101 - *	@dev_id: Device identity to free
   4.102 - *
   4.103 - *	Remove an interrupt handler. The handler is removed and if the
   4.104 - *	interrupt line is no longer in use by any driver it is disabled.
   4.105 - *	On a shared IRQ the caller must ensure the interrupt is disabled
   4.106 - *	on the card it drives before calling this function. The function
   4.107 - *	does not return until any executing interrupts for this IRQ
   4.108 - *	have completed.
   4.109 - *
   4.110 - *	This function must not be called from interrupt context.
   4.111 - */
   4.112 -
   4.113 -void free_irq(unsigned int irq)
   4.114 -{
   4.115 -	irq_desc_t *desc;
   4.116 -	unsigned long flags;
   4.117 -
   4.118 -	if (irq >= NR_IRQS)
   4.119 -		return;
   4.120 -
   4.121 -	desc = irq_descp(irq);
   4.122 -	spin_lock_irqsave(&desc->lock,flags);
   4.123 -	if (desc->action) {
   4.124 -		struct irqaction * action = desc->action;
   4.125 -		desc->action = NULL;
   4.126 -				desc->status |= IRQ_DISABLED;
   4.127 -				desc->handler->shutdown(irq);
   4.128 -			spin_unlock_irqrestore(&desc->lock,flags);
   4.129 -
   4.130 -			/* Wait to make sure it's not being used on another CPU */
   4.131 -			synchronize_irq(irq);
   4.132 -			xfree(action);
   4.133 -			return;
   4.134 -		}
   4.135 -		printk(KERN_ERR "Trying to free free IRQ%d\n",irq);
   4.136 -		spin_unlock_irqrestore(&desc->lock,flags);
   4.137 -}
   4.138 -
   4.139 -EXPORT_SYMBOL(free_irq);
   4.140 -
   4.141  /*
   4.142   * IRQ autodetection code..
   4.143   *
   4.144 @@ -357,12 +230,15 @@ EXPORT_SYMBOL(free_irq);
   4.145   * disabled.
   4.146   */
   4.147  
   4.148 -int setup_irq(unsigned int irq, struct irqaction * new)
   4.149 +int setup_vector(unsigned int irq, struct irqaction * new)
   4.150  {
   4.151  	unsigned long flags;
   4.152  	struct irqaction *old, **p;
   4.153  	irq_desc_t *desc = irq_descp(irq);
   4.154  
   4.155 +	printf ("setup_vector(%d): handler=%p, flags=%x\n",
   4.156 +		irq, desc->handler, desc->status);
   4.157 +
   4.158  	/*
   4.159  	 * The following block of code has to be executed atomically
   4.160  	 */
   4.161 @@ -378,11 +254,30 @@ int setup_irq(unsigned int irq, struct i
   4.162  	desc->depth = 0;
   4.163  	desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_GUEST);
   4.164  	desc->handler->startup(irq);
   4.165 +	desc->handler->enable(irq);
   4.166  	spin_unlock_irqrestore(&desc->lock,flags);
   4.167  
   4.168  	return 0;
   4.169  }
   4.170  
   4.171 +/* Vectors reserved by xen (and thus not sharable with domains).  */
   4.172 +unsigned long ia64_xen_vector[BITS_TO_LONGS(NR_IRQS)];
   4.173 +
   4.174 +int setup_irq(unsigned int irq, struct irqaction * new)
   4.175 +{
   4.176 +	unsigned int vec;
   4.177 +	int res;
   4.178 +
   4.179 +	/* Get vector for IRQ.  */
   4.180 +	if (acpi_gsi_to_irq (irq, &vec) < 0)
   4.181 +		return -ENOSYS;
   4.182 +	/* Reserve the vector (and thus the irq).  */
   4.183 +	if (test_and_set_bit(vec, ia64_xen_vector))
   4.184 +		return -EBUSY;
   4.185 +	res = setup_vector (vec, new);
   4.186 +	return res;
   4.187 +}
   4.188 +
   4.189  /*
   4.190   * HANDLING OF GUEST-BOUND PHYSICAL IRQS
   4.191   */
   4.192 @@ -622,15 +517,3 @@ void guest_forward_keyboard_input(int ir
   4.193  {
   4.194  	vcpu_pend_interrupt(dom0->vcpu[0],irq);
   4.195  }
   4.196 -
   4.197 -void serial_input_init(void)
   4.198 -{
   4.199 -	int retval;
   4.200 -	int irq = 0x30;	// FIXME
   4.201 -
   4.202 -	retval = request_irq(irq,guest_forward_keyboard_input,SA_INTERRUPT,"siminput",NULL);
   4.203 -	if (retval) {
   4.204 -		printk("serial_input_init: broken request_irq call\n");
   4.205 -		while(1);
   4.206 -	}
   4.207 -}
     5.1 --- a/xen/arch/ia64/xen/xensetup.c	Wed Jun 21 10:40:20 2006 -0600
     5.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed Jun 21 11:15:08 2006 -0600
     5.3 @@ -40,9 +40,9 @@ cpumask_t cpu_present_map;
     5.4  extern unsigned long domain0_ready;
     5.5  
     5.6  int find_max_pfn (unsigned long, unsigned long, void *);
     5.7 -void start_of_day(void);
     5.8  
     5.9  /* FIXME: which header these declarations should be there ? */
    5.10 +extern void initialize_keytable(void);
    5.11  extern long is_platform_hp_ski(void);
    5.12  extern void early_setup_arch(char **);
    5.13  extern void late_setup_arch(char **);
    5.14 @@ -61,6 +61,12 @@ boolean_param("nosmp", opt_nosmp);
    5.15  static unsigned int max_cpus = NR_CPUS;
    5.16  integer_param("maxcpus", max_cpus); 
    5.17  
    5.18 +/* xencons: if true enable xenconsole input (and irq).
    5.19 +   Note: you have to disable 8250 serials in domains (to avoid use of the
    5.20 +   same resource).  */
    5.21 +static int opt_xencons = 0;
    5.22 +boolean_param("xencons", opt_xencons);
    5.23 +
    5.24  /*
    5.25   * opt_xenheap_megabytes: Size of Xen heap in megabytes, including:
    5.26   *	xen image
    5.27 @@ -231,7 +237,7 @@ md_overlaps(efi_memory_desc_t *md, unsig
    5.28  
    5.29  void start_kernel(void)
    5.30  {
    5.31 -    unsigned char *cmdline;
    5.32 +    char *cmdline;
    5.33      void *heap_start;
    5.34      unsigned long nr_pages;
    5.35      unsigned long dom0_memory_start, dom0_memory_size;
    5.36 @@ -247,7 +253,7 @@ void start_kernel(void)
    5.37      /* Kernel may be relocated by EFI loader */
    5.38      xen_pstart = ia64_tpa(KERNEL_START);
    5.39  
    5.40 -    early_setup_arch((char **) &cmdline);
    5.41 +    early_setup_arch(&cmdline);
    5.42  
    5.43      /* We initialise the serial devices very early so we can get debugging. */
    5.44      if (running_on_sim) hpsim_serial_init();
    5.45 @@ -414,23 +420,16 @@ printk("About to call scheduler_init()\n
    5.46      idle_domain = domain_create(IDLE_DOMAIN_ID, 0);
    5.47      BUG_ON(idle_domain == NULL);
    5.48  
    5.49 -    late_setup_arch((char **) &cmdline);
    5.50 +    late_setup_arch(&cmdline);
    5.51      alloc_dom_xen_and_dom_io();
    5.52      setup_per_cpu_areas();
    5.53      mem_init();
    5.54  
    5.55      local_irq_disable();
    5.56      init_IRQ ();
    5.57 -printk("About to call init_xen_time()\n");
    5.58      init_xen_time(); /* initialise the time */
    5.59 -printk("About to call timer_init()\n");
    5.60      timer_init();
    5.61  
    5.62 -#ifdef CONFIG_XEN_CONSOLE_INPUT	/* CONFIG_SERIAL_8250_CONSOLE=n in dom0! */
    5.63 -    initialize_keytable();
    5.64 -    serial_init_postirq();
    5.65 -#endif
    5.66 -
    5.67  #ifdef CONFIG_SMP
    5.68      if ( opt_nosmp )
    5.69      {
    5.70 @@ -475,8 +474,14 @@ printk("num_online_cpus=%d, max_cpus=%d\
    5.71  printk("About to call sort_main_extable()\n");
    5.72      sort_main_extable();
    5.73  
    5.74 +    init_rid_allocator ();
    5.75  
    5.76 -    init_rid_allocator ();
    5.77 +    local_irq_enable();
    5.78 +
    5.79 +    if (opt_xencons) {
    5.80 +	    initialize_keytable();
    5.81 +	    serial_init_postirq();
    5.82 +    }
    5.83  
    5.84      /* Create initial domain 0. */
    5.85  printk("About to call domain_create()\n");
    5.86 @@ -512,14 +517,11 @@ printk("About to call init_trace_bufs()\
    5.87      init_trace_bufs();
    5.88  
    5.89      /* Give up the VGA console if DOM0 is configured to grab it. */
    5.90 -#ifdef CONFIG_XEN_CONSOLE_INPUT	/* CONFIG_SERIAL_8250_CONSOLE=n in dom0! */
    5.91 -    console_endboot(cmdline && strstr(cmdline, "tty0"));
    5.92 -#endif
    5.93 +    if (opt_xencons)
    5.94 +	console_endboot(cmdline && strstr(cmdline, "tty0"));
    5.95  
    5.96      domain0_ready = 1;
    5.97  
    5.98 -    local_irq_enable();
    5.99 -
   5.100      printf("About to call schedulers_start dom0=%p, idle_dom=%p\n",
   5.101  	   dom0, idle_domain);
   5.102      schedulers_start();
     6.1 --- a/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Wed Jun 21 10:40:20 2006 -0600
     6.2 +++ b/xen/include/asm-ia64/linux-xen/asm/iosapic.h	Wed Jun 21 11:15:08 2006 -0600
     6.3 @@ -158,6 +158,7 @@ struct rte_entry {
     6.4  
     6.5  #define IOSAPIC_RTEINDEX(reg)	(((reg) - 0x10) >> 1)
     6.6  extern unsigned long ia64_vector_mask[];
     6.7 +extern unsigned long ia64_xen_vector[];
     6.8  #endif /* XEN */
     6.9  
    6.10  # endif /* !__ASSEMBLY__ */