svn commit: r184585 - in projects/releng_7_xen/sys: conf dev/xen/console dev/xen/netfront i386/conf i386/i386 i386/include i386/isa i386/pci kern libkern sys xen/xenbus

Kip Macy kmacy at FreeBSD.org
Sun Nov 2 23:52:19 PST 2008


Author: kmacy
Date: Mon Nov  3 07:52:18 2008
New Revision: 184585
URL: http://svn.freebsd.org/changeset/base/184585

Log:
  Checkpoint current state of integration - still need to resolve 3 or 4 files

Added:
  projects/releng_7_xen/sys/i386/conf/XEN
  projects/releng_7_xen/sys/libkern/strcspn.c   (contents, props changed)
Modified:
  projects/releng_7_xen/sys/conf/files
  projects/releng_7_xen/sys/conf/files.i386
  projects/releng_7_xen/sys/conf/options.i386
  projects/releng_7_xen/sys/dev/xen/console/console.c
  projects/releng_7_xen/sys/dev/xen/netfront/netfront.c
  projects/releng_7_xen/sys/i386/i386/genassym.c
  projects/releng_7_xen/sys/i386/i386/intr_machdep.c
  projects/releng_7_xen/sys/i386/i386/local_apic.c
  projects/releng_7_xen/sys/i386/i386/machdep.c
  projects/releng_7_xen/sys/i386/i386/swtch.s
  projects/releng_7_xen/sys/i386/i386/sys_machdep.c
  projects/releng_7_xen/sys/i386/i386/vm_machdep.c
  projects/releng_7_xen/sys/i386/include/apicvar.h
  projects/releng_7_xen/sys/i386/include/asmacros.h
  projects/releng_7_xen/sys/i386/include/cpufunc.h
  projects/releng_7_xen/sys/i386/include/param.h
  projects/releng_7_xen/sys/i386/include/pcpu.h
  projects/releng_7_xen/sys/i386/include/pmap.h
  projects/releng_7_xen/sys/i386/include/segments.h
  projects/releng_7_xen/sys/i386/include/smp.h
  projects/releng_7_xen/sys/i386/include/vmparam.h
  projects/releng_7_xen/sys/i386/isa/npx.c
  projects/releng_7_xen/sys/i386/pci/pci_cfgreg.c
  projects/releng_7_xen/sys/i386/pci/pci_pir.c
  projects/releng_7_xen/sys/kern/kern_fork.c
  projects/releng_7_xen/sys/kern/kern_synch.c
  projects/releng_7_xen/sys/kern/subr_trap.c
  projects/releng_7_xen/sys/sys/libkern.h
  projects/releng_7_xen/sys/xen/xenbus/xenbus_xs.c

Modified: projects/releng_7_xen/sys/conf/files
==============================================================================
--- projects/releng_7_xen/sys/conf/files	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/conf/files	Mon Nov  3 07:52:18 2008	(r184585)
@@ -2201,3 +2201,19 @@ gnu/fs/xfs/xfs_iomap.c		optional xfs \
 	compile-with "${NORMAL_C} -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs"
 gnu/fs/xfs/xfs_behavior.c	optional xfs \
 	compile-with "${NORMAL_C} -I$S/gnu/fs/xfs/FreeBSD -I$S/gnu/fs/xfs/FreeBSD/support -I$S/gnu/fs/xfs"
+
+
+xen/gnttab.c                   optional xen
+xen/features.c                 optional xen
+xen/evtchn/evtchn.c            optional xen
+xen/evtchn/evtchn_dev.c                optional xen
+xen/xenbus/xenbus_client.c     optional xen
+xen/xenbus/xenbus_comms.c      optional xen
+xen/xenbus/xenbus_dev.c                optional xen
+xen/xenbus/xenbus_probe.c      optional xen
+xen/xenbus/xenbus_probe_backend.c      optional xen
+xen/xenbus/xenbus_xs.c         optional xen
+dev/xen/console/console.c      optional xen
+dev/xen/console/xencons_ring.c optional xen
+dev/xen/blkfront/blkfront.c    optional xen
+dev/xen/netfront/netfront.c    optional xen

Modified: projects/releng_7_xen/sys/conf/files.i386
==============================================================================
--- projects/releng_7_xen/sys/conf/files.i386	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/conf/files.i386	Mon Nov  3 07:52:18 2008	(r184585)
@@ -261,8 +261,8 @@ i386/cpufreq/smist.c		optional cpufreq
 i386/i386/atomic.c		standard				\
 	compile-with	"${CC} -c ${CFLAGS} ${DEFINED_PROF:S/^$/-fomit-frame-pointer/} ${.IMPSRC}"
 i386/i386/autoconf.c		standard
-i386/i386/bios.c		standard
-i386/i386/bioscall.s		standard
+i386/i386/bios.c		optional native
+i386/i386/bioscall.s		optional native
 i386/i386/bpf_jit_machdep.c	optional bpf_jitter
 i386/i386/busdma_machdep.c	standard
 i386/i386/db_disasm.c		optional ddb
@@ -271,7 +271,8 @@ i386/i386/db_trace.c		optional ddb
 i386/i386/dump_machdep.c	standard
 i386/i386/elan-mmcr.c		optional cpu_elan | cpu_soekris
 i386/i386/elf_machdep.c		standard
-i386/i386/exception.s		standard
+i386/i386/exception.s		optional native
+i386/xen/exception.s		optional xen
 i386/i386/gdb_machdep.c		optional gdb
 i386/i386/geode.c		optional cpu_geode
 i386/i386/i686_mem.c		optional mem
@@ -282,23 +283,28 @@ i386/i386/intr_machdep.c	standard
 i386/i386/io.c			optional io
 i386/i386/io_apic.c		optional apic
 i386/i386/k6_mem.c		optional mem
-i386/i386/legacy.c		standard
+i386/i386/legacy.c		optional native
 i386/i386/local_apic.c		optional apic
-i386/i386/locore.s		standard	no-obj
+i386/i386/locore.s		optional native	no-obj
+i386/xen/locore.s		optional xen	no-obj
 i386/i386/longrun.c		optional cpu_enable_longrun
 i386/i386/machdep.c		standard
+i386/xen/xen_machdep.c		optional xen
 i386/i386/mem.c			optional mem
 i386/i386/minidump_machdep.c	standard
 i386/i386/mp_clock.c		optional smp
-i386/i386/mp_machdep.c		optional smp
+i386/i386/mp_machdep.c		optional native smp
+i386/xen/mp_machdep.c		optional xen smp
 i386/i386/mp_watchdog.c		optional mp_watchdog smp
-i386/i386/mpboot.s		optional smp
-i386/i386/mptable.c		optional apic
+i386/i386/mpboot.s		optional smp native
+i386/i386/mptable.c		optional apic native
+i386/xen/mptable.c		optional apic xen
 i386/i386/mptable_pci.c		optional apic pci
 i386/i386/msi.c			optional apic pci
 i386/i386/nexus.c		standard
 i386/i386/perfmon.c		optional perfmon
-i386/i386/pmap.c		standard
+i386/i386/pmap.c		optional native
+i386/xen/pmap.c			optional xen
 i386/i386/ptrace_machdep.c	standard
 i386/i386/stack_machdep.c	optional ddb | stack
 i386/i386/support.s		standard
@@ -328,9 +334,10 @@ i386/ibcs2/ibcs2_util.c		optional ibcs2
 i386/ibcs2/ibcs2_xenix.c	optional ibcs2
 i386/ibcs2/ibcs2_xenix_sysent.c	optional ibcs2
 i386/ibcs2/imgact_coff.c	optional ibcs2
-i386/isa/atpic.c		standard
+i386/isa/atpic.c		optional atpic
 #i386/isa/atpic_vector.s		standard
-i386/isa/clock.c		standard
+i386/isa/clock.c		optional native
+i386/xen/clock.c		optional xen
 i386/isa/dpms.c			optional dpms
 i386/isa/elcr.c			standard
 i386/isa/elink.c		optional ep | ie

Modified: projects/releng_7_xen/sys/conf/options.i386
==============================================================================
--- projects/releng_7_xen/sys/conf/options.i386	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/conf/options.i386	Mon Nov  3 07:52:18 2008	(r184585)
@@ -150,3 +150,6 @@ STOP_NMI		opt_cpu.h
 
 # BPF just-in-time compiler
 BPF_JITTER		opt_bpf.h
+
+NATIVE			opt_global.h
+XEN			opt_global.h

Modified: projects/releng_7_xen/sys/dev/xen/console/console.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/console/console.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/dev/xen/console/console.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -1,5 +1,5 @@
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+
 
 #include <sys/param.h>
 #include <sys/module.h>
@@ -18,8 +18,8 @@ __FBSDID("$FreeBSD$");
 #include <machine/xen/hypervisor.h>
 #include <machine/xen/xen_intr.h>
 #include <sys/cons.h>
-#include <sys/priv.h>
 #include <sys/proc.h>
+#include <sys/priv.h>
 
 #include <dev/xen/console/xencons_ring.h>
 #include <xen/interface/io/console.h>
@@ -32,7 +32,9 @@ __FBSDID("$FreeBSD$");
 
 static char driver_name[] = "xc";
 devclass_t xc_devclass; /* do not make static */
-static void	xcoutwakeup(struct tty *);
+static void	xcstart (struct tty *);
+static int	xcparam (struct tty *, struct termios *);
+static void	xcstop (struct tty *, int);
 static void	xc_timeout(void *);
 static void __xencons_tx_flush(void);
 static boolean_t xcons_putc(int c);
@@ -42,7 +44,7 @@ static void xc_shutdown(void *arg, int h
 static int xc_mute;
 
 static void xcons_force_flush(void);
-static void xencons_priv_interrupt(void *);
+static int xencons_priv_interrupt(void *);
 
 static cn_probe_t       xccnprobe;
 static cn_init_t        xccninit;
@@ -72,7 +74,7 @@ static unsigned int cnsl_evt_reg;
 static unsigned int wc, wp; /* write_cons, write_prod */
 
 #define CDEV_MAJOR 12
-#define	XCUNIT(x)	(dev2unit(x))
+#define	XCUNIT(x)	(minor(x))
 #define ISTTYOPEN(tp)	((tp) && ((tp)->t_state & TS_ISOPEN))
 #define CN_LOCK_INIT(x, _name) \
         mtx_init(&x, _name, NULL, MTX_SPIN|MTX_RECURSE)
@@ -93,20 +95,34 @@ static unsigned int wc, wp; /* write_con
 
 static struct tty *xccons;
 
-static tsw_open_t	xcopen;
-static tsw_close_t	xcclose;
+struct xc_softc {
+	int    xc_unit;
+	struct cdev *xc_dev;
+};
+
 
-static struct ttydevsw xc_ttydevsw = {
-        .tsw_flags	= TF_NOPREFIX,
-        .tsw_open	= xcopen,
-        .tsw_close	= xcclose,
-        .tsw_outwakeup	= xcoutwakeup,
+static d_open_t  xcopen;
+static d_close_t xcclose;
+static d_ioctl_t xcioctl;
+
+static struct cdevsw xc_cdevsw = {
+	.d_version =    D_VERSION,
+        .d_flags =      D_TTY | D_NEEDGIANT,
+        .d_name =       driver_name,
+        .d_open =       xcopen,
+        .d_close =      xcclose,
+        .d_read =       ttyread,
+        .d_write =      ttywrite,
+        .d_ioctl =      xcioctl,
+        .d_poll =       ttypoll,
+        .d_kqfilter =   ttykqfilter,
 };
 
 static void
 xccnprobe(struct consdev *cp)
 {
 	cp->cn_pri = CN_REMOTE;
+	cp->cn_tp = xccons;
 	sprintf(cp->cn_name, "%s0", driver_name);
 }
 
@@ -209,20 +225,32 @@ xc_identify(driver_t *driver, device_t p
 static int
 xc_probe(device_t dev)
 {
+	struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
 
+	sc->xc_unit = device_get_unit(dev);
 	return (0);
 }
 
 static int
 xc_attach(device_t dev) 
 {
+	struct xc_softc *sc = (struct xc_softc *)device_get_softc(dev);
+
 
 	if (xen_start_info->flags & SIF_INITDOMAIN) {
 		xc_consdev.cn_putc = xccnputc_dom0;
 	} 
 
-	xccons = tty_alloc(&xc_ttydevsw, NULL, NULL);
-	tty_makedev(xccons, NULL, "xc%r", 0);
+	sc->xc_dev = make_dev(&xc_cdevsw, 0, UID_ROOT, GID_WHEEL, 0600, "xc%r", 0);
+	xccons = ttyalloc();
+
+	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;
 
 	callout_init(&xc_callout, 0);
 
@@ -236,9 +264,8 @@ xc_attach(device_t dev) 
 				 VIRQ_CONSOLE,
 				 0,
 				 "console",
-				 NULL,
 				 xencons_priv_interrupt,
-				 INTR_TYPE_TTY) < 0);
+					 NULL, INTR_TYPE_TTY) < 0);
 		
 	}
 
@@ -266,15 +293,11 @@ xencons_rx(char *buf, unsigned len)
 {
 	int           i;
 	struct tty *tp = xccons;
-
-	if (xen_console_up) {
-		tty_lock(tp);
-		for (i = 0; i < len; i++)
-			ttydisc_rint(tp, buf[i], 0);
-		ttydisc_rint_done(tp);
-		tty_unlock(tp);
-	} else {
-		for (i = 0; i < len; i++)
+	
+	for (i = 0; i < len; i++) {
+		if (xen_console_up) 
+			(*linesw[tp->t_line]->l_rint)(buf[i], tp);
+		else
 			rbuf[RBUF_MASK(rp++)] = buf[i];
 	}
 }
@@ -282,7 +305,7 @@ xencons_rx(char *buf, unsigned len)
 static void 
 __xencons_tx_flush(void)
 {
-	int        sz;
+	int        sz, work_done = 0;
 
 	CN_LOCK(cn_mtx);
 	while (wc != wp) {
@@ -299,8 +322,16 @@ __xencons_tx_flush(void)
 				break;
 			wc += sent;
 		}
+		work_done = 1;
 	}
 	CN_UNLOCK(cn_mtx);
+
+	/*
+	 * ttwakeup calls routines using blocking locks
+	 *
+	 */
+	if (work_done && xen_console_up && curthread->td_critnest == 0)
+		ttwakeup(xccons);
 }
 
 void
@@ -309,7 +340,7 @@ xencons_tx(void)
 	__xencons_tx_flush();
 }
 
-static void
+static int
 xencons_priv_interrupt(void *arg)
 {
 
@@ -320,21 +351,79 @@ xencons_priv_interrupt(void *arg)
 		xencons_rx(rbuf, l);
 
 	xencons_tx();
+	return (FILTER_HANDLED);
 }
 
-static int
-xcopen(struct tty *tp)
+int
+xcopen(struct cdev *dev, int flag, int mode, struct thread *td)
 {
+	struct xc_softc *sc;
+	int unit = XCUNIT(dev);
+	struct tty *tp;
+	int s, error;
+
+	sc = (struct xc_softc *)device_get_softc(
+		devclass_get_device(xc_devclass, unit));
+	if (sc == NULL)
+		return (ENXIO);
+    
+	tp = dev->si_tty;
+	s = spltty();
+	if (!ISTTYOPEN(tp)) {
+		tp->t_state |= TS_CARR_ON;
+		ttychars(tp);
+		tp->t_iflag = TTYDEF_IFLAG;
+		tp->t_oflag = TTYDEF_OFLAG;
+		tp->t_cflag = TTYDEF_CFLAG|CLOCAL;
+		tp->t_lflag = TTYDEF_LFLAG;
+		tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
+		xcparam(tp, &tp->t_termios);
+		ttsetwater(tp);
+	} else if (tp->t_state & TS_XCLUDE && suser(td)) {
+		splx(s);
+		return (EBUSY);
+	}
+	splx(s);
 
 	xen_console_up = 1;
+
+	error =  (*linesw[tp->t_line]->l_open)(dev, tp);
+	return error;
+}
+
+int
+xcclose(struct cdev *dev, int flag, int mode, struct thread *td)
+{
+	struct tty *tp = dev->si_tty;
+    
+	if (tp == NULL)
+		return (0);
+	xen_console_up = 0;
+    
+	spltty();
+	(*linesw[tp->t_line]->l_close)(tp, flag);
+	tty_close(tp);
+	spl0();
 	return (0);
 }
 
-static void
-xcclose(struct tty *tp)
+
+int
+xcioctl(struct cdev *dev, u_long cmd, caddr_t data, int flag, struct thread *td)
 {
+	struct tty *tp = dev->si_tty;
+	int error;
+    
+	error = (*linesw[tp->t_line]->l_ioctl)(tp, cmd, data, flag, td);
+	if (error != ENOIOCTL)
+		return (error);
 
-	xen_console_up = 0;
+	error = ttioctl(tp, cmd, data, flag);
+
+	if (error != ENOIOCTL)
+		return (error);
+
+	return (ENOTTY);
 }
 
 static inline int 
@@ -349,15 +438,31 @@ __xencons_put_char(int ch)
 
 
 static void
-xcoutwakeup(struct tty *tp)
+xcstart(struct tty *tp)
 {
 	boolean_t cons_full = FALSE;
-	char c;
 
-	while (ttydisc_getc(tp, &c, 1) == 1 && !cons_full)
-		cons_full = xcons_putc(c);
+	CN_LOCK(cn_mtx);
+	if (tp->t_state & (TS_TIMEOUT | TS_TTSTOP)) {
+			CN_UNLOCK(cn_mtx);
+
+		ttwwakeup(tp);
+		return;
+	}
 
-	if (cons_full) {
+	tp->t_state |= TS_BUSY;
+	CN_UNLOCK(cn_mtx);
+
+	while (tp->t_outq.c_cc != 0 && !cons_full)
+		cons_full = xcons_putc(getc(&tp->t_outq));
+
+	/* if the console is close to full leave our state as busy */
+	if (!cons_full) {
+			CN_LOCK(cn_mtx);
+			tp->t_state &= ~TS_BUSY;
+			CN_UNLOCK(cn_mtx);
+			ttwwakeup(tp);
+	} else {
 	    	/* let the timeout kick us in a bit */
 	    	xc_start_needed = TRUE;
 	}
@@ -365,6 +470,17 @@ xcoutwakeup(struct tty *tp)
 }
 
 static void
+xcstop(struct tty *tp, int flag)
+{
+
+	if (tp->t_state & TS_BUSY) {
+		if ((tp->t_state & TS_TTSTOP) == 0) {
+			tp->t_state |= TS_FLUSH;
+		}
+	}
+}
+
+static void
 xc_timeout(void *v)
 {
 	struct	tty *tp;
@@ -372,19 +488,33 @@ xc_timeout(void *v)
 
 	tp = (struct tty *)v;
 
-	tty_lock(tp);
-	while ((c = xccncheckc(NULL)) != -1)
-		ttydisc_rint(tp, c, 0);
+	while ((c = xccncheckc(NULL)) != -1) {
+		if (tp->t_state & TS_ISOPEN) {
+			(*linesw[tp->t_line]->l_rint)(c, tp);
+		}
+	}
 
 	if (xc_start_needed) {
 	    	xc_start_needed = FALSE;
-		xcoutwakeup(tp);
+		xcstart(tp);
 	}
-	tty_unlock(tp);
 
 	callout_reset(&xc_callout, XC_POLLTIME, xc_timeout, tp);
 }
 
+/*
+ * Set line parameters.
+ */
+int
+xcparam(struct tty *tp, struct termios *t)
+{
+	tp->t_ispeed = t->c_ispeed;
+	tp->t_ospeed = t->c_ospeed;
+	tp->t_cflag = t->c_cflag;
+	return (0);
+}
+
+
 static device_method_t xc_methods[] = {
 	DEVMETHOD(device_identify, xc_identify),
 	DEVMETHOD(device_probe, xc_probe),
@@ -395,7 +525,7 @@ static device_method_t xc_methods[] = {
 static driver_t xc_driver = {
 	driver_name,
 	xc_methods,
-	0,
+	sizeof(struct xc_softc),
 };
 
 /*** Forcibly flush console data before dying. ***/

Modified: projects/releng_7_xen/sys/dev/xen/netfront/netfront.c
==============================================================================
--- projects/releng_7_xen/sys/dev/xen/netfront/netfront.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/dev/xen/netfront/netfront.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/socket.h>
 #include <sys/queue.h>
+#include <sys/lock.h>
 #include <sys/sx.h>
 
 #include <net/if.h>
@@ -347,7 +348,7 @@ makembuf (struct mbuf *buf)
         m->m_len = buf->m_len;
 		m_copydata(buf, 0, buf->m_pkthdr.len, mtod(m,caddr_t) );
 
-		m->m_ext.ext_arg1 = (caddr_t *)(uintptr_t)(vtophys(mtod(m,caddr_t)) >> PAGE_SHIFT);
+		m->m_ext.ext_args = (caddr_t *)(uintptr_t)(vtophys(mtod(m,caddr_t)) >> PAGE_SHIFT);
 	
        	return m;
 }
@@ -749,7 +750,7 @@ refill:
 		if ((m_new = mbufq_dequeue(&sc->xn_rx_batch)) == NULL)
 			break;
 
-		m_new->m_ext.ext_arg1 = (vm_paddr_t *)(uintptr_t)(
+		m_new->m_ext.ext_args = (vm_paddr_t *)(uintptr_t)(
 				vtophys(m_new->m_ext.ext_buf) >> PAGE_SHIFT);
 
 		id = xennet_rxidx(req_prod + i);
@@ -1214,7 +1215,7 @@ xennet_get_responses(struct netfront_inf
 				MULTI_update_va_mapping(mcl, (u_long)vaddr,
 				    (((vm_paddr_t)mfn) << PAGE_SHIFT) | PG_RW |
 				    PG_V | PG_M | PG_A, 0);
-				pfn = (uint32_t)m->m_ext.ext_arg1;
+				pfn = (uint32_t)m->m_ext.ext_args;
 				mmu->ptr = ((vm_paddr_t)mfn << PAGE_SHIFT) |
 				    MMU_MACHPHYS_UPDATE;
 				mmu->val = pfn;

Added: projects/releng_7_xen/sys/i386/conf/XEN
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ projects/releng_7_xen/sys/i386/conf/XEN	Mon Nov  3 07:52:18 2008	(r184585)
@@ -0,0 +1,150 @@
+#
+# GENERIC -- Generic kernel configuration file for FreeBSD/i386
+#
+# For more information on this file, please read the handbook section on
+# Kernel Configuration Files:
+#
+#    http://www.FreeBSD.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-config.html
+#
+# The handbook is also available locally in /usr/share/doc/handbook
+# if you've installed the doc distribution, otherwise always see the
+# FreeBSD World Wide Web server (http://www.FreeBSD.org/) for the
+# latest information.
+#
+# An exhaustive list of options and more detailed explanations of the
+# device lines is also present in the ../../conf/NOTES and NOTES files.
+# If you are in doubt as to the purpose or necessity of a line, check first
+# in NOTES.
+#
+# $FreeBSD: head/sys/i386/conf/XEN 182902 2008-09-10 07:11:08Z kmacy $
+
+cpu		I686_CPU
+ident		GENERIC
+
+# To statically compile in device wiring instead of /boot/device.hints
+#hints		"GENERIC.hints"		# Default places to look for devices.
+
+makeoptions	DEBUG=-g		# Build kernel with gdb(1) debug symbols
+makeoptions	MODULES_OVERRIDE=""
+
+#options 	SCHED_ULE		# ULE scheduler
+#options 	PREEMPTION		# Enable kernel thread preemption
+options		SCHED_4BSD		 
+
+options 	INET			# InterNETworking
+options 	INET6			# IPv6 communications protocols
+options 	SCTP			# Stream Control Transmission Protocol
+options 	FFS			# Berkeley Fast Filesystem
+options 	SOFTUPDATES		# Enable FFS soft updates support
+options 	UFS_ACL			# Support for access control lists
+options 	UFS_DIRHASH		# Improve performance on big directories
+options 	UFS_GJOURNAL		# Enable gjournal-based UFS journaling
+options 	MD_ROOT			# MD is a potential root device
+options 	NFSCLIENT		# Network Filesystem Client
+options 	NFSSERVER		# Network Filesystem Server
+options 	NFSLOCKD		# Network Lock Manager
+options 	NFS_ROOT		# NFS usable as /, requires NFSCLIENT
+options 	MSDOSFS			# MSDOS Filesystem
+options 	CD9660			# ISO 9660 Filesystem
+options 	PROCFS			# Process filesystem (requires PSEUDOFS)
+options 	PSEUDOFS		# Pseudo-filesystem framework
+options 	GEOM_PART_GPT		# GUID Partition Tables.
+options 	GEOM_LABEL		# Provides labelization
+options 	COMPAT_43TTY		# BSD 4.3 TTY compat [KEEP THIS!]
+options 	COMPAT_FREEBSD4		# Compatible with FreeBSD4
+options 	COMPAT_FREEBSD5		# Compatible with FreeBSD5
+options 	COMPAT_FREEBSD6		# Compatible with FreeBSD6
+options 	SCSI_DELAY=5000		# Delay (in ms) before probing SCSI
+options 	KTRACE			# ktrace(1) support
+options 	STACK			# stack(9) support
+options 	SYSVSHM			# SYSV-style shared memory
+options 	SYSVMSG			# SYSV-style message queues
+options 	SYSVSEM			# SYSV-style semaphores
+options 	_KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions
+options 	KBD_INSTALL_CDEV	# install a CDEV entry in /dev
+options  	HWPMC_HOOKS		# Necessary kernel hooks for hwpmc(4)
+options 	AUDIT			# Security event auditing
+
+# Debugging for use in -current
+options 	KDB			# Enable kernel debugger support.
+options 	DDB			# Support DDB.
+options 	GDB			# Support remote GDB.
+options 	INVARIANTS		# Enable calls of extra sanity checking
+options 	INVARIANT_SUPPORT	# Extra sanity checks of internal structures, required by INVARIANTS
+options 	WITNESS			# Enable checks to detect deadlocks and cycles
+options 	WITNESS_SKIPSPIN	# Don't run witness on spinlocks for speed
+
+options		PAE
+nooption	NATIVE
+option		XEN
+nodevice	atpic
+nodevice	isa
+options		MCLSHIFT=12
+
+# To make an SMP kernel, the next two lines are needed
+options 	SMP			# Symmetric MultiProcessor Kernel
+device		apic			# I/O APIC
+
+# CPU frequency control
+#device		cpufreq
+
+# atkbdc0 controls both the keyboard and the PS/2 mouse
+device		atkbdc		# AT keyboard controller
+device		atkbd		# AT keyboard
+device		psm		# PS/2 mouse
+
+device		kbdmux		# keyboard multiplexer
+
+#device		vga		# VGA video card driver
+
+device		splash		# Splash screen and screen saver support
+
+# syscons is the default console driver, resembling an SCO console
+#device		sc
+
+# Power management support (see NOTES for more options)
+#device		apm
+# Add suspend/resume support for the i8254.
+device		pmtimer
+
+
+device		pci
+
+# PCCARD (PCMCIA) support
+# PCMCIA and cardbus bridge support
+#device		cbb		# cardbus (yenta) bridge
+#device		pccard		# PC Card (16-bit) bus
+#device		cardbus		# CardBus (32-bit) bus
+
+# Serial (COM) ports
+device		uart		# Generic UART driver
+
+# Parallel port
+device		ppc
+device		ppbus		# Parallel port bus (required)
+device		lpt		# Printer
+device		plip		# TCP/IP over parallel
+device		ppi		# Parallel port interface device
+#device		vpo		# Requires scbus and da
+
+# If you've got a "dumb" serial or parallel PCI card that is
+# supported by the puc(4) glue driver, uncomment the following
+# line to enable it (connects to sio, uart and/or ppc drivers):
+#device		puc
+
+# Pseudo devices.
+device		loop		# Network loopback
+device		random		# Entropy device
+device		ether		# Ethernet support
+device		tun		# Packet tunnel.
+device		pty		# Pseudo-ttys (telnet etc)
+device		md		# Memory "disks"
+device		gif		# IPv6 and IPv4 tunneling
+device		faith		# IPv6-to-IPv4 relaying (translation)
+device		firmware	# firmware assist module
+
+# The `bpf' device enables the Berkeley Packet Filter.
+# Be aware of the administrative consequences of enabling this!
+# Note that 'bpf' is required for DHCP.
+device		bpf		# Berkeley packet filter
+

Modified: projects/releng_7_xen/sys/i386/i386/genassym.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/genassym.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/i386/i386/genassym.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -228,3 +228,9 @@ ASSYM(MTX_RECURSECNT, offsetof(struct mt
 ASSYM(BUS_SPACE_HANDLE_BASE, offsetof(struct bus_space_handle, bsh_base));
 ASSYM(BUS_SPACE_HANDLE_IAT, offsetof(struct bus_space_handle, bsh_iat));
 #endif
+
+#ifdef XEN
+#include <machine/xen/hypervisor.h>
+ASSYM(PC_CR3, offsetof(struct pcpu, pc_cr3));
+ASSYM(HYPERVISOR_VIRT_START, __HYPERVISOR_VIRT_START);
+#endif

Modified: projects/releng_7_xen/sys/i386/i386/intr_machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/intr_machdep.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/i386/i386/intr_machdep.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -594,6 +594,12 @@ intr_shuffle_irqs(void *arg __unused)
 	struct intsrc *isrc;
 	int i;
 
+#ifdef XEN
+	/*
+	 * Doesn't work yet
+	 */
+	return;
+#endif		
 	/* Don't bother on UP. */
 	if (mp_ncpus == 1)
 		return;

Modified: projects/releng_7_xen/sys/i386/i386/local_apic.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/local_apic.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/i386/i386/local_apic.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -1109,6 +1109,9 @@ apic_setup_io(void *dummy __unused)
 		printf("%s: Failed to setup I/O APICs: returned %d\n",
 		    best_enum->apic_name, retval);
 
+#ifdef XEN
+	return;
+#endif
 	/*
 	 * Finish setting up the local APIC on the BSP once we know how to
 	 * properly program the LINT pins.

Modified: projects/releng_7_xen/sys/i386/i386/machdep.c
==============================================================================
--- projects/releng_7_xen/sys/i386/i386/machdep.c	Mon Nov  3 06:37:59 2008	(r184584)
+++ projects/releng_7_xen/sys/i386/i386/machdep.c	Mon Nov  3 07:52:18 2008	(r184585)
@@ -142,6 +142,25 @@ int arch_i386_is_xbox = 0;
 uint32_t arch_i386_xbox_memsize = 0;
 #endif
 
+#ifdef XEN
+/* XEN includes */
+#include <machine/xen/xen-os.h>
+#include <machine/xen/hypervisor.h>
+#include <machine/xen/xen-os.h>
+#include <machine/xen/xenvar.h>
+#include <machine/xen/xenfunc.h>
+#include <machine/xen/xen_intr.h>
+
+void Xhypervisor_callback(void);
+void failsafe_callback(void);
+
+extern trap_info_t trap_table[];
+struct proc_ldt default_proc_ldt;
+extern int init_first;
+int running_xen = 1;
+extern unsigned long physfree;
+#endif /* XEN */
+
 /* Sanity check for __curthread() */
 CTASSERT(offsetof(struct pcpu, pc_curthread) == 0);
 
@@ -288,8 +307,9 @@ cpu_startup(dummy)
 	 */
 	bufinit();
 	vm_pager_bufferinit();
-
+#ifndef XEN
 	cpu_setregs();
+#endif
 }
 
 /*
@@ -1119,6 +1139,36 @@ cpu_est_clockrate(int cpu_id, uint64_t *
 	return (0);
 }
 
+static int	cpu_idle_hlt = 1;
+TUNABLE_INT("machdep.cpu_idle_hlt", &cpu_idle_hlt);
+SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW,
+    &cpu_idle_hlt, 0, "Idle loop HLT enable");
+
+static void cpu_idle_default(void);
+
+
+/* Other subsystems (e.g., ACPI) can hook this later. */
+void (*cpu_idle_hook)(void) = cpu_idle_default;
+
+#ifdef XEN
+
+void
+cpu_halt(void)
+{
+	HYPERVISOR_shutdown(SHUTDOWN_poweroff);
+}
+
+int scheduler_running;
+
+static void
+cpu_idle_default(void)
+{
+
+	enable_intr();
+	idle_block();
+}
+
+#else
 /*
  * Shutdown the CPU as much as possible
  */
@@ -1144,10 +1194,6 @@ cpu_halt(void)
  * XXX I'm turning it on for SMP as well by default for now.  It seems to
  * help lock contention somewhat, and this is critical for HTT. -Peter
  */
-static int	cpu_idle_hlt = 1;
-TUNABLE_INT("machdep.cpu_idle_hlt", &cpu_idle_hlt);
-SYSCTL_INT(_machdep, OID_AUTO, cpu_idle_hlt, CTLFLAG_RW,
-    &cpu_idle_hlt, 0, "Idle loop HLT enable");
 
 static void
 cpu_idle_default(void)
@@ -1160,6 +1206,8 @@ cpu_idle_default(void)
 	__asm __volatile("sti; hlt");
 }
 
+#endif
+
 /*
  * Note that we have to be careful here to avoid a race between checking
  * sched_runnable() and actually halting.  If we don't do this, we may waste
@@ -1184,9 +1232,6 @@ cpu_idle(void)
 	}
 }
 
-/* Other subsystems (e.g., ACPI) can hook this later. */
-void (*cpu_idle_hook)(void) = cpu_idle_default;
-
 /*
  * Clear registers on exec
  */
@@ -1309,10 +1354,16 @@ SYSCTL_ULONG(_machdep, OID_AUTO, guessed
  */
 
 int _default_ldt;
+
+#ifdef XEN
+union descriptor *gdt;
+union descriptor *ldt;
+#else
 union descriptor gdt[NGDT * MAXCPU];	/* global descriptor table */
+union descriptor ldt[NLDT];		/* local descriptor table */
+#endif
 static struct gate_descriptor idt0[NIDT];
 struct gate_descriptor *idt = &idt0[0];	/* interrupt descriptor table */
-union descriptor ldt[NLDT];		/* local descriptor table */
 struct region_descriptor r_gdt, r_idt;	/* table descriptors */
 struct mtx dt_lock;			/* lock for GDT and LDT */
 
@@ -1337,7 +1388,7 @@ struct soft_segment_descriptor gdt_segs[
 {	0x0,			/* segment base address  */
 	0x0,			/* length */
 	0,			/* segment type */
-	0,			/* segment descriptor priority level */
+	SEL_KPL,		/* segment descriptor priority level */
 	0,			/* segment descriptor present */
 	0, 0,
 	0,			/* default 32 vs 16 bit size */
@@ -1346,7 +1397,7 @@ struct soft_segment_descriptor gdt_segs[
 {	0x0,			/* segment base address  */
 	0xfffff,		/* length - all address space */
 	SDT_MEMRWA,		/* segment type */
-	0,			/* segment descriptor priority level */
+	SEL_KPL,		/* segment descriptor priority level */
 	1,			/* segment descriptor present */
 	0, 0,
 	1,			/* default 32 vs 16 bit size */
@@ -1373,7 +1424,7 @@ struct soft_segment_descriptor gdt_segs[
 {	0x0,			/* segment base address  */
 	0xfffff,		/* length - all address space */
 	SDT_MEMERA,		/* segment type */
-	0,			/* segment descriptor priority level */
+	SEL_KPL,		/* segment descriptor priority level */
 	1,			/* segment descriptor present */
 	0, 0,
 	1,			/* default 32 vs 16 bit size */
@@ -1382,7 +1433,7 @@ struct soft_segment_descriptor gdt_segs[
 {	0x0,			/* segment base address  */
 	0xfffff,		/* length - all address space */
 	SDT_MEMRWA,		/* segment type */
-	0,			/* segment descriptor priority level */
+	SEL_KPL,		/* segment descriptor priority level */
 	1,			/* segment descriptor present */
 	0, 0,
 	1,			/* default 32 vs 16 bit size */
@@ -1409,11 +1460,12 @@ struct soft_segment_descriptor gdt_segs[
 {	0x400,			/* segment base address */
 	0xfffff,		/* length */
 	SDT_MEMRWA,		/* segment type */
-	0,			/* segment descriptor priority level */
+	SEL_KPL,		/* segment descriptor priority level */
 	1,			/* segment descriptor present */
 	0, 0,
 	1,			/* default 32 vs 16 bit size */
 	1  			/* limit granularity (byte/page units)*/ },
+#ifndef XEN
 /* GPROC0_SEL	9 Proc 0 Tss Descriptor */
 {
 	0x0,			/* segment base address */
@@ -1505,6 +1557,7 @@ struct soft_segment_descriptor gdt_segs[
 	0, 0,
 	0,			/* default 32 vs 16 bit size */
 	0  			/* limit granularity (byte/page units)*/ },
+#endif /* !XEN */
 };
 
 static struct soft_segment_descriptor ldt_segs[] = {
@@ -1742,7 +1795,16 @@ getmemsize(int first)
 		goto physmap_done;
 	}
 #endif
-
+#if defined(XEN)
+	has_smap = 0;
+	Maxmem = xen_start_info->nr_pages - init_first;
+	physmem = Maxmem;
+	basemem = 0;
+	physmap[0] = init_first << PAGE_SHIFT;
+	physmap[1] = ptoa(Maxmem) - round_page(MSGBUF_SIZE);
+	physmap_idx = 0;
+	goto physmap_done;
+#endif	
 	hasbrokenint12 = 0;
 	TUNABLE_INT_FETCH("hw.hasbrokenint12", &hasbrokenint12);
 	bzero(&vmf, sizeof(vmf));
@@ -1904,7 +1966,7 @@ int15e820:
 		vmf.vmf_ah = 0x88;
 		vm86_intcall(0x15, &vmf);
 		extmem = vmf.vmf_ax;
-#else
+#elif !defined(XEN)
 		/*
 		 * Prefer the RTC value for extended memory.
 		 */
@@ -1995,6 +2057,7 @@ physmap_done:
 	    getenv_quad("dcons.size", &dcons_size) == 0)
 		dcons_addr = 0;
 
+#ifndef XEN
 	/*
 	 * physmap is in bytes, so when converting to page boundaries,
 	 * round up the start address and round down the end address.
@@ -2112,7 +2175,11 @@ do_next:
 	}
 	*pte = 0;
 	invltlb();
-
+#else
+	phys_avail[0] = physfree;
+	phys_avail[1] = xen_start_info->nr_pages*PAGE_SIZE;
+#endif
+	
 	/*
 	 * XXX
 	 * The last chunk must contain at least one page plus the message
@@ -2135,8 +2202,227 @@ do_next:
 	for (off = 0; off < round_page(MSGBUF_SIZE); off += PAGE_SIZE)
 		pmap_kenter((vm_offset_t)msgbufp + off, phys_avail[pa_indx] +
 		    off);
+
+	PT_UPDATES_FLUSH();
+}
+
+#ifdef XEN
+#define MTOPSIZE (1<<(14 + PAGE_SHIFT))
+
+void
+init386(first)
+	int first;
+{
+	unsigned long gdtmachpfn;
+	int error, gsel_tss, metadata_missing, x;
+	struct pcpu *pc;
+	struct callback_register event = {
+		.type = CALLBACKTYPE_event,
+		.address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)Xhypervisor_callback },
+	};
+	struct callback_register failsafe = {
+		.type = CALLBACKTYPE_failsafe,
+		.address = {GSEL(GCODE_SEL, SEL_KPL), (unsigned long)failsafe_callback },
+	};
+
+	thread0.td_kstack = proc0kstack;
+	thread0.td_pcb = (struct pcb *)
+	   (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
+
+	/*
+ 	 * This may be done better later if it gets more high level
+ 	 * components in it. If so just link td->td_proc here.
+	 */
+	proc_linkup0(&proc0, &thread0);
+
+	metadata_missing = 0;
+	if (xen_start_info->mod_start) {
+		preload_metadata = (caddr_t)xen_start_info->mod_start;
+		preload_bootstrap_relocate(KERNBASE);
+	} else {
+		metadata_missing = 1;
+	}
+	if (envmode == 1)
+		kern_envp = static_env;
+	else if ((caddr_t)xen_start_info->cmd_line)
+	        kern_envp = xen_setbootenv((caddr_t)xen_start_info->cmd_line);
+
+	boothowto |= xen_boothowto(kern_envp);
+	
+	/* Init basic tunables, hz etc */
+	init_param1();
+
+	/*
+	 * XEN occupies a portion of the upper virtual address space 
+	 * At its base it manages an array mapping machine page frames 
+	 * to physical page frames - hence we need to be able to 
+	 * access 4GB - (64MB  - 4MB + 64k) 

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-projects mailing list