[SLOF] [PATCH v3 1/6] Link libnet code to Paflof and add a wrapper for netboot()

Alexey Kardashevskiy aik at ozlabs.ru
Thu Oct 13 10:41:20 AEDT 2016


On 12/10/16 21:44, Thomas Huth wrote:
> 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 by
> the netboot() function.

This breaks my netboot setup.

Expected:
==============================================
Trying to load:  from: /pci at 800000020000000/ethernet at 2 ...
 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP: done
  Using IPv4 address: 10.61.191.0
  Requesting file "image.aiktest0" via TFTP from 10.61.2.7
  Receiving data:  270 KBytes
  TFTP: Received image.aiktest0 (270 KBytes)
  Successfully loaded

Try to netboot

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP: done
  Using IPv4 address: 10.61.191.0
  Requesting file "/etc/01-c0-41-49-4b-00-00" via TFTP from 10.61.2.7
  Receiving data:  0 KBytes
  TFTP: Received /etc/01-c0-41-49-4b-00-00 (0 KBytes)
Config file read, 468 bytes


Welcome to yaboot
Hit <TAB> for boot options.


Welcome to yaboot version 1.3.17.141415
Enter "help" to get some basic usage information
boot:
==============================================


What I get:
==============================================
Trying to load:  from: /pci at 800000020000000/ethernet at 2 ...
 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP: done
  Using IPv4 address: 10.61.191.0
  Requesting file "image.aiktest0" via TFTP from 10.61.2.7
  Receiving data:  270 KBytes
  TFTP: Received image.aiktest0 (270 KBytes)
  Successfully loaded

Try to netboot

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file
ERROR: stack overflow in engine()!

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc
Error, can't read config file
Welcome to yaboot version 1.3.17.141415
Enter "help" to get some basic usage information
boot:
Please wait, loading kernel...

 Initializing NIC
  Reading MAC address from device: c0:41:49:4b:00:00
  Requesting information via DHCP:  010writemethod 'load' failed fffffbbc

Can't read Elf e_ident/e_type/e_machine info
boot:
==============================================



My QEMU cmd line:
==============================================
/home/aik/p/qemu-kvm/ppc64-softmmu/qemu-system-ppc64 -enable-kvm -m 4G \
-nodefaults \
-chardev stdio,id=STDIO0,signal=off,mux=on \
-device spapr-vty,id=svty0,chardev=STDIO0,reg=0x71000100 \
-mon id=MON0,chardev=STDIO0,mode=readline -nographic -vga none \
-device virtio-serial-pci,id=vserial0 \
-netdev tap,id=TAP0,vhost=on,helper=/home/aik/qemu-bridge-helper \
-device \
"virtio-net-pci,id=vnet0,bootindex=+1,mac=C0:41:49:4b:00:00,netdev=TAP0" \
-trace events=qemu_trace_events \
-machine pseries \
-smp 16,threads=8 \
-L /home/aik/t/qemu-ppc64-bios/ -bios ./slof.bin
==============================================

My yaboot config:
==============================================
alexey at bran:/srv/tftp$ cat ./etc/01-c0-41-49-4b-00-01
init-message = "\nWelcome to yaboot\nHit <TAB> for boot options.\n\n"
timeout=2000
default=3.11.aik

#image=zImage.3.11.aik
image=aik/vmlinux-3.11.aik
	label=3.11.aik
	initrd=aik/initramfs-3.11.aik.img
	read-only
	append="console=hvc0 pci=pcie_bus_safe"

image=aik/vmlinuz.rhel7
	label=aik.rhel7
	initrd=aik/initrd.img.rhel7
	read-only
	append="ro inst.sshd inst.repo=http://10.33.4.4/distros/rhel7/
root=live:http://10.33.4.4/distros/rhel7/LiveOS/squashfs.img vnc=1"
==============================================


> 
> Signed-off-by: Thomas Huth <thuth at redhat.com>
> ---
>  board-qemu/slof/Makefile     |  8 +++++---
>  clients/net-snk/app/main.c   |  2 --
>  lib/libnet/libnet.code       | 19 +++++++++++++++++++
>  lib/libnet/libnet.in         |  2 ++
>  slof/fs/packages/obp-tftp.fs |  7 ++++---
>  5 files changed, 30 insertions(+), 8 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 940a15a..efca16e 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/clients/net-snk/app/main.c b/clients/net-snk/app/main.c
> index 22aeba7..3a01ac6 100644
> --- a/clients/net-snk/app/main.c
> +++ b/clients/net-snk/app/main.c
> @@ -31,8 +31,6 @@ main(int argc, char *argv[])
>  	int i;
>  	of_set_callback((void *) &_callback_entry);
>  
> -	if (strcmp(argv[0], "netboot") == 0 && argc >= 5)
> -		return netboot(argc, argv);
>  	if (strcmp(argv[0], "ping") == 0)
>  		return ping(argc, argv);
>  #ifdef SNK_BIOSEMU_APPS
> diff --git a/lib/libnet/libnet.code b/lib/libnet/libnet.code
> new file mode 100644
> index 0000000..66f955f
> --- /dev/null
> +++ b/lib/libnet/libnet.code
> @@ -0,0 +1,19 @@
> +
> +#include <netapps.h>
> +
> +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
> 


-- 
Alexey


More information about the SLOF mailing list