PERFORCE change 89249 for review
Kip Macy
kmacy at FreeBSD.org
Thu Jan 5 20:28:21 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=89249
Change 89249 by kmacy at kmacy:freebsd7_xen3 on 2006/01/06 04:27:21
first *small* changes for DOM0 support
add PHYSDEV_ACCESS option
add DOM0 support to console driver
Affected files ...
.. //depot/projects/xen3/src/sys/conf/options.i386-xen#2 edit
.. //depot/projects/xen3/src/sys/dev/xen/console/console.c#2 edit
Differences ...
==== //depot/projects/xen3/src/sys/conf/options.i386-xen#2 (text+ko) ====
@@ -32,8 +32,14 @@
# Change KVM size. Changes things all over the kernel.
KVA_PAGES opt_global.h
+
+# support xen hypervisor.
XEN opt_global.h
+# support physical device access
+XEN_PHYSDEV_ACCESS opt_global.h
+
+
# Physical address extensions and support for >4G ram. As above.
PAE opt_global.h
==== //depot/projects/xen3/src/sys/dev/xen/console/console.c#2 (text+ko) ====
@@ -16,11 +16,13 @@
#include <machine/stdarg.h>
#include <machine/xen-os.h>
#include <machine/hypervisor.h>
+#include <machine/xen_intr.h>
#include <sys/cons.h>
#include <dev/xen/console/xencons_ring.h>
#include <machine/xen-public/io/console.h>
+
#include "opt_ddb.h"
#ifdef DDB
#include <ddb/ddb.h>
@@ -39,12 +41,14 @@
static void xc_shutdown(void *arg, int howto);
static int xc_mute;
-void xcons_force_flush(void);
+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;
#define XC_POLLTIME (hz/10)
@@ -106,16 +110,16 @@
static void
xccnprobe(struct consdev *cp)
{
- cp->cn_pri = CN_REMOTE;
- cp->cn_tp = xccons;
- sprintf(cp->cn_name, "%s0", driver_name);
+ cp->cn_pri = CN_REMOTE;
+ cp->cn_tp = xccons;
+ sprintf(cp->cn_name, "%s0", driver_name);
}
static void
xccninit(struct consdev *cp)
{
- CN_LOCK_INIT(cn_mtx,"XCONS LOCK");
+ CN_LOCK_INIT(cn_mtx,"XCONS LOCK");
}
int
@@ -140,16 +144,16 @@
int
xccncheckc(struct consdev *dev)
{
- int ret = (xc_mute ? 0 : -1);
- int flags;
- CN_LOCK(cn_mtx, flags);
- if ( (rp - rc) ){
- /* we need to return only one char */
- ret = (int)rbuf[RBUF_MASK(rc)];
- rc++;
- }
- CN_UNLOCK(cn_mtx, flags);
- return(ret);
+ int ret = (xc_mute ? 0 : -1);
+ int flags;
+ CN_LOCK(cn_mtx, flags);
+ if ( (rp - rc) ){
+ /* we need to return only one char */
+ ret = (int)rbuf[RBUF_MASK(rc)];
+ rc++;
+ }
+ CN_UNLOCK(cn_mtx, flags);
+ return(ret);
}
static void
@@ -161,6 +165,12 @@
CN_UNLOCK(cn_mtx, flags);
}
+static void
+xccnputc_dom0(struct consdev *dev, int c)
+{
+ HYPERVISOR_console_io(CONSOLEIO_write, 1, (char *)&c);
+}
+
static boolean_t
xcons_putc(int c)
{
@@ -213,32 +223,47 @@
static int
xc_attach(device_t dev)
{
- struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
- TRACE_ENTER;
+ struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
+
+
+ if (xen_start_info->flags & SIF_INITDOMAIN) {
+ xc_consdev.cn_putc = xccnputc_dom0;
+ }
- sc->xc_dev = make_dev(&xc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "xc%r", 0);
- xccons = ttymalloc(NULL);
+ sc->xc_dev = make_dev(&xc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "xc%r", 0);
+ xccons = ttymalloc(NULL);
- sc->xc_dev->si_drv1 = (void *)sc;
- sc->xc_dev->si_tty = xccons;
+ sc->xc_dev->si_drv1 = (void *)sc;
+ sc->xc_dev->si_tty = xccons;
- xccons->t_oproc = xcstart;
- xccons->t_param = xcparam;
- xccons->t_stop = xcstop;
- xccons->t_dev = sc->xc_dev;
+ xccons->t_oproc = xcstart;
+ xccons->t_param = xcparam;
+ xccons->t_stop = xcstop;
+ xccons->t_dev = sc->xc_dev;
+
+ callout_init(&xc_callout, 0);
- callout_init(&xc_callout, 0);
+ xencons_ring_init();
- xencons_ring_init();
+ cnsl_evt_reg = 1;
+ callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, xccons);
+
+ if (xen_start_info->flags & SIF_INITDOMAIN) {
+ PANIC_IF(bind_virq_to_irqhandler(
+ VIRQ_CONSOLE,
+ 0,
+ "console",
+ xencons_priv_interrupt,
+ INTR_TYPE_TTY) < 0);
+
+ }
- cnsl_evt_reg = 1;
- callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, xccons);
- /* register handler to flush console on shutdown */
- if ((EVENTHANDLER_REGISTER(shutdown_post_sync, xc_shutdown,
- NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
+ /* register handler to flush console on shutdown */
+ if ((EVENTHANDLER_REGISTER(shutdown_post_sync, xc_shutdown,
+ NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
printf("xencons: shutdown event registration failed!\n");
-
+
TRACE_EXIT;
return (0);
}
@@ -250,9 +275,7 @@
xc_shutdown(void *arg, int howto)
{
xc_mute = 1;
-#ifdef notyet
xcons_force_flush();
-#endif
}
void
@@ -310,17 +333,20 @@
__xencons_tx_flush();
CN_UNLOCK(cn_mtx, flags);
}
-#ifdef nomore
-static void
-xencons_tx_flush_task_routine(void * data, int arg)
+
+static void
+xencons_priv_interrupt(void *arg)
{
- int flags;
- CN_LOCK(cn_mtx, flags);
- xc_tx_task_queued = FALSE;
- __xencons_tx_flush();
- CN_UNLOCK(cn_mtx, flags);
+
+ static char rbuf[16];
+ int l;
+
+ while ((l = HYPERVISOR_console_io(CONSOLEIO_read, 16, rbuf)) > 0)
+ xencons_rx(rbuf, l);
+
+ xencons_tx();
}
-#endif
+
int
xcopen(struct cdev *dev, int flag, int mode, struct thread *td)
{
@@ -484,59 +510,45 @@
static device_method_t xc_methods[] = {
- DEVMETHOD(device_identify, xc_identify),
- DEVMETHOD(device_probe, xc_probe),
- DEVMETHOD(device_attach, xc_attach),
- {0, 0}
+ DEVMETHOD(device_identify, xc_identify),
+ DEVMETHOD(device_probe, xc_probe),
+ DEVMETHOD(device_attach, xc_attach),
+ {0, 0}
};
static driver_t xc_driver = {
- driver_name,
- xc_methods,
- sizeof(struct xc_softc),
+ driver_name,
+ xc_methods,
+ sizeof(struct xc_softc),
};
-#if 0
+
/*** Forcibly flush console data before dying. ***/
void
xcons_force_flush(void)
{
- int sz;
+ int sz;
- /*
- * We use dangerous control-interface functions that require a quiescent
- * system and no interrupts. Try to ensure this with a global cli().
- */
- cli();
+ if (xen_start_info->flags & SIF_INITDOMAIN)
+ return;
- /* Spin until console data is flushed through to the domain controller. */
- while ( (wc != wp) && !ctrl_if_transmitter_empty() )
- {
- /* Interrupts are disabled -- we must manually reap responses. */
- ctrl_if_discard_responses();
+ /* Spin until console data is flushed through to the domain controller. */
+ while (wc != wp) {
+ int sent = 0;
+ if ((sz = wp - wc) == 0)
+ continue;
+
+ sent = xencons_ring_send(&wbuf[WBUF_MASK(wc)], sz);
+ if (sent > 0)
+ wc += sent;
+ }
+}
- if ( (sz = wp - wc) == 0 )
- continue;
- if ( sz > sizeof(msg.msg) )
- sz = sizeof(msg.msg);
- if ( sz > (WBUF_SIZE - WBUF_MASK(wc)) )
- sz = WBUF_SIZE - WBUF_MASK(wc);
-
- msg.type = CMSG_CONSOLE;
- msg.subtype = CMSG_CONSOLE_DATA;
- msg.length = sz;
- memcpy(msg.msg, &wbuf[WBUF_MASK(wc)], sz);
-
- if ( ctrl_if_send_message_noblock(&msg, NULL, 0) == 0 )
- wc += sz;
- }
-}
-#endif
DRIVER_MODULE(xc, nexus, xc_driver, xc_devclass, 0, 0);
/*
* Local variables:
* mode: C
* c-set-style: "BSD"
- * c-basic-offset: 4
+ * c-basic-offset: 8
* tab-width: 4
* indent-tabs-mode: t
* End:
More information about the p4-projects
mailing list