Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 180789
b: refs/heads/master
c: 971f339
h: refs/heads/master
i:
  180787: 5aafe94
v: v3
  • Loading branch information
Rusty Russell committed Feb 24, 2010
1 parent edae931 commit 2bc9cf1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a23ea92474e558b071d3e43d961ec767c31faebd
refs/heads/master: 971f3390003619ea4ac0b20ee93dfd3209025790
60 changes: 34 additions & 26 deletions trunk/drivers/char/virtio_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ static struct virtio_device *vdev;
static unsigned int in_len;
static char *in, *inbuf;

/* The operations for our console. */
static struct hv_ops virtio_cons;

/* The hvc device */
static struct hvc_struct *hvc;

/* This is the very early arch-specified put chars function. */
static int (*early_put_chars)(u32, const char *, int);

/*
* The put_chars() callback is pretty straightforward.
*
Expand All @@ -47,6 +47,9 @@ static int put_chars(u32 vtermno, const char *buf, int count)
struct scatterlist sg[1];
unsigned int len;

if (unlikely(early_put_chars))
return early_put_chars(vtermno, buf, count);

/* This is a convenient routine to initialize a single-elem sg list */
sg_init_one(sg, buf, count);

Expand Down Expand Up @@ -117,21 +120,6 @@ static int get_chars(u32 vtermno, char *buf, int count)
return count;
}

/*
* Console drivers are initialized very early so boot messages can go
* out, so we do things slightly differently from the generic virtio
* initialization of the net and block drivers.
*
* At this stage, the console is output-only. It's too early to set
* up a virtqueue, so we let the drivers do some boutique early-output
* thing.
*/
int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
{
virtio_cons.put_chars = put_chars;
return hvc_instantiate(0, 0, &virtio_cons);
}

/*
* virtio console configuration. This supports:
* - console resize
Expand Down Expand Up @@ -174,6 +162,30 @@ static void hvc_handle_input(struct virtqueue *vq)
hvc_kick();
}

/* The operations for the console. */
static struct hv_ops hv_ops = {
.get_chars = get_chars,
.put_chars = put_chars,
.notifier_add = notifier_add_vio,
.notifier_del = notifier_del_vio,
.notifier_hangup = notifier_del_vio,
};

/*
* Console drivers are initialized very early so boot messages can go
* out, so we do things slightly differently from the generic virtio
* initialization of the net and block drivers.
*
* At this stage, the console is output-only. It's too early to set
* up a virtqueue, so we let the drivers do some boutique early-output
* thing.
*/
int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int))
{
early_put_chars = put_chars;
return hvc_instantiate(0, 0, &hv_ops);
}

/*
* Once we're further in boot, we get probed like any other virtio
* device. At this stage we set up the output virtqueue.
Expand Down Expand Up @@ -209,13 +221,6 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
in_vq = vqs[0];
out_vq = vqs[1];

/* Start using the new console output. */
virtio_cons.get_chars = get_chars;
virtio_cons.put_chars = put_chars;
virtio_cons.notifier_add = notifier_add_vio;
virtio_cons.notifier_del = notifier_del_vio;
virtio_cons.notifier_hangup = notifier_del_vio;

/*
* The first argument of hvc_alloc() is the virtual console
* number, so we use zero. The second argument is the
Expand All @@ -228,14 +233,17 @@ static int __devinit virtcons_probe(struct virtio_device *dev)
* pointers. The final argument is the output buffer size: we
* can do any size, so we put PAGE_SIZE here.
*/
hvc = hvc_alloc(0, 0, &virtio_cons, PAGE_SIZE);
hvc = hvc_alloc(0, 0, &hv_ops, PAGE_SIZE);
if (IS_ERR(hvc)) {
err = PTR_ERR(hvc);
goto free_vqs;
}

/* Register the input buffer the first time. */
add_inbuf();

/* Start using the new console output. */
early_put_chars = NULL;
return 0;

free_vqs:
Expand Down

0 comments on commit 2bc9cf1

Please sign in to comment.