ia64/linux-2.6.18-xen.hg

view drivers/char/hvc_vio.c @ 893:f994bfe9b93b

linux/blktap2: reduce TLB flush scope

c/s 885 added very coarse TLB flushing. Since these flushes always
follow single page updates, single page flushes (when available) are
sufficient.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jun 04 10:32:57 2009 +0100 (2009-06-04)
parents 831230e53067
children
line source
1 /*
2 * vio driver interface to hvc_console.c
3 *
4 * This code was moved here to allow the remaing code to be reused as a
5 * generic polling mode with semi-reliable transport driver core to the
6 * console and tty subsystems.
7 *
8 *
9 * Copyright (C) 2001 Anton Blanchard <anton@au.ibm.com>, IBM
10 * Copyright (C) 2001 Paul Mackerras <paulus@au.ibm.com>, IBM
11 * Copyright (C) 2004 Benjamin Herrenschmidt <benh@kernel.crashing.org>, IBM Corp.
12 * Copyright (C) 2004 IBM Corporation
13 *
14 * Additional Author(s):
15 * Ryan S. Arnold <rsa@us.ibm.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 */
32 #include <linux/types.h>
33 #include <linux/init.h>
35 #include <asm/hvconsole.h>
36 #include <asm/vio.h>
37 #include <asm/prom.h>
39 #include "hvc_console.h"
41 char hvc_driver_name[] = "hvc_console";
43 static struct vio_device_id hvc_driver_table[] __devinitdata = {
44 {"serial", "hvterm1"},
45 { "", "" }
46 };
47 MODULE_DEVICE_TABLE(vio, hvc_driver_table);
49 static int filtered_get_chars(uint32_t vtermno, char *buf, int count)
50 {
51 unsigned long got;
52 int i;
54 /*
55 * Vio firmware will read up to SIZE_VIO_GET_CHARS at its own discretion
56 * so we play safe and avoid the situation where got > count which could
57 * overload the flip buffer.
58 */
59 if (count < SIZE_VIO_GET_CHARS)
60 return -EAGAIN;
62 got = hvc_get_chars(vtermno, buf, count);
64 /*
65 * Work around a HV bug where it gives us a null
66 * after every \r. -- paulus
67 */
68 for (i = 1; i < got; ++i) {
69 if (buf[i] == 0 && buf[i-1] == '\r') {
70 --got;
71 if (i < got)
72 memmove(&buf[i], &buf[i+1],
73 got - i);
74 }
75 }
76 return got;
77 }
79 static struct hv_ops hvc_get_put_ops = {
80 .get_chars = filtered_get_chars,
81 .put_chars = hvc_put_chars,
82 };
84 static int __devinit hvc_vio_probe(struct vio_dev *vdev,
85 const struct vio_device_id *id)
86 {
87 struct hvc_struct *hp;
89 /* probed with invalid parameters. */
90 if (!vdev || !id)
91 return -EPERM;
93 hp = hvc_alloc(vdev->unit_address, vdev->irq, &hvc_get_put_ops);
94 if (IS_ERR(hp))
95 return PTR_ERR(hp);
96 dev_set_drvdata(&vdev->dev, hp);
98 return 0;
99 }
101 static int __devexit hvc_vio_remove(struct vio_dev *vdev)
102 {
103 struct hvc_struct *hp = dev_get_drvdata(&vdev->dev);
105 return hvc_remove(hp);
106 }
108 static struct vio_driver hvc_vio_driver = {
109 .id_table = hvc_driver_table,
110 .probe = hvc_vio_probe,
111 .remove = hvc_vio_remove,
112 .driver = {
113 .name = hvc_driver_name,
114 .owner = THIS_MODULE,
115 }
116 };
118 static int hvc_vio_init(void)
119 {
120 int rc;
122 /* Register as a vio device to receive callbacks */
123 rc = vio_register_driver(&hvc_vio_driver);
125 return rc;
126 }
127 module_init(hvc_vio_init); /* after drivers/char/hvc_console.c */
129 static void hvc_vio_exit(void)
130 {
131 vio_unregister_driver(&hvc_vio_driver);
132 }
133 module_exit(hvc_vio_exit);
135 /* the device tree order defines our numbering */
136 static int hvc_find_vtys(void)
137 {
138 struct device_node *vty;
139 int num_found = 0;
141 for (vty = of_find_node_by_name(NULL, "vty"); vty != NULL;
142 vty = of_find_node_by_name(vty, "vty")) {
143 uint32_t *vtermno;
145 /* We have statically defined space for only a certain number
146 * of console adapters.
147 */
148 if (num_found >= MAX_NR_HVC_CONSOLES)
149 break;
151 vtermno = (uint32_t *)get_property(vty, "reg", NULL);
152 if (!vtermno)
153 continue;
155 if (device_is_compatible(vty, "hvterm1")) {
156 hvc_instantiate(*vtermno, num_found, &hvc_get_put_ops);
157 ++num_found;
158 }
159 }
161 return num_found;
162 }
163 console_initcall(hvc_find_vtys);