# HG changeset patch # User gingold@virtu10 # Node ID 10f04d1d52f294b5bf5af21ce476a784a56dfe09 # Parent 8314141cfe543d0e83b15a6eca9569df4b82a0b2 Makes xen serial console working in input. You need to add 'xencons=y' 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 diff -r 8314141cfe54 -r 10f04d1d52f2 xen/arch/ia64/linux-xen/iosapic.c --- a/xen/arch/ia64/linux-xen/iosapic.c Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/arch/ia64/linux-xen/iosapic.c Wed Jun 21 14:30:49 2006 +0200 @@ -1185,6 +1185,7 @@ int iosapic_guest_write(unsigned long ph /* Sanity check. Vector should be allocated before this update */ if ((rte_index > ios->num_rte) || + test_bit(vec, ia64_xen_vector) || ((vec > IA64_FIRST_DEVICE_VECTOR) && (vec < IA64_LAST_DEVICE_VECTOR) && (!test_bit(vec - IA64_FIRST_DEVICE_VECTOR, ia64_vector_mask)))) diff -r 8314141cfe54 -r 10f04d1d52f2 xen/arch/ia64/linux-xen/irq_ia64.c --- a/xen/arch/ia64/linux-xen/irq_ia64.c Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/arch/ia64/linux-xen/irq_ia64.c Wed Jun 21 14:30:49 2006 +0200 @@ -233,6 +233,10 @@ static struct irqaction ipi_irqaction = }; #endif +#ifdef XEN +extern void setup_vector (unsigned int vec, struct irqaction *action); +#endif + void register_percpu_irq (ia64_vector vec, struct irqaction *action) { @@ -245,7 +249,11 @@ register_percpu_irq (ia64_vector vec, st desc->status |= IRQ_PER_CPU; desc->handler = &irq_type_ia64_lsapic; if (action) +#ifdef XEN + setup_vector(irq, action); +#else setup_irq(irq, action); +#endif } } diff -r 8314141cfe54 -r 10f04d1d52f2 xen/arch/ia64/xen/acpi.c --- a/xen/arch/ia64/xen/acpi.c Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/arch/ia64/xen/acpi.c Wed Jun 21 14:30:49 2006 +0200 @@ -50,7 +50,7 @@ #include #include #include -//#include +#include #define BAD_MADT_ENTRY(entry, end) ( \ (!entry) || (unsigned long)entry + sizeof(*entry) > end || \ @@ -650,7 +650,7 @@ acpi_boot_init (void) printk(KERN_INFO "%d CPUs available, %d CPUs total\n", available_cpus, total_cpus); return 0; } -#if 0 + int acpi_gsi_to_irq (u32 gsi, unsigned int *irq) { @@ -667,7 +667,7 @@ acpi_gsi_to_irq (u32 gsi, unsigned int * } return 0; } - +#if 0 int acpi_register_irq (u32 gsi, u32 polarity, u32 trigger) { diff -r 8314141cfe54 -r 10f04d1d52f2 xen/arch/ia64/xen/irq.c --- a/xen/arch/ia64/xen/irq.c Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/arch/ia64/xen/irq.c Wed Jun 21 14:30:49 2006 +0200 @@ -124,17 +124,6 @@ inline void synchronize_irq(unsigned int inline void synchronize_irq(unsigned int irq) {} EXPORT_SYMBOL(synchronize_irq); #endif - -static int noirqdebug; - -static int __init noirqdebug_setup(char *str) -{ - noirqdebug = 1; - printk("IRQ lockup detection disabled\n"); - return 1; -} - -__setup("noirqdebug", noirqdebug_setup); /* * Generic enable/disable code: this just calls @@ -232,122 +221,6 @@ out: return 1; } -/** - * request_irq - allocate an interrupt line - * @irq: Interrupt line to allocate - * @handler: Function to be called when the IRQ occurs - * @irqflags: Interrupt type flags - * @devname: An ascii name for the claiming device - * @dev_id: A cookie passed back to the handler function - * - * This call allocates interrupt resources and enables the - * interrupt line and IRQ handling. From the point this - * call is made your handler function may be invoked. Since - * your handler function must clear any interrupt the board - * raises, you must take care both to initialise your hardware - * and to set up the interrupt handler in the right order. - * - * Dev_id must be globally unique. Normally the address of the - * device data structure is used as the cookie. Since the handler - * receives this value it makes sense to use it. - * - * If your interrupt is shared you must pass a non NULL dev_id - * as this is required when freeing the interrupt. - * - * Flags: - * - * SA_SHIRQ Interrupt is shared - * - * SA_INTERRUPT Disable local interrupts while processing - * - * SA_SAMPLE_RANDOM The interrupt can be used for entropy - * - */ - -int request_irq(unsigned int irq, - irqreturn_t (*handler)(int, void *, struct pt_regs *), - unsigned long irqflags, - const char * devname, - void *dev_id) -{ - int retval; - struct irqaction * action; - - /* - * Sanity-check: shared interrupts should REALLY pass in - * a real dev-ID, otherwise we'll have trouble later trying - * to figure out which interrupt is which (messes up the - * interrupt freeing logic etc). - */ - if (irqflags & SA_SHIRQ) { - if (!dev_id) - printk(KERN_ERR "Bad boy: %s called us without a dev_id!\n", devname); - } - - if (irq >= NR_IRQS) - return -EINVAL; - if (!handler) - return -EINVAL; - - action = xmalloc(struct irqaction); - if (!action) - return -ENOMEM; - - action->handler = (void *) handler; - action->name = devname; - action->dev_id = dev_id; - - retval = setup_irq(irq, action); - if (retval) - xfree(action); - return retval; -} - -EXPORT_SYMBOL(request_irq); - -/** - * free_irq - free an interrupt - * @irq: Interrupt line to free - * @dev_id: Device identity to free - * - * Remove an interrupt handler. The handler is removed and if the - * interrupt line is no longer in use by any driver it is disabled. - * On a shared IRQ the caller must ensure the interrupt is disabled - * on the card it drives before calling this function. The function - * does not return until any executing interrupts for this IRQ - * have completed. - * - * This function must not be called from interrupt context. - */ - -void free_irq(unsigned int irq) -{ - irq_desc_t *desc; - unsigned long flags; - - if (irq >= NR_IRQS) - return; - - desc = irq_descp(irq); - spin_lock_irqsave(&desc->lock,flags); - if (desc->action) { - struct irqaction * action = desc->action; - desc->action = NULL; - desc->status |= IRQ_DISABLED; - desc->handler->shutdown(irq); - spin_unlock_irqrestore(&desc->lock,flags); - - /* Wait to make sure it's not being used on another CPU */ - synchronize_irq(irq); - xfree(action); - return; - } - printk(KERN_ERR "Trying to free free IRQ%d\n",irq); - spin_unlock_irqrestore(&desc->lock,flags); -} - -EXPORT_SYMBOL(free_irq); - /* * IRQ autodetection code.. * @@ -357,11 +230,14 @@ EXPORT_SYMBOL(free_irq); * disabled. */ -int setup_irq(unsigned int irq, struct irqaction * new) +int setup_vector(unsigned int irq, struct irqaction * new) { unsigned long flags; struct irqaction *old, **p; irq_desc_t *desc = irq_descp(irq); + + printf ("setup_vector(%d): handler=%p, flags=%x\n", + irq, desc->handler, desc->status); /* * The following block of code has to be executed atomically @@ -378,9 +254,28 @@ int setup_irq(unsigned int irq, struct i desc->depth = 0; desc->status &= ~(IRQ_DISABLED | IRQ_INPROGRESS | IRQ_GUEST); desc->handler->startup(irq); + desc->handler->enable(irq); spin_unlock_irqrestore(&desc->lock,flags); return 0; +} + +/* Vectors reserved by xen (and thus not sharable with domains). */ +unsigned long ia64_xen_vector[BITS_TO_LONGS(NR_IRQS)]; + +int setup_irq(unsigned int irq, struct irqaction * new) +{ + unsigned int vec; + int res; + + /* Get vector for IRQ. */ + if (acpi_gsi_to_irq (irq, &vec) < 0) + return -ENOSYS; + /* Reserve the vector (and thus the irq). */ + if (test_and_set_bit(vec, ia64_xen_vector)) + return -EBUSY; + res = setup_vector (vec, new); + return res; } /* @@ -622,15 +517,3 @@ void guest_forward_keyboard_input(int ir { vcpu_pend_interrupt(dom0->vcpu[0],irq); } - -void serial_input_init(void) -{ - int retval; - int irq = 0x30; // FIXME - - retval = request_irq(irq,guest_forward_keyboard_input,SA_INTERRUPT,"siminput",NULL); - if (retval) { - printk("serial_input_init: broken request_irq call\n"); - while(1); - } -} diff -r 8314141cfe54 -r 10f04d1d52f2 xen/arch/ia64/xen/xensetup.c --- a/xen/arch/ia64/xen/xensetup.c Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/arch/ia64/xen/xensetup.c Wed Jun 21 14:30:49 2006 +0200 @@ -40,9 +40,9 @@ extern unsigned long domain0_ready; extern unsigned long domain0_ready; int find_max_pfn (unsigned long, unsigned long, void *); -void start_of_day(void); /* FIXME: which header these declarations should be there ? */ +extern void initialize_keytable(void); extern long is_platform_hp_ski(void); extern void early_setup_arch(char **); extern void late_setup_arch(char **); @@ -60,6 +60,12 @@ boolean_param("nosmp", opt_nosmp); /* maxcpus: maximum number of CPUs to activate. */ static unsigned int max_cpus = NR_CPUS; integer_param("maxcpus", max_cpus); + +/* xencons: if true enable xenconsole input (and irq). + Note: you have to disable 8250 serials in domains (to avoid use of the + same resource). */ +static int opt_xencons = 0; +boolean_param("xencons", opt_xencons); /* * opt_xenheap_megabytes: Size of Xen heap in megabytes, including: @@ -231,7 +237,7 @@ md_overlaps(efi_memory_desc_t *md, unsig void start_kernel(void) { - unsigned char *cmdline; + char *cmdline; void *heap_start; unsigned long nr_pages; unsigned long dom0_memory_start, dom0_memory_size; @@ -247,7 +253,7 @@ void start_kernel(void) /* Kernel may be relocated by EFI loader */ xen_pstart = ia64_tpa(KERNEL_START); - early_setup_arch((char **) &cmdline); + early_setup_arch(&cmdline); /* We initialise the serial devices very early so we can get debugging. */ if (running_on_sim) hpsim_serial_init(); @@ -414,22 +420,15 @@ printk("About to call scheduler_init()\n idle_domain = domain_create(IDLE_DOMAIN_ID, 0); BUG_ON(idle_domain == NULL); - late_setup_arch((char **) &cmdline); + late_setup_arch(&cmdline); alloc_dom_xen_and_dom_io(); setup_per_cpu_areas(); mem_init(); local_irq_disable(); init_IRQ (); -printk("About to call init_xen_time()\n"); init_xen_time(); /* initialise the time */ -printk("About to call timer_init()\n"); timer_init(); - -#ifdef CONFIG_XEN_CONSOLE_INPUT /* CONFIG_SERIAL_8250_CONSOLE=n in dom0! */ - initialize_keytable(); - serial_init_postirq(); -#endif #ifdef CONFIG_SMP if ( opt_nosmp ) @@ -475,8 +474,14 @@ printk("About to call sort_main_extable( printk("About to call sort_main_extable()\n"); sort_main_extable(); - init_rid_allocator (); + + local_irq_enable(); + + if (opt_xencons) { + initialize_keytable(); + serial_init_postirq(); + } /* Create initial domain 0. */ printk("About to call domain_create()\n"); @@ -512,13 +517,9 @@ printk("About to call init_trace_bufs()\ init_trace_bufs(); /* Give up the VGA console if DOM0 is configured to grab it. */ -#ifdef CONFIG_XEN_CONSOLE_INPUT /* CONFIG_SERIAL_8250_CONSOLE=n in dom0! */ console_endboot(cmdline && strstr(cmdline, "tty0")); -#endif domain0_ready = 1; - - local_irq_enable(); printf("About to call schedulers_start dom0=%p, idle_dom=%p\n", dom0, idle_domain); diff -r 8314141cfe54 -r 10f04d1d52f2 xen/include/asm-ia64/linux-xen/asm/iosapic.h --- a/xen/include/asm-ia64/linux-xen/asm/iosapic.h Tue Jun 20 17:02:22 2006 -0600 +++ b/xen/include/asm-ia64/linux-xen/asm/iosapic.h Wed Jun 21 14:30:49 2006 +0200 @@ -158,6 +158,7 @@ struct rte_entry { #define IOSAPIC_RTEINDEX(reg) (((reg) - 0x10) >> 1) extern unsigned long ia64_vector_mask[]; +extern unsigned long ia64_xen_vector[]; #endif /* XEN */ # endif /* !__ASSEMBLY__ */