ARM/integratorcp support for rumprun

  • From: Antti Kantee <pooka@xxxxxx>
  • To: rumpkernel-users <rumpkernel-users@xxxxxxxxxxxxx>
  • Date: Thu, 13 Aug 2015 14:30:28 +0000

Hi,

So I finally got around to making rumprun work on some ARM system. By coincidence, that system happened to be the Integrator CP board, since that was the first thing that showed up on ddg as having good QEMU support.

The bits to rumprun have been committed. The catch is that some changes to src-netbsd are needed. As usual, figuring out how to properly integrate code is much more difficult than just writing it, so it might take a while before support is available "out-of-the-box". In case someone is interested in repeating the ARM experiment now, I'm attaching the current set of patches. In addition to applying that patch against src-netbsd, you also need src/sys/arch/evbarm/{dev,ifpga,integrator} from the NetBSD tree.

I'm currently gearing towards ARM boards simply being components. Those components define which devices are present and how to access them. That's what librumpboard_integrator is about (rumpdev_bus_space obviously doesn't belong in there, but it was a quick way to get things going). Theoretically, assuming the same compiler target, you could even select which ARM system you want to run on by baking against the correct board target. If someone has better ideas, shoot/shout.

I did light testing by running a simple TCP/IP application and ping -f, so MD stability seems reasonable.

Here's the "dmesg":
https://gist.github.com/anttikantee/417f881bfeca1f0c3606

If someone still has one of these boards, would be interesting to hear if the system works also on metal.

Now we need some infrastructure changes to rumprun to better support architectures with incompatible "boards" (as opposed to x86 where everything is pretty much plug-and-play uniform).

- antti
diff --git a/lib/libc/arch/arm/Makefile.inc b/lib/libc/arch/arm/Makefile.inc
index b3d2182..33f5e46 100644
--- a/lib/libc/arch/arm/Makefile.inc
+++ b/lib/libc/arch/arm/Makefile.inc
@@ -2,7 +2,9 @@

.include <bsd.own.mk>

+.if ${RUMPRUN} != "yes"
SRCS+= __aeabi_read_tp.S __sigaction14_sigtramp.c __sigtramp2.S
+.endif

.if empty(LIBC_MACHINE_ARCH:Mearmv7*)
AFLAGS+= -marm
diff --git a/sys/rump/dev/lib/libintegrator/INTEGRATOR.ioconf
b/sys/rump/dev/lib/libintegrator/INTEGRATOR.ioconf
new file mode 100644
index 0000000..aaf5dc1
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/INTEGRATOR.ioconf
@@ -0,0 +1,16 @@
+# $NetBSD$
+#
+
+ioconf integrator
+
+include "conf/files"
+include "rump/dev/files.rump"
+
+pseudo-root mainbus*
+
+device ifpga {[offset = -1], [irq = -1]}: bus_space_generic
+attach ifpga at mainbus
+ifpga* at mainbus0
+
+attach sm at ifpga with sm_ifpga
+sm0 at ifpga? offset 0xb8000000 irq 27
diff --git a/sys/rump/dev/lib/libintegrator/Makefile
b/sys/rump/dev/lib/libintegrator/Makefile
new file mode 100644
index 0000000..6138250
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/Makefile
@@ -0,0 +1,26 @@
+.include <bsd.own.mk>
+
+.PATH: ${.CURDIR}/../../../../arch/evbarm/ifpga \
+ ${.CURDIR}/../../../../dev/ic
+
+RUMPTOP= ${TOPRUMP}
+
+LIB= rumpboard_integrator
+IOCONF= INTEGRATOR.ioconf
+
+SRCS= ifpga.c sm_ifpga.c
+SRCS+= smc91cxx.c
+SRCS+= rumpdev_bus_space.c
+SRCS+= integrator_component.c
+
+CPPFLAGS+= -I${.CURDIR}
+
+RUMPCOMP_USER_SRCS= ifpga_user.c
+RUMPCOMP_USER_CPPFLAGS+=-I${.CURDIR}/../../../../../../include
+RUMPCOMP_USER_CPPFLAGS+=-I${.CURDIR}/../../../../../../platform/hw/include
+
+.undef RUMPKERN_ONLY
+
+.include "${RUMPTOP}/Makefile.rump"
+.include <bsd.lib.mk>
+.include <bsd.klinks.mk>
diff --git a/sys/rump/dev/lib/libintegrator/ifpga_user.c
b/sys/rump/dev/lib/libintegrator/ifpga_user.c
new file mode 100644
index 0000000..5644c73
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/ifpga_user.c
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2015 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <hw/types.h>
+#include <hw/kernel.h>
+
+#include "rumpcomp_ifpga_user.h"
+
+int
+rumpcomp_ifpga_intr_establish(int (*f)(void *), void *arg, int irq)
+{
+
+ return bmk_isr_init(f, arg, irq);
+}
diff --git a/sys/rump/dev/lib/libintegrator/integrator_component.c
b/sys/rump/dev/lib/libintegrator/integrator_component.c
new file mode 100644
index 0000000..9502e6f
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/integrator_component.c
@@ -0,0 +1,48 @@
+/* $NetBSD$ */
+
+/*
+ * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD$");
+
+#include <sys/param.h>
+#include <sys/conf.h>
+#include <sys/device.h>
+#include <sys/mbuf.h>
+#include <sys/stat.h>
+
+#include <dev/audio_if.h>
+
+#include "ioconf.c"
+
+#include "rump_private.h"
+
+RUMP_COMPONENT(RUMP_COMPONENT_DEV)
+{
+
+ config_init_component(cfdriver_ioconf_integrator,
+ cfattach_ioconf_integrator, cfdata_ioconf_integrator);
+}
diff --git a/sys/rump/dev/lib/libintegrator/opt_inet.h
b/sys/rump/dev/lib/libintegrator/opt_inet.h
new file mode 100644
index 0000000..9897da6
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/opt_inet.h
@@ -0,0 +1 @@
+#define INET
diff --git a/sys/rump/dev/lib/libintegrator/opt_pci.h
b/sys/rump/dev/lib/libintegrator/opt_pci.h
new file mode 100644
index 0000000..e69de29
diff --git a/sys/rump/dev/lib/libintegrator/pci.h
b/sys/rump/dev/lib/libintegrator/pci.h
new file mode 100644
index 0000000..e69de29
diff --git a/sys/rump/dev/lib/libintegrator/rumpcomp_ifpga_user.h
b/sys/rump/dev/lib/libintegrator/rumpcomp_ifpga_user.h
new file mode 100644
index 0000000..18253f7
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/rumpcomp_ifpga_user.h
@@ -0,0 +1 @@
+int rumpcomp_ifpga_intr_establish(int (*)(void *), void *, int);
diff --git a/sys/rump/dev/lib/libintegrator/rumpdev_bus_space.c
b/sys/rump/dev/lib/libintegrator/rumpdev_bus_space.c
new file mode 100644
index 0000000..055ede1
--- /dev/null
+++ b/sys/rump/dev/lib/libintegrator/rumpdev_bus_space.c
@@ -0,0 +1,282 @@
+/* $NetBSD: rumpdev_bus_space.c,v 1.5 2015/06/15 15:38:52 pooka Exp $
*/
+
+/*-
+ * Copyright (c) 2013 Antti Kantee. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/atomic.h>
+#include <sys/bus.h>
+
+#include <sys/param.h>
+
+void ifpga_intr_init(void);
+void ifpga_intr_postinit(void);
+void
+ifpga_intr_init(void)
+{ }
+void
+ifpga_intr_postinit(void)
+{ }
+
+int ifpga_common_bs_tag;
+
+#include <evbarm/ifpga/ifpgavar.h>
+
+#include "rumpcomp_ifpga_user.h"
+
+void *
+ifpga_intr_establish(int irq, int ipl, int (*f)(void *), void *arg)
+{
+
+ if (rumpcomp_ifpga_intr_establish(f, arg, irq) != 0)
+ return NULL;
+ return (void *)1;
+}
+
+int
+bus_space_map(bus_space_tag_t bst, bus_addr_t address, bus_size_t size,
+ int flags, bus_space_handle_t *handlep)
+{
+
+ *handlep = address + 0x10000000;
+ return 0;
+}
+
+uint8_t
+bus_space_read_1(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset)
+{
+ uint8_t rv;
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("inb %1, %0" : "=a"(rv) : "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ rv = *(volatile uint8_t *)(bsh + offset);
+ }
+
+ return rv;
+}
+
+uint16_t
+bus_space_read_2(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset)
+{
+ uint16_t rv;
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("in %1, %0" : "=a"(rv) : "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ rv = *(volatile uint16_t *)(bsh + offset);
+ }
+
+ return rv;
+}
+
+uint32_t
+bus_space_read_4(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset)
+{
+ uint32_t rv;
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("inl %1, %0" : "=a"(rv) : "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ rv = *(volatile uint32_t *)(bsh + offset);
+ }
+
+ return rv;
+}
+
+void
+bus_space_read_multi_1(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint8_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ *datap++ = bus_space_read_1(bst, bsh, offset);
+ bus_space_barrier(bst, bsh, offset, 1, BUS_SPACE_BARRIER_READ);
+ }
+}
+
+void
+bus_space_read_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint16_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ *datap++ = bus_space_read_2(bst, bsh, offset);
+ bus_space_barrier(bst, bsh, offset, 2, BUS_SPACE_BARRIER_READ);
+ }
+}
+
+void
+bus_space_read_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint32_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ *datap++ = bus_space_read_4(bst, bsh, offset);
+ bus_space_barrier(bst, bsh, offset, 4, BUS_SPACE_BARRIER_READ);
+ }
+}
+
+void
+bus_space_write_1(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint8_t v)
+{
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("outb %0, %1" :: "a"(v), "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ *(volatile uint8_t *)(bsh + offset) = v;
+ }
+}
+
+void
+bus_space_write_2(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint16_t v)
+{
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("out %0, %1" :: "a"(v), "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ *(volatile uint16_t *)(bsh + offset) = v;
+ }
+}
+
+void
+bus_space_write_4(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, uint32_t v)
+{
+
+ if (bst == 0) {
+#ifdef IOSPACE_SUPPORTED
+ unsigned short addr = bsh + offset;
+ __asm__ __volatile__("outl %0, %1" :: "a"(v), "d"(addr));
+#else
+ panic("IO space not supported");
+#endif
+ } else {
+ *(volatile uint32_t *)(bsh + offset) = v;
+ }
+}
+
+void
+bus_space_write_multi_1(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, const uint8_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ const uint8_t value = *datap++;
+
+ bus_space_write_1(bst, bsh, offset, value);
+ bus_space_barrier(bst, bsh, offset, 1, BUS_SPACE_BARRIER_WRITE);
+ }
+}
+
+void
+bus_space_write_multi_2(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, const uint16_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ const uint16_t value = *datap++;
+
+ bus_space_write_2(bst, bsh, offset, value);
+ bus_space_barrier(bst, bsh, offset, 2, BUS_SPACE_BARRIER_WRITE);
+ }
+}
+
+void
+bus_space_write_multi_4(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, const uint32_t *datap, bus_size_t count)
+{
+
+ while (count--) {
+ const uint32_t value = *datap++;
+
+ bus_space_write_4(bst, bsh, offset, value);
+ bus_space_barrier(bst, bsh, offset, 4, BUS_SPACE_BARRIER_WRITE);
+ }
+}
+
+paddr_t
+bus_space_mmap(bus_space_tag_t bst, bus_addr_t addr, off_t off,
+ int prot, int flags)
+{
+
+ panic("%s: unimplemented", __func__);
+}
+
+int
+bus_space_subregion(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, bus_size_t size, bus_space_handle_t *nhandlep)
+{
+
+ *nhandlep = bsh + offset;
+ return 0;
+}
+
+void
+bus_space_unmap(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t size)
+{
+
+ panic("%s: unimplemented", __func__);
+}
+
+void
+bus_space_barrier(bus_space_tag_t bst, bus_space_handle_t bsh,
+ bus_size_t offset, bus_size_t len, int flags)
+{
+
+ /* weelll ... */
+ membar_sync();
+}
diff --git a/sys/rump/dev/lib/libmiiphy/Makefile
b/sys/rump/dev/lib/libmiiphy/Makefile
index f795ce3..efa683d 100644
--- a/sys/rump/dev/lib/libmiiphy/Makefile
+++ b/sys/rump/dev/lib/libmiiphy/Makefile
@@ -10,7 +10,7 @@ IOCONF= MIIPHY.ioconf

SRCS= phy_at_mii.c

-SRCS+= mii.c mii_ethersubr.c mii_physubr.c ukphy.c ukphy_subr.c
+SRCS+= mii.c mii_bitbang.c mii_ethersubr.c mii_physubr.c ukphy.c ukphy_subr.c
SRCS+= acphy.c amhphy.c atphy.c bmtphy.c brgphy.c ciphy.c dmphy.c etphy.c \
exphy.c gentbi.c glxtphy.c gphyter.c icsphy.c igphy.c ihphy.c ikphy.c \
inphy.c iophy.c lxtphy.c makphy.c nsphy.c nsphyter.c pnaphy.c \
diff --git a/sys/rump/include/sys/bus.h b/sys/rump/include/sys/bus.h
index c7eedbc..50b499b 100644
--- a/sys/rump/include/sys/bus.h
+++ b/sys/rump/include/sys/bus.h
@@ -35,9 +35,15 @@
*/

/* bus space defs */
+#if 0
+typedef unsigned long bus_space_tag_t;
+#else
+struct bus_space;
+typedef struct bus_space *bus_space_tag_t;
+#endif
+
typedef unsigned long bus_addr_t;
typedef unsigned long bus_size_t;
-typedef unsigned long bus_space_tag_t;
typedef unsigned long bus_space_handle_t;

/* bus dma defs */

Other related posts:

  • » ARM/integratorcp support for rumprun - Antti Kantee