Re: [RFC PATCH 29/35] Add the Xen virtual console driver.
From: Andrew Morton
Date: Sat May 13 2006 - 08:31:26 EST
On Tue, 09 May 2006 00:00:29 -0700
Chris Wright <chrisw@xxxxxxxxxxxx> wrote:
> This provides a bootstrap and ongoing emergency console which is
> intended to be available from very early during boot and at all times
> thereafter, in contrast with alternatives such as UDP-based syslogd,
> or logging in via ssh. The protocol is based on a simple shared-memory
> ring buffer.
>
> ...
>
> +/* The kernel and user-land drivers share a common transmit buffer. */
> +static unsigned int wbuf_size = 4096;
> +#define WBUF_MASK(_i) ((_i)&(wbuf_size-1))
> +static char *wbuf;
> +static unsigned int wc, wp; /* write_cons, write_prod */
> +
> +static int __init xencons_bufsz_setup(char *str)
> +{
> + unsigned int goal;
> + goal = simple_strtoul(str, NULL, 0);
> + while (wbuf_size < goal)
> + wbuf_size <<= 1;
roundup_pow_of_two()
> +/* This lock protects accesses to the common transmit buffer. */
> +static spinlock_t xencons_lock = SPIN_LOCK_UNLOCKED;
DEFINE_SPINLOCK() (entire patchset)
> +
> +static void kcons_write(
> + struct console *c, const char *s, unsigned int count)
> +{
> + int i = 0;
> + unsigned long flags;
> +
> + spin_lock_irqsave(&xencons_lock, flags);
> +
> + while (i < count) {
> + for (; i < count; i++) {
> + if ((wp - wc) >= (wbuf_size - 1))
> + break;
> + if ((wbuf[WBUF_MASK(wp++)] = s[i]) == '\n')
> + wbuf[WBUF_MASK(wp++)] = '\r';
> + }
> +
> + __xencons_tx_flush();
> + }
> +
> + spin_unlock_irqrestore(&xencons_lock, flags);
> +}
hm. You have all that elaborate generate-ringbuffer-code-with-C-macros
stuff in the header file patch, yet this code (blessedly) doesn't use it.
> +static void kcons_write_dom0(
> + struct console *c, const char *s, unsigned int count)
> +{
> + int rc;
> +
> + while ((count > 0) &&
> + ((rc = HYPERVISOR_console_io(
> + CONSOLEIO_write, count, (char *)s)) > 0)) {
> + count -= rc;
> + s += rc;
> + }
> +}
must.. not.. mention.. coding.. style..
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/