From patchwork Fri Sep 9 19:52:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 668217 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sW7CQ4B8sz9s5w for ; Sat, 10 Sep 2016 05:52:34 +1000 (AEST) Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3sW7CQ3FFQzDsFG for ; Sat, 10 Sep 2016 05:52:34 +1000 (AEST) X-Original-To: slof@lists.ozlabs.org Delivered-To: slof@lists.ozlabs.org Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3sW7CC0M19zDrqL for ; Sat, 10 Sep 2016 05:52:23 +1000 (AEST) Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 685A24E4C7; Fri, 9 Sep 2016 19:52:21 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u89Jq9Yw006604; Fri, 9 Sep 2016 15:52:20 -0400 From: Thomas Huth To: slof@lists.ozlabs.org Date: Fri, 9 Sep 2016 21:52:05 +0200 Message-Id: <1473450729-19359-8-git-send-email-thuth@redhat.com> In-Reply-To: <1473450729-19359-1-git-send-email-thuth@redhat.com> References: <1473450729-19359-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 09 Sep 2016 19:52:21 +0000 (UTC) Subject: [SLOF] [PATCH 07/11] Link libnet code to Paflof and add a wrapper for netboot() X-BeenThere: slof@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Patches for https://github.com/aik/SLOF" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: slof-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "SLOF" 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 --- 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