summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-08-24 08:27:42 +0000
committered <ed@FreeBSD.org>2009-08-24 08:27:42 +0000
commite23bffc564ab5535d22eea5710c2e1dc24512239 (patch)
tree1f2a291a67e0e98a20996d7ec7da83fb54c2f972
parent52d0adc8f68b84e4f3af6d83cf3502ed56aafe3d (diff)
downloadFreeBSD-src-e23bffc564ab5535d22eea5710c2e1dc24512239.zip
FreeBSD-src-e23bffc564ab5535d22eea5710c2e1dc24512239.tar.gz
Cleanups to the Xen console driver:
- Use CONSOLE_DRIVER() instead of the deprecated CONS_DRIVER() declaration. - This means we cannot use cn_checkc anymore, which is supposed to do the same as cn_getc nowadays. Remove the cn_getc implementation (that was never being called) and rename cn_checkc to cn_getc. - Don't run-time patch cn_putc, but add the logic to xc_cnputc(). This means I could do some cleanups to our console code... Tested by: nobody on hackers@
-rw-r--r--sys/dev/xen/console/console.c68
1 files changed, 27 insertions, 41 deletions
diff --git a/sys/dev/xen/console/console.c b/sys/dev/xen/console/console.c
index 68bb0ae..df5c3ee 100644
--- a/sys/dev/xen/console/console.c
+++ b/sys/dev/xen/console/console.c
@@ -45,17 +45,15 @@ static int xc_mute;
static void xcons_force_flush(void);
static void xencons_priv_interrupt(void *);
-static cn_probe_t xccnprobe;
-static cn_init_t xccninit;
-static cn_getc_t xccngetc;
-static cn_putc_t xccnputc;
-static cn_putc_t xccnputc_dom0;
-static cn_checkc_t xccncheckc;
+static cn_probe_t xc_cnprobe;
+static cn_init_t xc_cninit;
+static cn_term_t xc_cnterm;
+static cn_getc_t xc_cngetc;
+static cn_putc_t xc_cnputc;
#define XC_POLLTIME (hz/10)
-CONS_DRIVER(xc, xccnprobe, xccninit, NULL, xccngetc,
- xccncheckc, xccnputc, NULL);
+CONSOLE_DRIVER(xc);
static int xen_console_up;
static boolean_t xc_start_needed;
@@ -105,7 +103,7 @@ static struct ttydevsw xc_ttydevsw = {
};
static void
-xccnprobe(struct consdev *cp)
+xc_cnprobe(struct consdev *cp)
{
cp->cn_pri = CN_REMOTE;
sprintf(cp->cn_name, "%s0", driver_name);
@@ -113,37 +111,19 @@ xccnprobe(struct consdev *cp)
static void
-xccninit(struct consdev *cp)
+xc_cninit(struct consdev *cp)
{
CN_LOCK_INIT(cn_mtx,"XCONS LOCK");
}
-int
-xccngetc(struct consdev *dev)
-{
- int c;
- if (xc_mute)
- return 0;
- do {
- if ((c = xccncheckc(dev)) == -1) {
-#ifdef KDB
- if (!kdb_active)
-#endif
- /*
- * Polling without sleeping in Xen
- * doesn't work well. Sleeping gives
- * other things like clock a chance to
- * run
- */
- tsleep(&cn_mtx, PWAIT | PCATCH,
- "console sleep", XC_POLLTIME);
- }
- } while(c == -1);
- return c;
+
+static void
+xc_cnterm(struct consdev *cp)
+{
}
-int
-xccncheckc(struct consdev *dev)
+static int
+xc_cngetc(struct consdev *dev)
{
int ret = (xc_mute ? 0 : -1);
@@ -162,17 +142,27 @@ xccncheckc(struct consdev *dev)
}
static void
-xccnputc(struct consdev *dev, int c)
+xc_cnputc_domu(struct consdev *dev, int c)
{
xcons_putc(c);
}
static void
-xccnputc_dom0(struct consdev *dev, int c)
+xc_cnputc_dom0(struct consdev *dev, int c)
{
HYPERVISOR_console_io(CONSOLEIO_write, 1, (char *)&c);
}
+static void
+xc_cnputc(struct consdev *dev, int c)
+{
+
+ if (xen_start_info->flags & SIF_INITDOMAIN)
+ xc_cnputc_dom0(dev, c);
+ else
+ xc_cnputc_domu(dev, c);
+}
+
extern int db_active;
static boolean_t
xcons_putc(int c)
@@ -226,10 +216,6 @@ xc_attach(device_t dev)
{
int error;
- if (xen_start_info->flags & SIF_INITDOMAIN) {
- xc_consdev.cn_putc = xccnputc_dom0;
- }
-
xccons = tty_alloc(&xc_ttydevsw, NULL);
tty_makedev(xccons, NULL, "xc%r", 0);
@@ -388,7 +374,7 @@ xc_timeout(void *v)
tp = (struct tty *)v;
tty_lock(tp);
- while ((c = xccncheckc(NULL)) != -1)
+ while ((c = xc_cngetc(NULL)) != -1)
ttydisc_rint(tp, c, 0);
if (xc_start_needed) {
OpenPOWER on IntegriCloud