Implement network booting directly into the s390-ccw BIOS
cover Implement network booting directly into the s390-ccw BIOS
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.ins
The .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
Thomas
Thomas Huth (14):
pc-bios/s390-ccw: Add the libc from the SLOF firmware pc-bios/s390-ccw: Start using the libc from SLOF pc-bios/s390-ccw: Add a write() function for stdio pc-bios/s390-ccw: Add implementation of sbrk() pc-bios/s390-ccw: Add the TFTP network loading stack from SLOF
libnet: Remove remainders of netsave code
libnet: Rework error message printing
libnet: Refactor some code of netload() into a separate function pc-bios/s390-ccw: Make the basic libnet code compilable pc-bios/s390-ccw: Add timer code for the libnet pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Load file via an intermediate .INS file pc-bios/s390-ccw: Allow loading to address 0 pc-bios/s390-ccw: Wire up the netload code
configure | 6 +- hw/s390x/ipl.c | 2 +- pc-bios/s390-ccw/Makefile | 14 +- pc-bios/s390-ccw/bootmap.c | 10 +- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/libc/Makefile | 47 ++ pc-bios/s390-ccw/libc/README.txt | 49 ++ pc-bios/s390-ccw/libc/ctype/Makefile.inc | 21 + pc-bios/s390-ccw/libc/ctype/isdigit.c | 25 + pc-bios/s390-ccw/libc/ctype/isprint.c | 18 + pc-bios/s390-ccw/libc/ctype/isspace.c | 29 + pc-bios/s390-ccw/libc/ctype/isxdigit.c | 21 + pc-bios/s390-ccw/libc/ctype/tolower.c | 18 + pc-bios/s390-ccw/libc/ctype/toupper.c | 21 + pc-bios/s390-ccw/libc/include/ctype.h | 24 + pc-bios/s390-ccw/libc/include/errno.h | 34 + pc-bios/s390-ccw/libc/include/limits.h | 32 + pc-bios/s390-ccw/libc/include/stdarg.h | 22 + pc-bios/s390-ccw/libc/include/stdbool.h | 20 + pc-bios/s390-ccw/libc/include/stddef.h | 25 + pc-bios/s390-ccw/libc/include/stdint.h | 28 + pc-bios/s390-ccw/libc/include/stdio.h | 63 ++ pc-bios/s390-ccw/libc/include/stdlib.h | 34 + pc-bios/s390-ccw/libc/include/string.h | 37 ++ pc-bios/s390-ccw/libc/include/sys/socket.h | 53 ++ pc-bios/s390-ccw/libc/include/unistd.h | 28 + pc-bios/s390-ccw/libc/stdio/Makefile.inc | 24 + pc-bios/s390-ccw/libc/stdio/fileno.c | 19 + pc-bios/s390-ccw/libc/stdio/fprintf.c | 26 + pc-bios/s390-ccw/libc/stdio/printf.c | 27 + pc-bios/s390-ccw/libc/stdio/putc.c | 25 + pc-bios/s390-ccw/libc/stdio/putchar.c | 21 + pc-bios/s390-ccw/libc/stdio/puts.c | 28 + pc-bios/s390-ccw/libc/stdio/setvbuf.c | 28 + pc-bios/s390-ccw/libc/stdio/sprintf.c | 30 + pc-bios/s390-ccw/libc/stdio/stdchnls.c | 23 + pc-bios/s390-ccw/libc/stdio/vfprintf.c | 27 + pc-bios/s390-ccw/libc/stdio/vsnprintf.c | 298 +++++++++ pc-bios/s390-ccw/libc/stdio/vsprintf.c | 19 + pc-bios/s390-ccw/libc/stdlib/Makefile.inc | 23 + pc-bios/s390-ccw/libc/stdlib/atoi.c | 18 + pc-bios/s390-ccw/libc/stdlib/atol.c | 18 + pc-bios/s390-ccw/libc/stdlib/error.c | 15 + pc-bios/s390-ccw/libc/stdlib/free.c | 26 + pc-bios/s390-ccw/libc/stdlib/malloc.c | 157 +++++ pc-bios/s390-ccw/libc/stdlib/malloc_defs.h | 16 + pc-bios/s390-ccw/libc/stdlib/memalign.c | 26 + pc-bios/s390-ccw/libc/stdlib/rand.c | 29 + pc-bios/s390-ccw/libc/stdlib/realloc.c | 40 ++ pc-bios/s390-ccw/libc/stdlib/strtol.c | 115 ++++ pc-bios/s390-ccw/libc/stdlib/strtoul.c | 105 ++++ pc-bios/s390-ccw/libc/string/Makefile.inc | 23 + pc-bios/s390-ccw/libc/string/memchr.c | 29 + pc-bios/s390-ccw/libc/string/memcmp.c | 30 + pc-bios/s390-ccw/libc/string/memcpy.c | 27 + pc-bios/s390-ccw/libc/string/memmove.c | 42 ++ pc-bios/s390-ccw/libc/string/memset.c | 25 + pc-bios/s390-ccw/libc/string/strcasecmp.c | 28 + pc-bios/s390-ccw/libc/string/strcat.c | 24 + pc-bios/s390-ccw/libc/string/strchr.c | 28 + pc-bios/s390-ccw/libc/string/strcmp.c | 28 + pc-bios/s390-ccw/libc/string/strcpy.c | 25 + pc-bios/s390-ccw/libc/string/strlen.c | 27 + pc-bios/s390-ccw/libc/string/strncasecmp.c | 32 + pc-bios/s390-ccw/libc/string/strncmp.c | 31 + pc-bios/s390-ccw/libc/string/strncpy.c | 33 + pc-bios/s390-ccw/libc/string/strstr.c | 37 ++ pc-bios/s390-ccw/libc/string/strtok.c | 45 ++ pc-bios/s390-ccw/libnet/Makefile | 42 ++ pc-bios/s390-ccw/libnet/args.c | 179 ++++++ pc-bios/s390-ccw/libnet/args.h | 23 + pc-bios/s390-ccw/libnet/dhcp.c | 955 +++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/dhcp.h | 49 ++ pc-bios/s390-ccw/libnet/dhcpv6.c | 212 +++++++ pc-bios/s390-ccw/libnet/dhcpv6.h | 154 +++++ pc-bios/s390-ccw/libnet/dns.c | 526 ++++++++++++++++ pc-bios/s390-ccw/libnet/dns.h | 28 + pc-bios/s390-ccw/libnet/ethernet.c | 189 ++++++ pc-bios/s390-ccw/libnet/ethernet.h | 47 ++ pc-bios/s390-ccw/libnet/icmpv6.c | 409 ++++++++++++ pc-bios/s390-ccw/libnet/icmpv6.h | 135 ++++ pc-bios/s390-ccw/libnet/ipv4.c | 898 +++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv4.h | 97 +++ pc-bios/s390-ccw/libnet/ipv6.c | 774 +++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv6.h | 188 ++++++ pc-bios/s390-ccw/libnet/ndp.c | 184 ++++++ pc-bios/s390-ccw/libnet/ndp.h | 72 +++ pc-bios/s390-ccw/libnet/netapps.h | 25 + pc-bios/s390-ccw/libnet/netload.c | 600 ++++++++++++++++++ pc-bios/s390-ccw/libnet/tcp.c | 46 ++ pc-bios/s390-ccw/libnet/tcp.h | 27 + pc-bios/s390-ccw/libnet/tftp.c | 595 ++++++++++++++++++ pc-bios/s390-ccw/libnet/tftp.h | 50 ++ pc-bios/s390-ccw/libnet/time.h | 6 + pc-bios/s390-ccw/libnet/timer.c | 40 ++ pc-bios/s390-ccw/libnet/udp.c | 115 ++++ pc-bios/s390-ccw/libnet/udp.h | 53 ++ pc-bios/s390-ccw/main.c | 3 +- pc-bios/s390-ccw/s390-ccw.h | 30 +- pc-bios/s390-ccw/sbrk.c | 39 ++ pc-bios/s390-ccw/sclp.c | 32 +- pc-bios/s390-ccw/virtio-net.c | 125 ++++ pc-bios/s390-ccw/virtio.c | 16 +- pc-bios/s390-ccw/virtio.h | 11 + 104 files changed, 9296 insertions(+), 57 deletions(-) create mode 100644 pc-bios/s390-ccw/libc/Makefile create mode 100644 pc-bios/s390-ccw/libc/README.txt create mode 100644 pc-bios/s390-ccw/libc/ctype/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/ctype/isdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isprint.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isspace.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isxdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/tolower.c create mode 100644 pc-bios/s390-ccw/libc/ctype/toupper.c create mode 100644 pc-bios/s390-ccw/libc/include/ctype.h create mode 100644 pc-bios/s390-ccw/libc/include/errno.h create mode 100644 pc-bios/s390-ccw/libc/include/limits.h create mode 100644 pc-bios/s390-ccw/libc/include/stdarg.h create mode 100644 pc-bios/s390-ccw/libc/include/stdbool.h create mode 100644 pc-bios/s390-ccw/libc/include/stddef.h create mode 100644 pc-bios/s390-ccw/libc/include/stdint.h create mode 100644 pc-bios/s390-ccw/libc/include/stdio.h create mode 100644 pc-bios/s390-ccw/libc/include/stdlib.h create mode 100644 pc-bios/s390-ccw/libc/include/string.h create mode 100644 pc-bios/s390-ccw/libc/include/sys/socket.h create mode 100644 pc-bios/s390-ccw/libc/include/unistd.h create mode 100644 pc-bios/s390-ccw/libc/stdio/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdio/fileno.c create mode 100644 pc-bios/s390-ccw/libc/stdio/fprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/printf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putc.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putchar.c create mode 100644 pc-bios/s390-ccw/libc/stdio/puts.c create mode 100644 pc-bios/s390-ccw/libc/stdio/setvbuf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/sprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/stdchnls.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vfprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsnprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdlib/atoi.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/atol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/error.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/free.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc_defs.h create mode 100644 pc-bios/s390-ccw/libc/stdlib/memalign.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/rand.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/realloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtoul.c create mode 100644 pc-bios/s390-ccw/libc/string/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/string/memchr.c create mode 100644 pc-bios/s390-ccw/libc/string/memcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/memcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/memmove.c create mode 100644 pc-bios/s390-ccw/libc/string/memset.c create mode 100644 pc-bios/s390-ccw/libc/string/strcasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcat.c create mode 100644 pc-bios/s390-ccw/libc/string/strchr.c create mode 100644 pc-bios/s390-ccw/libc/string/strcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strlen.c create mode 100644 pc-bios/s390-ccw/libc/string/strncasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strstr.c create mode 100644 pc-bios/s390-ccw/libc/string/strtok.c create mode 100644 pc-bios/s390-ccw/libnet/Makefile create mode 100644 pc-bios/s390-ccw/libnet/args.c create mode 100644 pc-bios/s390-ccw/libnet/args.h create mode 100644 pc-bios/s390-ccw/libnet/dhcp.c create mode 100644 pc-bios/s390-ccw/libnet/dhcp.h create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.c create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.h create mode 100644 pc-bios/s390-ccw/libnet/dns.c create mode 100644 pc-bios/s390-ccw/libnet/dns.h create mode 100644 pc-bios/s390-ccw/libnet/ethernet.c create mode 100644 pc-bios/s390-ccw/libnet/ethernet.h create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.c create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.h create mode 100644 pc-bios/s390-ccw/libnet/ipv4.c create mode 100644 pc-bios/s390-ccw/libnet/ipv4.h create mode 100644 pc-bios/s390-ccw/libnet/ipv6.c create mode 100644 pc-bios/s390-ccw/libnet/ipv6.h create mode 100644 pc-bios/s390-ccw/libnet/ndp.c create mode 100644 pc-bios/s390-ccw/libnet/ndp.h create mode 100644 pc-bios/s390-ccw/libnet/netapps.h create mode 100644 pc-bios/s390-ccw/libnet/netload.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.h create mode 100644 pc-bios/s390-ccw/libnet/tftp.c create mode 100644 pc-bios/s390-ccw/libnet/tftp.h create mode 100644 pc-bios/s390-ccw/libnet/time.h create mode 100644 pc-bios/s390-ccw/libnet/timer.c create mode 100644 pc-bios/s390-ccw/libnet/udp.c create mode 100644 pc-bios/s390-ccw/libnet/udp.h create mode 100644 pc-bios/s390-ccw/sbrk.c create mode 100644 pc-bios/s390-ccw/virtio-net.c
Signature · 1 line
1.8.3.1
RFC PATCH 2/14 pc-bios/s390-ccw: Start using the libc from SLOF
Change the Makefiles to make the libc compilable within the s390-ccw firmware build system, link it and start using it by switching the implementations of the memset() and memcpy() functions to the ones from the libc.
--- configure | 5 ++-- pc-bios/s390-ccw/Makefile | 8 ++++++- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/libc/Makefile | 38 ++++++++++--------------------- pc-bios/s390-ccw/libc/ctype/Makefile.inc | 3 ++- pc-bios/s390-ccw/libc/stdio/Makefile.inc | 9 ++++---- pc-bios/s390-ccw/libc/stdlib/Makefile.inc | 3 ++- pc-bios/s390-ccw/libc/string/Makefile.inc | 3 ++- pc-bios/s390-ccw/s390-ccw.h | 30 +++--------------------- 9 files changed, 37 insertions(+), 63 deletions(-)
configure +3 -2
@@ -6377,7 +6377,8 @@ fi # build tree in object directory in case the source is not in the current directory DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" DIRS="$DIRS docs docs/interop fsdev" -DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas pc-bios/s390-ccw" +DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" +DIRS="$DIRS pc-bios/s390-ccw pc-bios/s390-ccw/libc" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
@@ -6385,7 +6386,7 @@ FILES="$FILES tests/tcg/cris/Makefile tests/tcg/cris/.gdbinit" FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" -FILES="$FILES pc-bios/s390-ccw/Makefile" +FILES="$FILES pc-bios/s390-ccw/Makefile pc-bios/s390-ccw/libc/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" FILES="$FILES pc-bios/qemu-icon.bmp" FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
pc-bios/s390-ccw/Makefile +7 -1
@@ -7,12 +7,14 @@ include $(SRC_PATH)/rules.mak $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) -.PHONY : all clean build-all +.PHONY : all clean build-all libc.a OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o +OBJECTS += libc.a QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing +QEMU_CFLAGS += -I$(SRC_PATH)/pc-bios/s390-ccw/libc/include QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) LDFLAGS += -Wl,-pie -nostdlib
@@ -21,6 +23,9 @@ build-all: s390-ccw.img s390-ccw.elf: $(OBJECTS) $(call quiet-command,$(CC) $(LDFLAGS) -o $@ $(OBJECTS),"BUILD","$(TARGET_DIR)$@") +libc.a: + @$(MAKE) -C libc V="$(V)" + STRIP ?= strip s390-ccw.img: s390-ccw.elf
@@ -30,3 +35,4 @@ $(OBJECTS): Makefile clean: rm -f *.o *.d *.img *.elf *~ + @$(MAKE) -C libc clean
pc-bios/s390-ccw/bootmap.h +1 -0
@@ -11,6 +11,7 @@#ifndef _PC_BIOS_S390_CCW_BOOTMAP_H#define _PC_BIOS_S390_CCW_BOOTMAP_H +#include <stddef.h> #include "s390-ccw.h" #include "virtio.h"
pc-bios/s390-ccw/libc/Makefile +12 -26
@@ -10,52 +10,38 @@ # * IBM Corporation - initial implementation # ****************************************************************************/ -TOPCMNDIR ?= ../.. +include ../../../config-host.mak +include $(SRC_PATH)/rules.mak -LIBCCMNDIR = $(shell pwd) +LIBCCMNDIR = $(SRC_PATH)/pc-bios/s390-ccw/libc STRINGCMNDIR = $(LIBCCMNDIR)/string CTYPECMNDIR = $(LIBCCMNDIR)/ctype STDLIBCMNDIR = $(LIBCCMNDIR)/stdlib STDIOCMNDIR = $(LIBCCMNDIR)/stdio -GETOPTCMNDIR = $(LIBCCMNDIR)/getopt -include $(TOPCMNDIR)/make.rules - - -CPPFLAGS = -I$(LIBCCMNDIR)/include -LDFLAGS= -nostdlib +QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float +QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) +QEMU_CFLAGS += -I$(LIBCCMNDIR)/include +LDFLAGS += -Wl,-pie -nostdlib TARGET = ../libc.a - all: $(TARGET) -# Use the following target to build a native version of the lib -# (for example for debugging purposes): -native: - $(MAKE) CROSS="" CC=$(HOSTCC) NATIVEBUILD=1 - - include $(STRINGCMNDIR)/Makefile.inc include $(CTYPECMNDIR)/Makefile.inc include $(STDLIBCMNDIR)/Makefile.inc include $(STDIOCMNDIR)/Makefile.inc -include $(GETOPTCMNDIR)/Makefile.inc - -OBJS = $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) $(GETOPT_OBJS) -ifneq ($(NATIVEBUILD),1) -# These parts of the libc use assembler, so they can only be compiled when -# we are _not_ building a native version. -endif +OBJS = $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) $(TARGET): $(OBJS) - $(AR) -rc $@ $(OBJS) - $(RANLIB) $@ - + $(call quiet-command,$(AR) -rc $@ $(OBJS),"AR","$(TARGET_DIR)$@") clean: - $(RM) $(TARGET) $(OBJS) + rm -f $(TARGET) $(OBJS) distclean: clean
pc-bios/s390-ccw/libc/ctype/Makefile.inc +2 -1
@@ -17,4 +17,5 @@ CTYPE_SRCS = $(CTYPE_SRC_C:%=$(CTYPECMNDIR)/%) $(CTYPE_SRC_ASM:%=$(CTYPECMNDIR)/ CTYPE_OBJS = $(CTYPE_SRC_C:%.c=%.o) $(CTYPE_SRC_ASM:%.S=%.o) %.o : $(CTYPECMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $($@-cflags) \ + -c -o $@ $<,"CC","$(TARGET_DIR)$@")
pc-bios/s390-ccw/libc/stdio/Makefile.inc +5 -4
@@ -11,13 +11,14 @@ # ****************************************************************************/ -STDIO_SRC_C = fscanf.c sprintf.c vfprintf.c vsnprintf.c vsprintf.c fprintf.c \ - printf.c setvbuf.c putc.c puts.c putchar.c scanf.c stdchnls.c \ - vfscanf.c vsscanf.c fileno.c +STDIO_SRC_C = sprintf.c vfprintf.c vsnprintf.c vsprintf.c fprintf.c \ + printf.c setvbuf.c putc.c puts.c putchar.c stdchnls.c \ + fileno.c STDIO_SRC_ASM = STDIO_SRCS = $(STDIO_SRC_C:%=$(STDIOCMNDIR)/%) $(STDIO_SRC_ASM:%=$(STDIOCMNDIR)/%) STDIO_OBJS = $(STDIO_SRC_C:%.c=%.o) $(STDIO_SRC_ASM:%.S=%.o) %.o : $(STDIOCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $($@-cflags) \ + -c -o $@ $<,"CC","$(TARGET_DIR)$@")
pc-bios/s390-ccw/libc/stdlib/Makefile.inc +2 -1
@@ -19,4 +19,5 @@ STDLIB_SRCS = $(STDLIB_SRC_C:%=$(STDLIBCMNDIR)/%) $(STDLIB_SRC_ASM:%=$(STDLIBCMN STDLIB_OBJS = $(STDLIB_SRC_C:%.c=%.o) $(STDLIB_SRC_ASM:%.S=%.o) %.o : $(STDLIBCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $($@-cflags) \ + -c -o $@ $<,"CC","$(TARGET_DIR)$@")
pc-bios/s390-ccw/libc/string/Makefile.inc +2 -1
@@ -19,4 +19,5 @@ STRING_SRCS = $(STRING_SRC_C:%=$(STRINGCMNDIR)/%) $(STRING_SRC_ASM:%=$(STRINGCMN STRING_OBJS = $(STRING_SRC_C:%.c=%.o) $(STRING_SRC_ASM:%.S=%.o) %.o : $(STRINGCMNDIR)/%.c - $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ + $(call quiet-command,$(CC) $(QEMU_CFLAGS) $(CFLAGS) $($@-cflags) \ + -c -o $@ $<,"CC","$(TARGET_DIR)$@")
pc-bios/s390-ccw/s390-ccw.h +3 -27
@@ -11,6 +11,8 @@#ifndef S390_CCW_H #define S390_CCW_H +#include <string.h> +/* #define DEBUG */ typedef unsigned char u8 ;
@@ -18,7 +20,6 @@ typedef unsigned short u16;typedef unsigned int u32 ;typedef unsigned long long u64 ;typedef unsigned long ulong ; -typedef long size_t ;typedef int bool ;typedef unsigned char uint8_t ;typedef unsigned short uint16_t ;
@@ -39,9 +40,7 @@ typedef unsigned long long __u64;#ifndef EBUSY #define EBUSY 2#endif -#ifndef NULL -#define NULL 0 -#endif +#ifndef MIN #define MIN (a, b) (((a) < (b)) ? (a) : (b))#endif
@@ -88,18 +87,6 @@ ulong get_second(void);/* bootmap.c */ void zipl_load (void ); -static inline void *memset (void *s,int c,size_t n) -{ -int i; -unsigned char *p = s; - -for (i =0 ; i < n; i++) { - p[i] = c; - } - -return s; -} -static inline void fill_hex (char *out,unsigned char val) {const char hex[] ="0123456789abcdef" ;
@@ -169,17 +156,6 @@ static inline void sleep(unsigned int seconds) } } -static inline void *memcpy (void *s1,const void *s2,size_t n) -{ -uint8_t *p1 = s1; -const uint8_t *p2 = s2; - -while (n--) { - p1[n] = p2[n]; - } -return s1; -} -static inline void IPL_assert (bool term,const char *message) {if (!term) {
Signature · 1 line
1.8.3.1
RFC PATCH 3/14 pc-bios/s390-ccw: Add a write() function for stdio
In reply to Thomas HuthThe stdio functions from the SLOF libc need a write() function for printing text to stdout/stderr. Let's implement this function by refactoring the code from sclp_print().
--- pc-bios/s390-ccw/sclp.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
pc-bios/s390-ccw/sclp.c +14 -18
@@ -8,6 +8,7 @@* directory. */ +#include <unistd.h> #include "s390-ccw.h" #include "sclp.h"
@@ -51,34 +52,29 @@ void sclp_setup(void)sclp_set_write_mask (); } -static int _strlen (const char *str) +ssize_t write (int fd,const void *buf,size_t len) { -int i; -for (i =0 ; *str; i++) - str++; -return i; -} - -static void _memcpy (char *dest,const char *src,int len) -{ -int i; -for (i =0 ; i < len; i++) - dest[i] = src[i]; -} - -void sclp_print (const char *str) -{ -int len =_strlen (str);WriteEventData *sccb = (void *)_sccb; +if (fd !=1 && fd !=2 ) { +return -EIO ; + } + sccb->h.length =sizeof (WriteEventData) + len; sccb->h.function_code =SCLP_FC_NORMAL_WRITE ; sccb->ebh.length =sizeof (EventBufferHeader) + len; sccb->ebh.type =SCLP_EVENT_ASCII_CONSOLE_DATA ; sccb->ebh.flags =0 ; -_memcpy (sccb->data, str, len); +memcpy (sccb->data, buf, len);sclp_service_call (SCLP_CMD_WRITE_EVENT_DATA , sccb); + +return len; +} + +void sclp_print (const char *str) +{ +write (1 , str,strlen (str)); }void sclp_get_loadparm_ascii (char *loadparm)
Signature · 1 line
1.8.3.1
RFC PATCH 4/14 pc-bios/s390-ccw: Add implementation of sbrk()
In reply to Thomas HuthTo be able to use malloc() and friends from the SLOF libc, we need to provide an implementation of the sbrk() function. This patch adds such an implemenation, which has been taken from the SLOF firmware, too. Since the sbrk() function uses a big array as the heap, we now also have got to lower the fwbase in hw/s390x/ipl.c accordingly.
--- hw/s390x/ipl.c | 2 +- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/sbrk.c | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 pc-bios/s390-ccw/sbrk.c
hw/s390x/ipl.c +1 -1
@@ -113,7 +113,7 @@ static void s390_ipl_realize(DeviceState *dev, Error **errp)* even if an external kernel has been defined. */ if (!ipl->kernel || ipl->enforce_bios) { -uint64_t fwbase = (MIN (ram_size,0x80000000U ) -0x200000 ) & ~0xffffUL ; +uint64_t fwbase = (MIN (ram_size,0x80000000U ) -0x400000 ) & ~0xffffUL ;if (bios_name ==NULL ) { bios_name = ipl->firmware;
pc-bios/s390-ccw/Makefile +1 -1
@@ -10,7 +10,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) .PHONY : all clean build-all libc.a OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o -OBJECTS += libc.a +OBJECTS += libc.a sbrk.o QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing
pc-bios/s390-ccw/sbrk.c new file +39 -0
@@ -0,0 +1,39 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <unistd.h> + +#define HEAP_SIZE 0x200000 + + +static char heap[HEAP_SIZE ]; +static char *actptr; + +void *sbrk (int increment) +{ +char *oldptr; + +/* Called for the first time? Then init the actual pointer */ +if (!actptr) { + actptr = heap; + } + +if (actptr + increment > heap +HEAP_SIZE ) { +/* Out of memory */ +return (void *)-1 ; + } + + oldptr = actptr; + actptr += increment; + +return oldptr; +}
Signature · 1 line
1.8.3.1
RFC PATCH 6/14 libnet: Remove remainders of netsave code
In reply to Thomas HuthThe code does not exist in the repository, so it does not make sense to keep the prototypes and the Forth wrapper around.
--- pc-bios/s390-ccw/libnet/netapps.h | 1 - pc-bios/s390-ccw/libnet/tftp.h | 2 -- 2 files changed, 3 deletions(-)
pc-bios/s390-ccw/libnet/netapps.h +0 -1
@@ -20,7 +20,6 @@ struct filename_ip;extern int netload (char *buffer,int len,char *ret_buffer,int huge_load,int block_size,char *args_fs,int alen); -extern int netsave (int argc,char *argv[]);extern int ping (char *args_fs,int alen);extern int dhcp (char *ret_buffer,struct filename_ip *fn_ip,unsigned int retries,int flags);
pc-bios/s390-ccw/libnet/tftp.h +0 -2
@@ -42,8 +42,6 @@ typedef struct {int tftp (filename_ip_t *,unsigned char *,int ,unsigned int ,tftp_err_t *,int32_t mode,int32_t blocksize,int ip_version); -int tftp_netsave (filename_ip_t *,uint8_t * buffer,int len, -int use_ci,unsigned int retries,tftp_err_t * tftp_err);int32_t handle_tftp (int fd,uint8_t *,int32_t );void handle_tftp_dun (uint8_t err_code);
Signature · 1 line
1.8.3.1
RFC PATCH 1/14 pc-bios/s390-ccw: Add the libc from the SLOF firmware
In reply to Thomas HuthTo be able to use some more advanced libc functions in the s390-ccw firmware, like printf() and malloc(), we need a better libc here. This patch adds the C library from the SLOF firmware (taken from the SLOF commit ID 62674aabe20612a9786fa03e87cf6916ba97a99a). The files are copied without modifications here and will be adapted for the s390-ccw firmware by the next patch. I just removed the getopt() and scanf()-like functions from the libc since we likely do not need them in the s390-ccw firmware.
--- pc-bios/s390-ccw/libc/Makefile | 61 ++++++ pc-bios/s390-ccw/libc/README.txt | 49 +++++ pc-bios/s390-ccw/libc/ctype/Makefile.inc | 20 ++ pc-bios/s390-ccw/libc/ctype/isdigit.c | 25 +++ pc-bios/s390-ccw/libc/ctype/isprint.c | 18 ++ pc-bios/s390-ccw/libc/ctype/isspace.c | 29 +++ pc-bios/s390-ccw/libc/ctype/isxdigit.c | 21 ++ pc-bios/s390-ccw/libc/ctype/tolower.c | 18 ++ pc-bios/s390-ccw/libc/ctype/toupper.c | 21 ++ pc-bios/s390-ccw/libc/include/ctype.h | 24 +++ pc-bios/s390-ccw/libc/include/errno.h | 34 ++++ pc-bios/s390-ccw/libc/include/limits.h | 32 ++++ pc-bios/s390-ccw/libc/include/stdarg.h | 22 +++ pc-bios/s390-ccw/libc/include/stdbool.h | 20 ++ pc-bios/s390-ccw/libc/include/stddef.h | 25 +++ pc-bios/s390-ccw/libc/include/stdint.h | 28 +++ pc-bios/s390-ccw/libc/include/stdio.h | 63 ++++++ pc-bios/s390-ccw/libc/include/stdlib.h | 34 ++++ pc-bios/s390-ccw/libc/include/string.h | 37 ++++ pc-bios/s390-ccw/libc/include/sys/socket.h | 53 +++++ pc-bios/s390-ccw/libc/include/unistd.h | 28 +++ pc-bios/s390-ccw/libc/stdio/Makefile.inc | 23 +++ pc-bios/s390-ccw/libc/stdio/fileno.c | 19 ++ pc-bios/s390-ccw/libc/stdio/fprintf.c | 26 +++ pc-bios/s390-ccw/libc/stdio/printf.c | 27 +++ pc-bios/s390-ccw/libc/stdio/putc.c | 25 +++ pc-bios/s390-ccw/libc/stdio/putchar.c | 21 ++ pc-bios/s390-ccw/libc/stdio/puts.c | 28 +++ pc-bios/s390-ccw/libc/stdio/setvbuf.c | 28 +++ pc-bios/s390-ccw/libc/stdio/sprintf.c | 30 +++ pc-bios/s390-ccw/libc/stdio/stdchnls.c | 23 +++ pc-bios/s390-ccw/libc/stdio/vfprintf.c | 27 +++ pc-bios/s390-ccw/libc/stdio/vsnprintf.c | 298 +++++++++++++++++++++++++++++ pc-bios/s390-ccw/libc/stdio/vsprintf.c | 19 ++ pc-bios/s390-ccw/libc/stdlib/Makefile.inc | 22 +++ pc-bios/s390-ccw/libc/stdlib/atoi.c | 18 ++ pc-bios/s390-ccw/libc/stdlib/atol.c | 18 ++ pc-bios/s390-ccw/libc/stdlib/error.c | 15 ++ pc-bios/s390-ccw/libc/stdlib/free.c | 26 +++ pc-bios/s390-ccw/libc/stdlib/malloc.c | 157 +++++++++++++++ pc-bios/s390-ccw/libc/stdlib/malloc_defs.h | 16 ++ pc-bios/s390-ccw/libc/stdlib/memalign.c | 26 +++ pc-bios/s390-ccw/libc/stdlib/rand.c | 29 +++ pc-bios/s390-ccw/libc/stdlib/realloc.c | 40 ++++ pc-bios/s390-ccw/libc/stdlib/strtol.c | 115 +++++++++++ pc-bios/s390-ccw/libc/stdlib/strtoul.c | 105 ++++++++++ pc-bios/s390-ccw/libc/string/Makefile.inc | 22 +++ pc-bios/s390-ccw/libc/string/memchr.c | 29 +++ pc-bios/s390-ccw/libc/string/memcmp.c | 30 +++ pc-bios/s390-ccw/libc/string/memcpy.c | 27 +++ pc-bios/s390-ccw/libc/string/memmove.c | 42 ++++ pc-bios/s390-ccw/libc/string/memset.c | 25 +++ pc-bios/s390-ccw/libc/string/strcasecmp.c | 28 +++ pc-bios/s390-ccw/libc/string/strcat.c | 24 +++ pc-bios/s390-ccw/libc/string/strchr.c | 28 +++ pc-bios/s390-ccw/libc/string/strcmp.c | 28 +++ pc-bios/s390-ccw/libc/string/strcpy.c | 25 +++ pc-bios/s390-ccw/libc/string/strlen.c | 27 +++ pc-bios/s390-ccw/libc/string/strncasecmp.c | 32 ++++ pc-bios/s390-ccw/libc/string/strncmp.c | 31 +++ pc-bios/s390-ccw/libc/string/strncpy.c | 33 ++++ pc-bios/s390-ccw/libc/string/strstr.c | 37 ++++ pc-bios/s390-ccw/libc/string/strtok.c | 45 +++++ 63 files changed, 2356 insertions(+) create mode 100644 pc-bios/s390-ccw/libc/Makefile create mode 100644 pc-bios/s390-ccw/libc/README.txt create mode 100644 pc-bios/s390-ccw/libc/ctype/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/ctype/isdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isprint.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isspace.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isxdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/tolower.c create mode 100644 pc-bios/s390-ccw/libc/ctype/toupper.c create mode 100644 pc-bios/s390-ccw/libc/include/ctype.h create mode 100644 pc-bios/s390-ccw/libc/include/errno.h create mode 100644 pc-bios/s390-ccw/libc/include/limits.h create mode 100644 pc-bios/s390-ccw/libc/include/stdarg.h create mode 100644 pc-bios/s390-ccw/libc/include/stdbool.h create mode 100644 pc-bios/s390-ccw/libc/include/stddef.h create mode 100644 pc-bios/s390-ccw/libc/include/stdint.h create mode 100644 pc-bios/s390-ccw/libc/include/stdio.h create mode 100644 pc-bios/s390-ccw/libc/include/stdlib.h create mode 100644 pc-bios/s390-ccw/libc/include/string.h create mode 100644 pc-bios/s390-ccw/libc/include/sys/socket.h create mode 100644 pc-bios/s390-ccw/libc/include/unistd.h create mode 100644 pc-bios/s390-ccw/libc/stdio/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdio/fileno.c create mode 100644 pc-bios/s390-ccw/libc/stdio/fprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/printf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putc.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putchar.c create mode 100644 pc-bios/s390-ccw/libc/stdio/puts.c create mode 100644 pc-bios/s390-ccw/libc/stdio/setvbuf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/sprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/stdchnls.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vfprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsnprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdlib/atoi.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/atol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/error.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/free.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc_defs.h create mode 100644 pc-bios/s390-ccw/libc/stdlib/memalign.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/rand.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/realloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtoul.c create mode 100644 pc-bios/s390-ccw/libc/string/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/string/memchr.c create mode 100644 pc-bios/s390-ccw/libc/string/memcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/memcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/memmove.c create mode 100644 pc-bios/s390-ccw/libc/string/memset.c create mode 100644 pc-bios/s390-ccw/libc/string/strcasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcat.c create mode 100644 pc-bios/s390-ccw/libc/string/strchr.c create mode 100644 pc-bios/s390-ccw/libc/string/strcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strlen.c create mode 100644 pc-bios/s390-ccw/libc/string/strncasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strstr.c create mode 100644 pc-bios/s390-ccw/libc/string/strtok.c
pc-bios/s390-ccw/libc/Makefile new file +61 -0
@@ -0,0 +1,61 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + +TOPCMNDIR ?= ../.. + +LIBCCMNDIR = $(shell pwd) +STRINGCMNDIR = $(LIBCCMNDIR)/string +CTYPECMNDIR = $(LIBCCMNDIR)/ctype +STDLIBCMNDIR = $(LIBCCMNDIR)/stdlib +STDIOCMNDIR = $(LIBCCMNDIR)/stdio +GETOPTCMNDIR = $(LIBCCMNDIR)/getopt + +include $(TOPCMNDIR)/make.rules + + +CPPFLAGS = -I$(LIBCCMNDIR)/include +LDFLAGS= -nostdlib + +TARGET = ../libc.a + + +all: $(TARGET) + +# Use the following target to build a native version of the lib +# (for example for debugging purposes): +native: + $(MAKE) CROSS="" CC=$(HOSTCC) NATIVEBUILD=1 + + +include $(STRINGCMNDIR)/Makefile.inc +include $(CTYPECMNDIR)/Makefile.inc +include $(STDLIBCMNDIR)/Makefile.inc +include $(STDIOCMNDIR)/Makefile.inc +include $(GETOPTCMNDIR)/Makefile.inc + +OBJS = $(STRING_OBJS) $(CTYPE_OBJS) $(STDLIB_OBJS) $(STDIO_OBJS) $(GETOPT_OBJS) + +ifneq ($(NATIVEBUILD),1) +# These parts of the libc use assembler, so they can only be compiled when +# we are _not_ building a native version. +endif + + +$(TARGET): $(OBJS) + $(AR) -rc $@ $(OBJS) + $(RANLIB) $@ + + +clean: + $(RM) $(TARGET) $(OBJS) + +distclean: clean
pc-bios/s390-ccw/libc/README.txt new file +49 -0
49 lines not on this page · raw message
pc-bios/s390-ccw/libc/ctype/Makefile.inc new file +20 -0
@@ -0,0 +1,20 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + + +CTYPE_SRC_C = isdigit.c isprint.c isspace.c isxdigit.c tolower.c toupper.c +CTYPE_SRC_ASM = +CTYPE_SRCS = $(CTYPE_SRC_C:%=$(CTYPECMNDIR)/%) $(CTYPE_SRC_ASM:%=$(CTYPECMNDIR)/%) +CTYPE_OBJS = $(CTYPE_SRC_C:%.c=%.o) $(CTYPE_SRC_ASM:%.S=%.o) + +%.o : $(CTYPECMNDIR)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
pc-bios/s390-ccw/libc/ctype/isdigit.c new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <ctype.h> + +int isdigit (int ch) +{ +switch (ch) { +case '0' :case '1' :case '2' :case '3' :case '4' : +case '5' :case '6' :case '7' :case '8' :case '9' : +return 1 ; + +default : +return 0 ; + } +}
pc-bios/s390-ccw/libc/ctype/isprint.c new file +18 -0
@@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <ctype.h> + +int isprint (int ch) +{ +return (ch >=32 && ch <127 ); +}
pc-bios/s390-ccw/libc/ctype/isspace.c new file +29 -0
@@ -0,0 +1,29 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <ctype.h> + +int isspace (int ch) +{ +switch (ch) { +case ' ' : +case '\f' : +case '\n' : +case '\r' : +case '\t' : +case '\v' : +return 1 ; + +default : +return 0 ; + } +}
pc-bios/s390-ccw/libc/ctype/isxdigit.c new file +21 -0
@@ -0,0 +1,21 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <ctype.h> + +int isxdigit (int ch) +{ +return ( + (ch >='0' && ch <='9' ) | + (ch >='A' && ch <='F' ) | + (ch >='a' && ch <='f' ) ); +}
pc-bios/s390-ccw/libc/ctype/tolower.c new file +18 -0
@@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <ctype.h> + +int tolower (int c) +{ +return (((c >='A' ) && (c <='Z' )) ? (c -'A' +'a' ) : c); +}
pc-bios/s390-ccw/libc/ctype/toupper.c new file +21 -0
@@ -0,0 +1,21 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "ctype.h" + +int toupper (int cha) +{ +if ((cha >='a' ) && (cha <='z' )) +return (cha -'a' +'A' ); +return (cha); +}
pc-bios/s390-ccw/libc/include/ctype.h new file +24 -0
@@ -0,0 +1,24 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _CTYPE_H +#define _CTYPE_H + +int isdigit (int c); +int isxdigit (int c); +int isprint (int c); +int isspace (int c); + +int tolower (int c); +int toupper (int c); + +#endif
pc-bios/s390-ccw/libc/include/errno.h new file +34 -0
@@ -0,0 +1,34 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _ERRNO_H +#define _ERRNO_H + +extern int errno; + +/* +* Error number definitions +*/ +#define EPERM 1/* not permitted */ +#define ENOENT 2/* file or directory not found */ +#define EIO 5/* input/output error */ +#define ENOMEM 12/* not enough space */ +#define EACCES 13/* permission denied */ +#define EFAULT 14/* bad address */ +#define EBUSY 16/* resource busy */ +#define EEXIST 17/* file already exists */ +#define ENODEV 19/* device not found */ +#define EINVAL 22/* invalid argument */ +#define EDOM 33/* math argument out of domain of func */ +#define ERANGE 34/* math result not representable */ + +#endif
pc-bios/s390-ccw/libc/include/limits.h new file +32 -0
@@ -0,0 +1,32 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _LIMITS_H +#define _LIMITS_H + +#define UCHAR_MAX 255 +#define SCHAR_MAX 127 +#define SCHAR_MIN (-128) + +#define USHRT_MAX 65535 +#define SHRT_MAX 32767 +#define SHRT_MIN (-32768) + +#define UINT_MAX (4294967295U) +#define INT_MAX 2147483647 +#define INT_MIN (-2147483648) + +#define ULONG_MAX ((unsigned long)-1L) +#define LONG_MAX (ULONG_MAX/2) +#define LONG_MIN ((-LONG_MAX)-1) + +#endif
pc-bios/s390-ccw/libc/include/stdarg.h new file +22 -0
@@ -0,0 +1,22 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STDARG_H +#define _STDARG_H + +typedef __builtin_va_list va_list ; + +#define va_start (v,l) __builtin_va_start(v,l) +#define va_arg (v,l) __builtin_va_arg(v,l) +#define va_end (v) __builtin_va_end(v) + +#endif
pc-bios/s390-ccw/libc/include/stdbool.h new file +20 -0
@@ -0,0 +1,20 @@ +/****************************************************************************** +* Copyright (c) 2013 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STDBOOL_H +#define _STDBOOL_H + +#ifndef __cplusplus +typedef enum { false =0 , true }bool ; +#endif + +#endif
pc-bios/s390-ccw/libc/include/stddef.h new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STDDEF_H +#define _STDDEF_H + + +#define NULL ((void *)0) + + +typedef unsigned int size_t ; + + +#endif + +
pc-bios/s390-ccw/libc/include/stdint.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STDINT_H +#define _STDINT_H + +typedef unsigned char uint8_t ; +typedef signed char int8_t ; + +typedef unsigned short uint16_t ; +typedef signed short int16_t ; + +typedef unsigned int uint32_t ; +typedef signed int int32_t ; + +typedef unsigned long long uint64_t ; +typedef signed long long int64_t ; + +#endif
pc-bios/s390-ccw/libc/include/stdio.h new file +63 -0
63 lines not on this page · raw message
pc-bios/s390-ccw/libc/include/stdlib.h new file +34 -0
@@ -0,0 +1,34 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STDLIB_H +#define _STDLIB_H + +#include "stddef.h" + +#define RAND_MAX 32767 + + +void *malloc (size_t size); +void *realloc (void *ptr,size_t size); +void free (void *ptr); +void *memalign (size_t boundary,size_t size); + +int atoi (const char *str); +long atol (const char *str); +unsigned long int strtoul (const char *nptr,char **endptr,int base); +long int strtol (const char *nptr,char **endptr,int base); + +int rand (void ); +void srand (unsigned int seed); + +#endif
pc-bios/s390-ccw/libc/include/string.h new file +37 -0
@@ -0,0 +1,37 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _STRING_H +#define _STRING_H + +#include "stddef.h" + +char *strcpy (char *dest,const char *src); +char *strncpy (char *dest,const char *src,size_t n); +char *strcat (char *dest,const char *src); +int strcmp (const char *s1,const char *s2); +int strncmp (const char *s1,const char *s2,size_t n); +int strcasecmp (const char *s1,const char *s2); +int strncasecmp (const char *s1,const char *s2,size_t n); +char *strchr (const char *s,int c); +char *strrchr (const char *s,int c); +size_t strlen (const char *s); +char *strstr (const char *hay,const char *needle); +char *strtok (char *src,const char *pattern); + +void *memset (void *s,int c,size_t n); +void *memchr (const void *s,int c,size_t n); +void *memcpy (void *dest,const void *src,size_t n); +void *memmove (void *dest,const void *src,size_t n); +int memcmp (const void *s1,const void *s2,size_t n); + +#endif
pc-bios/s390-ccw/libc/include/sys/socket.h new file +53 -0
53 lines not on this page · raw message
pc-bios/s390-ccw/libc/include/unistd.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _UNISTD_H +#define _UNISTD_H + +#include <stddef.h> + +typedef long ssize_t ; + +extern int open (const char *name,int flags); +extern int close (int fd); +extern ssize_t read (int fd,void *buf,size_t count); +extern ssize_t write (int fd,const void *buf,size_t count); +extern ssize_t lseek (int fd,long offset,int whence); + +extern void *sbrk (int increment); + +#endif
pc-bios/s390-ccw/libc/stdio/Makefile.inc new file +23 -0
@@ -0,0 +1,23 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + + +STDIO_SRC_C = fscanf.c sprintf.c vfprintf.c vsnprintf.c vsprintf.c fprintf.c \ + printf.c setvbuf.c putc.c puts.c putchar.c scanf.c stdchnls.c \ + vfscanf.c vsscanf.c fileno.c + +STDIO_SRC_ASM = +STDIO_SRCS = $(STDIO_SRC_C:%=$(STDIOCMNDIR)/%) $(STDIO_SRC_ASM:%=$(STDIOCMNDIR)/%) +STDIO_OBJS = $(STDIO_SRC_C:%.c=%.o) $(STDIO_SRC_ASM:%.S=%.o) + +%.o : $(STDIOCMNDIR)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
pc-bios/s390-ccw/libc/stdio/fileno.c new file +19 -0
@@ -0,0 +1,19 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdio.h> + +int +fileno (FILE *stream) +{ +return stream->fd; +}
pc-bios/s390-ccw/libc/stdio/fprintf.c new file +26 -0
@@ -0,0 +1,26 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "stdio.h" + + +int fprintf (FILE *stream,const char * fmt, ...) +{ +int count; +va_list ap; + +va_start (ap, fmt); + count =vfprintf (stream, fmt, ap); +va_end (ap); + +return count; +}
pc-bios/s390-ccw/libc/stdio/printf.c new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "stdio.h" + + +int printf (const char * fmt, ...) +{ +int count; +va_list ap; + +va_start (ap, fmt); + count =vfprintf (stdout, fmt, ap); +va_end (ap); + +return count; +} +
pc-bios/s390-ccw/libc/stdio/putc.c new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "stdio.h" +#include "unistd.h" + +int +putc (int ch,FILE *stream) +{ +unsigned char outchar = ch; + +if (write (stream->fd, &outchar,1 ) ==1 ) +return outchar; +else +return EOF ; +}
pc-bios/s390-ccw/libc/stdio/putchar.c new file +21 -0
@@ -0,0 +1,21 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdio.h" + + +int +putchar (int ch) +{ +return putc (ch, stdout); +}
pc-bios/s390-ccw/libc/stdio/puts.c new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdio.h" +#include "string.h" +#include "unistd.h" + + +int +puts (const char *str) +{ +int ret; + + ret =write (stdout->fd, str,strlen (str)); +write (stdout->fd,"\r\n" ,2 ); + +return ret; +}
pc-bios/s390-ccw/libc/stdio/setvbuf.c new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdio.h> + +int setvbuf (FILE *stream,char *buf,int mode ,size_t size) +{ +if (mode != _IONBF && mode != _IOLBF && mode != _IOFBF) +return -1 ; + stream->buf = buf; + stream->mode = mode; + stream->bufsiz = size; +return 0 ; +} + +void setbuf (FILE *stream,char *buf) +{ +setvbuf (stream, buf, buf ? _IOFBF : _IONBF,BUFSIZ ); +}
pc-bios/s390-ccw/libc/stdio/sprintf.c new file +30 -0
@@ -0,0 +1,30 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdio.h> + + +int sprintf (char *buff,const char *format, ...) +{ +va_list ar; +int count; + +if ((buff==NULL ) || (format==NULL )) +return (-1 ); + +va_start (ar, format); + count =vsprintf (buff, format, ar); +va_end (ar); + +return (count); +} +
pc-bios/s390-ccw/libc/stdio/stdchnls.c new file +23 -0
@@ -0,0 +1,23 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdio.h" + +static char stdin_buffer[BUFSIZ ], stdout_buffer[BUFSIZ ]; + +FILE stdin_data = { .fd =0 , .mode = _IOLBF, .pos =0 , + .buf = stdin_buffer, .bufsiz =BUFSIZ }; +FILE stdout_data = { .fd =1 , .mode = _IOLBF, .pos =0 , + .buf = stdout_buffer, .bufsiz =BUFSIZ }; +FILE stderr_data = { .fd =2 , .mode = _IONBF, .pos =0 , + .buf =NULL , .bufsiz =0 };
pc-bios/s390-ccw/libc/stdio/vfprintf.c new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "stdio.h" +#include "unistd.h" + + +int vfprintf (FILE *stream,const char *fmt,va_list ap) +{ +int count; +char buffer[320 ]; + + count =vsnprintf (buffer,sizeof (buffer), fmt, ap); +write (stream->fd, buffer, count); + +return count; +} +
pc-bios/s390-ccw/libc/stdio/vsnprintf.c new file +298 -0
298 lines not on this page · raw message
pc-bios/s390-ccw/libc/stdio/vsprintf.c new file +19 -0
@@ -0,0 +1,19 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "stdio.h" + +int +vsprintf (char *buffer,const char *format,va_list arg) +{ +return vsnprintf (buffer,0x7fffffff , format, arg); +}
pc-bios/s390-ccw/libc/stdlib/Makefile.inc new file +22 -0
@@ -0,0 +1,22 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + + +STDLIB_SRC_C = error.c atoi.c atol.c strtoul.c strtol.c rand.c \ + malloc.c memalign.c realloc.c free.c + +STDLIB_SRC_ASM = +STDLIB_SRCS = $(STDLIB_SRC_C:%=$(STDLIBCMNDIR)/%) $(STDLIB_SRC_ASM:%=$(STDLIBCMNDIR)/%) +STDLIB_OBJS = $(STDLIB_SRC_C:%.c=%.o) $(STDLIB_SRC_ASM:%.S=%.o) + +%.o : $(STDLIBCMNDIR)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
pc-bios/s390-ccw/libc/stdlib/atoi.c new file +18 -0
@@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdlib.h> + +int atoi (const char *str) +{ +return strtol (str,NULL ,0 ); +}
pc-bios/s390-ccw/libc/stdlib/atol.c new file +18 -0
@@ -0,0 +1,18 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdlib.h> + +long atol (const char *str) +{ +return strtol (str,NULL ,0 ); +}
pc-bios/s390-ccw/libc/stdlib/error.c new file +15 -0
@@ -0,0 +1,15 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +int errno; +
pc-bios/s390-ccw/libc/stdlib/free.c new file +26 -0
@@ -0,0 +1,26 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdlib.h" +#include "malloc_defs.h" + +void +free (void *ptr) +{ +struct chunk *header; + + header = (struct chunk *) ptr; + header--; + header->inuse =0 ; + +}
pc-bios/s390-ccw/libc/stdlib/malloc.c new file +157 -0
157 lines not on this page · raw message
pc-bios/s390-ccw/libc/stdlib/malloc_defs.h new file +16 -0
@@ -0,0 +1,16 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +struct chunk { +unsigned inuse :4 ; +unsigned length :28 ; +} __attribute__((packed));
pc-bios/s390-ccw/libc/stdlib/memalign.c new file +26 -0
@@ -0,0 +1,26 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdlib.h" + + +void * +memalign (size_t blocksize,size_t bytes) +{ +void *x; + + x =malloc (bytes + blocksize); + x = (void *) (((unsigned long ) x + blocksize -1 ) & ~(blocksize -1 )); + +return (void *) x; +}
pc-bios/s390-ccw/libc/stdlib/rand.c new file +29 -0
@@ -0,0 +1,29 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <stdlib.h> + + +static unsigned long _rand =1 ; + +int +rand (void ) +{ + _rand = _rand *1237732973 +34563 ; + +return ((unsigned int ) (_rand >>16 ) &RAND_MAX ); +} + +void srand (unsigned int seed) +{ + _rand = seed; +}
pc-bios/s390-ccw/libc/stdlib/realloc.c new file +40 -0
@@ -0,0 +1,40 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#include "stdlib.h" +#include "string.h" +#include "malloc_defs.h" + +void * +realloc (void *ptr,size_t size) +{ +struct chunk *header; +char *newptr, *start; + + header = (struct chunk *) ptr; + header--; + +if (size <= header->length) +return ptr; + + newptr = (char *)malloc (size); +if (newptr ==NULL ) +return 0 ; + + start = newptr; +memcpy ((void *) newptr, (const void *) ptr, header->length); + + header->inuse =0 ; + +return start; +}
pc-bios/s390-ccw/libc/stdlib/strtol.c new file +115 -0
115 lines not on this page · raw message
pc-bios/s390-ccw/libc/stdlib/strtoul.c new file +105 -0
105 lines not on this page · raw message
pc-bios/s390-ccw/libc/string/Makefile.inc new file +22 -0
@@ -0,0 +1,22 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + + +STRING_SRC_C = strcat.c strchr.c strcmp.c strcpy.c strlen.c strncmp.c \ + strncpy.c strstr.c memset.c memcpy.c memmove.c memchr.c \ + memcmp.c strcasecmp.c strncasecmp.c strtok.c +STRING_SRC_ASM = +STRING_SRCS = $(STRING_SRC_C:%=$(STRINGCMNDIR)/%) $(STRING_SRC_ASM:%=$(STRINGCMNDIR)/%) +STRING_OBJS = $(STRING_SRC_C:%.c=%.o) $(STRING_SRC_ASM:%.S=%.o) + +%.o : $(STRINGCMNDIR)/%.c + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
pc-bios/s390-ccw/libc/string/memchr.c new file +29 -0
@@ -0,0 +1,29 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "string.h" + + +void * +memchr (const void *ptr,int c,size_t n) +{ +unsigned char ch = (unsigned char )c; +const unsigned char *p = ptr; + +while (n-- >0 ) { +if (*p == ch) +return (void *)p; + p +=1 ; + } + +return NULL ; +}
pc-bios/s390-ccw/libc/string/memcmp.c new file +30 -0
@@ -0,0 +1,30 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "string.h" + + +int +memcmp (const void *ptr1,const void *ptr2,size_t n) +{ +const unsigned char *p1 = ptr1; +const unsigned char *p2 = ptr2; + +while (n-- >0 ) { +if (*p1 != *p2) +return (*p1 - *p2); + p1 +=1 ; + p2 +=1 ; + } + +return 0 ; +}
pc-bios/s390-ccw/libc/string/memcpy.c new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "string.h" + +void * +memcpy (void *dest,const void *src,size_t n) +{ +char *cdest; +const char *csrc = src; + + cdest = dest; +while (n-- >0 ) { + *cdest++ = *csrc++; + } + +return dest; +}
pc-bios/s390-ccw/libc/string/memmove.c new file +42 -0
42 lines not on this page · raw message
pc-bios/s390-ccw/libc/string/memset.c new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include "string.h" + +void * +memset (void *dest,int c,size_t size) +{ +unsigned char *d = (unsigned char *)dest; + +while (size-- >0 ) { + *d++ = (unsigned char )c; + } + +return dest; +}
pc-bios/s390-ccw/libc/string/strcasecmp.c new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> +#include <ctype.h> + +int +strcasecmp (const char *s1,const char *s2) +{ +while (*s1 !=0 && *s2 !=0 ) { +if (toupper (*s1) !=toupper (*s2)) +break ; + ++s1; + ++s2; + } + +return *s1 - *s2; +} +
pc-bios/s390-ccw/libc/string/strcat.c new file +24 -0
@@ -0,0 +1,24 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +char * +strcat (char *dst,const char *src) +{ +int p; + + p =strlen (dst); +strcpy (&dst[p], src); + +return dst; +}
pc-bios/s390-ccw/libc/string/strchr.c new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +char * +strchr (const char *s,int c) +{ +char cb = c; + +while (*s !=0 ) { +if (*s == cb) { +return (char *)s; + } + s +=1 ; + } + +return NULL ; +}
pc-bios/s390-ccw/libc/string/strcmp.c new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + + +int +strcmp (const char *s1,const char *s2) +{ +while (*s1 !=0 && *s2 !=0 ) { +if (*s1 != *s2) +break ; + s1 +=1 ; + s2 +=1 ; + } + +return *s1 - *s2; +} +
pc-bios/s390-ccw/libc/string/strcpy.c new file +25 -0
@@ -0,0 +1,25 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +char * +strcpy (char *dst,const char *src) +{ +char *ptr = dst; + +do { + *ptr++ = *src; + }while (*src++ !=0 ); + +return dst; +}
pc-bios/s390-ccw/libc/string/strlen.c new file +27 -0
@@ -0,0 +1,27 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +size_t +strlen (const char *s) +{ +int len =0 ; + +while (*s !=0 ) { + len +=1 ; + s +=1 ; + } + +return len; +} +
pc-bios/s390-ccw/libc/string/strncasecmp.c new file +32 -0
@@ -0,0 +1,32 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> +#include <ctype.h> + + +int +strncasecmp (const char *s1,const char *s2,size_t n) +{ +if (n <1 ) +return 0 ; + +while (*s1 !=0 && *s2 !=0 && --n >0 ) { +if (toupper (*s1) !=toupper (*s2)) +break ; + ++s1; + ++s2; + } + +return toupper (*s1) -toupper (*s2); +} +
pc-bios/s390-ccw/libc/string/strncmp.c new file +31 -0
@@ -0,0 +1,31 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + + +int +strncmp (const char *s1,const char *s2,size_t n) +{ +if (n <1 ) +return 0 ; + +while (*s1 !=0 && *s2 !=0 && --n >0 ) { +if (*s1 != *s2) +break ; + s1 +=1 ; + s2 +=1 ; + } + +return *s1 - *s2; +} +
pc-bios/s390-ccw/libc/string/strncpy.c new file +33 -0
@@ -0,0 +1,33 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +char * +strncpy (char *dst,const char *src,size_t n) +{ +char *ret = dst; + +/* Copy string */ +while (*src !=0 && n >0 ) { + *dst++ = *src++; + n -=1 ; + } + +/* strncpy always clears the rest of destination string... */ +while (n >0 ) { + *dst++ =0 ; + n -=1 ; + } + +return ret; +}
pc-bios/s390-ccw/libc/string/strstr.c new file +37 -0
@@ -0,0 +1,37 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#include <string.h> + +char * +strstr (const char *hay,const char *needle) +{ +char *pos; +int hlen, nlen; + +if (hay ==NULL || needle ==NULL ) +return NULL ; + + hlen =strlen (hay); + nlen =strlen (needle); +if (nlen <1 ) +return (char *)hay; + +for (pos = (char *)hay; pos < hay + hlen; pos++) { +if (strncmp (pos, needle, nlen) ==0 ) { +return pos; + } + } + +return NULL ; +} +
pc-bios/s390-ccw/libc/string/strtok.c new file +45 -0
45 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC PATCH 7/14 libnet: Rework error message printing
In reply to Thomas HuthThere is a repetive pattern of code in netload.c to print out error message: snprintf(buf, ...) + bootmsg_error() + write_mm_log(). The code can be simplified / shortened quite a bit by consolidating this pattern in a helper function.
--- pc-bios/s390-ccw/libnet/netload.c | 126 +++++++++++++------------------------- 1 file changed, 44 insertions(+), 82 deletions(-)
pc-bios/s390-ccw/libnet/netload.c +44 -82
@@ -52,6 +52,23 @@ typedef struct {int tftp_retries; } obp_tftp_args_t; +/** +* Print error with preceeding error code +*/ +static void netload_error (int errcode,const char *format, ...) +{ +va_list vargs; +char buf[256 ]; + +sprintf (buf,"E%04X: (net) " , errcode); + +va_start (vargs, format); +vsnprintf (&buf[13 ],sizeof (buf) -13 , format, vargs); +va_end (vargs); + +bootmsg_error (errcode, &buf[7 ]); +write_mm_log (buf,strlen (buf),0x91 ); +}/** * Parses a argument string for IPv6 booting, extracts all
@@ -389,7 +406,6 @@ static void seed_rng(uint8_t mac[])int netload (char *buffer,int len,char *ret_buffer,int huge_load,int block_size,char *args_fs,int alen) { -char buf[256 ];int rc;filename_ip_t fn_ip;int fd_device;
@@ -427,17 +443,11 @@ int netload(char *buffer, int len, char *ret_buffer, int huge_load, }if (fd_device ==-1 ) { -strcpy (buf,"E3000: (net) Could not read MAC address" ); -bootmsg_error (0x3000 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3000 ,"Could not read MAC address" );return -100 ; }else if (fd_device ==-2 ) { -strcpy (buf,"E3006: (net) Could not initialize network device" ); -bootmsg_error (0x3006 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3006 ,"Could not initialize network device" );return -101 ; }
@@ -567,10 +577,7 @@ int netload(char *buffer, int len, char *ret_buffer, int huge_load,memcpy (&fn_ip.server_ip6.addr, &obp_tftp_args.si6addr.addr,16 ); }if (rc ==-1 ) { -strcpy (buf,"E3001: (net) Could not get IP address" ); -bootmsg_error (0x3001 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3001 ,"Could not get IP address" );close (fn_ip.fd);return -101 ; }
@@ -586,29 +593,21 @@ int netload(char *buffer, int len, char *ret_buffer, int huge_load, }if (rc ==-2 ) { -sprintf (buf, -"E3002: (net) ARP request to TFTP server " +netload_error (0x3002 ,"ARP request to TFTP server " "(%d.%d.%d.%d) failed" , ((fn_ip.server_ip >>24 ) &0xFF ), ((fn_ip.server_ip >>16 ) &0xFF ), ((fn_ip.server_ip >>8 ) &0xFF ), ( fn_ip.server_ip &0xFF )); -bootmsg_error (0x3002 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 );close (fn_ip.fd);return -102 ; }if (rc ==-4 || rc ==-3 ) { -strcpy (buf,"E3008: (net) Can't obtain TFTP server IP address" ); -bootmsg_error (0x3008 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3008 ,"Can't obtain TFTP server IP address" );close (fn_ip.fd);return -107 ; } -/*********************************************************** * * Load file via TFTP into buffer provided by OpenFirmware
@@ -649,114 +648,77 @@ int netload(char *buffer, int len, char *ret_buffer, int huge_load,printf (" TFTP: Received %s (%d KBytes)\n" , fn_ip.filename, rc /1024 ); }else if (rc ==-1 ) { -bootmsg_error (0x3003 ,"(net) unknown TFTP error" ); +netload_error (0x3003 ,"unknown TFTP error" );return -103 ; }else if (rc ==-2 ) { -sprintf (buf, -"E3004: (net) TFTP buffer of %d bytes " +netload_error (0x3004 ,"TFTP buffer of %d bytes " "is too small for %s" , len, fn_ip.filename); -bootmsg_error (0x3004 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 );return -104 ; }else if (rc ==-3 ) { -sprintf (buf,"E3009: (net) file not found: %s" , - fn_ip.filename); -bootmsg_error (0x3009 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3009 ,"file not found: %s" , + fn_ip.filename);return -108 ; }else if (rc ==-4 ) { -strcpy (buf,"E3010: (net) TFTP access violation" ); -bootmsg_error (0x3010 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3010 ,"TFTP access violation" );return -109 ; }else if (rc ==-5 ) { -strcpy (buf,"E3011: (net) illegal TFTP operation" ); -bootmsg_error (0x3011 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3011 ,"illegal TFTP operation" );return -110 ; }else if (rc ==-6 ) { -strcpy (buf,"E3012: (net) unknown TFTP transfer ID" ); -bootmsg_error (0x3012 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3012 ,"unknown TFTP transfer ID" );return -111 ; }else if (rc ==-7 ) { -strcpy (buf,"E3013: (net) no such TFTP user" ); -bootmsg_error (0x3013 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3013 ,"no such TFTP user" );return -112 ; }else if (rc ==-8 ) { -strcpy (buf,"E3017: (net) TFTP blocksize negotiation failed" ); -bootmsg_error (0x3017 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3017 ,"TFTP blocksize negotiation failed" );return -116 ; }else if (rc ==-9 ) { -strcpy (buf,"E3018: (net) file exceeds maximum TFTP transfer size" ); -bootmsg_error (0x3018 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3018 ,"file exceeds maximum TFTP transfer size" );return -117 ; }else if (rc <=-10 && rc >=-15 ) { -sprintf (buf,"E3005: (net) ICMP ERROR \"" ); +char *icmp_err_str;switch (rc) {case -ICMP_NET_UNREACHABLE -10 : -sprintf (buf+strlen (buf),"net unreachable" ); + icmp_err_str ="net unreachable" ;break ;case -ICMP_HOST_UNREACHABLE -10 : -sprintf (buf+strlen (buf),"host unreachable" ); + icmp_err_str ="host unreachable" ;break ;case -ICMP_PROTOCOL_UNREACHABLE -10 : -sprintf (buf+strlen (buf),"protocol unreachable" ); + icmp_err_str ="protocol unreachable" ;break ;case -ICMP_PORT_UNREACHABLE -10 : -sprintf (buf+strlen (buf),"port unreachable" ); + icmp_err_str ="port unreachable" ;break ;case -ICMP_FRAGMENTATION_NEEDED -10 : -sprintf (buf+strlen (buf),"fragmentation needed and DF set" ); + icmp_err_str ="fragmentation needed and DF set" ;break ;case -ICMP_SOURCE_ROUTE_FAILED -10 : -sprintf (buf+strlen (buf),"source route failed" ); + icmp_err_str ="source route failed" ;break ;default : -sprintf (buf+strlen (buf)," UNKNOWN" ); + icmp_err_str =" UNKNOWN" ;break ; } -sprintf (buf+strlen (buf),"\"" ); -bootmsg_error (0x3005 , &buf[7 ]); - -write_mm_log (buf,strlen (buf),0x91 ); +netload_error (0x3005 ,"ICMP ERROR \"%s\"" , icmp_err_str);return -105 ; }else if (rc ==-40 ) { -sprintf (buf, -"E3014: (net) TFTP error occurred after " +netload_error (0x3014 ,"TFTP error occurred after " "%d bad packets received" , tftp_err.bad_tftp_packets); -bootmsg_error (0x3014 , &buf[7 ]); -write_mm_log (buf,strlen (buf),0x91 );return -113 ; }else if (rc ==-41 ) { -sprintf (buf, -"E3015: (net) TFTP error occurred after " +netload_error (0x3015 ,"TFTP error occurred after " "missing %d responses" , tftp_err.no_packets); -bootmsg_error (0x3015 , &buf[7 ]); -write_mm_log (buf,strlen (buf),0x91 );return -114 ; }else if (rc ==-42 ) { -sprintf (buf, -"E3016: (net) TFTP error missing block %d, " +netload_error (0x3016 ,"TFTP error missing block %d, " "expected block was %d" , tftp_err.blocks_missed, tftp_err.blocks_received); -bootmsg_error (0x3016 , &buf[7 ]); -write_mm_log (buf,strlen (buf),0x91 );return -115 ; }return rc;
Signature · 1 line
1.8.3.1
RFC PATCH 8/14 libnet: Refactor some code of netload() into a separate function
In reply to Thomas Huthnetload() is a huge function, it's easy to lose track here. So let's refactor the TFTP-related loading and error printing code into a separate function instead.
--- pc-bios/s390-ccw/libnet/netload.c | 177 ++++++++++++++++++++------------------ 1 file changed, 93 insertions(+), 84 deletions(-)
pc-bios/s390-ccw/libnet/netload.c +93 -84
@@ -403,13 +403,101 @@ static void seed_rng(uint8_t mac[])srand (seed); } +static int tftp_load (filename_ip_t *fnip,unsigned char *buffer,int len, +unsigned int retries,int ip_vers) +{ +tftp_err_t tftp_err; +int rc; + + rc =tftp (fnip, buffer, len, retries, &tftp_err,1 ,1428 , ip_vers); + +if (rc >0 ) { +printf (" TFTP: Received %s (%d KBytes)\n" , fnip->filename, + rc /1024 ); + }else if (rc ==-1 ) { +netload_error (0x3003 ,"unknown TFTP error" ); +return -103 ; + }else if (rc ==-2 ) { +netload_error (0x3004 ,"TFTP buffer of %d bytes " +"is too small for %s" , + len, fnip->filename); +return -104 ; + }else if (rc ==-3 ) { +netload_error (0x3009 ,"file not found: %s" , + fnip->filename); +return -108 ; + }else if (rc ==-4 ) { +netload_error (0x3010 ,"TFTP access violation" ); +return -109 ; + }else if (rc ==-5 ) { +netload_error (0x3011 ,"illegal TFTP operation" ); +return -110 ; + }else if (rc ==-6 ) { +netload_error (0x3012 ,"unknown TFTP transfer ID" ); +return -111 ; + }else if (rc ==-7 ) { +netload_error (0x3013 ,"no such TFTP user" ); +return -112 ; + }else if (rc ==-8 ) { +netload_error (0x3017 ,"TFTP blocksize negotiation failed" ); +return -116 ; + }else if (rc ==-9 ) { +netload_error (0x3018 ,"file exceeds maximum TFTP transfer size" ); +return -117 ; + }else if (rc <=-10 && rc >=-15 ) { +char *icmp_err_str; +switch (rc) { +case -ICMP_NET_UNREACHABLE -10 : + icmp_err_str ="net unreachable" ; +break ; +case -ICMP_HOST_UNREACHABLE -10 : + icmp_err_str ="host unreachable" ; +break ; +case -ICMP_PROTOCOL_UNREACHABLE -10 : + icmp_err_str ="protocol unreachable" ; +break ; +case -ICMP_PORT_UNREACHABLE -10 : + icmp_err_str ="port unreachable" ; +break ; +case -ICMP_FRAGMENTATION_NEEDED -10 : + icmp_err_str ="fragmentation needed and DF set" ; +break ; +case -ICMP_SOURCE_ROUTE_FAILED -10 : + icmp_err_str ="source route failed" ; +break ; +default : + icmp_err_str =" UNKNOWN" ; +break ; + } +netload_error (0x3005 ,"ICMP ERROR \"%s\"" , icmp_err_str); +return -105 ; + }else if (rc ==-40 ) { +netload_error (0x3014 ,"TFTP error occurred after " +"%d bad packets received" , + tftp_err.bad_tftp_packets); +return -113 ; + }else if (rc ==-41 ) { +netload_error (0x3015 ,"TFTP error occurred after " +"missing %d responses" , + tftp_err.no_packets); +return -114 ; + }else if (rc ==-42 ) { +netload_error (0x3016 ,"TFTP error missing block %d, " +"expected block was %d" , + tftp_err.blocks_missed, + tftp_err.blocks_received); +return -115 ; + } + +return rc; +} +int netload (char *buffer,int len,char *ret_buffer,int huge_load,int block_size,char *args_fs,int alen) {int rc;filename_ip_t fn_ip;int fd_device; -tftp_err_t tftp_err;obp_tftp_args_t obp_tftp_args;char null_ip[4 ] = {0x00 ,0x00 ,0x00 ,0x00 };char null_ip6[16 ] = {0x00 ,0x00 ,0x00 ,0x00 ,
@@ -633,94 +721,15 @@ int netload(char *buffer, int len, char *ret_buffer, int huge_load,printf ("%s\n" , ip6_str); } -// accept at most 20 bad packets -// wait at most for 40 packets - rc =tftp (&fn_ip, (unsigned char *) buffer, - len, obp_tftp_args.tftp_retries, - &tftp_err, huge_load, block_size, ip_version); +/* Do the TFTP load and print error message if necessary */ + rc =tftp_load (&fn_ip, (unsigned char *)buffer, len, + obp_tftp_args.tftp_retries, ip_version); -if (obp_tftp_args.ip_init ==IP_INIT_DHCP ) +if (obp_tftp_args.ip_init ==IP_INIT_DHCP )dhcp_send_release (fn_ip.fd);close (fn_ip.fd); -if (rc >0 ) { -printf (" TFTP: Received %s (%d KBytes)\n" , fn_ip.filename, - rc /1024 ); - }else if (rc ==-1 ) { -netload_error (0x3003 ,"unknown TFTP error" ); -return -103 ; - }else if (rc ==-2 ) { -netload_error (0x3004 ,"TFTP buffer of %d bytes " -"is too small for %s" , - len, fn_ip.filename); -return -104 ; - }else if (rc ==-3 ) { -netload_error (0x3009 ,"file not found: %s" , - fn_ip.filename); -return -108 ; - }else if (rc ==-4 ) { -netload_error (0x3010 ,"TFTP access violation" ); -return -109 ; - }else if (rc ==-5 ) { -netload_error (0x3011 ,"illegal TFTP operation" ); -return -110 ; - }else if (rc ==-6 ) { -netload_error (0x3012 ,"unknown TFTP transfer ID" ); -return -111 ; - }else if (rc ==-7 ) { -netload_error (0x3013 ,"no such TFTP user" ); -return -112 ; - }else if (rc ==-8 ) { -netload_error (0x3017 ,"TFTP blocksize negotiation failed" ); -return -116 ; - }else if (rc ==-9 ) { -netload_error (0x3018 ,"file exceeds maximum TFTP transfer size" ); -return -117 ; - }else if (rc <=-10 && rc >=-15 ) { -char *icmp_err_str; -switch (rc) { -case -ICMP_NET_UNREACHABLE -10 : - icmp_err_str ="net unreachable" ; -break ; -case -ICMP_HOST_UNREACHABLE -10 : - icmp_err_str ="host unreachable" ; -break ; -case -ICMP_PROTOCOL_UNREACHABLE -10 : - icmp_err_str ="protocol unreachable" ; -break ; -case -ICMP_PORT_UNREACHABLE -10 : - icmp_err_str ="port unreachable" ; -break ; -case -ICMP_FRAGMENTATION_NEEDED -10 : - icmp_err_str ="fragmentation needed and DF set" ; -break ; -case -ICMP_SOURCE_ROUTE_FAILED -10 : - icmp_err_str ="source route failed" ; -break ; -default : - icmp_err_str =" UNKNOWN" ; -break ; - } -netload_error (0x3005 ,"ICMP ERROR \"%s\"" , icmp_err_str); -return -105 ; - }else if (rc ==-40 ) { -netload_error (0x3014 ,"TFTP error occurred after " -"%d bad packets received" , - tftp_err.bad_tftp_packets); -return -113 ; - }else if (rc ==-41 ) { -netload_error (0x3015 ,"TFTP error occurred after " -"missing %d responses" , - tftp_err.no_packets); -return -114 ; - }else if (rc ==-42 ) { -netload_error (0x3016 ,"TFTP error missing block %d, " -"expected block was %d" , - tftp_err.blocks_missed, - tftp_err.blocks_received); -return -115 ; - }return rc; }
Signature · 1 line
1.8.3.1
RFC PATCH 10/14 pc-bios/s390-ccw: Add timer code for the libnet
In reply to Thomas HuthThe libnet expects certain timer functions to exist, so that it is able to deal with timeouts etc.
This patch implements these timer functions via the STORE CLOCK (stck) CPU instruction.
--- pc-bios/s390-ccw/libnet/Makefile | 2 +- pc-bios/s390-ccw/libnet/timer.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 pc-bios/s390-ccw/libnet/timer.c
pc-bios/s390-ccw/libnet/Makefile +1 -1
@@ -24,7 +24,7 @@ QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) LDFLAGS += -Wl,-pie -nostdlib SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c dhcp.c tftp.c \ - ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c args.c + ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c args.c timer.c OBJS = $(SRCS:%.c=%.o)
pc-bios/s390-ccw/libnet/timer.c new file +40 -0
@@ -0,0 +1,40 @@ +/* +* Timer functions for libnet +* +* Copyright 2017 Thomas Huth, Red Hat Inc. +* +* This code is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +*/ + +#include <stdint.h> +#include "time.h" + +static uint64_t dest_timer; + +static uint64_t get_timer_ms (void ) +{ +uint64_t clk; + + asmvolatile (" stck %0 " : :"Q" (clk) :"memory" ); + +/* Bit 51 is incrememented each microsecond */ +return (clk >> (63 -51 )) /1000 ; +} + +void set_timer (int val) +{ + dest_timer =get_timer_ms () + val; +} + +int get_timer (void ) +{ +return dest_timer -get_timer_ms (); +} + +int get_sec_ticks (void ) +{ +return 1000 ;/* number of ticks in 1 second */ +}
Signature · 1 line
1.8.3.1
RFC PATCH 9/14 pc-bios/s390-ccw: Make the basic libnet code compilable
In reply to Thomas HuthAdjust the Makefiles, remove non-required code and fix some spots that generated compiler warnings / errors with the s390-ccw firmware CFLAGS.
--- configure | 3 +- pc-bios/s390-ccw/Makefile | 6 +- pc-bios/s390-ccw/libnet/Makefile | 38 ++--- pc-bios/s390-ccw/libnet/netapps.h | 4 +- pc-bios/s390-ccw/libnet/netload.c | 319 ++------------------------------------ pc-bios/s390-ccw/libnet/tftp.c | 2 +- 6 files changed, 33 insertions(+), 339 deletions(-)
configure +2 -1
@@ -6378,7 +6378,7 @@ fi DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32 tests/libqos tests/qapi-schema tests/tcg/xtensa tests/qemu-iotests" DIRS="$DIRS docs docs/interop fsdev" DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas" -DIRS="$DIRS pc-bios/s390-ccw pc-bios/s390-ccw/libc" +DIRS="$DIRS pc-bios/s390-ccw pc-bios/s390-ccw/libc pc-bios/s390-ccw/libnet" DIRS="$DIRS roms/seabios roms/vgabios" DIRS="$DIRS qapi-generated" FILES="Makefile tests/tcg/Makefile qdict-test-data.txt"
@@ -6387,6 +6387,7 @@ FILES="$FILES tests/tcg/lm32/Makefile tests/tcg/xtensa/Makefile po/Makefile" FILES="$FILES pc-bios/optionrom/Makefile pc-bios/keymaps" FILES="$FILES pc-bios/spapr-rtas/Makefile" FILES="$FILES pc-bios/s390-ccw/Makefile pc-bios/s390-ccw/libc/Makefile" +FILES="$FILES pc-bios/s390-ccw/libnet/Makefile" FILES="$FILES roms/seabios/Makefile roms/vgabios/Makefile" FILES="$FILES pc-bios/qemu-icon.bmp" FILES="$FILES .gdbinit scripts" # scripts needed by relative path in .gdbinit
pc-bios/s390-ccw/Makefile +5 -1
@@ -7,7 +7,7 @@ include $(SRC_PATH)/rules.mak $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) -.PHONY : all clean build-all libc.a +.PHONY : all clean build-all libc.a libnet.a OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o OBJECTS += libc.a sbrk.o
@@ -26,6 +26,9 @@ s390-ccw.elf: $(OBJECTS) libc.a: @$(MAKE) -C libc V="$(V)" +libnet.a: + @$(MAKE) -C libnet V="$(V)" + STRIP ?= strip s390-ccw.img: s390-ccw.elf
@@ -36,3 +39,4 @@ $(OBJECTS): Makefile clean: rm -f *.o *.d *.img *.elf *~ @$(MAKE) -C libc clean + @$(MAKE) -C libnet clean
pc-bios/s390-ccw/libnet/Makefile +15 -23
@@ -10,16 +10,21 @@ # * IBM Corporation - initial implementation # ****************************************************************************/ -ifndef TOP - TOP = $(shell while ! test -e make.rules; do cd .. ; done; pwd) - export TOP -endif -include $(TOP)/make.rules +include ../../../config-host.mak +include $(SRC_PATH)/rules.mak -CFLAGS += -I. -I.. -I../libc/include -I$(TOP)/include +$(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw/libnet) -SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c bootp.c dhcp.c tftp.c \ - ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c ping.c args.c +QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float +QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing -Wno-redundant-decls +QEMU_CFLAGS += -I$(SRC_PATH)/pc-bios/s390-ccw/libnet +QEMU_CFLAGS += -I$(SRC_PATH)/pc-bios/s390-ccw/libc/include +QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector) +LDFLAGS += -Wl,-pie -nostdlib + +SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c dhcp.c tftp.c \ + ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c args.c OBJS = $(SRCS:%.c=%.o)
@@ -28,23 +33,10 @@ TARGET = ../libnet.a all: $(TARGET) $(TARGET): $(OBJS) - $(AR) -rc $@ $(OBJS) - $(RANLIB) $@ + $(call quiet-command,$(AR) -rc $@ $(OBJS),"AR","$(TARGET_DIR)$@") clean: - $(RM) $(TARGET) $(OBJS) + rm -f $(TARGET) $(OBJS) distclean: clean - $(RM) Makefile.dep - - -# Rules for creating the dependency file: -depend: - $(RM) Makefile.dep - $(MAKE) Makefile.dep - -Makefile.dep: Makefile - $(CC) -M $(CPPFLAGS) $(CFLAGS) $(SRCS) > Makefile.dep -# Include dependency file if available: --include Makefile.dep
pc-bios/s390-ccw/libnet/netapps.h +1 -3
@@ -18,9 +18,7 @@struct filename_ip ; -extern int netload (char *buffer,int len,char *ret_buffer,int huge_load, -int block_size,char *args_fs,int alen); -extern int ping (char *args_fs,int alen); +extern int netload (char *buffer,int len,char *ret_buffer);extern int dhcp (char *ret_buffer,struct filename_ip *fn_ip,unsigned int retries,int flags);
pc-bios/s390-ccw/libnet/netload.c +9 -310
374 lines not on this page · raw message
pc-bios/s390-ccw/libnet/tftp.c +1 -1
@@ -265,7 +265,7 @@ static void print_progress(int urgent, int received_bytes)sprintf (buffer,"%d KBytes" , (progress_last_bytes >>10 ));for (ptr = buffer; *ptr !=0 ; ++ptr) *ptr ='\b' ; -printf (buffer); +printf ("%s" , buffer); }printf ("%d KBytes" , (received_bytes >>10 )); i =1 ;
Signature · 1 line
1.8.3.1
RFC PATCH 11/14 pc-bios/s390-ccw: Add virtio-net driver code
In reply to Thomas HuthThis virtio-net driver contains the recv() and send() functions that are required by libnet to receive and send packets.
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/virtio-net.c | 125 ++++++++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/virtio.c | 16 ++++-- pc-bios/s390-ccw/virtio.h | 11 ++++ 4 files changed, 149 insertions(+), 5 deletions(-) create mode 100644 pc-bios/s390-ccw/virtio-net.c
pc-bios/s390-ccw/Makefile +1 -1
@@ -9,7 +9,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) .PHONY : all clean build-all libc.a libnet.a -OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o +OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-net.o OBJECTS += libc.a sbrk.o QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float
pc-bios/s390-ccw/virtio-net.c new file +125 -0
125 lines not on this page · raw message
pc-bios/s390-ccw/virtio.c +12 -4
@@ -69,7 +69,7 @@ static long virtio_notify(SubChannelId schid, int vq_idx, long cookie)* Virtio functions * ***********************************************/ -static int drain_irqs (SubChannelId schid) +int drain_irqs (SubChannelId schid) {Irb irb = {};int r =0 ;
@@ -148,13 +148,13 @@ static void vring_init(VRing *vr, VqInfo *info)debug_print_addr ("init vr" , vr); } -static bool vring_notify (VRing *vr) +bool vring_notify (VRing *vr) { vr->cookie =virtio_notify (vr->schid, vr->id, vr->cookie);return vr->cookie >=0 ; } -static void vring_send_buf (VRing *vr,void *p,int len,int flags) +void vring_send_buf (VRing *vr,void *p,int len,int flags) {/* For follow-up chains we need to keep the first entry point */ if (!(flags &VRING_HIDDEN_IS_CHAIN )) {
@@ -187,7 +187,7 @@ ulong get_second(void)return (get_clock () >>12 ) /1000000 ; } -static int vr_poll (VRing *vr) +int vr_poll (VRing *vr) {if (vr->used->idx == vr->used_idx) {vring_notify (vr);
@@ -495,6 +495,11 @@ static void virtio_setup_ccw(VDev *vdev)run_ccw (vdev,CCW_CMD_VDEV_RESET ,NULL ,0 );switch (vdev->senseid.cu_model) { +case VIRTIO_ID_NET : + vdev->nr_vqs =3 ; + vdev->cmd_vr_idx =0 ; + cfg_size =sizeof (vdev->config.net); +break ;case VIRTIO_ID_BLOCK : vdev->nr_vqs =1 ; vdev->cmd_vr_idx =0 ;
@@ -549,6 +554,9 @@ void virtio_setup_device(SubChannelId schid)virtio_setup_ccw (&vdev);switch (vdev.senseid.cu_model) { +case VIRTIO_ID_NET : +sclp_print ("Using virtio-net.\n" ); +break ;case VIRTIO_ID_BLOCK :sclp_print ("Using virtio-blk.\n" );if (!virtio_ipl_disk_is_valid ()) {
pc-bios/s390-ccw/virtio.h +11 -0
@@ -254,6 +254,12 @@ struct ScsiDevice { };typedef struct ScsiDevice ScsiDevice ; +struct VirtioNetConfig { +uint8_t mac[6 ]; +uint16_t status; +}; +typedef struct VirtioNetConfig VirtioNetConfig ; +struct VDev {int nr_vqs;VRing *vrings;
@@ -266,6 +272,7 @@ struct VDev {union {VirtioBlkConfig blk;VirtioScsiConfig scsi; +VirtioNetConfig net; } config;ScsiDevice *scsi_device;bool is_cdrom;
@@ -291,6 +298,10 @@ struct VirtioCmd { };typedef struct VirtioCmd VirtioCmd ; +bool vring_notify (VRing *vr); +int drain_irqs (SubChannelId schid); +void vring_send_buf (VRing *vr,void *p,int len,int flags); +int vr_poll (VRing *vr);int virtio_run (VDev *vdev,int vqid,VirtioCmd *cmd);#endif /* VIRTIO_H */
Signature · 1 line
1.8.3.1
RFC PATCH 12/14 pc-bios/s390-ccw: Load file via an intermediate .INS file
In reply to Thomas HuthWe need to know which files have to be loaded at which address. Normally you need at least two files, a kernel image and an initrd image. Since the normal DHCP information only provides one file, we now load an intermediate .INS file first which has to contain the information about the other files. The .INS file has the same syntax as the .INS files that are already used on s390x Linux distribution CD-ROMs: First line is the title (starting with "* "), and in the following lines you can find the file names followed by the address where they should be loaded.
--- pc-bios/s390-ccw/libnet/netapps.h | 2 +- pc-bios/s390-ccw/libnet/netload.c | 72 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 68 insertions(+), 6 deletions(-)
pc-bios/s390-ccw/libnet/netapps.h +1 -1
@@ -18,7 +18,7 @@struct filename_ip ; -extern int netload (char *buffer,int len,char *ret_buffer); +extern int netload (void );extern int dhcp (char *ret_buffer,struct filename_ip *fn_ip,unsigned int retries,int flags);
pc-bios/s390-ccw/libnet/netload.c +67 -5
102 lines not on this page · raw message
Signature · 1 line
1.8.3.1
RFC PATCH 13/14 pc-bios/s390-ccw: Allow loading to address 0
In reply to Thomas HuthKernels are normally loaded to address 0, so the check for NULL in the TFTP code has to be replaced.
--- pc-bios/s390-ccw/libnet/tftp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
pc-bios/s390-ccw/libnet/tftp.c +6 -5
@@ -26,6 +26,7 @@#define MAX_BLOCKSIZE 1428#define BUFFER_LEN 256 +#define INVALID_BUFFER ((void *)-1L)#define ENOTFOUND 1#define EACCESS 2
@@ -45,7 +46,7 @@/* Local variables */ static unsigned char packet[BUFFER_LEN ]; -static unsigned char *buffer =NULL ; +static unsigned char *buffer =INVALID_BUFFER ;static unsigned short block;static unsigned short blocksize;static char blocksize_str[6 ];/* Blocksize string for read request */
@@ -337,7 +338,7 @@ int32_t handle_tftp(int fd, uint8_t *pkt, int32_t packetsize)struct tftphdr *tftp;/* buffer is only set if we are handling TFTP */ -if (buffer ==NULL ) +if (buffer ==INVALID_BUFFER )return 0 ;#ifndef __DEBUG__
@@ -536,7 +537,7 @@ int tftp(filename_ip_t * _fn_ip, unsigned char *_buffer, int _len,printf (" Receiving data: " );print_progress (-1 ,0 ); -// Setting buffer to a non-zero address enabled handling of received TFTP packets. +/* Set buffer to a valid address, enables handling of received packets */ buffer = _buffer;set_timer (TICKS_SEC );
@@ -579,8 +580,8 @@ int tftp(filename_ip_t * _fn_ip, unsigned char *_buffer, int _len, } } -// Setting buffer to NULL disables handling of received TFTP packets. - buffer =NULL ; +/* Setting buffer invalid to disable handling of received packets */ + buffer =INVALID_BUFFER ;if (tftp_errno)return tftp_errno;
Signature · 1 line
1.8.3.1
RFC PATCH 14/14 pc-bios/s390-ccw: Wire up the netload code
In reply to Thomas HuthLink the libnet.a to the s390-ccw.elf file, call netload() instead of the external network boot image, and jump to loaded kernel at address 0, so that we can finally do a full network boot with the s390-ccw firmware now.
--- pc-bios/s390-ccw/Makefile | 2 +- pc-bios/s390-ccw/bootmap.c | 10 +++++++++- pc-bios/s390-ccw/main.c | 3 +-- 3 files changed, 11 insertions(+), 4 deletions(-)
pc-bios/s390-ccw/Makefile +1 -1
@@ -10,7 +10,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/s390-ccw) .PHONY : all clean build-all libc.a libnet.a OBJECTS = start.o main.o bootmap.o sclp.o virtio.o virtio-scsi.o virtio-net.o -OBJECTS += libc.a sbrk.o +OBJECTS += libnet.a libc.a sbrk.o QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing
pc-bios/s390-ccw/bootmap.c +9 -1
@@ -11,6 +11,7 @@#include "s390-ccw.h" #include "bootmap.h" #include "virtio.h" +#include "libnet/netapps.h" #ifdef DEBUG /* #define DEBUG_FALLBACK */
@@ -744,7 +745,14 @@ void zipl_load(void) }if (virtio_get_device_type () ==VIRTIO_ID_NET ) { -jump_to_IPL_code (vdev->netboot_start_addr); +long len; + + len =netload (); +if (len <0 ) { +panic ("Network loading failed" ); + } +sclp_print ("Netload done, starting kernel...\n" ); + asmvolatile (" lpsw 0(%0) " : :"r" (0 ) :"memory" ); }ipl_scsi ();
pc-bios/s390-ccw/main.c +1 -2
@@ -150,12 +150,11 @@ static void virtio_setup(void)IPL_assert (found,"No virtio device found" ); +virtio_setup_device (blk_schid);if (virtio_get_device_type () ==VIRTIO_ID_NET ) {sclp_print ("Network boot device detected\n" ); vdev->netboot_start_addr = iplb.ccw.netboot_start_addr; }else { -virtio_setup_device (blk_schid); -IPL_assert (virtio_ipl_disk_is_valid (),"No valid IPL device detected" ); } }
Signature · 1 line
1.8.3.1
RFC PATCH 5/14 pc-bios/s390-ccw: Add the TFTP network loading stack from SLOF
In reply to Thomas HuthAdd the files for TFTP network loading from SLOF to the s390-ccw firmware. The files have been copied unmodified from SLOF commit ID 62674aabe20612a9786fa03e87cf6916ba97a99a an will be adjusted for the s390-ccw firmware by the following commits.
--- pc-bios/s390-ccw/libnet/Makefile | 50 ++ pc-bios/s390-ccw/libnet/args.c | 179 +++++++ pc-bios/s390-ccw/libnet/args.h | 23 + pc-bios/s390-ccw/libnet/dhcp.c | 955 +++++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/dhcp.h | 49 ++ pc-bios/s390-ccw/libnet/dhcpv6.c | 212 ++++++++ pc-bios/s390-ccw/libnet/dhcpv6.h | 154 ++++++ pc-bios/s390-ccw/libnet/dns.c | 526 ++++++++++++++++++++ pc-bios/s390-ccw/libnet/dns.h | 28 ++ pc-bios/s390-ccw/libnet/ethernet.c | 189 ++++++++ pc-bios/s390-ccw/libnet/ethernet.h | 47 ++ pc-bios/s390-ccw/libnet/icmpv6.c | 409 ++++++++++++++++ pc-bios/s390-ccw/libnet/icmpv6.h | 135 ++++++ pc-bios/s390-ccw/libnet/ipv4.c | 898 ++++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv4.h | 97 ++++ pc-bios/s390-ccw/libnet/ipv6.c | 774 ++++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv6.h | 188 ++++++++ pc-bios/s390-ccw/libnet/ndp.c | 184 +++++++ pc-bios/s390-ccw/libnet/ndp.h | 72 +++ pc-bios/s390-ccw/libnet/netapps.h | 28 ++ pc-bios/s390-ccw/libnet/netload.c | 868 +++++++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/tcp.c | 46 ++ pc-bios/s390-ccw/libnet/tcp.h | 27 ++ pc-bios/s390-ccw/libnet/tftp.c | 594 +++++++++++++++++++++++ pc-bios/s390-ccw/libnet/tftp.h | 52 ++ pc-bios/s390-ccw/libnet/time.h | 6 + pc-bios/s390-ccw/libnet/udp.c | 115 +++++ pc-bios/s390-ccw/libnet/udp.h | 53 ++ 28 files changed, 6958 insertions(+) create mode 100644 pc-bios/s390-ccw/libnet/Makefile create mode 100644 pc-bios/s390-ccw/libnet/args.c create mode 100644 pc-bios/s390-ccw/libnet/args.h create mode 100644 pc-bios/s390-ccw/libnet/dhcp.c create mode 100644 pc-bios/s390-ccw/libnet/dhcp.h create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.c create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.h create mode 100644 pc-bios/s390-ccw/libnet/dns.c create mode 100644 pc-bios/s390-ccw/libnet/dns.h create mode 100644 pc-bios/s390-ccw/libnet/ethernet.c create mode 100644 pc-bios/s390-ccw/libnet/ethernet.h create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.c create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.h create mode 100644 pc-bios/s390-ccw/libnet/ipv4.c create mode 100644 pc-bios/s390-ccw/libnet/ipv4.h create mode 100644 pc-bios/s390-ccw/libnet/ipv6.c create mode 100644 pc-bios/s390-ccw/libnet/ipv6.h create mode 100644 pc-bios/s390-ccw/libnet/ndp.c create mode 100644 pc-bios/s390-ccw/libnet/ndp.h create mode 100644 pc-bios/s390-ccw/libnet/netapps.h create mode 100644 pc-bios/s390-ccw/libnet/netload.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.h create mode 100644 pc-bios/s390-ccw/libnet/tftp.c create mode 100644 pc-bios/s390-ccw/libnet/tftp.h create mode 100644 pc-bios/s390-ccw/libnet/time.h create mode 100644 pc-bios/s390-ccw/libnet/udp.c create mode 100644 pc-bios/s390-ccw/libnet/udp.h
pc-bios/s390-ccw/libnet/Makefile new file +50 -0
@@ -0,0 +1,50 @@ +# ***************************************************************************** +# * Copyright (c) 2004, 2008 IBM Corporation +# * All rights reserved. +# * This program and the accompanying materials +# * are made available under the terms of the BSD License +# * which accompanies this distribution, and is available at +# * http://www.opensource.org/licenses/bsd-license.php +# * +# * Contributors: +# * IBM Corporation - initial implementation +# ****************************************************************************/ + +ifndef TOP + TOP = $(shell while ! test -e make.rules; do cd .. ; done; pwd) + export TOP +endif +include $(TOP)/make.rules + +CFLAGS += -I. -I.. -I../libc/include -I$(TOP)/include + +SRCS = ethernet.c ipv4.c udp.c tcp.c dns.c bootp.c dhcp.c tftp.c \ + ipv6.c dhcpv6.c icmpv6.c ndp.c netload.c ping.c args.c + +OBJS = $(SRCS:%.c=%.o) + +TARGET = ../libnet.a + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(AR) -rc $@ $(OBJS) + $(RANLIB) $@ + +clean: + $(RM) $(TARGET) $(OBJS) + +distclean: clean + $(RM) Makefile.dep + + +# Rules for creating the dependency file: +depend: + $(RM) Makefile.dep + $(MAKE) Makefile.dep + +Makefile.dep: Makefile + $(CC) -M $(CPPFLAGS) $(CFLAGS) $(SRCS) > Makefile.dep + +# Include dependency file if available: +-include Makefile.dep
pc-bios/s390-ccw/libnet/args.c new file +179 -0
179 lines not on this page · raw message
pc-bios/s390-ccw/libnet/args.h new file +23 -0
@@ -0,0 +1,23 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + +#ifndef _ARGS_H +#define _ARGS_H + +const char *get_arg_ptr (const char *,unsigned int ); +unsigned int get_args_count (const char *); +unsigned int get_arg_length (const char *); +char *argncpy (const char *,unsigned int ,char *,unsigned int ); +int strtoip (const char *,char [4 ]); +int strtoip_netmask (const char *,char [4 ],unsigned int *netmask); + +#endif /* _ARGS_H */
pc-bios/s390-ccw/libnet/dhcp.c new file +955 -0
955 lines not on this page · raw message
pc-bios/s390-ccw/libnet/dhcp.h new file +49 -0
49 lines not on this page · raw message
pc-bios/s390-ccw/libnet/dhcpv6.c new file +212 -0
212 lines not on this page · raw message
pc-bios/s390-ccw/libnet/dhcpv6.h new file +154 -0
154 lines not on this page · raw message
pc-bios/s390-ccw/libnet/dns.c new file +526 -0
526 lines not on this page · raw message
pc-bios/s390-ccw/libnet/dns.h new file +28 -0
@@ -0,0 +1,28 @@ +/****************************************************************************** +* Copyright (c) 2004, 2008 IBM Corporation +* All rights reserved. +* This program and the accompanying materials +* are made available under the terms of the BSD License +* which accompanies this distribution, and is available at +* http://www.opensource.org/licenses/bsd-license.php +* +* Contributors: +* IBM Corporation - initial implementation +*****************************************************************************/ + + +#ifndef _DNS_H_ +#define _DNS_H_ + +#include <stdint.h> + +/* Initialize the environment for DNS client. */ +extern int8_t dns_init (uint32_t _dns_server_ip,uint8_t _dns_server_ipv6[16 ],uint8_t ip_version); + +/* For given URL retrieves IPv4 from DNS-server. */ +extern int8_t dns_get_ip (int fd,char * url,uint8_t * domain_ip,uint8_t ip_version); + +/* Handles DNS-packets, which are detected by receive_ether. */ +extern int32_t handle_dns (uint8_t * packet,int32_t packetsize); + +#endif
pc-bios/s390-ccw/libnet/ethernet.c new file +189 -0
189 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ethernet.h new file +47 -0
47 lines not on this page · raw message
pc-bios/s390-ccw/libnet/icmpv6.c new file +409 -0
409 lines not on this page · raw message
pc-bios/s390-ccw/libnet/icmpv6.h new file +135 -0
135 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ipv4.c new file +898 -0
44 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ipv4.h new file +97 -0
97 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ipv6.c new file +774 -0
774 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ipv6.h new file +188 -0
188 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ndp.c new file +184 -0
184 lines not on this page · raw message
pc-bios/s390-ccw/libnet/ndp.h new file +72 -0
72 lines not on this page · raw message
pc-bios/s390-ccw/libnet/netapps.h new file +28 -0
Lines of this file are not shown. View the raw message.
pc-bios/s390-ccw/libnet/netload.c new file +868 -0
868 lines not on this page · raw message
pc-bios/s390-ccw/libnet/tcp.c new file +46 -0
46 lines not on this page · raw message
pc-bios/s390-ccw/libnet/tcp.h new file +27 -0
Lines of this file are not shown. View the raw message.
pc-bios/s390-ccw/libnet/tftp.c new file +594 -0
594 lines not on this page · raw message
pc-bios/s390-ccw/libnet/tftp.h new file +52 -0
52 lines not on this page · raw message
pc-bios/s390-ccw/libnet/time.h new file +6 -0
Lines of this file are not shown. View the raw message.
pc-bios/s390-ccw/libnet/udp.c new file +115 -0
115 lines not on this page · raw message
pc-bios/s390-ccw/libnet/udp.h new file +53 -0
53 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.8.3.1
Part of the diff is not shown here. View the raw message.
Hi Thomas,
This is really interesting :)
Quoted 23 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.insThe .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
IMHO 75k is not that huge compared to the Linux based netboot image.
Quoted 9 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Quoted 5 lines
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
Can't it be extended to support HTTP boot?
Quoted 220 lines
Thomas
Thomas Huth (14):
pc-bios/s390-ccw: Add the libc from the SLOF firmware pc-bios/s390-ccw: Start using the libc from SLOF pc-bios/s390-ccw: Add awrite()function for stdio pc-bios/s390-ccw: Add implementation ofsbrk()pc-bios/s390-ccw: Add the TFTP network loading stack from SLOF
libnet: Remove remainders of netsave code
libnet: Rework error message printing
libnet: Refactor some code ofnetload()into a separate function pc-bios/s390-ccw: Make the basic libnet code compilable pc-bios/s390-ccw: Add timer code for the libnet pc-bios/s390-ccw: Add virtio-net driver code pc-bios/s390-ccw: Load file via an intermediate .INS file pc-bios/s390-ccw: Allow loading to address 0 pc-bios/s390-ccw: Wire up the netload codeconfigure | 6 +- hw/s390x/ipl.c | 2 +- pc-bios/s390-ccw/Makefile | 14 +- pc-bios/s390-ccw/bootmap.c | 10 +- pc-bios/s390-ccw/bootmap.h | 1 + pc-bios/s390-ccw/libc/Makefile | 47 ++ pc-bios/s390-ccw/libc/README.txt | 49 ++ pc-bios/s390-ccw/libc/ctype/Makefile.inc | 21 + pc-bios/s390-ccw/libc/ctype/isdigit.c | 25 + pc-bios/s390-ccw/libc/ctype/isprint.c | 18 + pc-bios/s390-ccw/libc/ctype/isspace.c | 29 + pc-bios/s390-ccw/libc/ctype/isxdigit.c | 21 + pc-bios/s390-ccw/libc/ctype/tolower.c | 18 + pc-bios/s390-ccw/libc/ctype/toupper.c | 21 + pc-bios/s390-ccw/libc/include/ctype.h | 24 + pc-bios/s390-ccw/libc/include/errno.h | 34 + pc-bios/s390-ccw/libc/include/limits.h | 32 + pc-bios/s390-ccw/libc/include/stdarg.h | 22 + pc-bios/s390-ccw/libc/include/stdbool.h | 20 + pc-bios/s390-ccw/libc/include/stddef.h | 25 + pc-bios/s390-ccw/libc/include/stdint.h | 28 + pc-bios/s390-ccw/libc/include/stdio.h | 63 ++ pc-bios/s390-ccw/libc/include/stdlib.h | 34 + pc-bios/s390-ccw/libc/include/string.h | 37 ++ pc-bios/s390-ccw/libc/include/sys/socket.h | 53 ++ pc-bios/s390-ccw/libc/include/unistd.h | 28 + pc-bios/s390-ccw/libc/stdio/Makefile.inc | 24 + pc-bios/s390-ccw/libc/stdio/fileno.c | 19 + pc-bios/s390-ccw/libc/stdio/fprintf.c | 26 + pc-bios/s390-ccw/libc/stdio/printf.c | 27 + pc-bios/s390-ccw/libc/stdio/putc.c | 25 + pc-bios/s390-ccw/libc/stdio/putchar.c | 21 + pc-bios/s390-ccw/libc/stdio/puts.c | 28 + pc-bios/s390-ccw/libc/stdio/setvbuf.c | 28 + pc-bios/s390-ccw/libc/stdio/sprintf.c | 30 + pc-bios/s390-ccw/libc/stdio/stdchnls.c | 23 + pc-bios/s390-ccw/libc/stdio/vfprintf.c | 27 + pc-bios/s390-ccw/libc/stdio/vsnprintf.c | 298 +++++++++ pc-bios/s390-ccw/libc/stdio/vsprintf.c | 19 + pc-bios/s390-ccw/libc/stdlib/Makefile.inc | 23 + pc-bios/s390-ccw/libc/stdlib/atoi.c | 18 + pc-bios/s390-ccw/libc/stdlib/atol.c | 18 + pc-bios/s390-ccw/libc/stdlib/error.c | 15 + pc-bios/s390-ccw/libc/stdlib/free.c | 26 + pc-bios/s390-ccw/libc/stdlib/malloc.c | 157 +++++ pc-bios/s390-ccw/libc/stdlib/malloc_defs.h | 16 + pc-bios/s390-ccw/libc/stdlib/memalign.c | 26 + pc-bios/s390-ccw/libc/stdlib/rand.c | 29 + pc-bios/s390-ccw/libc/stdlib/realloc.c | 40 ++ pc-bios/s390-ccw/libc/stdlib/strtol.c | 115 ++++ pc-bios/s390-ccw/libc/stdlib/strtoul.c | 105 ++++ pc-bios/s390-ccw/libc/string/Makefile.inc | 23 + pc-bios/s390-ccw/libc/string/memchr.c | 29 + pc-bios/s390-ccw/libc/string/memcmp.c | 30 + pc-bios/s390-ccw/libc/string/memcpy.c | 27 + pc-bios/s390-ccw/libc/string/memmove.c | 42 ++ pc-bios/s390-ccw/libc/string/memset.c | 25 + pc-bios/s390-ccw/libc/string/strcasecmp.c | 28 + pc-bios/s390-ccw/libc/string/strcat.c | 24 + pc-bios/s390-ccw/libc/string/strchr.c | 28 + pc-bios/s390-ccw/libc/string/strcmp.c | 28 + pc-bios/s390-ccw/libc/string/strcpy.c | 25 + pc-bios/s390-ccw/libc/string/strlen.c | 27 + pc-bios/s390-ccw/libc/string/strncasecmp.c | 32 + pc-bios/s390-ccw/libc/string/strncmp.c | 31 + pc-bios/s390-ccw/libc/string/strncpy.c | 33 + pc-bios/s390-ccw/libc/string/strstr.c | 37 ++ pc-bios/s390-ccw/libc/string/strtok.c | 45 ++ pc-bios/s390-ccw/libnet/Makefile | 42 ++ pc-bios/s390-ccw/libnet/args.c | 179 ++++++ pc-bios/s390-ccw/libnet/args.h | 23 + pc-bios/s390-ccw/libnet/dhcp.c | 955 +++++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/dhcp.h | 49 ++ pc-bios/s390-ccw/libnet/dhcpv6.c | 212 +++++++ pc-bios/s390-ccw/libnet/dhcpv6.h | 154 +++++ pc-bios/s390-ccw/libnet/dns.c | 526 ++++++++++++++++ pc-bios/s390-ccw/libnet/dns.h | 28 + pc-bios/s390-ccw/libnet/ethernet.c | 189 ++++++ pc-bios/s390-ccw/libnet/ethernet.h | 47 ++ pc-bios/s390-ccw/libnet/icmpv6.c | 409 ++++++++++++ pc-bios/s390-ccw/libnet/icmpv6.h | 135 ++++ pc-bios/s390-ccw/libnet/ipv4.c | 898 +++++++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv4.h | 97 +++ pc-bios/s390-ccw/libnet/ipv6.c | 774 +++++++++++++++++++++++ pc-bios/s390-ccw/libnet/ipv6.h | 188 ++++++ pc-bios/s390-ccw/libnet/ndp.c | 184 ++++++ pc-bios/s390-ccw/libnet/ndp.h | 72 +++ pc-bios/s390-ccw/libnet/netapps.h | 25 + pc-bios/s390-ccw/libnet/netload.c | 600 ++++++++++++++++++ pc-bios/s390-ccw/libnet/tcp.c | 46 ++ pc-bios/s390-ccw/libnet/tcp.h | 27 + pc-bios/s390-ccw/libnet/tftp.c | 595 ++++++++++++++++++ pc-bios/s390-ccw/libnet/tftp.h | 50 ++ pc-bios/s390-ccw/libnet/time.h | 6 + pc-bios/s390-ccw/libnet/timer.c | 40 ++ pc-bios/s390-ccw/libnet/udp.c | 115 ++++ pc-bios/s390-ccw/libnet/udp.h | 53 ++ pc-bios/s390-ccw/main.c | 3 +- pc-bios/s390-ccw/s390-ccw.h | 30 +- pc-bios/s390-ccw/sbrk.c | 39 ++ pc-bios/s390-ccw/sclp.c | 32 +- pc-bios/s390-ccw/virtio-net.c | 125 ++++ pc-bios/s390-ccw/virtio.c | 16 +- pc-bios/s390-ccw/virtio.h | 11 + 104 files changed, 9296 insertions(+), 57 deletions(-) create mode 100644 pc-bios/s390-ccw/libc/Makefile create mode 100644 pc-bios/s390-ccw/libc/README.txt create mode 100644 pc-bios/s390-ccw/libc/ctype/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/ctype/isdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isprint.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isspace.c create mode 100644 pc-bios/s390-ccw/libc/ctype/isxdigit.c create mode 100644 pc-bios/s390-ccw/libc/ctype/tolower.c create mode 100644 pc-bios/s390-ccw/libc/ctype/toupper.c create mode 100644 pc-bios/s390-ccw/libc/include/ctype.h create mode 100644 pc-bios/s390-ccw/libc/include/errno.h create mode 100644 pc-bios/s390-ccw/libc/include/limits.h create mode 100644 pc-bios/s390-ccw/libc/include/stdarg.h create mode 100644 pc-bios/s390-ccw/libc/include/stdbool.h create mode 100644 pc-bios/s390-ccw/libc/include/stddef.h create mode 100644 pc-bios/s390-ccw/libc/include/stdint.h create mode 100644 pc-bios/s390-ccw/libc/include/stdio.h create mode 100644 pc-bios/s390-ccw/libc/include/stdlib.h create mode 100644 pc-bios/s390-ccw/libc/include/string.h create mode 100644 pc-bios/s390-ccw/libc/include/sys/socket.h create mode 100644 pc-bios/s390-ccw/libc/include/unistd.h create mode 100644 pc-bios/s390-ccw/libc/stdio/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdio/fileno.c create mode 100644 pc-bios/s390-ccw/libc/stdio/fprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/printf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putc.c create mode 100644 pc-bios/s390-ccw/libc/stdio/putchar.c create mode 100644 pc-bios/s390-ccw/libc/stdio/puts.c create mode 100644 pc-bios/s390-ccw/libc/stdio/setvbuf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/sprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/stdchnls.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vfprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsnprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdio/vsprintf.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/stdlib/atoi.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/atol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/error.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/free.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/malloc_defs.h create mode 100644 pc-bios/s390-ccw/libc/stdlib/memalign.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/rand.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/realloc.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtol.c create mode 100644 pc-bios/s390-ccw/libc/stdlib/strtoul.c create mode 100644 pc-bios/s390-ccw/libc/string/Makefile.inc create mode 100644 pc-bios/s390-ccw/libc/string/memchr.c create mode 100644 pc-bios/s390-ccw/libc/string/memcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/memcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/memmove.c create mode 100644 pc-bios/s390-ccw/libc/string/memset.c create mode 100644 pc-bios/s390-ccw/libc/string/strcasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcat.c create mode 100644 pc-bios/s390-ccw/libc/string/strchr.c create mode 100644 pc-bios/s390-ccw/libc/string/strcmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strcpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strlen.c create mode 100644 pc-bios/s390-ccw/libc/string/strncasecmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncmp.c create mode 100644 pc-bios/s390-ccw/libc/string/strncpy.c create mode 100644 pc-bios/s390-ccw/libc/string/strstr.c create mode 100644 pc-bios/s390-ccw/libc/string/strtok.c create mode 100644 pc-bios/s390-ccw/libnet/Makefile create mode 100644 pc-bios/s390-ccw/libnet/args.c create mode 100644 pc-bios/s390-ccw/libnet/args.h create mode 100644 pc-bios/s390-ccw/libnet/dhcp.c create mode 100644 pc-bios/s390-ccw/libnet/dhcp.h create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.c create mode 100644 pc-bios/s390-ccw/libnet/dhcpv6.h create mode 100644 pc-bios/s390-ccw/libnet/dns.c create mode 100644 pc-bios/s390-ccw/libnet/dns.h create mode 100644 pc-bios/s390-ccw/libnet/ethernet.c create mode 100644 pc-bios/s390-ccw/libnet/ethernet.h create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.c create mode 100644 pc-bios/s390-ccw/libnet/icmpv6.h create mode 100644 pc-bios/s390-ccw/libnet/ipv4.c create mode 100644 pc-bios/s390-ccw/libnet/ipv4.h create mode 100644 pc-bios/s390-ccw/libnet/ipv6.c create mode 100644 pc-bios/s390-ccw/libnet/ipv6.h create mode 100644 pc-bios/s390-ccw/libnet/ndp.c create mode 100644 pc-bios/s390-ccw/libnet/ndp.h create mode 100644 pc-bios/s390-ccw/libnet/netapps.h create mode 100644 pc-bios/s390-ccw/libnet/netload.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.c create mode 100644 pc-bios/s390-ccw/libnet/tcp.h create mode 100644 pc-bios/s390-ccw/libnet/tftp.c create mode 100644 pc-bios/s390-ccw/libnet/tftp.h create mode 100644 pc-bios/s390-ccw/libnet/time.h create mode 100644 pc-bios/s390-ccw/libnet/timer.c create mode 100644 pc-bios/s390-ccw/libnet/udp.c create mode 100644 pc-bios/s390-ccw/libnet/udp.h create mode 100644 pc-bios/s390-ccw/sbrk.c create mode 100644 pc-bios/s390-ccw/virtio-net.c
Quoted 11 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.Neat :)
Quoted 9 lines
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.ins
or the dnsmasq tftp server configured by libvirt (SCNR)
Quoted 9 lines
The .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
The size may be less of an issue than the general overhead for initialization. Since the current approach of the s390-ccw firmware of lazy loading (only if a network boot is requested) takes care of that, would it be conceivable that you build a standalone network boot firmware image instead of incorporating that into the base firmware?
Quoted 4 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Alternatively, one could load a single boot image (consisting of kernel and initrd concatenated, i.e. the bootable ISO format). This could serve as a more potent "stage 2" boot loader.
Quoted 9 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easil>
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
I don't have an opinion on whether HTTP, FTP, etc is needed, but at some point in time it would definitely be cool to have IPv6 support. Not sure whether SLOF has that included.
Quoted 4 lines
Thomas
[...]
Signature · 8 lines
Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 11 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
Quoted 5 lines
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
Pretty cool stuff!
Quoted 7 lines
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.insThe .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
As mentioned in patch #1, would it somehow be able to include code rather than copying it and maintaining it separately?
Quoted 4 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
Guess this is the way to go for now.
Quoted 10 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
Good question, I think all these solutions will require way more effort.
Quoted 2 lines
Thomas
Signature · 3 lines
Thanks, David
Re: [Qemu-devel] [RFC PATCH 01/14] pc-bios/s390-ccw: Add the libc from the SLOF firmware
In reply to Thomas HuthQuoted 9 lines · Thomas Huth
To be able to use some more advanced libc functions in the s390-ccw firmware, like
printf()andmalloc(), we need a better libc here. This patch adds the C library from the SLOF firmware (taken from the SLOF commit ID62674aabe20612a9786fa03e87cf6916ba97a99a). The files are copied without modifications here and will be adapted for the s390-ccw firmware by the next patch. I just removed thegetopt()and scanf()-like functions from the libc since we likely do not need them in the s390-ccw firmware.
We have SLOF as a git submodule in roms/SLOF.
I wonder if there would a way to avoid duplicating files.
E.g. build s390x-ccw.img only if roms/SLOF is checked out and link/copy the right folder.
Then, also the question regarding coding style is gone.
Would something like that work?
Signature · 3 lines
Thanks, David
Quoted 23 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \ -netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.insThe .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
I think 75k is still perfectly reasonable, yes.
Quoted 9 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Quoted 5 lines
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
IMHO the only viable next step would be to support UEFI and build on top of that - either by porting edk2 or U-Boot to s390x.
The problem with solutions like petitboot or home grown grub2 targets is that it becomes a documentation and knowledge sharing nightmare down the road. The less we're different from everyone else, the easier it becomes to maintain s390x.
Alex
Quoted 1 line · Viktor Mihajlovski
On 27.06.2017 13:48, Thomas Huth wrote:
[...]
Quoted 8 lines
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
The size may be less of an issue than the general overhead for initialization.
Which concerns with regards to overhead do you have here? Startup time? As far as I can tell, that's not an issue here - the firmware still starts very fast.
Quoted 4 lines
Since the current approach of the s390-ccw firmware of
lazy loading (only if a network boot is requested) takes care of that, would it be conceivable that you build a standalone network boot firmware image instead of incorporating that into the base firmware?
That would shoot down the big advantage of this approach: Not to have to fiddle with multiple firmware images - which is my main motivation here. I'd like to avoid that we have to create yet another firmware package in the distros. (Otherwise, what's the purpose of this when putting it into yet another binary? We could then simply continue the current approach with the Linux binary instead)
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 3 lines
Alternatively, one could load a single boot image (consisting of kernel and initrd concatenated, i.e. the bootable ISO format). This could serve as a more potent "stage 2" boot loader.
Agreed, that's also a common practice when doing network booting. I guess the firmware could also support both quite easily, direct single boot images, and .INS files. The latter could be detected via the file name or with the magic string "* " at the beginning.
Quoted 11 lines
Quoted 8 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easil>
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?I don't have an opinion on whether HTTP, FTP, etc is needed, but at some point in time it would definitely be cool to have IPv6 support. Not sure whether SLOF has that included.
Yes, IPv6 is included in this networking stack.
Thomas
Quoted 2 lines · Alexander Graf
On 27.06.17 13:48, Thomas Huth wrote:
[...]
Quoted 8 lines
Quoted 5 lines
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
IMHO the only viable next step would be to support UEFI and build on top of that - either by porting edk2 or U-Boot to s390x.
I can't speak of U-Boot, but you certainly don't want to port edk2 to a big endian machine. Been there, seen that.
Quoted 4 lines
The problem with solutions like petitboot or home grown grub2 targets is that it becomes a documentation and knowledge sharing nightmare down the road. The less we're different from everyone else, the easier it becomes to maintain s390x.
petitboot is basically a Linux system (with a shell, too). And grub2 is also a common boot loader on x86 nowadays ... so not sure whether they would really be a knowledge sharing nightmare? I think they would be more common for "server" people than the U-Boot loader, which is likely only familiar to "embedded" folks.
Thomas
Re: [Qemu-devel] [RFC PATCH 01/14] pc-bios/s390-ccw: Add the libc from the SLOF firmware
In reply to David HildenbrandQuoted 13 lines · David Hildenbrand
Quoted 9 lines · Thomas Huth
To be able to use some more advanced libc functions in the s390-ccw firmware, like
printf()andmalloc(), we need a better libc here. This patch adds the C library from the SLOF firmware (taken from the SLOF commit ID62674aabe20612a9786fa03e87cf6916ba97a99a). The files are copied without modifications here and will be adapted for the s390-ccw firmware by the next patch. I just removed thegetopt()and scanf()-like functions from the libc since we likely do not need them in the s390-ccw firmware.We have SLOF as a git submodule in roms/SLOF.
Quoted 8 lines
I wonder if there would a way to avoid duplicating files.
E.g. build s390x-ccw.img only if roms/SLOF is checked out and link/copy the right folder.
Then, also the question regarding coding style is gone.
Would something like that work?
Cool idea, I like it at a first glance. It might be possible ... but that also creates a lot of dependencies, e.g. each time there is a related change in the SLOF repository, you run into the problem that it might affect the s390-ccw firmware, too. Not sure whether we really always want to deal with that situation...
Thomas
On 27.06.2017 23:40, Thomas Huth wrote:
[...]
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Quoted 11 lines
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs. It will do no good to tell system administrators to have a totally different setup for s390 boot clients. If the firmware doesn't support it we will have to fall back to provide a Linux-based fat netboot image to the pxelinux handling :-(.
Quoted 24 lines
Quoted 3 lines
Alternatively, one could load a single boot image (consisting of kernel and initrd concatenated, i.e. the bootable ISO format). This could serve as a more potent "stage 2" boot loader.
Agreed, that's also a common practice when doing network booting. I guess the firmware could also support both quite easily, direct single boot images, and .INS files. The latter could be detected via the file name or with the magic string "* " at the beginning.
Quoted 11 lines
Quoted 8 lines
Quoted 1 line
- The code from SLOF uses a different coding style (TABs instead
of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easil>
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?I don't have an opinion on whether HTTP, FTP, etc is needed, but at some point in time it would definitely be cool to have IPv6 support. Not sure whether SLOF has that included.
Yes, IPv6 is included in this networking stack.
Thomas
Signature · 8 lines
Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
On 27.06.2017 18:50, Farhan Ali wrote:
[...]
Quoted 8 lines
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
IMHO 75k is not that huge compared to the Linux based netboot image.
True. I was just surprised that the size was now three times as big as before, but when you compare it to the huge size of a Linux kernel + initrd, 75k are of course close to nothing.
Quoted 8 lines
Quoted 8 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Quoted 7 lines
Quoted 5 lines
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
Can't it be extended to support HTTP boot?
Not so easily, since you need TCP support for this first. And TCP is way more complex to implement when compared with UDP.
Thomas
Interesting work, thanks for giving it a ry.
Quoted 10 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
What is the licensing situation with SLOF?
Quoted 13 lines
Once the patches have been applied, you can download an .INS file via TFTP which contains the information about the further files that have to be loaded - kernel, initrd, etc. For example, you can use the built-in TFTP and DHCP server of QEMU for this by starting QEMU with:
qemu-system-s390x ... -device virtio-net,netdev=n1,bootindex=1 \
-netdev user,id=n1,tftp=/path/to/tftp,bootfile=generic.insThe .INS file has to use the same syntax as the .INS files that can already be found on s390x Linux distribution installation CD-ROMs.
Quoted 6 lines
The patches are still in a rough shape, but before I continue here, I though I'd get some feedback first. Specifically:
- This adds a lot of additional code to the s390-ccw firmware (and the binary is afterwards three times as big as before, 75k instead of 25k) ... is that still acceptable?
Yes, sure. I think up to 1M everything is fine as long as the startup time stays low (e.g. if we want to do something like clear containers. Right now I can start a small Linux guest from qemu start to command line in <100ms without any optimization)
Quoted 4 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
I agree with Viktor that supporting a pxelinux config file is probably the better way, since this is what all exisiting servers admins understand. For the time being Linux will be the most relevant guest and requiring changes in management infrastructure will certainly make things very hard.
Quoted 3 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Is it possible to enhance SLOF and then link to the existing SLOF code?
Quoted 6 lines
- The code only supports TFTP (via UDP) ... I think that is OK for most use-cases, but if we ever want to support network booting via HTTP or something else that is based on TCP, we would need to use something else instead... Should we maybe rather head towards grub2, petitboot or something different instead?
Quoted 23 lines · Viktor Mihajlovski
On 27.06.2017 23:40, Thomas Huth wrote:
[...]Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Quoted 11 lines
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 3 lines
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs.
Are you really sure about the popularity of pxelinux? It's just one flavor of secondary stage network boot loaders - which also only exist on x86 so far, as far as I know. You can also use other loaders like grub2 or gPXE there instead. And other architectures also do not use pxelinux. For example on PowerPC, you normally use yaboot or grub2 as secondary stage boot loader via network instead.
Quoted 1 line
It will do no good to tell system administrators to have a totally>
different setup for s390 boot clients.
Trying to mimic pxelinux in the firmware still sounds wrong to me. That might also cause some confusion, e.g. if something in the config file is not fully supported (like menus?), or people might start wondering where to get the pxelinux binary itself for s390x ...
Maybe it would be better to port the pxelinux binary to s390x?
Quoted 3 lines
If the firmware doesn't support it we will have to fall
back to provide a Linux-based fat netboot image to the pxelinux handling :-(.
So far I haven't seen such a Linux-based netboot image yet ([1] mentions pxelinux, but not what software should be used to parse the config file), ... do you have a pointer to the software that parses the pxelinux config file there?
Thomas
[1] https://lists.gnu.org/archive/html/qemu-devel/2017-02/msg04333.html
Hi,
Quoted 11 lines
Quoted 3 lines
IMHO the only viable next step would be to support UEFI and build on top
of that - either by porting edk2 or U-Boot to s390x.I can't speak of U-Boot, but you certainly don't want to port edk2 to a big endian machine. Been there, seen that.
would really be a knowledge sharing nightmare? I think they would be more common for "server" people than the U-Boot loader, which is likely
only familiar to "embedded" folks.
Well, u-boot supports some[1] EFI interfaces these days, so you can run standard efi grub2 on embedded arm boards. From that point of view porting uboot to s390 might not be as silly as it initially looks like.
cheers,
Gerd
[1] barely enough to make grub2 happy.
Quoted 9 lines · Christian Borntraeger
Interesting work, thanks for giving it a ry.
Quoted 6 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
Quoted 6 lines
Quoted 4 lines
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
What is the licensing situation with SLOF?
All its code is licensed under the 3-Clause BSD License:
https://github.com/aik/SLOF/blob/master/LICENSE
AFAIK it should be fine to use such code in GPL-ed sources like the s390-ccw firmware, shouldn't it?
Quoted 8 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
I agree with Viktor that supporting a pxelinux config file is probably the better way, since this is what all exisiting servers admins understand. For the time being Linux will be the most relevant guest and requiring changes in management infrastructure will certainly make things very hard.
I have to say, the more I read about pxelinux, the more I think we should *not* directly support this in the firmware. pxelinux is clearly a secondary stage bootloader, with a rather complex config file, and features like config file name guessing via MAC-address or IP-address ... if we really want to support that on s390x, too, I think it should stay in a external binary instead, and not directly incorporated into the s390-ccw firmware (so that users finally have the choice whether they want to use pxelinux-style config files or grub2 or something different one day).
I guess the .INS file parsing in firmware was already a bad idea... all other typical firmware implementations can also only load one file - and if you need to load multiple files, you've got to use a secondary stage bootloader like pxelinux, yaboot or grub2. So if we agree to add network booting directly into the s390-ccw firmware, I think we should do the same here and only support loading of one file (without an additional config file). But then the question is, of course, whether it makes sense to add that support to the firmware at all, or whether we should simply continue with the current "s390-netboot.img" secondary-loader approach...
Quoted 5 lines
Quoted 3 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Is it possible to enhance SLOF and then link to the existing SLOF code?
I already submitted some of the clean-up patches to the SLOF mailing list, and Alexey has merged them now, e.g.:
https://github.com/aik/SLOF/commit/140c3f39db4ce4c0
And as I already mentioned in my reply to David, it should theoretically be possible to use the code from the roms/SLOF submodule in QEMU ... but then we've got to deal with sudden changes in the SLOF repository which might cause unwanted problems in the s390-ccw firmware. I guess we could give it a try (the libc code is very, very stable in SLOF, and the libnet code also changes only very seldomly) - of course only if we really decide that we want to have TFTP support directly in the firmware. If we rather want to continue with the s390-netboot.img approach instead, I have got to reconsider whether I continue with my efforts by putting that stuff into an external binary, or whether it makes more sense to look into porting pxelinux, grub2 or petitboot instead...
Thomas
Quoted 24 lines · Thomas Huth
Quoted 23 lines · Viktor Mihajlovski
On 27.06.2017 23:40, Thomas Huth wrote:
[...]Quoted 21 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 7 lines
Quoted 3 lines
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs.
Are you really sure about the popularity of pxelinux? It's just one flavor of secondary stage network boot loaders - which also only exist on x86 so far, as far as I know.
And it seems like it also only works with legacy BIOSes, i.e. you can not use it on EFI-only systems, if I've got that right:
https://github.com/openSUSE/kiwi/wiki/Setup-PXE-boot-with-EFI-Using-GRUB2
So I guess the significance of pxelinux will very likely decrease in the next years...
Thomas
Quoted 33 lines · Thomas Huth
Quoted 24 lines · Thomas Huth
Quoted 23 lines · Viktor Mihajlovski
On 27.06.2017 23:40, Thomas Huth wrote:
[...]Quoted 21 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 7 lines
Quoted 3 lines
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs.
Are you really sure about the popularity of pxelinux? It's just one flavor of secondary stage network boot loaders - which also only exist on x86 so far, as far as I know.
Quoted 8 lines
And it seems like it also only works with legacy BIOSes, i.e. you can not use it on EFI-only systems, if I've got that right:
https://github.com/openSUSE/kiwi/wiki/Setup-PXE-boot-with-EFI-Using-GRUB2
So I guess the significance of pxelinux will very likely decrease in the next years...
Maybe, but supposed goners tend to linger more often than not. I.e., the syslinux project offers a EFI bootloader called syslinux.efi equivalent to the pexelinux.0 BIOS loader.
Further, the OPAL firmware of newer POWER systems embeds petitboot and thus offers PXELINUX-compatible network boot as well.
I appreciate the idea of a proper BOOTP implementation though, so maybe a compromise could be to start off with your proposal with the slight modification that the final boot action is controlled by the bootfile content (file magic), similar to what you suggested in order to support both insfile and binary kernel. PXELINUX emulation could be triggered by a specially crafted bootfile then. What do you think?
Quoted 2 lines
Thomas
Signature · 8 lines
Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 39 lines · Viktor Mihajlovski
Quoted 38 lines · Thomas Huth
Quoted 24 lines · Thomas Huth
Quoted 23 lines · Viktor Mihajlovski
On 27.06.2017 23:40, Thomas Huth wrote:
[...]Quoted 21 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 7 lines
Quoted 3 lines
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs.
Are you really sure about the popularity of pxelinux? It's just one flavor of secondary stage network boot loaders - which also only exist on x86 so far, as far as I know.
And it seems like it also only works with legacy BIOSes, i.e. you can not use it on EFI-only systems, if I've got that right:
https://github.com/openSUSE/kiwi/wiki/Setup-PXE-boot-with-EFI-Using-GRUB2
Quoted 8 lines
Quoted 3 lines
So I guess the significance of pxelinux will very likely decrease in the next years...
Maybe, but supposed goners tend to linger more often than not. I.e., the syslinux project offers a EFI bootloader called syslinux.efi equivalent to the pexelinux.0 BIOS loader.
Further, the OPAL firmware of newer POWER systems embeds petitboot and thus offers PXELINUX-compatible network boot as well.
OK, true, ... you're slowly get me convinced that this pxelinux.cfg stuff is maybe not such a bad idea after all ... So I guess supporting at least the basic commands from the pxelinux config file would be appropriate... (the full set of commands is huge, see
http://www.syslinux.org/wiki/index.php?title=Config )
Quoted 6 lines
I appreciate the idea of a proper BOOTP implementation though, so maybe a compromise could be to start off with your proposal with the slight modification that the final boot action is controlled by the bootfile content (file magic), similar to what you suggested in order to support both insfile and binary kernel. PXELINUX emulation could be triggered by a specially crafted bootfile then. What do you think?
Yes, something like this could work:
1) Do DHCP to get TFTP server address and boot file name
2) Load the boot file from the TFTP server to address 0
3) If the boot file name ended with ".ins" or ".INS" (and the content starts with the "* " magic), treat it as an .INS file and load the files that are listed in there accordingly
4) If the boot file looks like a kernel, start it directly
5) If not successful in 3 or 4, start looking for a pxelinux config file by trying to download the config files as specified in
http://www.syslinux.org/wiki/index.php?title=PXELINUX#Configuration
and then parse the file and load the kernel + initrd accordingly.
Quite a bit of work, so I'll continue to ignore 5 for the first versions, but I agree now that it can certainly be added later.
Thomas
Quoted 75 lines · Thomas Huth
Quoted 39 lines · Viktor Mihajlovski
Quoted 38 lines · Thomas Huth
Quoted 24 lines · Thomas Huth
Quoted 23 lines · Viktor Mihajlovski
On 27.06.2017 23:40, Thomas Huth wrote:
[...]Quoted 21 lines
Quoted 9 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
It would be nice to support PXE-style boot, because the majority of boot servers is set up that way. A straightforward way would be to do a PXE emulation by attempting to download a pxelinux.cfg from the well-known locations, parsing the content (menu) and finally load the kernel, initrd and set the kernel command line as specified there. (I know, but you're already parsing the INS-File).
Please, don't mix up PXE and pxelinux (since you've used both terms in above paragraph). Assuming that you're only talking about pxlinux config files... are they that common on s390x already? Using the pxelinux config file syntax sounds like we would be completely bound to only loading Linux guests to me, since the boot loader has to know where to load the initrd and how to patch the kernel so that it can find the initrd. Using .INS files sounds more flexible to me instead, since you can also specify the addresses here - so you can theoretically also load other guest kernels, and that's IMHO the better approach since a firmware should stay as generic as possible.
Quoted 7 lines
Quoted 3 lines
In order to be consumable, the network boot should support the most common configurations. I would think that most network boot servers are setup as PXE boot servers using pxelinux configs.
Are you really sure about the popularity of pxelinux? It's just one flavor of secondary stage network boot loaders - which also only exist on x86 so far, as far as I know.
And it seems like it also only works with legacy BIOSes, i.e. you can not use it on EFI-only systems, if I've got that right:
https://github.com/openSUSE/kiwi/wiki/Setup-PXE-boot-with-EFI-Using-GRUB2
Quoted 8 lines
Quoted 3 lines
So I guess the significance of pxelinux will very likely decrease in the next years...
Maybe, but supposed goners tend to linger more often than not. I.e., the syslinux project offers a EFI bootloader called syslinux.efi equivalent to the pexelinux.0 BIOS loader.
Further, the OPAL firmware of newer POWER systems embeds petitboot and thus offers PXELINUX-compatible network boot as well.OK, true, ... you're slowly get me convinced that this pxelinux.cfg stuff is maybe not such a bad idea after all ... So I guess supporting at least the basic commands from the pxelinux config file would be appropriate... (the full set of commands is huge, see
http://www.syslinux.org/wiki/index.php?title=Config )Quoted 6 lines
I appreciate the idea of a proper BOOTP implementation though, so maybe a compromise could be to start off with your proposal with the slight modification that the final boot action is controlled by the bootfile content (file magic), similar to what you suggested in order to support both insfile and binary kernel. PXELINUX emulation could be triggered by a specially crafted bootfile then. What do you think?
Yes, something like this could work:
1) Do DHCP to get TFTP server address and boot file name
2) Load the boot file from the TFTP server to address 0
3) If the boot file name ended with ".ins" or ".INS" (and the content starts with the "* " magic), treat it as an .INS file and load the files that are listed in there accordingly
4) If the boot file looks like a kernel, start it directly
5) If not successful in 3 or 4, start looking for a pxelinux config file by trying to download the config files as specified in
http://www.syslinux.org/wiki/index.php?title=PXELINUX#Configuration
and then parse the file and load the kernel + initrd accordingly.
Quoted 2 lines
Quite a bit of work, so I'll continue to ignore 5 for the first versions, but I agree now that it can certainly be added later.
That sounds more than fair. Thanks!
Quoted 3 lines
Thomas
Signature · 8 lines
Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martina Köderitz Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 65 lines · Thomas Huth
Quoted 9 lines · Christian Borntraeger
Interesting work, thanks for giving it a ry.
Quoted 6 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
Quoted 6 lines
Quoted 4 lines
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
What is the licensing situation with SLOF?
All its code is licensed under the 3-Clause BSD License:
https://github.com/aik/SLOF/blob/master/LICENSE
AFAIK it should be fine to use such code in GPL-ed sources like the s390-ccw firmware, shouldn't it?
Quoted 8 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
I agree with Viktor that supporting a pxelinux config file is probably the better way, since this is what all exisiting servers admins understand. For the time being Linux will be the most relevant guest and requiring changes in management infrastructure will certainly make things very hard.
I have to say, the more I read about pxelinux, the more I think we should *not* directly support this in the firmware. pxelinux is clearly a secondary stage bootloader, with a rather complex config file, and features like config file name guessing via MAC-address or IP-address ... if we really want to support that on s390x, too, I think it should stay in a external binary instead, and not directly incorporated into the s390-ccw firmware (so that users finally have the choice whether they want to use pxelinux-style config files or grub2 or something different one day).
I guess the .INS file parsing in firmware was already a bad idea... all other typical firmware implementations can also only load one file - and if you need to load multiple files, you've got to use a secondary stage bootloader like pxelinux, yaboot or grub2. So if we agree to add network booting directly into the s390-ccw firmware, I think we should do the same here and only support loading of one file (without an additional config file). But then the question is, of course, whether it makes sense to add that support to the firmware at all, or whether we should simply continue with the current "s390-netboot.img" secondary-loader approach...
Quoted 5 lines
Quoted 3 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Is it possible to enhance SLOF and then link to the existing SLOF code?
I already submitted some of the clean-up patches to the SLOF mailing list, and Alexey has merged them now, e.g.:
Quoted 12 lines
And as I already mentioned in my reply to David, it should theoretically be possible to use the code from the roms/SLOF submodule in QEMU ... but then we've got to deal with sudden changes in the SLOF repository which might cause unwanted problems in the s390-ccw firmware. I guess we could give it a try (the libc code is very, very stable in SLOF, and the libnet code also changes only very seldomly) - of course only if we really decide that we want to have TFTP support directly in the firmware. If we rather want to continue with the s390-netboot.img approach instead, I have got to reconsider whether I continue with my efforts by putting that stuff into an external binary, or whether it makes more sense to look into porting pxelinux, grub2 or petitboot instead...
OK, thinking about all of this again, what do you think of the following approach:
Let's do not include network booting code into the s390-ccw.img, but keep the way that it uses an external s390-netboot.img for this job.
I'll then try to add an additional s390-netboot.img target to the Makefile, which will only be built if the roms/SLOF submodule has been checked out. That target then uses the libc and libnet from the SLOF submodule and links it with my virtio-net driver and some other required code from the s390-ccw bios into a s390-netboot.img binary that can be used for network booting.
This way ...
- the main s390-ccw.img stays independent from the changes in the SLOF, and we can tackle possible problems in the s390-netboot.img independently. And we don't have to deal with coding style issues in the libc and libnet.
- we can ship a s390-netboot.img with QEMU directly, so that network booting is possible out of the box without forcing the users / downstream distros to figure out how to build a netboot.img on their own
- we keep the possibility to use alternative s390-netboot.imgs in case the users need advanced features like booting via HTTP
Does that sound like an acceptable strategy?
Thomas
Quoted 103 lines · Thomas Huth
Quoted 65 lines · Thomas Huth
Quoted 9 lines · Christian Borntraeger
Interesting work, thanks for giving it a ry.
Quoted 6 lines · Thomas Huth
It's already possible to do a network boot of an s390x guest with an external netboot image (based on a Linux installation), but it would be much more convenient if the s390-ccw firmware supported network booting right out of the box, without the need to assemble such an external image first.
Quoted 6 lines
Quoted 4 lines
This patch series now introduces network booting via DHCP and TFTP directly into the s390-ccw firmware by re-using the networking stack from the SLOF firmware (see https://github.com/aik/SLOF/ for details), and adds a driver for virtio-net-ccw devices.
What is the licensing situation with SLOF?
All its code is licensed under the 3-Clause BSD License:
https://github.com/aik/SLOF/blob/master/LICENSE
AFAIK it should be fine to use such code in GPL-ed sources like the s390-ccw firmware, shouldn't it?
Quoted 8 lines
Quoted 3 lines
- Is it OK to require loading an .INS file first? Or does anybody have a better idea how to load multiple files (kernel, initrd, etc. ...)?
I agree with Viktor that supporting a pxelinux config file is probably the better way, since this is what all exisiting servers admins understand. For the time being Linux will be the most relevant guest and requiring changes in management infrastructure will certainly make things very hard.
I have to say, the more I read about pxelinux, the more I think we should *not* directly support this in the firmware. pxelinux is clearly a secondary stage bootloader, with a rather complex config file, and features like config file name guessing via MAC-address or IP-address ... if we really want to support that on s390x, too, I think it should stay in a external binary instead, and not directly incorporated into the s390-ccw firmware (so that users finally have the choice whether they want to use pxelinux-style config files or grub2 or something different one day).
I guess the .INS file parsing in firmware was already a bad idea... all other typical firmware implementations can also only load one file - and if you need to load multiple files, you've got to use a secondary stage bootloader like pxelinux, yaboot or grub2. So if we agree to add network booting directly into the s390-ccw firmware, I think we should do the same here and only support loading of one file (without an additional config file). But then the question is, of course, whether it makes sense to add that support to the firmware at all, or whether we should simply continue with the current "s390-netboot.img" secondary-loader approach...
Quoted 5 lines
Quoted 3 lines
- The code from SLOF uses a different coding style (TABs instead of space) ... is it OK to keep that coding style here so we can share patches between SLOF and s390-ccw more easily?
Is it possible to enhance SLOF and then link to the existing SLOF code?
I already submitted some of the clean-up patches to the SLOF mailing list, and Alexey has merged them now, e.g.:
Quoted 12 lines
And as I already mentioned in my reply to David, it should theoretically be possible to use the code from the roms/SLOF submodule in QEMU ... but then we've got to deal with sudden changes in the SLOF repository which might cause unwanted problems in the s390-ccw firmware. I guess we could give it a try (the libc code is very, very stable in SLOF, and the libnet code also changes only very seldomly) - of course only if we really decide that we want to have TFTP support directly in the firmware. If we rather want to continue with the s390-netboot.img approach instead, I have got to reconsider whether I continue with my efforts by putting that stuff into an external binary, or whether it makes more sense to look into porting pxelinux, grub2 or petitboot instead...
OK, thinking about all of this again, what do you think of the following approach:
Let's do not include network booting code into the s390-ccw.img, but keep the way that it uses an external s390-netboot.img for this job.
I'll then try to add an additional s390-netboot.img target to the
Makefile, which will only be built if the roms/SLOF submodule has been checked out. That target then uses the libc and libnet from the SLOF submodule and links it with my virtio-net driver and some other required code from the s390-ccw bios into a s390-netboot.img binary that can be used for network booting.This way ...
- the main s390-ccw.img stays independent from the changes in the SLOF, and we can tackle possible problems in the s390-netboot.img independently. And we don't have to deal with coding style issues in the libc and libnet.
- we can ship a s390-netboot.img with QEMU directly, so that network booting is possible out of the box without forcing the users / downstream distros to figure out how to build a netboot.img on their own
- we keep the possibility to use alternative s390-netboot.imgs in case the users need advanced features like booting via HTTP
Quoted 1 line
Does that sound like an acceptable strategy?
Sounds perfectly fine to me. Thanks a lot for doing this.