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..
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|