[SLOF] [PATCH 07/11] Link libnet code to Paflof and add a wrapper for netboot()

Thomas Huth thuth at redhat.com
Sat Sep 10 05:52:05 AEST 2016


Now that all necessary functions are provided by Paflof, too,
we can finally link the libnet code to this binary. To be able
to call the netboot() function from the Forth code now, we also
add a wrapper that takes the parameter string from the obp-tftp
package and converts it to an argv array that is expected from
the netboot() function.

Signed-off-by: Thomas Huth <thuth at redhat.com>
---
 board-qemu/slof/Makefile     |  8 +++++---
 lib/libnet/libnet.code       | 19 +++++++++++++++++++
 lib/libnet/libnet.in         |  2 ++
 slof/fs/packages/obp-tftp.fs |  7 ++++---
 4 files changed, 30 insertions(+), 6 deletions(-)
 create mode 100644 lib/libnet/libnet.code
 create mode 100644 lib/libnet/libnet.in

diff --git a/board-qemu/slof/Makefile b/board-qemu/slof/Makefile
index 9cd6c0a..129a4ab 100644
--- a/board-qemu/slof/Makefile
+++ b/board-qemu/slof/Makefile
@@ -21,7 +21,7 @@ all: version.o Makefile.dep OF.ffs paflof $(SLOFCMNDIR)/xvect.bin
 CPPFLAGS = -I$(LIBCMNDIR)/libbootmsg -I$(LIBCMNDIR)/libhvcall \
 	   -I$(LIBCMNDIR)/libvirtio -I$(LIBCMNDIR)/libnvram \
 	   -I$(LIBCMNDIR)/libusb -I$(LIBCMNDIR)/libveth \
-	   -I$(LIBCMNDIR)/libe1k
+	   -I$(LIBCMNDIR)/libe1k  -I$(LIBCMNDIR)/libnet
 SLOF_LIBS = \
 	$(LIBCMNDIR)/libbootmsg.a \
 	$(LIBCMNDIR)/libelf.a \
@@ -30,7 +30,8 @@ SLOF_LIBS = \
 	$(LIBCMNDIR)/libusb.a \
 	$(LIBCMNDIR)/libnvram.a \
 	$(LIBCMNDIR)/libveth.a \
-	$(LIBCMNDIR)/libe1k.a
+	$(LIBCMNDIR)/libe1k.a \
+	$(LIBCMNDIR)/libnet.a
 BOARD_SLOF_IN = \
 	$(LIBCMNDIR)/libhvcall/hvcall.in \
 	$(LIBCMNDIR)/libvirtio/virtio.in \
@@ -40,7 +41,8 @@ BOARD_SLOF_IN = \
 	$(LIBCMNDIR)/libnvram/libnvram.in \
 	$(LIBCMNDIR)/libbases/libbases.in \
 	$(LIBCMNDIR)/libveth/veth.in \
-	$(LIBCMNDIR)/libe1k/e1k.in
+	$(LIBCMNDIR)/libe1k/e1k.in \
+	$(LIBCMNDIR)/libnet/libnet.in
 BOARD_SLOF_CODE = $(BOARD_SLOF_IN:%.in=%.code)
 
 include $(SLOFCMNDIR)/Makefile.inc
diff --git a/lib/libnet/libnet.code b/lib/libnet/libnet.code
new file mode 100644
index 0000000..f528ba3
--- /dev/null
+++ b/lib/libnet/libnet.code
@@ -0,0 +1,19 @@
+
+extern int netboot(int argc, char *argv[]);
+
+PRIM(NET_X2d_LOAD)
+	int slen = TOS.n; POP;
+	char *arg = TOS.a;
+	char *argvs[8];
+	int i, p;
+	argvs[0] = arg;
+	i = 1;
+	for (p = 0; p < slen; p++) {
+		if (arg[p] == ' ') {
+			arg[p] = 0;
+			argvs[i] = &arg[p + 1];
+			i++;
+		}
+	}
+	TOS.n = netboot(i, argvs);
+MIRP
diff --git a/lib/libnet/libnet.in b/lib/libnet/libnet.in
new file mode 100644
index 0000000..365587c
--- /dev/null
+++ b/lib/libnet/libnet.in
@@ -0,0 +1,2 @@
+
+cod(NET-LOAD)
diff --git a/slof/fs/packages/obp-tftp.fs b/slof/fs/packages/obp-tftp.fs
index 047c9b6..e26025d 100644
--- a/slof/fs/packages/obp-tftp.fs
+++ b/slof/fs/packages/obp-tftp.fs
@@ -38,15 +38,16 @@ INSTANCE VARIABLE ciregs-buffer
     (u.) s" netboot " 2swap $cat s"  60000000 " $cat
 
     \ Allocate 1720 bytes to store the BOOTP-REPLY packet
-    6B8 alloc-mem dup >r (u.) $cat s"  " $cat
+    6B8 alloc-mem dup >r (u.) $cat
     huge-tftp-load @ IF s"  1 " ELSE s"  0 " THEN $cat
     \ Add desired TFTP-Blocksize as additional argument
     s" 1432 " $cat
     \ Add OBP-TFTP Bootstring argument, e.g. "10.128.0.1,bootrom.bin,10.128.40.1"
     my-args $cat
+    \ Zero-terminate string
+    s"  " $cat 2dup + 1 - 0 swap c!
 
-    \ Call SNK netboot loadr
-    (client-exec) dup 0< IF drop 0 THEN
+    net-load dup 0< IF drop 0 THEN
 
     \ Restore to old client interface register 
     ciregs-buffer @ ciregs ciregs-size move
-- 
1.8.3.1



More information about the SLOF mailing list