ia64/xen-unstable

view xen/arch/ia64/xen/sn_console.c @ 16785:af3550f53874

[IA64] domheap: Don't pin xenheap down. Now it's unnecessary.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents 40542d29da2b
children
line source
1 /*
2 * C-Brick Serial Port (and console) driver for SGI Altix machines.
3 *
4 * Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
5 */
7 #include <xen/lib.h>
8 #include <asm/acpi.h>
9 #include <asm/sn/sn_sal.h>
10 #include <xen/serial.h>
11 #include <xen/sched.h>
13 struct sn_console_data {
14 struct timer timer;
15 unsigned int timeout_ms;
16 int booted;
17 };
19 static struct sn_console_data console_data = {
20 .timeout_ms = 8 * 16 * 1000 / 9600,
21 };
24 /*
25 * sn_putc - Send a character to the console, polled or interrupt mode
26 */
27 static void sn_putc(struct serial_port *port, char c)
28 {
29 struct sn_console_data *sndata = port->uart;
31 if (sndata->booted)
32 ia64_sn_console_putb(&c, 1);
33 else
34 ia64_sn_console_putc(c);
35 }
37 /*
38 * sn_getc - Get a character from the console, polled or interrupt mode
39 */
40 static int sn_getc(struct serial_port *port, char *pc)
41 {
42 int ch;
44 ia64_sn_console_getc(&ch);
45 *pc = ch & 0xff;
46 return 1;
47 }
49 static void sn_endboot(struct serial_port *port)
50 {
51 struct sn_console_data *sndata = port->uart;
53 sndata->booted = 1;
54 }
57 static void sn_poll(void *data)
58 {
59 int ch, status;
60 struct serial_port *port = data;
61 struct sn_console_data *sndata = port->uart;
62 struct cpu_user_regs *regs = guest_cpu_user_regs();
64 status = ia64_sn_console_check(&ch);
65 if (!status && ch) {
66 serial_rx_interrupt(port, regs);
67 }
68 set_timer(&sndata->timer, NOW() + MILLISECS(sndata->timeout_ms));
69 }
72 static void sn_init_postirq(struct serial_port *port)
73 {
74 struct sn_console_data *sndata = port->uart;
76 init_timer(&sndata->timer, sn_poll, port, 0);
77 set_timer(&sndata->timer, NOW() + MILLISECS(console_data.timeout_ms));
78 }
81 static struct uart_driver sn_sal_console = {
82 .init_postirq = sn_init_postirq,
83 .putc = sn_putc,
84 .getc = sn_getc,
85 .endboot = sn_endboot,
86 };
89 /**
90 * early_sn_setup - early setup routine for SN platforms
91 *
92 * pulled from arch/ia64/sn/kernel/setup.c
93 */
94 static void __init early_sn_setup(void)
95 {
96 efi_system_table_t *efi_systab;
97 efi_config_table_t *config_tables;
98 struct ia64_sal_systab *sal_systab;
99 struct ia64_sal_desc_entry_point *ep;
100 char *p;
101 int i, j;
103 /*
104 * Parse enough of the SAL tables to locate the SAL entry point. Since, console
105 * IO on SN2 is done via SAL calls, early_printk won't work without this.
106 *
107 * This code duplicates some of the ACPI table parsing that is in efi.c & sal.c.
108 * Any changes to those file may have to be made hereas well.
109 */
110 efi_systab = (efi_system_table_t *) __va(ia64_boot_param->efi_systab);
111 config_tables = __va(efi_systab->tables);
112 for (i = 0; i < efi_systab->nr_tables; i++) {
113 if (!efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID)) {
114 sal_systab = __va(config_tables[i].table);
115 p = (char *)(sal_systab + 1);
116 for (j = 0; j < sal_systab->entry_count; j++) {
117 if (*p == SAL_DESC_ENTRY_POINT) {
118 ep = (struct ia64_sal_desc_entry_point
119 *)p;
120 ia64_sal_handler_init(__va
121 (ep->sal_proc),
122 __va(ep->gp));
123 return;
124 }
125 p += SAL_DESC_SIZE(*p);
126 }
127 }
128 }
129 /* Uh-oh, SAL not available?? */
130 printk(KERN_ERR "failed to find SAL entry point\n");
131 }
133 /**
134 * sn_serial_console_early_setup - Sets up early console output support
135 *
136 * pulled from drivers/serial/sn_console.c
137 */
138 int __init sn_serial_console_early_setup(void)
139 {
140 if (strcmp("sn2", acpi_get_sysname()))
141 return -1;
143 early_sn_setup(); /* Find SAL entry points */
144 serial_register_uart(0, &sn_sal_console, &console_data);
146 return 0;
147 }