ia64/xen-unstable

changeset 15133:40542d29da2b

[IA64] SN2 polling console driver

First cut of super simple console driver with polled input support. In
addition switch driver to use ia64_sn_console_putb() post-boot to get
interactive response.

Signed-off-by: Jes Sorensen <jes@sgi.com>
author Alex Williamson <alex.williamson@hp.com>
date Thu May 24 14:13:58 2007 -0600 (2007-05-24)
parents 03e04b861d91
children 466f71b1e831
files xen/arch/ia64/xen/sn_console.c
line diff
     1.1 --- a/xen/arch/ia64/xen/sn_console.c	Wed May 23 10:40:19 2007 -0600
     1.2 +++ b/xen/arch/ia64/xen/sn_console.c	Thu May 24 14:13:58 2007 -0600
     1.3 @@ -8,19 +8,84 @@
     1.4  #include <asm/acpi.h>
     1.5  #include <asm/sn/sn_sal.h>
     1.6  #include <xen/serial.h>
     1.7 +#include <xen/sched.h>
     1.8 +
     1.9 +struct sn_console_data {
    1.10 +	struct timer timer;
    1.11 +	unsigned int timeout_ms;
    1.12 +	int booted;
    1.13 +};
    1.14 +
    1.15 +static struct sn_console_data console_data = {
    1.16 +	.timeout_ms = 8 * 16 * 1000 / 9600,
    1.17 +};
    1.18 +
    1.19  
    1.20  /*
    1.21   * sn_putc - Send a character to the console, polled or interrupt mode
    1.22   */
    1.23  static void sn_putc(struct serial_port *port, char c)
    1.24  {
    1.25 -	ia64_sn_console_putc(c);
    1.26 +	struct sn_console_data *sndata = port->uart;
    1.27 +
    1.28 +	if (sndata->booted)
    1.29 +		ia64_sn_console_putb(&c, 1);
    1.30 +	else
    1.31 +		ia64_sn_console_putc(c);
    1.32 +}
    1.33 +
    1.34 +/*
    1.35 + * sn_getc - Get a character from the console, polled or interrupt mode
    1.36 + */
    1.37 +static int sn_getc(struct serial_port *port, char *pc)
    1.38 +{
    1.39 +	int ch;
    1.40 +
    1.41 +	ia64_sn_console_getc(&ch);
    1.42 +	*pc = ch & 0xff;
    1.43 +	return 1;
    1.44 +}
    1.45 +
    1.46 +static void sn_endboot(struct serial_port *port)
    1.47 +{
    1.48 +	struct sn_console_data *sndata = port->uart;
    1.49 +
    1.50 +	sndata->booted = 1;
    1.51  }
    1.52  
    1.53 +
    1.54 +static void sn_poll(void *data)
    1.55 +{
    1.56 +	int ch, status;
    1.57 +	struct serial_port *port = data;
    1.58 +	struct sn_console_data *sndata = port->uart;
    1.59 +	struct cpu_user_regs *regs = guest_cpu_user_regs();
    1.60 +
    1.61 +	status = ia64_sn_console_check(&ch);
    1.62 +	if (!status && ch) {
    1.63 +		serial_rx_interrupt(port, regs);
    1.64 +	}
    1.65 +	set_timer(&sndata->timer, NOW() + MILLISECS(sndata->timeout_ms));
    1.66 +}
    1.67 +
    1.68 +
    1.69 +static void sn_init_postirq(struct serial_port *port)
    1.70 +{
    1.71 +	struct sn_console_data *sndata = port->uart;
    1.72 +
    1.73 +        init_timer(&sndata->timer, sn_poll, port, 0);
    1.74 +        set_timer(&sndata->timer, NOW() + MILLISECS(console_data.timeout_ms));
    1.75 +}
    1.76 +
    1.77 +
    1.78  static struct uart_driver sn_sal_console = {
    1.79 +	.init_postirq = sn_init_postirq,
    1.80  	.putc = sn_putc,
    1.81 +	.getc = sn_getc,
    1.82 +	.endboot = sn_endboot,
    1.83  };
    1.84  
    1.85 +
    1.86  /**
    1.87   * early_sn_setup - early setup routine for SN platforms
    1.88   *
    1.89 @@ -45,8 +110,7 @@ static void __init early_sn_setup(void)
    1.90  	efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab);
    1.91  	config_tables = __va(efi_systab->tables);
    1.92  	for (i = 0; i < efi_systab->nr_tables; i++) {
    1.93 -		if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) ==
    1.94 -		    0) {
    1.95 +		if (!efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID)) {
    1.96  			sal_systab = __va(config_tables[i].table);
    1.97  			p = (char *)(sal_systab + 1);
    1.98  			for (j = 0; j < sal_systab->entry_count; j++) {
    1.99 @@ -73,11 +137,11 @@ static void __init early_sn_setup(void)
   1.100   */
   1.101  int __init sn_serial_console_early_setup(void)
   1.102  {
   1.103 -	if (strcmp("sn2",acpi_get_sysname()))
   1.104 +	if (strcmp("sn2", acpi_get_sysname()))
   1.105  		return -1;
   1.106  
   1.107  	early_sn_setup();	/* Find SAL entry points */
   1.108 -	serial_register_uart(0, &sn_sal_console, NULL);
   1.109 +	serial_register_uart(0, &sn_sal_console, &console_data);
   1.110  
   1.111  	return 0;
   1.112  }