diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2010-01-18 08:44:55 -0500 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2010-02-23 22:52:30 -0500 |
commit | a23ea92474e558b071d3e43d961ec767c31faebd (patch) | |
tree | bb95ff6c72488e19fb624e3ee00263bcf66ac52c | |
parent | 3b8706240ee6084ccb46e53cd3a554356b7eeec8 (diff) |
virtio: console: comment cleanup
Remove old lguest-style comments.
[Amit: - wingify comments acc. to kernel style
- indent comments ]
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Amit Shah <amit.shah@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
-rw-r--r-- | drivers/char/virtio_console.c | 108 | ||||
-rw-r--r-- | include/linux/virtio_console.h | 6 |
2 files changed, 58 insertions, 56 deletions
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index a035ae39a359..26e238cd7d2f 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -1,18 +1,5 @@ | |||
1 | /*D:300 | 1 | /* |
2 | * The Guest console driver | 2 | * Copyright (C) 2006, 2007, 2009 Rusty Russell, IBM Corporation |
3 | * | ||
4 | * Writing console drivers is one of the few remaining Dark Arts in Linux. | ||
5 | * Fortunately for us, the path of virtual consoles has been well-trodden by | ||
6 | * the PowerPC folks, who wrote "hvc_console.c" to generically support any | ||
7 | * virtual console. We use that infrastructure which only requires us to write | ||
8 | * the basic put_chars and get_chars functions and call the right register | ||
9 | * functions. | ||
10 | :*/ | ||
11 | |||
12 | /*M:002 The console can be flooded: while the Guest is processing input the | ||
13 | * Host can send more. Buffering in the Host could alleviate this, but it is a | ||
14 | * difficult problem in general. :*/ | ||
15 | /* Copyright (C) 2006, 2007 Rusty Russell, IBM Corporation | ||
16 | * | 3 | * |
17 | * This program is free software; you can redistribute it and/or modify | 4 | * 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 | 5 | * it under the terms of the GNU General Public License as published by |
@@ -34,8 +21,6 @@ | |||
34 | #include <linux/virtio_console.h> | 21 | #include <linux/virtio_console.h> |
35 | #include "hvc_console.h" | 22 | #include "hvc_console.h" |
36 | 23 | ||
37 | /*D:340 These represent our input and output console queues, and the virtio | ||
38 | * operations for them. */ | ||
39 | static struct virtqueue *in_vq, *out_vq; | 24 | static struct virtqueue *in_vq, *out_vq; |
40 | static struct virtio_device *vdev; | 25 | static struct virtio_device *vdev; |
41 | 26 | ||
@@ -49,12 +34,14 @@ static struct hv_ops virtio_cons; | |||
49 | /* The hvc device */ | 34 | /* The hvc device */ |
50 | static struct hvc_struct *hvc; | 35 | static struct hvc_struct *hvc; |
51 | 36 | ||
52 | /*D:310 The put_chars() callback is pretty straightforward. | 37 | /* |
38 | * The put_chars() callback is pretty straightforward. | ||
53 | * | 39 | * |
54 | * We turn the characters into a scatter-gather list, add it to the output | 40 | * We turn the characters into a scatter-gather list, add it to the |
55 | * queue and then kick the Host. Then we sit here waiting for it to finish: | 41 | * output queue and then kick the Host. Then we sit here waiting for |
56 | * inefficient in theory, but in practice implementations will do it | 42 | * it to finish: inefficient in theory, but in practice |
57 | * immediately (lguest's Launcher does). */ | 43 | * implementations will do it immediately (lguest's Launcher does). |
44 | */ | ||
58 | static int put_chars(u32 vtermno, const char *buf, int count) | 45 | static int put_chars(u32 vtermno, const char *buf, int count) |
59 | { | 46 | { |
60 | struct scatterlist sg[1]; | 47 | struct scatterlist sg[1]; |
@@ -63,8 +50,10 @@ static int put_chars(u32 vtermno, const char *buf, int count) | |||
63 | /* This is a convenient routine to initialize a single-elem sg list */ | 50 | /* This is a convenient routine to initialize a single-elem sg list */ |
64 | sg_init_one(sg, buf, count); | 51 | sg_init_one(sg, buf, count); |
65 | 52 | ||
66 | /* add_buf wants a token to identify this buffer: we hand it any | 53 | /* |
67 | * non-NULL pointer, since there's only ever one buffer. */ | 54 | * add_buf wants a token to identify this buffer: we hand it |
55 | * any non-NULL pointer, since there's only ever one buffer. | ||
56 | */ | ||
68 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) >= 0) { | 57 | if (out_vq->vq_ops->add_buf(out_vq, sg, 1, 0, (void *)1) >= 0) { |
69 | /* Tell Host to go! */ | 58 | /* Tell Host to go! */ |
70 | out_vq->vq_ops->kick(out_vq); | 59 | out_vq->vq_ops->kick(out_vq); |
@@ -77,8 +66,10 @@ static int put_chars(u32 vtermno, const char *buf, int count) | |||
77 | return count; | 66 | return count; |
78 | } | 67 | } |
79 | 68 | ||
80 | /* Create a scatter-gather list representing our input buffer and put it in the | 69 | /* |
81 | * queue. */ | 70 | * Create a scatter-gather list representing our input buffer and put |
71 | * it in the queue. | ||
72 | */ | ||
82 | static void add_inbuf(void) | 73 | static void add_inbuf(void) |
83 | { | 74 | { |
84 | struct scatterlist sg[1]; | 75 | struct scatterlist sg[1]; |
@@ -90,12 +81,14 @@ static void add_inbuf(void) | |||
90 | in_vq->vq_ops->kick(in_vq); | 81 | in_vq->vq_ops->kick(in_vq); |
91 | } | 82 | } |
92 | 83 | ||
93 | /*D:350 get_chars() is the callback from the hvc_console infrastructure when | 84 | /* |
94 | * an interrupt is received. | 85 | * get_chars() is the callback from the hvc_console infrastructure |
86 | * when an interrupt is received. | ||
95 | * | 87 | * |
96 | * Most of the code deals with the fact that the hvc_console() infrastructure | 88 | * Most of the code deals with the fact that the hvc_console() |
97 | * only asks us for 16 bytes at a time. We keep in_offset and in_used fields | 89 | * infrastructure only asks us for 16 bytes at a time. We keep |
98 | * for partially-filled buffers. */ | 90 | * in_offset and in_used fields for partially-filled buffers. |
91 | */ | ||
99 | static int get_chars(u32 vtermno, char *buf, int count) | 92 | static int get_chars(u32 vtermno, char *buf, int count) |
100 | { | 93 | { |
101 | /* If we don't have an input queue yet, we can't get input. */ | 94 | /* If we don't have an input queue yet, we can't get input. */ |
@@ -123,14 +116,16 @@ static int get_chars(u32 vtermno, char *buf, int count) | |||
123 | 116 | ||
124 | return count; | 117 | return count; |
125 | } | 118 | } |
126 | /*:*/ | ||
127 | 119 | ||
128 | /*D:320 Console drivers are initialized very early so boot messages can go out, | 120 | /* |
129 | * so we do things slightly differently from the generic virtio initialization | 121 | * Console drivers are initialized very early so boot messages can go |
130 | * of the net and block drivers. | 122 | * out, so we do things slightly differently from the generic virtio |
123 | * initialization of the net and block drivers. | ||
131 | * | 124 | * |
132 | * At this stage, the console is output-only. It's too early to set up a | 125 | * At this stage, the console is output-only. It's too early to set |
133 | * virtqueue, so we let the drivers do some boutique early-output thing. */ | 126 | * up a virtqueue, so we let the drivers do some boutique early-output |
127 | * thing. | ||
128 | */ | ||
134 | int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | 129 | int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) |
135 | { | 130 | { |
136 | virtio_cons.put_chars = put_chars; | 131 | virtio_cons.put_chars = put_chars; |
@@ -157,8 +152,8 @@ static void virtcons_apply_config(struct virtio_device *dev) | |||
157 | } | 152 | } |
158 | 153 | ||
159 | /* | 154 | /* |
160 | * we support only one console, the hvc struct is a global var | 155 | * we support only one console, the hvc struct is a global var We set |
161 | * We set the configuration at this point, since we now have a tty | 156 | * the configuration at this point, since we now have a tty |
162 | */ | 157 | */ |
163 | static int notifier_add_vio(struct hvc_struct *hp, int data) | 158 | static int notifier_add_vio(struct hvc_struct *hp, int data) |
164 | { | 159 | { |
@@ -179,13 +174,17 @@ static void hvc_handle_input(struct virtqueue *vq) | |||
179 | hvc_kick(); | 174 | hvc_kick(); |
180 | } | 175 | } |
181 | 176 | ||
182 | /*D:370 Once we're further in boot, we get probed like any other virtio device. | 177 | /* |
183 | * At this stage we set up the output virtqueue. | 178 | * Once we're further in boot, we get probed like any other virtio |
179 | * device. At this stage we set up the output virtqueue. | ||
184 | * | 180 | * |
185 | * To set up and manage our virtual console, we call hvc_alloc(). Since we | 181 | * To set up and manage our virtual console, we call hvc_alloc(). |
186 | * never remove the console device we never need this pointer again. | 182 | * Since we never remove the console device we never need this pointer |
183 | * again. | ||
187 | * | 184 | * |
188 | * Finally we put our input buffer in the input queue, ready to receive. */ | 185 | * Finally we put our input buffer in the input queue, ready to |
186 | * receive. | ||
187 | */ | ||
189 | static int __devinit virtcons_probe(struct virtio_device *dev) | 188 | static int __devinit virtcons_probe(struct virtio_device *dev) |
190 | { | 189 | { |
191 | vq_callback_t *callbacks[] = { hvc_handle_input, NULL}; | 190 | vq_callback_t *callbacks[] = { hvc_handle_input, NULL}; |
@@ -203,8 +202,6 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
203 | } | 202 | } |
204 | 203 | ||
205 | /* Find the queues. */ | 204 | /* Find the queues. */ |
206 | /* FIXME: This is why we want to wean off hvc: we do nothing | ||
207 | * when input comes in. */ | ||
208 | err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names); | 205 | err = vdev->config->find_vqs(vdev, 2, vqs, callbacks, names); |
209 | if (err) | 206 | if (err) |
210 | goto free; | 207 | goto free; |
@@ -219,15 +216,18 @@ static int __devinit virtcons_probe(struct virtio_device *dev) | |||
219 | virtio_cons.notifier_del = notifier_del_vio; | 216 | virtio_cons.notifier_del = notifier_del_vio; |
220 | virtio_cons.notifier_hangup = notifier_del_vio; | 217 | virtio_cons.notifier_hangup = notifier_del_vio; |
221 | 218 | ||
222 | /* The first argument of hvc_alloc() is the virtual console number, so | 219 | /* |
223 | * we use zero. The second argument is the parameter for the | 220 | * The first argument of hvc_alloc() is the virtual console |
224 | * notification mechanism (like irq number). We currently leave this | 221 | * number, so we use zero. The second argument is the |
225 | * as zero, virtqueues have implicit notifications. | 222 | * parameter for the notification mechanism (like irq |
223 | * number). We currently leave this as zero, virtqueues have | ||
224 | * implicit notifications. | ||
226 | * | 225 | * |
227 | * The third argument is a "struct hv_ops" containing the put_chars() | 226 | * The third argument is a "struct hv_ops" containing the |
228 | * get_chars(), notifier_add() and notifier_del() pointers. | 227 | * put_chars(), get_chars(), notifier_add() and notifier_del() |
229 | * The final argument is the output buffer size: we can do any size, | 228 | * pointers. The final argument is the output buffer size: we |
230 | * so we put PAGE_SIZE here. */ | 229 | * can do any size, so we put PAGE_SIZE here. |
230 | */ | ||
231 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); | 231 | hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE); |
232 | if (IS_ERR(hvc)) { | 232 | if (IS_ERR(hvc)) { |
233 | err = PTR_ERR(hvc); | 233 | err = PTR_ERR(hvc); |
diff --git a/include/linux/virtio_console.h b/include/linux/virtio_console.h index fe885174cc1f..9e0da40beae0 100644 --- a/include/linux/virtio_console.h +++ b/include/linux/virtio_console.h | |||
@@ -3,8 +3,10 @@ | |||
3 | #include <linux/types.h> | 3 | #include <linux/types.h> |
4 | #include <linux/virtio_ids.h> | 4 | #include <linux/virtio_ids.h> |
5 | #include <linux/virtio_config.h> | 5 | #include <linux/virtio_config.h> |
6 | /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so | 6 | /* |
7 | * anyone can use the definitions to implement compatible drivers/servers. */ | 7 | * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so |
8 | * anyone can use the definitions to implement compatible drivers/servers. | ||
9 | */ | ||
8 | 10 | ||
9 | /* Feature bits */ | 11 | /* Feature bits */ |
10 | #define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */ | 12 | #define VIRTIO_CONSOLE_F_SIZE 0 /* Does host provide console size? */ |