diff --git a/.gitignore b/.gitignore index 21b74ef6..599b9d0e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2016,2017,2019,2020,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2016,2017,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -67,6 +67,8 @@ m2/ /lib/x86-mes/0exit-42 /lib/x86-mes/exit-42 +/m2 + /lib/tests/*/[0-9a][0-9a-z]-* !/lib/tests/*/*.c !/lib/tests/*/*.exit @@ -83,6 +85,7 @@ m2/ /scaffold/tiny-mes /scaffold/argv-m2 +/scaffold/env-m2 /scaffold/hello-m2 /scaffold/main-m2 /scaffold/micro-mes-m2 diff --git a/.mailmap b/.mailmap new file mode 100644 index 00000000..bb4580fc --- /dev/null +++ b/.mailmap @@ -0,0 +1 @@ +Janneke Nieuwenhuizen \ No newline at end of file diff --git a/AUTHORS b/AUTHORS index 54ef18ae..86b86a30 100644 --- a/AUTHORS +++ b/AUTHORS @@ -36,6 +36,10 @@ lib/div.c (__mesabi_log2i) W. J. van der Laan Bugfixes for logand, 64bit build, and va_arg +RISC-V port + +Andrius Štikonas +Rewrite the RISC-V port to use new word-based macros. List of imported files @@ -91,7 +95,7 @@ lib/m2/x86/x86_defs.M1 lib/m2/x86/ELF-x86.hex2 * legalese -Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen +Copyright © 2016,2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/INSTALL b/INSTALL index bed4666b..e6ab222b 100644 --- a/INSTALL +++ b/INSTALL @@ -1,7 +1,7 @@ -*- org -*- #+TITLE: Building and Installing GNU Mes -Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen +Copyright © 2016,2017,2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright @@ -26,13 +26,13 @@ similar way. #+END_SRC *** Other GNU/Linux - - [[https://savannah.gnu.org/projects/mescc-tools/][mescc-tools]], 1.4.0 is known to work. - - [[https://github.com/oriansj/m2-planet][M2-Planet]] (optional), 1.9.0 is known to work. + - [[https://savannah.gnu.org/projects/mescc-tools/][mescc-tools]], 1.5.0 is known to work. + - [[https://github.com/oriansj/m2-planet][M2-Planet]] (optional), 1.11.0 is known to work. - [[https://savannah.gnu.org/projects/nyacc][Nyacc]], 1.00.2 is known to work. - GNU Gcc, 7.5.0 is known to work. - - GNU Guile, version 3.0.4 is know to work. + - GNU Guile, version 3.0.4 is known to work. - SH, /bin/sh, GNU Bash 5.0.16 is known to work. - - GNU coreutils + - GNU coreutils. - sed, GNU sed 4.8 is known to work. ** Build it diff --git a/NEWS b/NEWS index e85e403b..2776b73c 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,21 @@ Copyright © 2016,2017,2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen = 10 +An array overflow bug was fixed in `63-struct-cell.c'. * Changes in 0.24.2 since 0.24.1 ** Build *** A number of compile warnings have been fixed. diff --git a/PORTING b/PORTING index 6e1a293c..155927e3 100644 --- a/PORTING +++ b/PORTING @@ -22,7 +22,9 @@ to your config.scm and run guix system reconfigure. For example (note: ARM is no longer a 'port', see HACKING) #+BEGIN_SRC bash - guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git guile gzip help2man make mescc-tools nyacc openssh-sans-x pkg-config sed tar texinfo + guix shell --system=armhf-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo + guix shell --system=aarch64-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man m2-planet make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo + guix shell --system=riscv64-linux --pure bash coreutils diffutils findutils gawk gcc-toolchain grep git-minimal guile gzip help2man m2-planet make mescc-tools nyacc@1.00.2 openssh-sans-x pkg-config sed tar texinfo #+END_SRC ** Try it @@ -75,7 +77,7 @@ a Reduced Binary seed, thus significantly reducing the Trusted Computing Base (TCB), strategic decisions about the build process can start. * Legalese -Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> +Copyright © 2019,2022,2023 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/README b/README index cfcfd5a1..e485d22d 100644 --- a/README +++ b/README @@ -4,11 +4,11 @@ #+SUBTITLE: Maxwell Equations of Software [[https://www.gnu.org/software/mes][GNU Mes]] is a Scheme interpreter and C compiler for bootstrapping the GNU -System. Since version 0.22 it has again helped to halve the size of -opaque, uninspectable binary seeds that are currently being used in the -[[https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25][Further Reduced Binary Seed bootstrap]] of [[https://www.gnu.org/software/guix][GNU Guix]]. The final goal is to -help create a full-source bootstrap as part of the [[https://bootstrappable.org][bootstrappable builds]] -effort for UNIX-like operating systems. +System. It has helped to decimate the number and size of binary seeds +that were used in the bootstrap of [[https://www.gnu.org/software/guix][GNU Guix]] 1.0. Recently, version +0.24.2 has realized the first [[https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/][Full Source Bootstrap]] for Guix. The final +goal is to help create a full source bootstrap as part of the +[[https://bootstrappable.org][bootstrappable builds]] effort for any UNIX-like operating system. The Scheme interpreter is written in ~5,000 LOC of simple C, and the C compiler written in Scheme and these are mutual self-hosting. Mes can @@ -20,14 +20,14 @@ R7RS ellipsis, Matt Wette's [[https://www.nongnu.org/nyacc][Nyacc]] --and test s support a REPL and a C99 compiler: mescc. Mes + MesCC + Mes C Library can build a [[https://gitlab.com/janneke/tinycc][bootstrappable TinyCC]] that is -self-hosting. Using this tcc and the Mes C library we now have a -Reduced Binary Seed bootstrap for the gnutools triplet: glibc-2.2.5, +self-hosting. Using this bootstrappable-tcc and the Mes C library we +can build an ancient version of the GNU tools triplet: glibc-2.2.5, binutils-2.20.1, gcc-2.95.3. This is enough to bootstrap Guix for i686-linux, x86_64-linux, armhf-linux and aarch64-linux. -Mes is inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John -McCarthy page 13, GNU Guix's source/binary packaging transparency and -Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]] ~500 byte self-hosting hex assembler. +Mes was inspired by The Maxwell Equations of Software: [[https://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf][LISP-1.5]] -- John +McCarthy page 13, Guix's source/binary packaging transparency and +Jeremiah Orians's [[https://github.com/oriansj/stage0][stage0]], a ~500-byte self-hosting hex assembler. We are very grateful to NLNet for sponsoring the [[https://nlnet.nl/project/GNUMes][Reduced Binary Seed bootstrap]], the [[https://nlnet.nl/project/GNUMes-arm][ARM port]], and the [[https://nlnet.nl/project/GNUMes-ARM_RISC-V][Full Source Bootstrap.]] @@ -67,8 +67,8 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING * Links [0] https://www.gnu.org/software/mes - [1] https://guix.gnu.org/blog/2020/guix-further-reduces-bootstrap-seed-to-25 - [2] https://www.gnu.org/software/guix + [1] https://www.gnu.org/software/guix + [2] https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/ [3] https://bootstrappable.org [4] https://github.com/oriansj/m2-planet [5] https://savannah.nongnu.org/projects/mescc-tools @@ -83,7 +83,7 @@ General Public Licence version 3 or later. See the file [[file:COPYING][COPYING [14] https://nlnet.nl/project/GNUMes-ARM_RISC-V * Legalese -Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> +Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/build-aux/GNUmakefile.in b/build-aux/GNUmakefile.in index 419bc72f..7af36148 100644 --- a/build-aux/GNUmakefile.in +++ b/build-aux/GNUmakefile.in @@ -85,7 +85,7 @@ PHONY_TARGETS:=\ .PHONY: $(PHONY_TARGETS) -X86_ARCH_HEADERS = $(wildcard $(scrdest)include/linux/x86/*.h) +X86_ARCH_HEADERS = $(wildcard $(srcdest)include/linux/x86/*.h) ARCH_HEADERS = $(X86_ARCH_HEADERS:$(srcdest)include/linux/x86/%=include/arch/%) default: all @@ -170,10 +170,13 @@ uninstall: doc/version.texi: ${srcdest}doc/mes.texi GNUmakefile @mkdir -p $(@D) - (set `LANG= date -r $< +'%d %B %Y'`;\ - echo "@set UPDATED $$1 $$2 $$3"; \ - echo "@set UPDATED-MONTH $$2 $$3"; \ - echo "@set EDITION $(VERSION)"; \ + timestamp=$$({ git log --pretty=format:%ct -- $< \ + || date +%s -r $<; } \ + | sort -n -r | head -n 1); \ + dmy=$$(date --date="@$$timestamp" "+%-d %B %Y"); \ + (echo "@set UPDATED $$dmy"; \ + echo "@set UPDATED-MONTH $$my"; \ + echo "@set EDITION $(VERSION)"; \ echo "@set VERSION $(VERSION)") > $@ doc: doc/version.texi @@ -227,6 +230,10 @@ man: doc/mes.1 doc/mescc.1 doc/mesar.1 %: %.o %: %.c +# help2man reproducibility +SOURCE_DATE_EPOCH=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null || echo 0) +export SOURCE_DATE_EPOCH + doc/mes.1: src/${program_prefix}mes | build MES_ARENA=10000000 ./pre-inst-env $(HELP2MAN) \ --name="Scheme interpreter for bootstrapping the GNU system" \ @@ -286,7 +293,7 @@ TARBALL_VERSION=$(COMMIT:v%=%) TARBALL_DIR:=$(PACKAGE)-$(TARBALL_VERSION) TARBALL:=$(TARBALL_DIR).tar.gz # Be friendly to Debian; avoid using EPOCH -MTIME=$(shell git show HEAD --format=%ct --no-patch 2>/dev/null) +MTIME=$(SOURCE_DIR_EPOCH) # Reproducible tarball TAR_FLAGS=--sort=name --mtime=@$(MTIME) --owner=0 --group=0 --numeric-owner --mode=go=rX,u+rw,a-s @@ -398,7 +405,7 @@ gen-announce: $(GEN_ANNOUNCE) \ --release-type=beta \ --package-name=mes \ - --previous-version='0.24.1' \ + --previous-version='0.24.2' \ --current-version=$(VERSION) \ --gpg-key-id=$(GPG_KEY_ID) \ --url-directory=https://ftp.gnu.org/gnu/mes \ diff --git a/build-aux/bootstrap.sh.in b/build-aux/bootstrap.sh.in index a2451d02..8502cb6a 100644 --- a/build-aux/bootstrap.sh.in +++ b/build-aux/bootstrap.sh.in @@ -1,7 +1,7 @@ #! @SHELL@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2019,2020 Jan (janneke) Nieuwenhuizen +# Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -54,16 +54,18 @@ AM_CPPFLAGS="-D HAVE_CONFIG_H=1 -I ${srcdest}include -I ../include -I include" AM_CFLAGS="-L ${srcdest}lib" mkdir -p $mes_cpu-mes -$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c +cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c . +$CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS crt1.c cp crt1.o $mes_cpu-mes cp crt1.s $mes_cpu-mes objects= for c in $libc_mini_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -72,10 +74,11 @@ $AR crD $mes_cpu-mes/libc-mini.a $objects objects= for c in $libmescc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -84,10 +87,11 @@ $AR crD $mes_cpu-mes/libmescc.a $objects objects= for c in $libc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -96,10 +100,11 @@ $AR crD $mes_cpu-mes/libc.a $objects objects= for c in $libc_tcc_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -113,10 +118,11 @@ AM_CFLAGS="-L ${srcdest}lib" objects= for c in $mes_SOURCES; do - o=$(basename $c .c).o + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) + o=$b.o if test ! -e $o -o ${srcdest}$c -nt $o; then echo " CC $c" - $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS ${srcdest}$c + $CC -c $AM_CPPFLAGS $CPPFLAGS $AM_CFLAGS $CFLAGS -o $o ${srcdest}$c fi objects="$objects $o" done @@ -136,3 +142,14 @@ cp bin/mes-mescc bin/mes fi @SHELL@ ${srcdest}build-aux/build-source-lib.sh ) +( + mkdir -p tcc-lib + cp config.sh tcc-lib + cd tcc-lib + compiler=tcc + if test -z "$srcdest"; then + srcdest=../ + srcdir=../ + fi + ${SHELL} ${srcdest}build-aux/build-source-lib.sh +) diff --git a/build-aux/build-guile.sh b/build-aux/build-guile.sh index dfbef410..9692a004 100755 --- a/build-aux/build-guile.sh +++ b/build-aux/build-guile.sh @@ -2,6 +2,7 @@ # GNU Mes --- Maxwell Equations of Software # Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen +# Copyright © 2021 W. J. van der Laan # # This file is part of GNU Mes. # @@ -38,6 +39,8 @@ module/mescc/armv4/as.scm module/mescc/armv4/info.scm module/mescc/i386/as.scm module/mescc/i386/info.scm +module/mescc/riscv64/as.scm +module/mescc/riscv64/info.scm module/mescc/x86_64/as.scm module/mescc/x86_64/info.scm module/mescc/info.scm diff --git a/build-aux/build-lib.sh b/build-aux/build-lib.sh index 4eaead50..b1caf80e 100755 --- a/build-aux/build-lib.sh +++ b/build-aux/build-lib.sh @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2019 Jan (janneke) Nieuwenhuizen +# Copyright © 2019,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -26,7 +26,8 @@ trap 'test -f .log && cat .log' EXIT mkdir -p $mes_cpu-mes -compile lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c +cp ${srcdest}lib/$mes_kernel/$mes_cpu-mes-$compiler/crt1.c . +compile crt1.c cp crt1.o $mes_cpu-mes if test -e crt1.s; then cp crt1.s $mes_cpu-mes diff --git a/build-aux/build-scaffold.sh b/build-aux/build-scaffold.sh index 96dbf4bd..25209fce 100755 --- a/build-aux/build-scaffold.sh +++ b/build-aux/build-scaffold.sh @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2017,2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -54,15 +54,9 @@ trace "TEST exit-42" [ $r != 42 ] && echo " => $r" [ $r = 42 ] -if $numbered_arch; then - stage0_cpu_flag="--Architecture $stage0_arch"; -else - stage0_cpu_flag="--architecture $stage0_cpu"; -fi - trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2" $HEX2\ --little-endian\ - $stage0_cpu_flag\ + --architecture $stage0_cpu\ --base-address 0x1000000\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0exit-42.hex2\ @@ -75,7 +69,7 @@ trace "TEST 0exit-42" trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2" $HEX2\ --little-endian\ - $stage0_cpu_flag\ + --architecture $stage0_cpu\ --base-address 0x1000000\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-exit-42.hex2\ @@ -101,7 +95,7 @@ trace "TEST hello-mes" trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2" $HEX2\ --little-endian\ - $stage0_cpu_flag\ + --architecture $stage0_cpu\ --base-address 0x1000000\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-0hello-mes.hex2\ @@ -114,7 +108,7 @@ trace "TEST 0hello-mes" trace "HEX2 ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2" $HEX2\ --little-endian\ - $stage0_cpu_flag\ + --architecture $stage0_cpu\ --base-address 0x1000000\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-header.hex2\ -f ${srcdest}lib/$mes_kernel/$mes_cpu-mes/elf$mes_bits-body-hello-mes.hex2\ diff --git a/build-aux/build.sh.in b/build-aux/build.sh.in index 3f356e10..f43bc10e 100644 --- a/build-aux/build.sh.in +++ b/build-aux/build.sh.in @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2019,2022,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -102,7 +102,10 @@ fi ) if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \ - || test "$mes_cpu" == "arm"); then + || test "$mes_cpu" == "x86_64" \ + || test "$mes_cpu" == "arm" \ + || test "$mes_cpu" == "riscv64" \ + ); then ( . ${srcdest}build-aux/trace.sh if [ -z "$V" -o "$V" = 0 ]; then @@ -113,6 +116,7 @@ if test -n "$M2_PLANET" && (test "$mes_cpu" == "x86" \ trace "KAEM scaffold/main.kaem" kaem --strict $__verbose -f scaffold/main.kaem trace "KAEM scaffold/hello.kaem" kaem --strict $__verbose -f scaffold/hello.kaem trace "KAEM scaffold/argv.kaem" kaem --strict $__verbose -f scaffold/argv.kaem + trace "KAEM scaffold/env.kaem" kaem --strict $__verbose -f scaffold/env.kaem trace "KAEM scaffold/read.kaem" kaem --strict $__verbose -f scaffold/read.kaem trace "KAEM kaem.run" kaem --strict $__verbose ) @@ -150,7 +154,6 @@ fi ${SHELL} ${srcdest}build-aux/build-lib.sh ${SHELL} ${srcdest}build-aux/build-source-lib.sh if $bootstrap; then - rm -f globals.* # FIXME: avoid name clash with globals from lib ${SHELL} ${srcdest}build-aux/build-mes.sh cp -f bin/mes-mescc ../bin cp -f bin/mes ../bin diff --git a/build-aux/cc.sh b/build-aux/cc.sh index 1a99e95f..edc93fba 100755 --- a/build-aux/cc.sh +++ b/build-aux/cc.sh @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -18,8 +18,12 @@ objects= compile () { - c=${srcdest}$1 - b=$(basename $c .c) + if test $(dirname $1) = "."; then + c=$1 + else + c=${srcdest}$1 + fi + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) o=$b.o objects="$objects $o" if test ! -e $o -o $c -nt $o; then @@ -34,7 +38,7 @@ archive () { sources="$@" objects= for c in $sources; do - b=$(basename $c .c) + b=$(echo $c | sed -re s,^[.]+/,, -e s,/,-,g -e s,[.]c$,,) o=$b.o compile $c done diff --git a/build-aux/cflags.sh b/build-aux/cflags.sh index 344e4cf8..58be5587 100644 --- a/build-aux/cflags.sh +++ b/build-aux/cflags.sh @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -18,20 +18,24 @@ case "$mes_cpu" in arm) - stage0_arch=40 + cc_cpu=arm stage0_cpu=armv7l ;; x86_64) - stage0_arch=2 + cc_cpu=x86_64 stage0_cpu=amd64 ;; x86) - stage0_arch=1 + cc_cpu=i386 stage0_cpu=x86 ;; + riscv64) + cc_cpu=riscv64 + stage0_cpu=riscv64 + ;; *) - stage0_arch=1 stage0_cpu=$mes_cpu + cc_cpu=$mes_cpu ;; esac diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh index 46479a04..7f75fe91 100755 --- a/build-aux/check-mescc.sh +++ b/build-aux/check-mescc.sh @@ -1,7 +1,9 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2017,2018,2019,2020,2022,2023 Jan (janneke) Nieuwenhuizen +# Copyright © 2023 Andrius Štikonas +# Copyright © 2023 Ekaitz Zarraga # # This file is part of GNU Mes. # @@ -46,6 +48,7 @@ lib/tests/scaffold/13-if-neq.c lib/tests/scaffold/14-if-goto.c lib/tests/scaffold/15-if-not-f.c lib/tests/scaffold/16-if-t.c +lib/tests/scaffold/16-cast.c lib/tests/scaffold/17-compare-char.c lib/tests/scaffold/17-compare-ge.c lib/tests/scaffold/17-compare-gt.c @@ -63,6 +66,7 @@ lib/tests/scaffold/17-compare-or.c lib/tests/scaffold/17-compare-and-or.c lib/tests/scaffold/17-compare-assign.c lib/tests/scaffold/17-compare-call.c +lib/tests/scaffold/17-compare-rotated.c lib/tests/scaffold/18-assign-shadow.c lib/tests/scaffold/20-while.c lib/tests/scaffold/21-char-array-simple.c @@ -97,12 +101,14 @@ lib/tests/scaffold/43-for-do-while.c lib/tests/scaffold/44-switch.c lib/tests/scaffold/44-switch-fallthrough.c lib/tests/scaffold/44-switch-body-fallthrough.c +lib/tests/scaffold/44-switch-body-fallthrough-not-default.c lib/tests/scaffold/45-void-call.c lib/tests/scaffold/46-function-static.c lib/tests/scaffold/47-function-expression.c lib/tests/scaffold/48-global-static.c lib/tests/assert/50-assert.c lib/tests/mes/50-itoa.c +lib/tests/scaffold/50-compare-rotated-weird.c lib/tests/posix/50-getenv.c lib/tests/stdlib/50-malloc.c lib/tests/string/50-memcmp.c @@ -132,6 +138,8 @@ lib/tests/scaffold/63-struct-cell.c lib/tests/scaffold/64-make-cell.c lib/tests/scaffold/65-read.c lib/tests/scaffold/66-local-char-array.c +lib/tests/scaffold/67-m1-overflow-check.c +lib/tests/scaffold/68-truncate-shift.c " tcc_tests=" @@ -190,6 +198,7 @@ lib/tests/scaffold/7u-inc-byte-word.c lib/tests/scaffold/7u-struct-func.c lib/tests/scaffold/7u-struct-size10.c lib/tests/scaffold/7u-vstack.c +lib/tests/scaffold/7v-struct-initialize-zeroes.c lib/tests/scaffold/70-array-in-struct-init.c lib/tests/scaffold/70-struct-short-enum-init.c lib/tests/scaffold/70-struct-post.c @@ -244,8 +253,6 @@ if test $compiler = mescc; then xfail_tests="$xfail_tests lib/tests/scaffold/17-compare-unsigned-char-le.c lib/tests/scaffold/17-compare-unsigned-short-le.c -lib/tests/scaffold/66-local-char-array.c -lib/tests/scaffold/72-typedef-struct-def-local.c lib/tests/scaffold/70-ternary-arithmetic-argument.c lib/tests/mes/90-abtod.c lib/tests/mes/90-dtoab.c @@ -263,6 +270,11 @@ lib/tests/scaffold/91-goto-array.c lib/tests/scaffold/a0-call-trunc-int.c " fi + if test $mes_cpu = riscv64; then + xfail_tests="$xfail_tests +lib/tests/scaffold/17-compare-rotated.c + " + fi fi if test $mes_cpu = x86_64; then @@ -290,6 +302,12 @@ lib/tests/scaffold/70-extern.c lib/tests/stdio/80-sscanf.c lib/tests/posix/90-execlp.c lib/tests/string/90-snprintf.c +" + fi + + if test $mes_cpu = riscv64; then + xfail_tests="$xfail_tests +lib/tests/scaffold/70-extern.c " fi fi @@ -298,7 +316,7 @@ fi if test -n "$bootstrap"; then TESTS="${TESTS-$mes_tests$tcc_tests}" else - TESTS="${TESTS-$mes_tests$tcc_test$gnu_tests}" + TESTS="${TESTS-$mes_tests$tcc_tests$gnu_tests}" fi # Allow for make check xfail_tests=lib/tests/setjmp/80-setjmp.c diff --git a/build-aux/config.sh.in b/build-aux/config.sh.in index 8b271423..a919f141 100644 --- a/build-aux/config.sh.in +++ b/build-aux/config.sh.in @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -57,7 +57,6 @@ abs_top_srcdir="@abs_top_srcdir@" arch="@arch@" build="@build@" host="@host@" -numbered_arch=${numbered_arch-"@numbered_arch@"} bootstrap=${bootstrap-@bootstrap@} compiler=${compiler-@compiler@} @@ -98,6 +97,7 @@ export CC export DIFF export SHELL export V +export cc_cpu export colors export compiler export courageous diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 609dcaff..2740a044 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2019,2020,2021 Jan (janneke) Nieuwenhuizen +# Copyright © 2019,2020,2021,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -30,6 +30,7 @@ fi . ./config.sh libc_mini_shared_SOURCES=" +lib/mes/__init_io.c lib/mes/eputs.c lib/mes/oputs.c " @@ -74,7 +75,7 @@ libc_mini_SOURCES="$libc_mini_shared_SOURCES" if test $mes_libc = mes; then libc_mini_SOURCES="$libc_mini_SOURCES -lib/mes/mini-write.c +lib/mes/write.c " fi @@ -107,8 +108,16 @@ lib/mes/ntoab.c lib/mes/oputc.c lib/mes/ultoa.c lib/mes/utoa.c +" + +# /include/mes/lib-cc.h already defines __raise.c as a macro for __TCC__ +# if we include it in the target source lib it explodes when reading the +# function definition +if test $compiler != tcc; then + libmes_SOURCES="$libmes_SOURCES lib/stub/__raise.c " +fi if test $mes_libc = mes; then libmes_SOURCES="$libmes_SOURCES @@ -215,6 +224,7 @@ lib/linux/malloc.c lib/linux/_read.c lib/linux/time.c lib/linux/unlink.c +lib/linux/wait4.c lib/linux/waitpid.c lib/linux/$mes_cpu-mes-$compiler/syscall.c lib/linux/getpid.c diff --git a/build-aux/export.make b/build-aux/export.make index 3bfb0bff..05b85611 100644 --- a/build-aux/export.make +++ b/build-aux/export.make @@ -1,5 +1,5 @@ # GNU Mes --- Maxwell Equations of Software -# Copyright © 2018 Jan (janneke) Nieuwenhuizen +# Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -43,6 +43,7 @@ export moduledir export sysconfdir export bootstrap +export cc_cpu export compiler export courageous export mes_system diff --git a/build-aux/install.sh.in b/build-aux/install.sh.in index f3a69229..f2e14ccf 100644 --- a/build-aux/install.sh.in +++ b/build-aux/install.sh.in @@ -114,6 +114,9 @@ fi if test -d mescc-lib/$mes_cpu-mes; then tar -cf- -C mescc-lib $mes_cpu-mes | tar -${v}xf- -C $DESTDIR$libdir fi +if test -d tcc-lib/$mes_cpu-mes; then + tar -cf- -C tcc-lib/$mes_cpu-mes . | tar -${v}xf- -C $DESTDIR$libdir +fi mkdir -p ${DESTDIR}${guile_site_dir} mkdir -p ${DESTDIR}${guile_site_ccache_dir} diff --git a/build-aux/pointer.sh b/build-aux/pointer.sh index 384b0689..51cea49f 100755 --- a/build-aux/pointer.sh +++ b/build-aux/pointer.sh @@ -48,7 +48,6 @@ sed -ri \ include/mes/mes.h \ include/mes/symbols.h \ include/mes/builtins.h \ - include/m2/lib.h \ src/builtins.c \ src/cc.c \ src/core.c \ diff --git a/configure b/configure index 39a5da38..1edca280 100755 --- a/configure +++ b/configure @@ -6,6 +6,7 @@ MES_ARENA=100000000 exec ${SCHEME-guile} -L . --no-auto-compile -e '(configure)' ;;; GNU Mes --- Maxwell Equations of Software ;;; Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Vagrant Cascadian +;;; Copyright © 2021 W. J. van der Laan ;;; ;;; configure: This file is part of GNU Mes. ;;; @@ -454,11 +455,11 @@ Some influential environment variables: (deps (fold (lambda (program results) (cons (check-program-version program) results)) '() - (list (make-dep "hex2" #:version '(1 4 0)) - (make-dep "M1" #:version '(1 4 0)) - (make-dep "blood-elf" #:version '(2 0 0)) - (make-dep "kaem" #:version '(1 0 0) #:optional? #t) - (make-dep "M2-Planet" #:version '(1 9 0) #:optional? #t) + (list (make-dep "hex2" #:version '(1 5 0)) + (make-dep "M1" #:version '(1 5 0)) + (make-dep "blood-elf" #:version '(2 0 1)) + (make-dep "kaem" #:version '(1 5 0) #:optional? #t) + (make-dep "M2-Planet" #:version '(1 11 0) #:optional? #t) (make-dep "diff" #:optional? #t) (make-dep "guile" #:version '(2 0) #:commands '("guile-3.0" "guile-3" "guile-2.2" "guile-2.0" "guile-2" "guile") #:optional? #t) (make-dep "mes" #:version '(0 22) #:optional? #t) @@ -538,12 +539,12 @@ Some influential environment variables: (mes-cpu (cond ((member mes-cpu '("i386" "i486" "i586" "i686")) "x86") ((member mes-cpu '("arm" "armv4" "armv7l")) "arm") (else mes-cpu))) - (mes-bits (if (member mes-cpu '("x86_64" "aarch64")) "64" + (mes-bits (if (member mes-cpu '("x86_64" "riscv64" "aarch64")) "64" "32")) (mes-libc (if system-libc? "system" "mes")) (mes-kernel (car (filter (compose not - (cut member <> '("pc" "portbld" "unknown"))) + (cut member <> '("pc" "portbld" "unknown" "redhat"))) (cdr host-type-list)))) (mes-kernel (if (string-prefix? "freebsd" mes-kernel) "freebsd" mes-kernel)) (mes-compiler (cond (gcc? "gcc") (tcc? "gcc") (mescc? "mescc") (else "bootstrap"))) @@ -556,12 +557,7 @@ Some influential environment variables: (and (file-exists? "/bin/sh") "/bin/sh") (file-name "sh" deps) "sh")) - (hex2 (file-name "hex2" deps)) - (numbered-arch? (begin - (stdout "checking for stage0 architecture flag... ") - (let ((numbered? (and hex2 (string-contains (gulp-pipe (string-append hex2 " --help 2>&1" )) "--Architecture 12345")))) - (stdout (if numbered? "numbered\n" "named\n")) - numbered?)))) + (hex2 (file-name "hex2" deps))) (define* (substitute file-name pairs #:key (target (if (string-suffix? ".in" file-name) @@ -580,7 +576,9 @@ Some influential environment variables: (when (and (not (member mes-system '("arm-linux-mes" "aarch64-linux-mes" "x86-linux-mes" - "x86_64-linux-mes"))) + "x86_64-linux-mes" + "riscv32-linux-mes" + "riscv64-linux-mes"))) (not with-courage?)) (stderr "platform not supported: ~a See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) @@ -656,7 +654,6 @@ See \"Porting GNU Mes\" in the manual, or try --with-courage\n" mes-system) ("@LDFLAGS@" . ,(or (getenv "LDFLAGS") "-static -g")) ("@HEX2FLAGS@" . ,(or (getenv "HEX2FLAGS") "")) ("@M1FLAGS@" . ,(or (getenv "M1FLAGS") "")) - ("@numbered_arch@" . ,(if numbered-arch? "true" "false")) ,@(map (lambda (o) @@ -725,7 +722,6 @@ GNU Mes is configured for libc: " mes-libc " kernel: " mes-kernel " system: " mes-system " - tools: " (if numbered-arch? "numbered" "named") " arch bootstrap: " (if with-bootstrap? "yes" "no") " courageous: " (if with-courage? "yes" "no") " diff --git a/configure.sh b/configure.sh index 2831452d..5d695422 100755 --- a/configure.sh +++ b/configure.sh @@ -2,6 +2,7 @@ # GNU Mes --- Maxwell Equations of Software # Copyright © 2018,2019,2021,2022,2023 Jan (janneke) Nieuwenhuizen +# Copyright © 2023 Ekaitz Zarraga # # This file is part of GNU Mes. # @@ -99,13 +100,6 @@ else GUILE_EFFECTIVE_VERSION=${GUILE_EFFECTIVE_VERSION-$(guile -c '(display (effective-version))')} fi -numbered_arch=false -mes_tools=named -if ( $HEX2 --help 2>&1 ) | grep -q "\-\-Architecture 12345"; then - numbered_arch=true - mes_tools=numbered -fi - bindir=$(eval echo ${bindir-$prefix/bin}) datadir=$(eval echo ${datadir-$prefix/share}) docdir=$(eval echo ${docdir-$datadir/doc/mes}) @@ -172,7 +166,6 @@ subst () { -e s,"@M2_PLANET@,$M2_PLANET,"\ -e s,"@KAEM@,$KAEM,"\ -e s,"@MES_FOR_BUILD@,$MES_FOR_BUILD,"\ - -e s,"@numbered_arch@,$numbered_arch,"\ -e s,"@SHELL@,$SHELL,"\ $1 > $2 } @@ -209,7 +202,7 @@ case "$host" in esac case "$mes_cpu" in - x86_64) + x86_64|riscv64) mes_bits=64;; *) mes_bits=32;; diff --git a/doc/announce/ANNOUNCE-0.24 b/doc/announce/ANNOUNCE-0.24 index 1b36ce56..cd876e78 100644 --- a/doc/announce/ANNOUNCE-0.24 +++ b/doc/announce/ANNOUNCE-0.24 @@ -10,7 +10,7 @@ Mes has now been ported to M2-Planet and can be bootstrapped using stage0-posix[0], starting from the 357-byte hex0 binary of the bootstrap-seeds[1], as was promised at FOSDEM'21[2]. -We are exciteda that the NlNet Foundation[4] is again sponsoring this +We are excited that the NlNet Foundation[4] is again sponsoring this work! What's next? diff --git a/doc/announce/ANNOUNCE-0.24.2 b/doc/announce/ANNOUNCE-0.24.2 index db866969..cf1d17d7 100644 --- a/doc/announce/ANNOUNCE-0.24.2 +++ b/doc/announce/ANNOUNCE-0.24.2 @@ -61,8 +61,8 @@ Enjoy! Here are the SHA1 and SHA256 checksums: - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.24.2.tar.gz + 30b0ce4cd37c87dca37b85a6c19646001881be46 mes-0.24.2.tar.gz + 7ddae0854e46ebfa18c13ab37e64839a7b86ea88aeed366a8d017efd11dae86e mes-0.24.2.tar.gz [*] Use a .sig file to verify that the corresponding file (without the .sig suffix) is intact. First, be sure to download both the .sig file diff --git a/doc/announce/ANNOUNCE-0.25 b/doc/announce/ANNOUNCE-0.25 new file mode 100644 index 00000000..81ed1751 --- /dev/null +++ b/doc/announce/ANNOUNCE-0.25 @@ -0,0 +1,108 @@ + +Subject: GNU Mes 0.25 released + +<#secure method=pgpmime mode=sign> + +We are happy to announce the release of GNU Mes 0.25! + +Although it's been only nine months since the previous release, this +release represents 116 commits over two years by six people. This +release brings RISC-V64-linux support. + +We are excited that the NLnet Foundation is sponsoring this work! + +What's next? + +Bringing the Full Source Bootstrap to NixOS. Full Guile compatible +module support, and support for running Gash and Gash-Utils. Support +for bootstrapping gcc-4.6.4, and a Full Source Bootstrap for +armhf-linux, and riscv64-linux. + +Enjoy! + +* About + + GNU Mes is a Scheme interpreter and C compiler for bootstrapping the + GNU System. It has helped to decimate the number and size of binary + seeds that were used in the bootstrap of GNU Guix 1.0. Recently, + version 0.24.2 has realized the first Full Source Bootstrap for Guix + . + The final goal is to help create a full source bootstrap as part of + the bootstrappable builds effort for any + UNIX-like operating system. + + Mes + MesCC + Mes C Library can build a bootstrappable TinyCC + that is self-hosting. Using this + bootstrappable-tcc and the Mes C library we can build an ancient + version of the GNU tools triplet: glibc-2.2.5, binutils-2.20.1, + gcc-2.95.3. This is enough to bootstrap Guix for i686-linux, + x86_64-linux, armhf-linux and aarch64-linux. + + Mes was inspired by The Maxwell Equations of Software: LISP-1.5 -- + John McCarthy page 13, Guix's source/binary packaging transparency and + Jeremiah Orians's Stage0 , a + ~500-byte self-hosting hex assembler. + +* Download + + git clone git://git.savannah.gnu.org/mes.git + + Here are the compressed sources and a GPG detached signature[*]: + https://ftp.gnu.org/gnu/mes/mes-0.25.tar.gz + https://ftp.gnu.org/gnu/mes/mes-0.25.tar.gz.sig + + Use a mirror for higher download bandwidth: + https://ftpmirror.gnu.org/mes/mes-0.25.tar.gz + https://ftpmirror.gnu.org/mes/mes-0.25.tar.gz.sig + + Here are the SHA1 and SHA256 checksums: + + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.25.tar.gz + xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx mes-0.25.tar.gz + + [*] Use a .sig file to verify that the corresponding file (without the + .sig suffix) is intact. First, be sure to download both the .sig file + and the corresponding tarball. Then, run a command like this: + + gpg --verify mes-0.25.tar.gz.sig + + If that command fails because you don't have the required public key, + or that public key has expired, try the following commands to update + or refresh it, and then rerun the 'gpg --verify' command. + + gpg --recv-keys 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273 + + Alternatively, Mes can be installed or updated using Guix: + + guix pull + guix install mes + + +* Changes in 0.25 since 0.24.2 + + ** Core + *** Support for riscv64-linux. + ** Build + *** Support M2-Planet build for x86_64-linux. + *** Building with M2-Planet-1.11.0 is now supported. + *** The requirement for M2-Planet's --bootstrap-mode was dropped. + ** Noteworthy bug fixes + *** In the REPL, `include', `load', and `,use MODULE' now work. + *** Using mes' `access' with R_OK now respects read permissions. + *** On 64bit, displayed values are no longer truncated. + *** On 64bit, MesCC now correctly supports 8-byte immediate values. + *** MesCC now initializes struct fields to 0. + *** The MesCC test suite passes with gcc >= 10 + An array overflow bug was fixed in `63-struct-cell.c'. + +Join bug-mes@gnu.org and #bootstrappable on irc.libera.chat for +discussions. + +Thanks to everyone who contributed to this release: + + 11 Andrius Štikonas + 1 Efraim Flashner + 25 Ekaitz Zarraga + 1 Emily Trau + 63 Janneke Nieuwenhuizen + 15 W. J. van der Laan diff --git a/doc/images/gcc-mesboot-graph.dot b/doc/images/gcc-mesboot-graph.dot index 8243fe72..f985df35 100644 --- a/doc/images/gcc-mesboot-graph.dot +++ b/doc/images/gcc-mesboot-graph.dot @@ -1,107 +1,80 @@ digraph "Guix bag" { - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" [label = "gcc-core-mesboot0@2.95.3", shape = box, fontname = sans]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = red]; - "/gnu/store/3va8hfvfyp6dbwqk3036kb25wbp0f81z-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = red]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" [label = "binutils-mesboot0@2.14", shape = box, fontname = sans]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = cyan3]; - "/gnu/store/8ghnzf9idpmva8l4n8fyvvgqlln4rddi-binutils-mesboot0-2.14.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = cyan3]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" [label = "bash-mesboot0@2.05b", shape = box, fontname = sans]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkgoldenrod]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkgoldenrod]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkgoldenrod]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkgoldenrod]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkgoldenrod]; - "/gnu/store/yx5dz5gi00q8h5i138h59j1jmbhr3qa4-bash-mesboot0-2.05b.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkgoldenrod]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [label = "make-mesboot0@3.80", shape = box, fontname = sans]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = magenta]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = magenta]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = magenta]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = magenta]; - "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = magenta]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [label = "tcc-boot0@0.9.26-1103-g6e62e0e", shape = box, fontname = sans]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" [color = darkseagreen]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [color = darkseagreen]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkseagreen]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkseagreen]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkseagreen]; - "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkseagreen]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" [label = "mes-boot@0.22", shape = box, fontname = sans]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" [color = peachpuff4]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [color = peachpuff4]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = peachpuff4]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = peachpuff4]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = peachpuff4]; - "/gnu/store/iny72b5k1f531xv7fr2i31j4gqknjv2l-mes-boot-0.22.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = peachpuff4]; - "/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" [label = "bootstrap-mes-rewired@0.19", shape = box, fontname = sans]; - "/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" -> "/gnu/store/r7bbw2ywmgqp6m5a1hp0fs4lhc51w3sq-bootstrap-mes-0.drv" [color = cyan3]; - "/gnu/store/xdhz4v7icrfwdbq1j5j052id8l04arms-bootstrap-mes-rewired-0.19.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = cyan3]; - "/gnu/store/r7bbw2ywmgqp6m5a1hp0fs4lhc51w3sq-bootstrap-mes-0.drv" [label = "bootstrap-mes@0", shape = box, fontname = sans]; - "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [label = "gash-boot@0.2.0", shape = box, fontname = sans]; - "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkviolet]; - "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkviolet]; - "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [label = "bootar@1a", shape = box, fontname = sans]; - "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue]; - "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [label = "guile-bootstrap@2.0", shape = box, fontname = sans]; - "/gnu/store/a6nbjivhxp65wqj5s8rz0fnmwzqxmhry-bootstrap-mescc-tools-0.5.2.drv" [label = "bootstrap-mescc-tools@0.5.2", shape = box, fontname = sans]; - "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [label = "gash-utils-boot@0.1.0", shape = box, fontname = sans]; - "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue]; - "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue]; - "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [label = "bzip2-mesboot@1.0.8", shape = box, fontname = sans]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue]; - "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" [label = "gzip-mesboot@1.2.4", shape = box, fontname = sans]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = red]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = red]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = red]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = red]; - "/gnu/store/qyphha8i1pylf10pm76400kq5d07zsvr-gzip-mesboot-1.2.4.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = red]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" [label = "patch-mesboot@2.5.9", shape = box, fontname = sans]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkseagreen]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkseagreen]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkseagreen]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkseagreen]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkseagreen]; - "/gnu/store/vn42sjmbh0zr9wn9lnbsdrxlh1zihx50-patch-mesboot-2.5.9.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkseagreen]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" [label = "sed-mesboot0@1.18", shape = box, fontname = sans]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = darkgoldenrod]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = darkgoldenrod]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = darkgoldenrod]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = darkgoldenrod]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = darkgoldenrod]; - "/gnu/store/16w6l2c80hh98kfykal9hpbm93cscbcg-sed-mesboot0-1.18.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = darkgoldenrod]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" [label = "tcc-boot@0.9.27", shape = box, fontname = sans]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/yy8bxckakx5f4rpvqfggrfy21y7bn53g-bzip2-mesboot-1.0.8.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/hlm2wxhh0irfjnds4i86imdqi13iwj81-make-mesboot0-3.80.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/0izhx7j1n6lcpcbvy9i9pyjkzjpbxrcj-tcc-boot0-0.9.26-1103-g6e62e0e.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/jrf5jckbwk949npav1p62vgcg95lr4mx-gash-boot-0.2.0.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/yl8gsvanaj8wgngmgc4an06g5ybadad2-gash-utils-boot-0.1.0.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/w77kjhmj4c4sncndnh0kvf0jfpwpradm-bootar-1a.drv" [color = blue]; - "/gnu/store/h1m81zsyi3l4yd9r7pd3ffanb61pszxy-tcc-boot-0.9.27.drv" -> "/gnu/store/qs4086i9b9q0b74l4wjqgzbdc3c0f58f-guile-bootstrap-2.0.drv" [color = blue]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" [label = "gcc-core-mesboot0@2.95.3", shape = box, fontname = sans]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod]; + "/gnu/store/8vp8iadwjcvhaaqpa1wy60irhjdppwx7-gcc-core-mesboot0-2.95.3.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" [label = "binutils-mesboot0@2.20.1a", shape = box, fontname = sans]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod]; + "/gnu/store/8r05q5i3aspzqkg1jr7py719r74nfaji-binutils-mesboot0-2.20.1a.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkgoldenrod]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" [label = "gzip-mesboot@1.2.4", shape = box, fontname = sans]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = peachpuff4]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = peachpuff4]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = peachpuff4]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = peachpuff4]; + "/gnu/store/l4dmmjr7sxzlyh0df7kqcjkfd3w4gink-gzip-mesboot-1.2.4.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = peachpuff4]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [label = "tcc-boot0@0.9.26-1136-g5bba73cc", shape = box, fontname = sans]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [color = cyan3]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [color = cyan3]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = cyan3]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = cyan3]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = cyan3]; + "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = cyan3]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [label = "mes-boot@0.24.2", shape = box, fontname = sans]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [color = darkseagreen]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkseagreen]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkseagreen]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkseagreen]; + "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkseagreen]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" [label = "stage0-posix@1.4", shape = box, fontname = sans]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" [color = darkviolet]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkviolet]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = darkviolet]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkviolet]; + "/gnu/store/xavqa6yvv08ns4xggf27wc14m2kw2pvn-stage0-posix-1.4.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkviolet]; + "/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" [label = "bootstrap-seeds@1.0.0", shape = ellipse, fontname = sans]; + "/gnu/store/7zxbgnrnhvm7g8bz1m5knpsbdfxzxl9g-bootstrap-seeds-1.0.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkgoldenrod]; + "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [label = "bootar@1b", shape = box, fontname = sans]; + "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = peachpuff4]; + "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [label = "guile-bootstrap@2.0", shape = ellipse, fontname = sans]; + "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [label = "gash-boot@0.3.0", shape = box, fontname = sans]; + "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkseagreen]; + "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkseagreen]; + "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [label = "gash-utils-boot@0.2.0", shape = box, fontname = sans]; + "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = darkviolet]; + "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = darkviolet]; + "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = darkviolet]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" [label = "patch-mesboot@2.5.9", shape = box, fontname = sans]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = blue]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = blue]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = blue]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = blue]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = blue]; + "/gnu/store/xznzx9xadd0x7z1az87likm636i8fldh-patch-mesboot-2.5.9.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = blue]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [label = "make-mesboot0@3.80", shape = box, fontname = sans]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = dimgrey]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = dimgrey]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = dimgrey]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = dimgrey]; + "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = dimgrey]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" [label = "tcc-boot@0.9.27", shape = box, fontname = sans]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/3a9ynm7wmrggy8fx030830561a6rqrdj-mes-boot-0.24.2.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/gqz3fvamvvzb2gp6b6kk4imr0kywvxcr-make-mesboot0-3.80.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/1jfd6izcr1f5ijkrh7z8bpfnkgfc6rvz-tcc-boot0-0.9.26-1136-g5bba73cc.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/08jspv02rj1zad6y6ascil5r8lw4zz7d-gash-boot-0.3.0.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/hjzqij47br5wns4y2dzs094rsp4q82n5-gash-utils-boot-0.2.0.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/c2rwfalxivxrs29b56hxxb8zz6ad38iz-bootar-1b.drv" [color = blue]; + "/gnu/store/qmxs62ligcdsdb0x3n00mgfr6hm8nx3h-tcc-boot-0.9.27.drv" -> "/gnu/store/5pfm57hqv1xk7bm9xc36y568ssv1zawb-guile-bootstrap-2.0.drv" [color = blue]; } diff --git a/doc/mes.texi b/doc/mes.texi index bdf2c420..72409fb7 100644 --- a/doc/mes.texi +++ b/doc/mes.texi @@ -13,7 +13,7 @@ @set OPENPGP-SIGNING-KEY-ID 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273 @copying -Copyright @copyright{} 2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen@* +Copyright @copyright{} 2018,2019,2020,2021,2022,2023 Janneke Nieuwenhuizen@* Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or @@ -93,7 +93,11 @@ Bootstrapping * The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk. * Invoking mes:: Running Mes, a minimalist Guile lookalike. * Invoking mescc:: Running the MesCC bootstrap compiler. -* Invoking mesar:: +* Invoking mesar:: Running the MesCC bootstrap archiver. + +The Mes Bootstrap Process + +* Full Source Bootstrap Deployments:: Invoking mes @@ -156,8 +160,8 @@ essential freedoms: @item The freedom to study how the program works, and change it so it does - your computing as you wish (freedom 1). Access to the source code is - a precondition for this. + your computing as you wish (freedom 1). Access to the source code + is a precondition for this. @item The freedom to redistribute copies so you can help others (freedom @@ -165,8 +169,8 @@ essential freedoms: @item The freedom to distribute copies of your modified versions to others - (freedom 3). By doing this you can give the whole community a chance - to benefit from your changes. Access to the source code is a + (freedom 3). By doing this you can give the whole community a + chance to benefit from your changes. Access to the source code is a precondition for this. @end enumerate @end quotation @@ -325,12 +329,21 @@ from source. @node Full Source Bootstrap @section Full Source Bootstrap +@quotation +The holy grail for bootstrappability will be connecting @code{hex0} to +@code{mes}. + +@author Carl Dong +@end quotation + Reduction of binary seeds is great, but there is an obvious target: we cannot allow any binary seeds in our software stack. Not even in the bootstrap binary seed. Maybe that is a bit too strong: we want to have the absolute minimum of binary seeds and all binary seeds need to be inspectable and must be reviewed. How big would the absolute minimal -set be? +set be? During the Guix 1.5 development series we managed to close the +gap between @code{stage0-posix} and @code{mes}. We refer to this as the +@emph{Full-Source Bootstrap}. @menu * Stage0:: The Magical Self-Hosting Hex Assembler. @@ -558,14 +571,14 @@ later, including 2.2.x and 3.0.x, @item @url{https://www.gnu.org/software/make/, GNU Make}. @item @url{https://savannah.gnu.org/projects/nyacc/, NYACC}, version 1.00.2, @item @url{https://gcc.gnu.org, GCC's gcc}, version 2.95.3 or later, including 10.2.0, -@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.4.0, +@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.5.0, @end itemize The following dependencies are optional: @itemize Support for building the bootstrap @file{bin/mes-m2} depends on -@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.9.0. +@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.11.0. @end itemize @cindex Guile, compatibility @@ -594,8 +607,8 @@ Bootstrapping Mes depends on the following packages: @itemize @item a POSIX-compatible shell -@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.4.0, -@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.9.0. +@item @url{https://savannah.gnu.org/projects/mescc-tools/, mescc-tools}, version 1.5.0, +@item @url{https://github.com/oriansj/m2-planet/, M2-Planet}, version 1.11.0. @item @url{https://savannah.gnu.org/projects/nyacc/, NYACC}, version 1.00.2, @end itemize @@ -684,17 +697,17 @@ responsibility. * The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk. * Invoking mes:: Running Mes, a minimalist Guile lookalike. * Invoking mescc:: Running the MesCC bootstrap compiler. -* Invoking mesar:: +* Invoking mesar:: Running the MesCC bootstrap archiver. @end menu @node The Mes Bootstrap Process @section The Mes Bootstrap Process -The Reduced Binary Seed bootstrap currently adopted by Guix@footnote{See +The Full Source Bootstrap currently adopted by Guix@footnote{See @file{gnu/packages/commencement.scm} in the @var{master} branch in Guix git @url{https://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/commencement.scm}}. -In its intiial form it is only available for x86-linux and armhf-linux. +In its intiial form it is only available for x86-linux. Currently, it goes like this: @@ -702,48 +715,48 @@ Currently, it goes like this: gcc-mesboot (4.9.4) ^ | - glibc-mesboot (2.16.0) + (...) ^ | - gcc-mesboot1 (4.7.4) + binutils-mesboot (2.20.1a), glibc-mesboot (2.2.5), + gcc-core-mesboot (2.95.3) ^ | - binutils-mesboot (2.20.1a) + patch-mesboot (2.5.9) ^ | - gcc-mesboot0 (2.95.3) + bootstrappable-tcc (0.9.26+31 patches) ^ | - glibc-mesboot0 (2.2.5) + gnu-make-mesboot0 (3.80) ^ | - gcc-core-mesboot (2.95.3) + gzip-mesboot (1.2.4) ^ | - make-mesboot0, diffutils-mesboot, binutils-mesboot0 (2.20.1a) + tcc-boot (0.9.27) ^ | - tcc-boot + mes-boot (0.24.2) ^ | - tcc-boot0 + stage0-posix (hex0..M2-Planet) ^ | - mes-boot + gash-boot, gash-utils-boot ^ | * - gash-boot, gash-utils-boot - ^ - | - * - bootstrap-mescc-tools, bootstrap-mes (~12 MiB) - bootstrap-guile (~48 MiB) + bootstrap-seeds (357-bytes for x86) + ~~~ + [bootstrap-guile-2.0.9 driver (~25 MiB)] @end verbatim -@c This graph is generated from wip-bootstrap, doing: +@c This graph is generated from Guix master, doing: -@c guix graph --type=bag -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' > doc/images/gcc-mesboot-graph.dot +@c guix graph --type=bag -e '(@@ (gnu packages commencement) gcc-core-mesboot0)' \ +@c | sed -re 's,((bootstrap-seeds|guile-bootstrap).*shape =) box,\1 ellipse,' \ +@c > doc/images/gcc-mesboot-graph.dot @c dot -T png doc/images/gcc-mesboot-graph.dot > doc/images/gcc-mesboot-graph.png Here's a generated dependency diagram to for the initial bootstrap gcc @@ -751,12 +764,6 @@ that builds the rest of Guix. @image{images/gcc-mesboot-graph,6in,,Reference graph of the gcc-core-mesboot0} -Work is ongoing to remove these binary seeds that were intentionally -injected by our own doing as temporary shortcut -@example -bootstrap-mescc-tools (seed), bootstrap-mes (seed) -@end example - For now, this additional non-bootstrapped dependencies (i.e., binary seeds) are taken for granted @@ -764,7 +771,53 @@ seeds) are taken for granted bootstrap-guile @end example -Our next priority is to eleminate these one by one. +Our next priority is to eleminate the dependency on +@code{bootstrap-guile} for @code{Gash} and @code{Gash-Utils}, and thus +for @code{Mes}. + +@menu +* Full Source Bootstrap Deployments:: +@end menu + +@node Full Source Bootstrap Deployments +@subsection Full Source Bootstrap Deployments + +@table @code + +@item GNU Guix +Reference implementation of the Full Source Bootstrap for +@code{i686-linux} and @code{x86_64-linux} +@url{https://guix.gnu.org/en/blog/2023/the-full-source-bootstrap-building-from-source-all-the-way-down/,Guix FSB, building from source all the way down}. + +@item Bitcoin Core +The first application of Guix' Reduced Binary Seed Bootstrap was done in +bitcoin core +@url{https://github.com/bitcoin/bitcoin/blob/master/contrib/guix/README.md, +Bootstrappable Bitcoin Core Builds}. + +@item Live Bootstrap +The @url{https://github.com/fosslinux/live-bootstrap/,live-bootstrap} +has no dependency on @code{guile-bootstrap}, and removes and bootstraps +generated autotools and flex/bison files. + +@item Freedesktop SDK +The Freedesktop SDK used to have an informal dependency on its previous +version being installed in binary from. This dependency was mostly +broken in +@url{https://gitlab.com/freedesktop-sdk/freedesktop-sdk/-/merge_requests/11557, +bootstrap freedesktop binary seed}, they still have a dependency on +binary Rust. + +@item Full Source Bootstrap from Git +Building on the Live Bootstrap, but building most everything from Git +@url{https://github.com/schierlm/FullSourceBootstrapFromGit, FSB from Git}. + +@item NixOS +Implementation of a FSB has started +@url{https://github.com/NixOS/nixpkgs/pull/227914,NixOS 256b bootstrap +(in progress)}. + +@end table @node Invoking mes @section Invoking mes diff --git a/guix/git/mes.scm b/guix/git/mes.scm index eeb0786e..37b85d3c 100644 --- a/guix/git/mes.scm +++ b/guix/git/mes.scm @@ -1,5 +1,6 @@ ;;; GNU Mes --- Maxwell Equations of Software -;;; Copyright © 2016,2017,2018,2019,2020,2021,2022 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2016,2017,2018,2019,2020,2021,2022,2023 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2023 Ekaitz Zarraga ;;; ;;; This file is part of GNU Mes. ;;; @@ -31,6 +32,7 @@ #:use-module (gnu packages commencement) #:use-module (gnu packages cross-base) #:use-module (gnu packages gcc) + #:use-module (gnu packages gdb) #:use-module (gnu packages graphviz) #:use-module (gnu packages guile) #:use-module (gnu packages man) @@ -54,20 +56,19 @@ (define-public mescc-tools (package (name "mescc-tools") - (version "1.4.0") + (version "1.5.0") (source (origin - (method git-fetch) - (uri (git-reference - (url "https://git.savannah.nongnu.org/r/mescc-tools.git") - (commit (string-append "Release_" version)) - (recursive? #t))) ;for M2libc - (file-name (git-file-name name version)) + (method url-fetch) + (uri (string-append + "https://github.com/oriansj/mescc-tools/releases/download/" + "Release_" version "/" name "-" version ".tar.gz")) (sha256 (base32 - "0z2ni2qn2np1walcaqlxz8sinzb78d4hiq9glddzf26wxc226hs4")))) + "1vjczlajyrbjcx9ld35vhdqbxfdwwy3axg0jray3iwnrf70qr700")))) (build-system gnu-build-system) - (supported-systems - '("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux")) + (supported-systems '("i686-linux" "x86_64-linux" + "armhf-linux" "aarch64-linux" + "riscv32-linux" "riscv64-linux")) (native-inputs (list which)) (arguments `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) @@ -87,19 +88,20 @@ get_machine.") (define-public m2-planet (package (name "m2-planet") - (version "1.9.0") + (version "1.11.0") (source (origin - (method git-fetch) - (uri (git-reference - (url "https://github.com/oriansj/m2-planet") - (commit (string-append "Release_" version)) - (recursive? #t))) ;for M2libc - (file-name (git-file-name name version)) + (method url-fetch) + (uri (string-append + "https://github.com/oriansj/M2-Planet/releases/download/" + "Release_" version "/" name "-" version ".tar.gz")) (sha256 (base32 - "0cgvvq91cbxxm93k8ayyvhpaf3c2lv10qw4wyqwn3hc1qb1cfyvr")))) + "1c510p55amxjyvjlx9jpa30gixlgmf6mmfnaqcs46412krymwg38")))) (native-inputs (list mescc-tools)) (build-system gnu-build-system) + (supported-systems '("i686-linux" "x86_64-linux" + "armhf-linux" "aarch64-linux" + "riscv32-linux" "riscv64-linux")) (arguments `(#:make-flags (list (string-append "PREFIX=" (assoc-ref %outputs "out")) (string-append "CC=" ,(cc-for-target))) @@ -191,7 +193,8 @@ extensive examples, including parsers for the Javascript and C99 languages.") (sha256 (base32 #!mes!# "0vp8v88zszh1imm3dvdfi3m8cywshdj7xcrsq4cgmss69s2y1nkx")))) (build-system gnu-build-system) - (supported-systems '("aarch64-linux" "armhf-linux" "i686-linux" "x86_64-linux")) + (supported-systems '("aarch64-linux" "armhf-linux" "i686-linux" + "x86_64-linux" "riscv64-linux")) (propagated-inputs (list mescc-tools nyacc)) (native-inputs (append @@ -238,7 +241,7 @@ Guile.") (license gpl3+))) (define-public mes.git - (let ((version #!mes!# "0.24.2") + (let ((version #!mes!# "0.24.2") (revision "0") (commit (read-string (open-pipe "git show HEAD | head -1 | cut -d ' ' -f 2" OPEN_READ)))) (package @@ -247,4 +250,7 @@ Guile.") (version (string-append version "-" revision "." (string-take commit 7))) (source (local-file %source-dir #:recursive? #t - #:select? (git-predicate %source-dir)))))) + #:select? (git-predicate %source-dir))) + (native-inputs + `(("gdb" ,gdb) + ,@(package-native-inputs mes)))))) diff --git a/include/fcntl.h b/include/fcntl.h index 2a8ece80..ff66fa40 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -1,6 +1,8 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Emily Trau * * This file is part of GNU Mes. * @@ -40,12 +42,17 @@ #define O_APPEND 0x400 #ifdef __arm__ -#define O_DIRECTORY 0x4000 -/*#define O_DIRECT 0x10000*/ +#define O_DIRECTORY 0x4000 +#define O_TMPFILE 0x404000 #else -#define O_DIRECTORY 0x10000 +#define O_DIRECTORY 0x10000 +#define O_TMPFILE 0x410000 #endif +#define AT_FDCWD -100 +#define AT_SYMLINK_NOFOLLOW 0x100 +#define AT_REMOVEDIR 0x200 + #elif __GNU__ #define O_RDONLY 1 #define O_WRONLY 2 @@ -69,8 +76,11 @@ #define creat(file_name, mode) open (file_name, O_WRONLY | O_CREAT | O_TRUNC, mode) int dup (int old); int dup2 (int old, int new); + +#if !__M2__ int fcntl (int filedes, int command, ...); int open (char const *s, int flags, ...); +#endif #endif // ! SYSTEM_LIBC diff --git a/include/linux/SYSCALLS b/include/linux/SYSCALLS new file mode 100644 index 00000000..652c20ec --- /dev/null +++ b/include/linux/SYSCALLS @@ -0,0 +1,111 @@ +#+COMMENT: -*- org -*- +#+TITLE: Linux System Calls + +|---------------+----------+-----+--------+-----+---------| +| name | old | x86 | x86_64 | arm | riscv64 | +|---------------+----------+-----+--------+-----+---------| +| libc-mini | | | | | | +|---------------+----------+-----+--------+-----+---------| +| exit | | 1 | 60 | 1 | 1 | +| write | | 4 | 1 | 4 | 4 | +|---------------+----------+-----+--------+-----+---------| +| libc | | | | | | +|---------------+----------+-----+--------+-----+---------| +| fork | | 2 | 57 | 2 | 2 | +| read | | 3 | 0 | 3 | 3 | +| open | | 5 | 2 | 5 | 5 | +| waitpid | | 7 | | | | +| wait4 | waitpid | 114 | 61 | 114 | 114 | +| execve | | 11 | 59 | 11 | 11 | +| chmod | | 15 | 90 | 15 | 15 | +| access | | 33 | 21 | 33 | 33 | +| brk | | 45 | 12 | 45 | 45 | +| ioctl | | 54 | 16 | 54 | 54 | +| fsync | | 118 | 74 | 118 | 118 | +| getcwd | | 183 | 79 | 183 | 183 | +| dup | | 41 | 32 | 41 | 41 | +| dup2 | | 63 | 33 | 63 | 63 | +| unlink | | 10 | 87 | 10 | 10 | +| gettimeofday | time | 78 | 96 | 78 | 78 | +| clock_gettime | | 265 | 228 | 263 | 260 | +| time | | 13 | 201 | 13 | | +|---------------+----------+-----+--------+-----+---------| +| libc+tcc | | | | | | +|---------------+----------+-----+--------+-----+---------| +| close | | 6 | 3 | 6 | 6 | +| lseek | | 19 | 8 | 19 | 19 | +| rmdir | | 40 | 84 | 40 | 40 | +| stat | | 106 | 4 | 106 | 106 | +|---------------+----------+-----+--------+-----+---------| +| libc+GNU | | | | | | +|---------------+----------+-----+--------+-----+---------| +| chdir | | 12 | 80 | 12 | 12 | +| link | | 9 | 86 | 9 | 9 | +| getpid | | 20 | 39 | 20 | 20 | +| getuid | | 24 | 102 | 24 | 199 | +| kill | | 37 | 62 | 37 | 37 | +| rename | | 38 | 82 | 38 | 38 | +| mkdir | | 39 | 83 | 39 | 39 | +| pipe | | 42 | 22 | 42 | 42 | +| getgid | | 47 | 104 | 47 | 200 | +| signal | | 48 | | | 48 | +| sigaction | | 67 | | 67 | 67 | +| rt_sigaction | | 174 | 13 | 174 | 174 | +| signal | | 48 | | | 48 | +| fcntl | | 55 | 72 | 55 | 55 | +| getrusage | | 77 | 98 | 77 | 77 | +| lstat | | 107 | 6 | 107 | 107 | +| setitimer | | 104 | 38 | 104 | 104 | +| fstat | | 108 | 5 | 108 | 108 | +| nanosleep | | 162 | 35 | 162 | 162 | +| getdents | | 141 | 78 | 141 | 141 | +|---------------+----------+-----+--------+-----+---------| +| GNU+bash | | | | | | +|---------------+----------+-----+--------+-----+---------| +| setuid | | 23 | 105 | 23 | 213 | +| geteuid | | 49 | 107 | 49 | 201 | +| getegid | | 50 | 108 | 50 | 202 | +| setgid | | 46 | 106 | 46 | 214 | +| getppid | | 64 | 110 | 64 | 64 | +|---------------+----------+-----+--------+-----+---------| +| GNU+make | | | | | | +|---------------+----------+-----+--------+-----+---------| +| sigprocmask | | 126 | | 126 | 126 | +|---------------+----------+-----+--------+-----+---------| +| GNU+tar | | | | | | +|---------------+----------+-----+--------+-----+---------| +| symlink | | 83 | 88 | 83 | 83 | +| readlink | | 85 | 89 | 85 | 85 | +| mknod | | 14 | 133 | 14 | 14 | +|---------------+----------+-----+--------+-----+---------| +| new | | | | | | +|---------------+----------+-----+--------+-----+---------| +| clone | fork | 120 | 56 | 120 | 120 | +| getdents64 | getdents | 220 | 217 | 217 | 220 | +| openat | open | 295 | 257 | 322 | 288 | +| mkdirat | mkdir | 296 | 258 | 323 | 289 | +| mknodat | mknod | 297 | 259 | 324 | 290 | +| unlinkat | rmdir | 301 | 263 | 328 | 294 | +| unlinkat | unlink | 301 | 263 | 328 | 294 | +| renameat | rename | 302 | 264 | 329 | 295 | +| linkat | link | 303 | 265 | 330 | 296 | +| symlinkat | symlink | 304 | 266 | 331 | 297 | +| readlinkat | readlink | 305 | 267 | 332 | 298 | +| fchmodat | chmod | 306 | 268 | 333 | 299 | +| faccessat | access | 307 | 269 | 334 | 300 | +| dup3 | dup2 | 330 | 292 | 358 | 326 | +| pipe2 | pipe | 331 | 293 | 359 | 325 | +|---------------+----------+-----+--------+-----+---------| + +* Sources + +https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl +https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl +https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl + +* Legalese +Copyright © 2022 Jan (janneke) Nieuwenhuizen <[[mailto:janneke@gnu.org][janneke@gnu.org]]> + + Copying and distribution of this file, with or without modification, + are permitted in any medium without royalty provided the copyright + notice and this notice are preserved. diff --git a/include/linux/arm/syscall.h b/include/linux/arm/syscall.h index ca9f1f97..acfc3669 100644 --- a/include/linux/arm/syscall.h +++ b/include/linux/arm/syscall.h @@ -18,54 +18,39 @@ * You should have received a copy of the GNU General Public License * along with GNU Mes. If not, see . */ +/* Commentary: + * See https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl + * + * Code: + */ #ifndef __MES_LINUX_ARM_SYSCALL_H #define __MES_LINUX_ARM_SYSCALL_H 1 -/* See https://github.com/torvalds/linux/blob/v4.19/arch/arm/tools/syscall.tbl */ - /* libc-mini */ #ifndef SYS_exit -// CONSTANT SYS_exit 0x01 #define SYS_exit 0x01 #endif #ifndef SYS_write -// CONSTANT SYS_write 0x04 #define SYS_write 0x04 #endif /* libc */ -// CONSTANT SYS_fork 0x02 #define SYS_fork 0x02 -// CONSTANT SYS_read 0x03 #define SYS_read 0x03 -// CONSTANT SYS_open 0x05 #define SYS_open 0x05 //#define SYS_waitpid -// CONSTANT SYS_wait4 0x72 #define SYS_wait4 0x72 -// CONSTANT SYS_execve 0x0b #define SYS_execve 0x0b -// CONSTANT SYS_chmod 0x0f #define SYS_chmod 0x0f -// CONSTANT SYS_access 0x21 #define SYS_access 0x21 -// CONSTANT SYS_brk 0x2d #define SYS_brk 0x2d -// CONSTANT SYS_ioctl 0x36 #define SYS_ioctl 0x36 -// CONSTANT SYS_fsync 0x76 #define SYS_fsync 0x76 -// CONSTANT SYS_getcwd 0xb7 #define SYS_getcwd 0xb7 -// CONSTANT SYS_dup 0x29 #define SYS_dup 0x29 -// CONSTANT SYS_dup2 0x3f #define SYS_dup2 0x3f -// CONSTANT SYS_unlink 0x0a #define SYS_unlink 0x0a -// CONSTANT SYS_gettimeofday 0x4e #define SYS_gettimeofday 0x4e -// CONSTANT SYS_clock_gettime 0x107 #define SYS_clock_gettime 0x107 /* libc+tcc */ diff --git a/include/linux/riscv32/kernel-stat.h b/include/linux/riscv32/kernel-stat.h new file mode 100644 index 00000000..9ac404f4 --- /dev/null +++ b/include/linux/riscv32/kernel-stat.h @@ -0,0 +1,46 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ +#ifndef __MES_LINUX_RISCV32_KERNEL_STAT_H +#define __MES_LINUX_RISCV32_KERNEL_STAT_H 1 + +// *INDENT-OFF* +struct stat +{ + unsigned long st_dev; + unsigned long st_ino; + unsigned short st_mode; + unsigned short st_nlink; + unsigned short st_uid; + unsigned short st_gid; + unsigned long st_rdev; + long st_size; /* Linux: unsigned long; glibc: off_t (i.e. signed) */ + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; /* Linux: unsigned long; glibc: time_t */ + unsigned long st_atime_usec; + time_t st_mtime; /* Linux: unsigned long; glibc: time_t */ + unsigned long st_mtime_usec; + time_t st_ctime; /* Linux: unsigned long; glibc: time_t */ + unsigned long st_ctime_usec; + unsigned long __foo0; + unsigned long __foo1; +}; + +#endif // __MES_LINUX_RISCV32_KERNEL_STAT_H diff --git a/include/linux/riscv64/kernel-stat.h b/include/linux/riscv64/kernel-stat.h new file mode 100644 index 00000000..9519ef39 --- /dev/null +++ b/include/linux/riscv64/kernel-stat.h @@ -0,0 +1,46 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ +#ifndef __MES_LINUX_RISCV64_KERNEL_STAT_H +#define __MES_LINUX_RISCV64_KERNEL_STAT_H 1 + +// *INDENT-OFF* +struct stat +{ + unsigned long st_dev; + unsigned long st_ino; + unsigned int st_mode; + unsigned int st_nlink; + unsigned int st_uid; + unsigned int st_gid; + unsigned long st_rdev; + long st_size; + unsigned long st_blksize; + unsigned long st_blocks; + time_t st_atime; + unsigned long st_atime_usec; + time_t st_mtime; + unsigned long st_mtime_usec; + time_t st_ctime; + unsigned long st_ctime_usec; + unsigned long __foo0; + unsigned long __foo1; +}; + +#endif // __MES_LINUX_RISCV64_KERNEL_STAT_H diff --git a/include/linux/riscv64/syscall.h b/include/linux/riscv64/syscall.h new file mode 100644 index 00000000..5d5f8bf1 --- /dev/null +++ b/include/linux/riscv64/syscall.h @@ -0,0 +1,101 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ +#ifndef __MES_LINUX_RISCV_SYSCALL_H +#define __MES_LINUX_RISCV_SYSCALL_H 1 + +/** RISC-V uses the asm-generic syscalls (asm-generic/unistd.h) with the + following configuration for 64-bit: + * #define __ARCH_WANT_NEW_STAT + * #define __ARCH_WANT_SET_GET_RLIMIT + * #define __ARCH_WANT_SYS_CLONE3 + */ + +#define MAKESTRING(s) #s +#define MAKESTRING2(s) MAKESTRING (rd_a7 ! ## s addi) +#define RISCV_SYSCALL(s) MAKESTRING2 (s) + +// libc-mini +#ifndef SYS_exit +#define SYS_exit 93 +#endif +#ifndef SYS_write +#define SYS_write 64 +#endif + +// libc +#define SYS_clone 220 +#define SYS_read 63 +#define SYS_openat 56 +#define SYS_wait4 260 +#define SYS_execve 221 +#define SYS_fchmodat 53 +#define SYS_faccessat 48 +#define SYS_brk 214 +#define SYS_ioctl 29 +#define SYS_fsync 82 + +// libc+tcc +#define SYS_close 57 +#define SYS_lseek 62 +#define SYS_unlinkat 35 +#define SYS_gettimeofday 169 +#define SYS_getcwd 17 + +// libc+gnu + +#define SYS_chdir 49 +#define SYS_linkat 37 +#define SYS_getpid 172 +#define SYS_getuid 174 +#define SYS_kill 129 +#define SYS_renameat2 276 +#define SYS_mkdirat 34 +#define SYS_dup 23 +#define SYS_pipe2 59 +#define SYS_getgid 176 +#define SYS_rt_sigaction 134 +#define SYS_fcntl 25 +#define SYS_dup3 24 +#define SYS_getrusage 165 +#define SYS_newfstatat 79 +#define SYS_setitimer 103 +#define SYS_fstat 80 +#define SYS_nanosleep 101 +#define SYS_getdents64 61 +#define SYS_clock_gettime 113 + +// bash +#define SYS_setuid 146 +#define SYS_geteuid 175 +#define SYS_getegid 177 +#define SYS_setgid 144 +#define SYS_getppid 173 + +// make+POSIX +#define SYS_rt_sigprocmask 135 + +// tar +#define SYS_symlinkat 36 +#define SYS_readlinkat 78 +#define SYS_mknodat 33 + +#endif // __MES_LINUX_RISCV_SYSCALL_H diff --git a/include/linux/syscall.h b/include/linux/syscall.h index 0af5fd70..8cc1a27a 100644 --- a/include/linux/syscall.h +++ b/include/linux/syscall.h @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -26,6 +27,7 @@ long _sys_call1 (long sys_call, long one); long _sys_call2 (long sys_call, long one, long two); long _sys_call3 (long sys_call, long one, long two, long three); long _sys_call4 (long sys_call, long one, long two, long three, long four); +long _sys_call5 (long sys_call, long one, long two, long three, long four, long five); long _sys_call6 (long sys_call, long one, long two, long three, long four, long five, long six); #endif //__MES_SYSCALL_H diff --git a/include/linux/x86/syscall.h b/include/linux/x86/syscall.h index d849c175..aa0308a1 100644 --- a/include/linux/x86/syscall.h +++ b/include/linux/x86/syscall.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -17,55 +17,40 @@ * You should have received a copy of the GNU General Public License * along with GNU Mes. If not, see . */ +/* Commentary: + * See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_32.tbl + * + * Code: + */ #ifndef __MES_LINUX_X86_SYSCALL_H #define __MES_LINUX_X86_SYSCALL_H 1 /* libc-mini */ #ifndef SYS_exit -// CONSTANT SYS_exit 0x01 #define SYS_exit 0x01 #endif #ifndef SYS_write -// CONSTANT SYS_write 0x04 #define SYS_write 0x04 #endif /* libc */ -// CONSTANT SYS_fork 0x02 #define SYS_fork 0x02 -// CONSTANT SYS_read 0x03 #define SYS_read 0x03 -// CONSTANT SYS_open 0x05 #define SYS_open 0x05 -// CONSTANT SYS_waitpid 0x07 #define SYS_waitpid 0x07 -// CONSTANT SYS_wait4 0x72 #define SYS_wait4 0x72 -// CONSTANT SYS_execve 0x0b #define SYS_execve 0x0b -// CONSTANT SYS_chmod 0x0f #define SYS_chmod 0x0f -// CONSTANT SYS_access 0x21 #define SYS_access 0x21 -// CONSTANT SYS_brk 0x2d #define SYS_brk 0x2d -// CONSTANT SYS_ioctl 0x36 #define SYS_ioctl 0x36 -// CONSTANT SYS_fsync 0x76 #define SYS_fsync 0x76 -// CONSTANT SYS_getcwd 0xb7 #define SYS_getcwd 0xb7 -// CONSTANT SYS_dup 0x29 #define SYS_dup 0x29 -// CONSTANT SYS_dup2 0x3f #define SYS_dup2 0x3f -// CONSTANT SYS_unlink 0x0a #define SYS_unlink 0x0a -// CONSTANT SYS_gettimeofday 0x4e #define SYS_gettimeofday 0x4e -// CONSTANT SYS_clock_gettime 0x109 #define SYS_clock_gettime 0x109 -// CONSTANT SYS_time 0x0d #define SYS_time 0x0d /* libc+tcc */ diff --git a/include/linux/x86_64/syscall.h b/include/linux/x86_64/syscall.h index 36ef06bc..06f15c3c 100644 --- a/include/linux/x86_64/syscall.h +++ b/include/linux/x86_64/syscall.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -17,12 +17,21 @@ * You should have received a copy of the GNU General Public License * along with GNU Mes. If not, see . */ +/* Commentary: + * See https://github.com/torvalds/linux/blob/v4.19/arch/x86/entry/syscalls/syscall_64.tbl + * + * Code: + */ #ifndef __MES_LINUX_X86_64_SYSCALL_H #define __MES_LINUX_X86_64_SYSCALL_H 1 // libc-mini -// #define SYS_write 0x01 -// #define SYS_exit 0x3c +#ifndef SYS_write +#define SYS_write 0x01 +#endif +#ifndef SYS_exit +#define SYS_exit 0x3c +#endif // libc #define SYS_fork 0x39 @@ -36,16 +45,19 @@ #define SYS_brk 0x0c #define SYS_ioctl 0x10 #define SYS_fsync 0x4a +#define SYS_getcwd 0x4f +#define SYS_dup 0x20 +#define SYS_dup2 0x21 +#define SYS_unlink 0x57 +#define SYS_gettimeofday 0x60 +#define SYS_clock_gettime 0xe4 +#define SYS_time 0xc9 // libc+tcc #define SYS_close 0x03 -#define SYS_time 0xc9 #define SYS_lseek 0x08 -#define SYS_unlink 0x57 #define SYS_rmdir 0x54 -#define SYS_gettimeofday 0x60 #define SYS_stat 0x04 -#define SYS_getcwd 0x4f // libc+gnu #define SYS_chdir 0x50 @@ -55,20 +67,17 @@ #define SYS_kill 0x3e #define SYS_rename 0x52 #define SYS_mkdir 0x53 -#define SYS_dup 0x20 #define SYS_pipe 0x16 #define SYS_getgid 0x68 #define SYS_rt_sigaction 0x0d #define SYS_rt_sigreturn 0x0f #define SYS_fcntl 0x48 -#define SYS_dup2 0x21 #define SYS_getrusage 0x62 #define SYS_lstat 0x06 #define SYS_setitimer 0x26 #define SYS_fstat 0x05 #define SYS_nanosleep 0x33 #define SYS_getdents 0x4e -#define SYS_clock_gettime 0xe4 // bash #define SYS_setuid 0x69 diff --git a/include/m2/lib.h b/include/m2/lib.h deleted file mode 100644 index 93762931..00000000 --- a/include/m2/lib.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * GNU Mes --- Maxwell Equations of Software - * Copyright © 2019 Jan (janneke) Nieuwenhuizen - * - * This file is part of GNU Mes. - * - * GNU Mes 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 3 of the License, or (at - * your option) any later version. - * - * GNU Mes is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Mes. If not, see . - */ - -#ifndef __M2_LIB_H -#define __M2_LIB_H - -char **environ; -int __stdin; -int __stdout; -int __stderr; -int errno; - -// CONSTANT EOF 0xffffffff -// CONSTANT __FILEDES_MAX 512 - -char* cast_intp_to_charp (int *i); -char* cast_long_to_charp (long i); -long cast_charp_to_long (char const *); -long cast_int_to_long (int i); -long cast_voidp_to_long (void const *); - -char *itoa (int number); -char *ltoa (long number); -int __ungetc_p (int filedes); -int eputs (char *s); -int oputs (char *s); -int puts (char *s); -size_t strlen (char *s); -ssize_t _write (); -ssize_t write (int filedes, void *buffer, size_t size); -void __ungetc_clear (int filedes); -void __ungetc_init (); -void __ungetc_set (int filedes, int c); - -struct timezone -{ - int tz_minuteswest; - int tz_dsttime; -}; - -struct timespec -{ - long tv_sec; - long tv_nsec; -}; - -struct timeval -{ - long tv_sec; - long tv_usec; -}; - -#endif /* __M2_LIB_H */ diff --git a/include/m2/types.h b/include/m2/types.h index c5547f5c..91360223 100644 --- a/include/m2/types.h +++ b/include/m2/types.h @@ -20,6 +20,13 @@ #ifndef __M2_TYPES_H #define __M2_TYPES_H 1 +// FIXME M2_Planet chokes on -1, even inside #if ! __M2__ +#if __arm__ || __i386__ +#define EOF 0xffffffff +#else +#define EOF 0xffffffffffffffff +#endif + /* #ifndef __MES_CLOCK_T #define __MES_CLOCK_T diff --git a/include/mes/constants.h b/include/mes/constants.h index 42424390..ebf7787a 100644 --- a/include/mes/constants.h +++ b/include/mes/constants.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -23,76 +23,32 @@ /* Cell types */ -// CONSTANT TCHAR 0 #define TCHAR 0 -// CONSTANT TBYTES 1 #define TBYTES 1 -// CONSTANT TCLOSURE 2 #define TCLOSURE 2 -// CONSTANT TCONTINUATION 3 #define TCONTINUATION 3 -// CONSTANT TKEYWORD 4 #define TKEYWORD 4 -// CONSTANT TMACRO 5 #define TMACRO 5 -// CONSTANT TNUMBER 6 #define TNUMBER 6 -// CONSTANT TPAIR 7 #define TPAIR 7 -// CONSTANT TPORT 8 #define TPORT 8 -// CONSTANT TREF 9 #define TREF 9 -// CONSTANT TSPECIAL 10 #define TSPECIAL 10 -// CONSTANT TSTRING 11 #define TSTRING 11 -// CONSTANT TSTRUCT 12 #define TSTRUCT 12 -// CONSTANT TSYMBOL 13 #define TSYMBOL 13 -// CONSTANT TVALUES 14 #define TVALUES 14 -// CONSTANT TVARIABLE 15 #define TVARIABLE 15 -// CONSTANT TVECTOR 16 #define TVECTOR 16 -// CONSTANT TBROKEN_HEART 17 #define TBROKEN_HEART 17 /* Struct types */ -// CONSTANT STRUCT_TYPE 0 #define STRUCT_TYPE 0 -// CONSTANT STRUCT_PRINTER 1 #define STRUCT_PRINTER 1 -// CONSTANT GC_FRAME_SIZE 5 #define GC_FRAME_SIZE 5 -// CONSTANT GC_FRAME_PROCEDURE 4 #define GC_FRAME_PROCEDURE 4 -// CONSTANT STDIN 0 -// CONSTANT STDOUT 1 -// CONSTANT STDERR 2 - -/* Unknown type 1 -// CONSTANT EOF -1 -*/ - -// CONSTANT O_RDONLY 0 -// CONSTANT O_WRONLY 1 -// CONSTANT O_CREAT 0x40 -// CONSTANT O_TRUNC 0x200 - -// CONSTANT PATH_MAX 1024 -// CONSTANT __FILEDES_MAX 512 - -// CONSTANT S_IRUSR 00400 -// CONSTANT S_IWUSR 00200 - -// CONSTANT CLOCK_PROCESS_CPUTIME_ID 2 - - #endif /* __MES_CONSTANTS_H */ diff --git a/include/mes/lib-cc.h b/include/mes/lib-cc.h new file mode 100644 index 00000000..55c4fb1d --- /dev/null +++ b/include/mes/lib-cc.h @@ -0,0 +1,29 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ +#ifndef __MES_LIB_CC_H +#define __MES_LIB_CC_H + +#define EOF -1 + +#if __TINYC__ || SYSTEM_LIBC +#define __raise(x) -1 +#endif + +#endif //__MES_LIB_CC_H diff --git a/include/mes/lib-mini.h b/include/mes/lib-mini.h index 2874d527..d02751d2 100644 --- a/include/mes/lib-mini.h +++ b/include/mes/lib-mini.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2020,2022,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -25,26 +25,33 @@ #include #endif -// CONSTANT STDIN 0 #ifndef STDIN #define STDIN 0 #endif -// CONSTANT STDOUT 1 #ifndef STDOUT #define STDOUT 1 #endif -// CONSTANT STDERR 2 #ifndef STDERR #define STDERR 2 #endif +/* M2-Planet does not support pointer arithmetic. Explicitly compensate + for that by multiplying with M2_PTR_SIZE when using (char) + pointers. */ +#if __M2__ +#define M2_PTR_SIZE sizeof (void*) +#else +#define M2_PTR_SIZE 1 +#endif + extern char **environ; extern int __stdin; extern int __stdout; extern int __stderr; +void __init_io (); int eputs (char const *s); int puts (char const *s); int oputs (char const *s); @@ -63,10 +70,14 @@ int oputs (char const *s); #ifndef __MES_SIZE_T #define __MES_SIZE_T #undef size_t +#if __M2__ +typedef unsigned size_t; +#else typedef unsigned long size_t; #endif #endif #endif +#endif #ifndef _SSIZE_T #define _SSIZE_T diff --git a/include/mes/lib.h b/include/mes/lib.h index ceb2fb48..96a40f59 100644 --- a/include/mes/lib.h +++ b/include/mes/lib.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -22,6 +22,10 @@ #define __MES_LIB_H #include +#include + +#define __FILEDES_MAX 512 +extern char *__brk; char *cast_intp_to_charp (int const *i); char *cast_long_to_charp (long i); @@ -34,14 +38,11 @@ void __ungetc_init (); void __ungetc_clear (int filedes); void __ungetc_set (int filedes, int c); int __ungetc_p (int filedes); -double abtod (char const **p, int base); long abtol (char const **p, int base); -char *dtoab (double number, int base, int signed_p); char *itoa (int number); char *ltoa (long number); char *ltoab (long x, int base); char *ntoab (long number, unsigned base, int signed_p); -char *ultoa (unsigned long number); char *utoa (unsigned number); int eputc (int c); int fdgetc (int fd); @@ -61,10 +62,11 @@ char *search_path (char const *file_name); ssize_t _read (int fd, void *buffer, size_t size); void assert_msg (int check, char *msg); -extern char *__brk; -extern void (*__call_at_exit) (void); - -#define __FILEDES_MAX 512 +long __mesabi_imod (long a, long b); +long __mesabi_idiv (long a, long b); +void *__memcpy (void *dest, void const *src, size_t n); +void *__memmove (void *dest, void const *src, size_t n); +void *__memset (void *s, int c, size_t n); #if !SYSTEM_LIBC void __assert_fail (char const *s, char const *file, unsigned line, @@ -73,18 +75,20 @@ ssize_t __buffered_read (int filedes, void *buffer, size_t size); size_t __buffered_read_clear (int filedes); void _exit (int code); long brk (void *addr); +#ifndef __raise +int __raise (int signal); +#endif #endif // !SYSTEM_LIBC -long __mesabi_imod (long a, long b); -long __mesabi_idiv (long a, long b); +#if !__M2__ +extern void (*__call_at_exit) (void); +double abtod (char const **p, int base); +char *dtoab (double number, int base, int signed_p); +char *ultoa (unsigned long number); unsigned long __mesabi_umod (unsigned long a, unsigned long b); unsigned long __mesabi_udiv (unsigned long a, unsigned long b); unsigned long __mesabi_uldiv (unsigned long a, unsigned long b, unsigned long *remainder); - -void *__memcpy (void *dest, void const *src, size_t n); -void *__memmove (void *dest, void const *src, size_t n); -void *__memset (void *s, int c, size_t n); -int __raise (int signal); +#endif #endif //__MES_LIB_H diff --git a/include/mes/mes.h b/include/mes/mes.h index 337f03aa..c189ab69 100644 --- a/include/mes/mes.h +++ b/include/mes/mes.h @@ -53,6 +53,15 @@ struct scm }; }; +/* M2-Planet does not support pointer arithmetic. Explicitly compensate + for that by multiplying with M2_CELL_SIZE when using cell + pointers. */ +#if __M2__ +#define M2_CELL_SIZE sizeof (struct scm) +#else +#define M2_CELL_SIZE 1 +#endif + /* mes */ extern char *g_datadir; extern int g_debug; diff --git a/include/mes/symbols.h b/include/mes/symbols.h index 490fa1e2..6e435720 100644 --- a/include/mes/symbols.h +++ b/include/mes/symbols.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -137,14 +137,8 @@ extern struct scm *cell_type_broken_heart; extern struct scm *cell_symbol_program; extern struct scm *cell_symbol_test; -// CONSTANT SYMBOL_MAX 114 #define SYMBOL_MAX 114 - -// CONSTANT CELL_UNSPECIFIED 7 #define CELL_UNSPECIFIED 7 - -// CONSTANT CELL_SYMBOL_RECORD_TYPE 82 #define CELL_SYMBOL_RECORD_TYPE 82 - #endif /* __MES_SYMBOLS_H */ diff --git a/include/signal.h b/include/signal.h index 07730b02..aef1da50 100644 --- a/include/signal.h +++ b/include/signal.h @@ -29,9 +29,12 @@ #define _SIGSET_NITEMS (_NSIG / (8 * sizeof(unsigned long))) -typedef struct { +#if !__M2__ +typedef struct +{ unsigned long items[_SIGSET_NITEMS]; } sigset_t; +#endif typedef long stack_t; #include @@ -91,6 +94,7 @@ typedef long stack_t; #define SA_NOMASK SA_NODEFER #define SA_ONESHOT SA_RESETHAND +#if !__M2__ // lacks short, casts typedef struct siginfo_t { int si_signo; @@ -120,7 +124,7 @@ typedef struct siginfo_t } siginfo_t; // *INDENT-ON* -#if __MESC__ +#if __M2__ || __MESC__ typedef long sighandler_t; #else typedef void (*sighandler_t) (int); @@ -255,6 +259,7 @@ int sigemptyset (sigset_t * set); #endif int sigprocmask (int how, sigset_t const *set, sigset_t * oldset); +#endif // !__M2__ #endif //! SYSTEM_LIBC #endif // __MES_SIGNAL_H diff --git a/include/stdarg.h b/include/stdarg.h index 6a8fee6a..6cdf0dd6 100644 --- a/include/stdarg.h +++ b/include/stdarg.h @@ -1,6 +1,8 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas * * This file is part of GNU Mes. * @@ -24,9 +26,45 @@ #undef __MES_STDARG_H #include_next -#define va_arg8(ap, type) va_arg(ap, type) +#define va_arg8(ap, type) va_arg (ap, type) -#else // ! SYSTEM_LIBC +#elif (__GNUC__ || __TINYC__) && __riscv + +// GCC on RISC-V always passes arguments in registers. Implementing +// these macros without the use of built-ins would be very involved. +// TINYCC tries to be GCC compatible in this case. + +#if __TINYC__ < 928 +// Bootstrappable TINYCC (version < 928) needs some definitions in RISC-V +typedef char *__builtin_va_list; +#define __va_reg_size (__riscv_xlen >> 3) +#define _tcc_align(addr, type) \ + (((unsigned long)addr + __alignof__(type) - 1) \ + & -(__alignof__(type))) +#define __builtin_va_arg(ap, type) \ + (*(sizeof (type) > (2*__va_reg_size) \ + ? *(type **)((ap += __va_reg_size) - __va_reg_size) \ + : (ap = (va_list)(_tcc_align (ap, type) \ + + (sizeof (type) + __va_reg_size - 1) \ + & -__va_reg_size), \ + (type *)(ap - ((sizeof (type)+ __va_reg_size - 1) \ + & -__va_reg_size))))) + +#define __builtin_va_end(ap) (void)(ap) +#if !defined (__builtin_va_copy) +#define __builtin_va_copy(dest, src) (dest) = (src) +#endif +#endif // __TINYC__ < 928 + +typedef __builtin_va_list va_list; + +#define va_start(v, l) __builtin_va_start (v, l) +#define va_end(v) __builtin_va_end (v) +#define va_arg(v, l) __builtin_va_arg (v, l) +#define va_arg8(ap, type) va_arg (ap, type) +#define va_copy(d, s) __builtin_va_copy (d, s) + +#else // ! SYSTEM_LIBC && ! __riscv #include @@ -35,7 +73,7 @@ #endif typedef char *va_list; -#define va_start(ap, last) (void)((ap) = (char*)(&(last) + 1)) +#define va_start(ap, last) (void)((ap) = (char*)(&(last)) + sizeof (void*)) #define va_arg(ap, type) (type)(((long*)((ap) = ((ap) + sizeof (void*))))[-1]) #define va_align(ap, alignment) ((char*)((((unsigned long) (ap)) + (alignment) - 1) &~ ((alignment) - 1))) #define va_arg8(ap, type) (type)(((double*)((ap) = (va_align((ap), 8) + sizeof(double))))[-1]) diff --git a/include/stdint.h b/include/stdint.h index 0f85d6b0..694840dc 100644 --- a/include/stdint.h +++ b/include/stdint.h @@ -50,7 +50,7 @@ #undef ptrdiff_t typedef unsigned char uint8_t; -typedef char int8_t; +typedef signed char int8_t; typedef unsigned short uint16_t; typedef short int16_t; typedef unsigned uint32_t; @@ -87,7 +87,7 @@ typedef unsigned uintmax_t; #define INT_MIN -2147483648 #define INT_MAX 2147483647 -#if __i386__ || __arm__ +#if __i386__ || __arm__ || __riscv_xlen == 32 #define LONG_MIN INT_MIN #define LONG_MAX INT_MAX #define UINT_MAX UINT32_MAX @@ -95,7 +95,7 @@ typedef unsigned uintmax_t; #define LLONG_MIN INT64_MIN #define LLONG_MAX INT64_MAX #define SIZE_MAX UINT32_MAX -#elif __x86_64__ +#elif __x86_64__ || __riscv_xlen == 64 #define LONG_MIN INT64_MIN #define LONG_MAX INT64_MAX #define UINT_MAX UINT32_MAX diff --git a/include/stdio.h b/include/stdio.h index c8684e0f..c68576e0 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -65,30 +65,33 @@ int ferror (FILE * stream); int fflush (FILE * stream); int fgetc (FILE * stream); char *fgets (char *s, int size, FILE * stream); -int fprintf (FILE * stream, char const *format, ...); int fpurge (FILE * stream); int fputc (int c, FILE * stream); int fputs (char const *s, FILE * stream); -int fscanf (FILE * stream, char const *template, ...); int fseek (FILE * stream, long offset, int whence); int getc (FILE * stream); int getchar (void); char *getlogin (void); -int printf (char const *format, ...); int putc (int c, FILE * stream); int putchar (int c); int puts (char const *s); int remove (char const *file_name); int setvbuf (FILE * stream, char *buf, int mode, size_t size); -int snprintf (char *str, size_t size, char const *format, ...); -int sprintf (char *str, char const *format, ...); -int sscanf (char const *str, char const *format, ...); int ungetc (int c, FILE * stream); long ftell (FILE * stream); size_t fread (void *ptr, size_t size, size_t count, FILE * stream); size_t freadahead (FILE * fp); size_t fwrite (void const *ptr, size_t size, size_t count, FILE * stream); +#if !__M2__ +int fprintf (FILE * stream, char const *format, ...); +int fscanf (FILE * stream, char const *template, ...); +int printf (char const *format, ...); +int snprintf (char *str, size_t size, char const *format, ...); +int sprintf (char *str, char const *format, ...); +int sscanf (char const *str, char const *format, ...); +#endif // !__M2__ + #endif // ! SYSTEM_LIBC #endif // __MES_STDIO_H diff --git a/include/sys/ioctl.h b/include/sys/ioctl.h index 2650929e..c4bf13e5 100644 --- a/include/sys/ioctl.h +++ b/include/sys/ioctl.h @@ -28,8 +28,13 @@ #define TCGETS 0x5401 #define TCGETA 0x5405 +#if __M2__ +int ioctl (int fd, unsigned request, long data); +int ioctl3 (int fd, unsigned request, long data); +#else int ioctl (int fd, unsigned long request, ...); int ioctl3 (int fd, unsigned long request, long data); +#endif #endif // ! SYSTEM_LIBC diff --git a/include/sys/resource.h b/include/sys/resource.h index dab45d17..d277f08c 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -32,20 +32,20 @@ struct rusage { struct timeval ru_utime; struct timeval ru_stime; - long int ru_maxrss; - long int ru_ixrss; - long int ru_idrss; - long int ru_isrss; - long int ru_minflt; - long int ru_majflt; - long int ru_nswap; - long int ru_inblock; - long int ru_oublock; - long int ru_msgsnd; - long int ru_msgrcv; - long int ru_nsignals; - long int ru_nvcsw; - long int ru_nivcsw; + long ru_maxrss; + long ru_ixrss; + long ru_idrss; + long ru_isrss; + long ru_minflt; + long ru_majflt; + long ru_nswap; + long ru_inblock; + long ru_oublock; + long ru_msgsnd; + long ru_msgrcv; + long ru_nsignals; + long ru_nvcsw; + long ru_nivcsw; }; #define RUSAGE_SELF 0 diff --git a/include/sys/types.h b/include/sys/types.h index 7c2cc9be..b9e0d553 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,6 +20,8 @@ #ifndef __MES_SYS_TYPES_H #define __MES_SYS_TYPES_H 1 +#include + #if SYSTEM_LIBC #undef __MES_SYS_TYPES_H #include_next @@ -31,10 +33,6 @@ #define __MESCCLIB__ 15 #endif -#ifndef EOF -#define EOF -1 -#endif - #ifndef NULL #define NULL 0 #endif @@ -66,15 +64,23 @@ typedef unsigned gid_t; #ifndef __MES_INO_T #define __MES_INO_T #undef ino_t +#if __M2__ +typedef unsigned ino_t; +#else typedef unsigned long ino_t; #endif +#endif #if __SIZEOF_LONG_LONG__ == 8 #ifndef __MES_INO64_T #define __MES_INO64_T #undef ino64_t +#if __M2__ +typedef unsigned ino64_t; +#else typedef unsigned long long ino64_t; #endif +#endif #endif // __SIZEOF_LONG_LONG__ == 8 #if !defined (__MES_INTPTR_T) && !defined (__intptr_t_defined) @@ -83,8 +89,12 @@ typedef unsigned long long ino64_t; #undef intptr_t typedef long intptr_t; #undef uintptr_t +#if __M2__ +typedef unsigned uintptr_t; +#else typedef unsigned long uintptr_t; #endif +#endif #ifndef __MES_OFF_T #define __MES_OFF_T @@ -96,8 +106,12 @@ typedef long off_t; #ifndef __MES_OFF64_T #define __MES_OFF64_T #undef off64_t +#if __M2__ +typedef unsigned off64_t; +#else typedef unsigned long long off64_t; #endif +#endif #endif // __SIZEOF_LONG_LONG__ == 8 #ifndef __MES_PID_T @@ -126,9 +140,13 @@ typedef long sigval_t; #ifndef __MES_SIZE_T #define __MES_SIZE_T #undef size_t +#if __M2__ +typedef unsigned size_t; +#else typedef unsigned long size_t; #endif #endif +#endif #ifndef __MES_SSIZE_T #define __MES_SSIZE_T diff --git a/include/sys/wait.h b/include/sys/wait.h index 4cff86fc..ca476b8e 100644 --- a/include/sys/wait.h +++ b/include/sys/wait.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,6 +20,8 @@ #ifndef __MES_SYS_WAIT_H #define __MES_SYS_WAIT_H 1 +#include + #if SYSTEM_LIBC #undef __MES_SYS_WAIT_H #include_next @@ -35,6 +37,8 @@ typedef int pid_t; pid_t waitpid (pid_t pid, int *status_ptr, int options); pid_t wait (int *status_ptr); +pid_t wait4 (pid_t pid, int *wstatus, int options, + struct rusage *rusage); #endif // ! SYSTEM_LIBC diff --git a/include/time.h b/include/time.h index 161d006f..189200a1 100644 --- a/include/time.h +++ b/include/time.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -27,8 +27,8 @@ #ifndef __MES_TIME_T #define __MES_TIME_T 1 -typedef long int clockid_t; -typedef long int time_t; +typedef long clockid_t; +typedef long time_t; #endif struct tm diff --git a/kaem.arm b/kaem.arm new file mode 100644 index 00000000..4357c62b --- /dev/null +++ b/kaem.arm @@ -0,0 +1,25 @@ +#! /bin/sh +# Copyright © 2022 Jan (janneke) Nieuwenhuizen +# +# This file is part of GNU Mes. +# +# GNU Mes 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 3 of the License, or (at +# your option) any later version. +# +# GNU Mes is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mes. If not, see . + +# Usage: +# kaem --verbose --strict + +cc_cpu=arm +mes_cpu=arm +stage0_cpu=armv7l +kaem --verbose --strict diff --git a/kaem.riscv64 b/kaem.riscv64 new file mode 100644 index 00000000..cdee7236 --- /dev/null +++ b/kaem.riscv64 @@ -0,0 +1,26 @@ +#! /bin/sh +# Copyright © 2022 Jan (janneke) Nieuwenhuizen +# +# This file is part of GNU Mes. +# +# GNU Mes 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 3 of the License, or (at +# your option) any later version. +# +# GNU Mes is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mes. If not, see . + +# Usage: +# kaem --verbose --strict + +cc_cpu=riscv64 +mes_cpu=riscv64 +stage0_cpu=riscv64 +blood_elf_flag=--64 +kaem --verbose --strict diff --git a/kaem.run b/kaem.run index 1d8df90b..011773d6 100644 --- a/kaem.run +++ b/kaem.run @@ -1,5 +1,6 @@ #! /bin/sh # Copyright © 2019,2020,2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2023 Andrius Štikonas # # This file is part of GNU Mes. # @@ -19,41 +20,53 @@ # Usage: # kaem --verbose --strict +cc_cpu=${cc_cpu:-i386} mes_cpu=${mes_cpu:-x86} stage0_cpu=${stage0_cpu:-x86} +blood_elf_flag=${blood_elf_flag:---little-endian} mkdir -p m2 M2-Planet \ - --bootstrap-mode \ --debug \ --architecture ${stage0_cpu} \ - -f include/m2/lib.h \ + -D __${cc_cpu}__=1 \ + -D __linux__=1 \ + -f include/mes/config.h \ + -f include/mes/lib-mini.h \ + -f include/mes/lib.h \ -f lib/linux/${mes_cpu}-mes-m2/crt1.c \ + -f lib/mes/__init_io.c \ -f lib/linux/${mes_cpu}-mes-m2/_exit.c \ -f lib/linux/${mes_cpu}-mes-m2/_write.c \ -f lib/mes/globals.c \ -f lib/m2/cast.c \ - -f lib/m2/exit.c \ - -f lib/mes/mini-write.c \ - -f lib/linux/${mes_cpu}-mes-m2/syscall.c \ + -f lib/stdlib/exit.c \ + -f lib/mes/write.c \ -f include/linux/${mes_cpu}/syscall.h \ + -f lib/linux/${mes_cpu}-mes-m2/syscall.c \ -f lib/stub/__raise.c \ -f lib/linux/brk.c \ - -f lib/m2/malloc.c \ + -f lib/linux/malloc.c \ -f lib/string/memset.c \ - -f lib/m2/read.c \ + -f lib/linux/read.c \ -f lib/mes/fdgetc.c \ -f lib/stdio/getchar.c \ -f lib/stdio/putchar.c \ - -f lib/m2/open.c \ - -f lib/m2/mes_open.c \ + -f lib/stub/__buffered_read.c \ + -f include/fcntl.h \ + -f lib/linux/_open3.c \ + -f lib/linux/open.c \ + -f lib/mes/mes_open.c \ -f lib/string/strlen.c \ -f lib/mes/eputs.c \ -f lib/mes/fdputc.c \ -f lib/mes/eputc.c \ \ + -f include/time.h \ + -f include/sys/time.h \ -f include/m2/types.h \ + -f include/sys/types.h \ -f include/mes/mes.h \ -f include/mes/builtins.h \ -f include/mes/constants.h \ @@ -84,17 +97,22 @@ M2-Planet \ -f lib/linux/access.c \ -f include/linux/m2/kernel-stat.h \ -f include/sys/stat.h \ - -f lib/m2/chmod.c \ + -f lib/linux/chmod.c \ -f lib/linux/ioctl3.c \ + -f include/sys/ioctl.h \ -f lib/m2/isatty.c \ + -f include/signal.h \ -f lib/linux/fork.c \ -f lib/m2/execve.c \ -f lib/m2/execv.c \ - -f lib/m2/waitpid.c \ + -f include/sys/resource.h \ + -f lib/linux/wait4.c \ + -f lib/linux/waitpid.c \ -f lib/linux/gettimeofday.c \ - -f lib/m2/clock_gettime.c \ + -f lib/linux/clock_gettime.c \ -f lib/m2/time.c \ -f lib/linux/_getcwd.c \ + -f include/limits.h \ -f lib/m2/getcwd.c \ -f lib/linux/dup.c \ -f lib/linux/dup2.c \ @@ -112,6 +130,7 @@ M2-Planet \ -f src/math.c \ -f src/mes.c \ -f src/module.c \ + -f include/signal.h \ -f src/posix.c \ -f src/reader.c \ -f src/stack.c \ @@ -121,7 +140,7 @@ M2-Planet \ -f src/vector.c \ -o m2/mes.M1 -blood-elf --little-endian -f m2/mes.M1 -o m2/mes.blood-elf-M1 +blood-elf ${blood_elf_flag} --little-endian -f m2/mes.M1 -o m2/mes.blood-elf-M1 M1 \ --architecture ${stage0_cpu} \ diff --git a/kaem.x86 b/kaem.x86 new file mode 100644 index 00000000..caea7f87 --- /dev/null +++ b/kaem.x86 @@ -0,0 +1,25 @@ +#! /bin/sh +# Copyright © 2022 Jan (janneke) Nieuwenhuizen +# +# This file is part of GNU Mes. +# +# GNU Mes 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 3 of the License, or (at +# your option) any later version. +# +# GNU Mes is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mes. If not, see . + +# Usage: +# kaem --verbose --strict + +cc_cpu=i386 +mes_cpu=x86 +stage0_cpu=x86 +kaem --verbose --strict diff --git a/kaem.x86_64 b/kaem.x86_64 new file mode 100644 index 00000000..0e4d9229 --- /dev/null +++ b/kaem.x86_64 @@ -0,0 +1,27 @@ +#! /bin/sh +# Copyright © 2022 Jan (janneke) Nieuwenhuizen +# Copyright © 2023 Andrius Štikonas + +# This file is part of GNU Mes. +# +# GNU Mes 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 3 of the License, or (at +# your option) any later version. +# +# GNU Mes is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mes. If not, see . + +# Usage: +# kaem --verbose --strict + +cc_cpu=x86_64 +mes_cpu=x86_64 +stage0_cpu=amd64 +blood_elf_flag=--64 +kaem --verbose --strict diff --git a/lib/arm-mes/arm.M1 b/lib/arm-mes/arm.M1 index 384f8776..0830f7d3 100644 --- a/lib/arm-mes/arm.M1 +++ b/lib/arm-mes/arm.M1 @@ -269,6 +269,7 @@ DEFINE lsl____%r0,%r0,%r1 1001a0e1 # lsl %r0, %r0, %r1 DEFINE lsl____%r0,%r0,$i8 90a0e31009a0e1 # mov r9, #xx; lsl %r0, %r0, %r9 DEFINE lsl____%r1,%r1,$i8 90a0e31119a0e1 # mov r9, #xx; lsl %r1, %r1, %r9 DEFINE lsr____%r0,%r0,%r1 3001a0e1 # lsr %r0, %r0, %r1 +DEFINE asr____%r0,%r0,%r1 5001a0e1 # asr %r0, %r0, %r1 DEFINE ldr____%r0,(%sp,#$i8) 009de5 # ldr r0, [r13+xx] DEFINE ldr____%r1,(%sp,#$i8) 109de5 # ldr r1, [r13+xx] #DEFINE add____%r2,%r0,%r1,lsl#4 012280e0 diff --git a/lib/freebsd/x86-mes-gcc/_write.c b/lib/freebsd/x86-mes-gcc/_write.c index 54cfaf80..e9e7a0ba 100644 --- a/lib/freebsd/x86-mes-gcc/_write.c +++ b/lib/freebsd/x86-mes-gcc/_write.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2019,2020,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,7 +20,7 @@ #include "mes/lib-mini.h" -#define SYS_exit "0x01" +#define SYS_write "0x04" // *INDENT-OFF* ssize_t diff --git a/lib/freebsd/x86-mes-gcc/crt1.c b/lib/freebsd/x86-mes-gcc/crt1.c index 151d0279..f282fbf2 100644 --- a/lib/freebsd/x86-mes-gcc/crt1.c +++ b/lib/freebsd/x86-mes-gcc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,45 +19,20 @@ */ #include -//int main (int argc, char *argv[], char *envp[]); +int main (int argc, char *argv[], char *envp[]); // *INDENT-OFF* void _start () { asm ( - "mov $0,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stdin) - : //no inputs "" - ); - - asm ( - "mov $1,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stdout) - : //no inputs "" - ); - - asm ( - "mov $2,%%eax\n\t" - "mov %%eax,%0\n" - : "=r" (__stderr) - : //no inputs "" - ); - asm ( - "mov %%ebp,%%eax\n\t" - "add $4,%%eax\n\t" - "mov (%%eax),%%eax\n\t" - "add $3,%%eax\n\t" - "shl $2,%%eax\n\t" - "add %%ebp,%%eax\n\t" - "mov %%eax,%0\n\t" - "push %%eax\n\t" - : "=r" (environ) - : //no inputs "" - ); - asm ( + "mov %ebp,%eax\n\t" + "add $4,%eax\n\t" + "mov (%eax),%eax\n\t" + "add $3,%eax\n\t" + "shl $2,%eax\n\t" + "add %ebp,%eax\n\t" + "push %eax\n\t" "mov %ebp,%eax\n\t" "add $8,%eax\n\t" "push %eax\n\t" @@ -67,6 +42,7 @@ _start () "mov (%eax),%eax\n\t" "push %eax\n\t" + "call __init_io\n\t" "call main\n\t" "push %eax\n\t" diff --git a/lib/freebsd/x86-mes-mescc/crt1.c b/lib/freebsd/x86-mes-mescc/crt1.c index 83cde649..cb2ea878 100644 --- a/lib/freebsd/x86-mes-mescc/crt1.c +++ b/lib/freebsd/x86-mes-mescc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2021,2023 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -19,21 +19,11 @@ */ #include "mes/lib-mini.h" - int main (int argc, char *argv[], char *envp[]); int _start () { - asm ("mov____$i8,%eax !0"); - asm ("mov____%eax,0x32 &__stdin"); - - asm ("mov____$i8,%eax !1"); - asm ("mov____%eax,0x32 &__stdout"); - - asm ("mov____$i8,%eax !2"); - asm ("mov____%eax,0x32 &__stderr"); - asm ("mov____%ebp,%eax"); asm ("add____$i8,%eax !4"); @@ -42,7 +32,6 @@ _start () asm ("shl____$i8,%eax !0x02"); asm ("add____%ebp,%eax"); - asm ("mov____%eax,0x32 &environ"); asm ("push___%eax"); asm ("mov____%ebp,%eax"); @@ -54,6 +43,7 @@ _start () asm ("mov____(%eax),%eax"); asm ("push___%eax"); + __init_io (); main (); asm ("mov____%eax,%ebx"); diff --git a/lib/gnu/x86-mes-gcc/crt1.c b/lib/gnu/x86-mes-gcc/crt1.c index 18c41bb3..3138e33f 100644 --- a/lib/gnu/x86-mes-gcc/crt1.c +++ b/lib/gnu/x86-mes-gcc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * Mes --- Maxwell Equations of Software - * Copyright © 2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2019,2023 Janneke Nieuwenhuizen * * This file is part of Mes. * @@ -19,13 +19,13 @@ */ #include +int main (int argc, char *argv[], char *envp[]); char **environ; int __stdin; int __stdout; int __stderr; -int main (); void _exit (int status); void _hurd_start (void); diff --git a/lib/linux/_open3.c b/lib/linux/_open3.c index 40c2c067..26e5dc89 100644 --- a/lib/linux/_open3.c +++ b/lib/linux/_open3.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -26,7 +27,15 @@ int _open3 (char const *file_name, int flags, int mask) { - int r = _sys_call4 (SYS_openat, (long) -100, (long) file_name, (int) flags, (int) mask); + long long_file_name = cast_charp_to_long (file_name); +#if defined (SYS_open) + int r = _sys_call3 (SYS_open, long_file_name, flags, mask); +#elif defined (SYS_openat) + int r = _sys_call4 (SYS_openat, AT_FDCWD, long_file_name, flags, mask); +#else +#error No usable open syscall +#endif + __ungetc_init (); if (r > 2) { __ungetc_clear (r); diff --git a/lib/linux/access.c b/lib/linux/access.c index 303d3c0e..84e71139 100644 --- a/lib/linux/access.c +++ b/lib/linux/access.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -21,11 +22,18 @@ #include #include #include +#include int access (char const *file_name, int how) { long long_file_name = cast_charp_to_long (file_name); long long_how = cast_int_to_long (how); - return _sys_call4 (SYS_faccessat, -100, long_file_name, long_how, 0); +#if defined (SYS_access) + return _sys_call2 (SYS_access, long_file_name, long_how); +#elif defined (SYS_faccessat) + return _sys_call3 (SYS_faccessat, AT_FDCWD, long_file_name, long_how); +#else +#error No usable access sysall +#endif } diff --git a/lib/linux/arm-mes-gcc/crt1.c b/lib/linux/arm-mes-gcc/crt1.c index 41ad7a5e..134057ae 100644 --- a/lib/linux/arm-mes-gcc/crt1.c +++ b/lib/linux/arm-mes-gcc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen * Copyright © 2019,2020 Danny Milosavljevic * * This file is part of GNU Mes. @@ -20,7 +20,7 @@ */ #include -//int main (int argc, char *argv[], char *envp[]); +int main (int argc, char *argv[], char *envp[]); /* Note: GCC automatically emits a preable in order to set up the frame pointer: "push {fp}" "add fp, sp, 0" @@ -30,27 +30,6 @@ frame pointer: "push {fp}" "add fp, sp, 0" void _start () { - asm ( - "mov r0,#0\n\t" - "mov %0,r0\n" - : "=r" (__stdin) - : //no inputs "" - ); - - asm ( - "mov r0,#1\n\t" - "mov %0,r0\n" - : "=r" (__stdout) - : //no inputs "" - ); - - asm ( - "mov r0,#2\n\t" - "mov %0,r0\n" - : "=r" (__stderr) - : //no inputs "" - ); - /* environ = argv + argc + 1 */ asm ( "ldr r0,[fp,#4]\n\t" /* r0 = argc */ @@ -61,14 +40,10 @@ _start () "push {r2}\n\t" /* envp */ "push {r1}\n\t" /* argv */ "push {r0}\n\t" /* argc */ - "mov %0,r2\n\t" - : "=r" (environ) - : //no inputs "" - ); - asm ( "ldr r0,[sp]\n\t" /* argc */ "ldr r1,[sp, #4]\n\t" /* argv */ "ldr r2,[sp, #8]\n\t" /* envp */ + "bl __init_io\n\t" "bl main\n\t" "mov r7, #1\n\t" "swi #0\n\t" @@ -79,31 +54,6 @@ _start () void _start () { -#if 0 - __asm__ (".int 0xe320f000\n"); //nop {0} - __asm__ (".int 0xe320f000\n"); //nop {0} -#endif - - int *in = &__stdin; - int *out = &__stdout; - int *err = &__stderr; - char ***env = &environ; - -#if 0 - __asm__ (".int 0xe320f000\n"); //nop {0} - __asm__ (".int 0xe320f000\n"); //nop {0} - - __asm__ (".int 0xe320f000\n"); //nop {0} - *in = 0x22; - __asm__ (".int 0xe320f000\n"); //nop {0} - *out = 0x33; - __asm__ (".int 0xe320f000\n"); //nop {0} - *err = 0x44; - __asm__ (".int 0xe320f000\n"); //nop {0} - *env = 0x55; - __asm__ (".int 0xe320f000\n"); //nop {0} -#endif - /* environ = argv + argc + 1 */ __asm__ (".int 0xe59b000c\n"); //ldr r0, [fp, #12] __asm__ (".int 0xe28b1010\n"); //add r1, fp, #16 @@ -118,34 +68,11 @@ _start () __asm__ (".int 0xe52d0004\n"); //push {r0} ; (str r0, [sp, #-4]!) __asm__ (".int 0xe1a02002\n"); //mov r2, r2 - // *in = 0; - __asm__ (".int 0xe3a01000\n"); //mov r1, #0 - __asm__ (".int 0xe51b0004\n"); //ldr r0, [fp, #-4] - __asm__ (".int 0xe5801000\n"); //str r1, [r0] - __asm__ (".int 0xe320f000\n"); //nop {0} - - // *out = 1; - __asm__ (".int 0xe3a01001\n"); //mov r1, #1 - __asm__ (".int 0xe51b0008\n"); //ldr r0, [fp, #-8] - __asm__ (".int 0xe5801000\n"); //str r1, [r0] - __asm__ (".int 0xe320f000\n"); //nop {0} - - // *err = 2; - __asm__ (".int 0xe3a01002\n"); //mov r1, #2 - __asm__ (".int 0xe51b000c\n"); //ldr r0, [fp, #-12] - __asm__ (".int 0xe5801000\n"); //str r1, [r0] - __asm__ (".int 0xe320f000\n"); //nop {0} - - // *env = [sp, #8] - __asm__ (".int 0xe59d1008\n"); //ldr r1, [sp, #8] - __asm__ (".int 0xe51b0010\n"); //ldr r0, [fp, #-16] - __asm__ (".int 0xe5801000\n"); //str r1, [r0] - __asm__ (".int 0xe320f000\n"); //nop {0} - // setup argc, argv, envp parameters in registers __asm__ (".int 0xe59d0000\n"); //ldr r0, [sp] __asm__ (".int 0xe59d1004\n"); //ldr r1, [sp, #4] __asm__ (".int 0xe59d2008\n"); //ldr r2, [sp, #8] + __init_io (); main (); __asm__ (".int 0xe3a07001\n"); //mov r7, #1 diff --git a/lib/linux/arm-mes-m2/crt1.M1 b/lib/linux/arm-mes-m2/crt1.M1 index 4c71e9e8..f741d05f 100644 --- a/lib/linux/arm-mes-m2/crt1.M1 +++ b/lib/linux/arm-mes-m2/crt1.M1 @@ -1,6 +1,6 @@ ### GNU Mes --- Maxwell Equations of Software ### Copyright (C) 2016 Jeremiah Orians -### Copyright © 2022 Jan (janneke) Nieuwenhuizen +### Copyright © 2022,2023 Jan (janneke) Nieuwenhuizen ### ### This file is part of GNU Mes. ### @@ -32,21 +32,10 @@ '0' R0 R0 ADD BP ARITH2_ALWAYS ; ENVP_address = BP + OFFSET {R0} PUSH_ALWAYS ; Put envp on the stack - mov____%r0,0x32 &GLOBAL_environ - ;; Stack offset !4 BP ADD BP ARITH_ALWAYS ; Fix BP - ;;^~FUNCTION___init_io CALL_ALWAYS ; Setup for FILE* - - ;; Initialize MesCC lib file descriptors. - !0 mov____$i8,%r0 - mov____%r0,0x32 &GLOBAL___stdin - !1 mov____$i8,%r0 - mov____%r0,0x32 &GLOBAL___stdout - !2 mov____$i8,%r0 - mov____%r0,0x32 &GLOBAL___stderr - + ^~FUNCTION___init_io CALL_ALWAYS ; Init libc ^~FUNCTION_main CALL_ALWAYS ; Jump right into main SYS_exit mov____$i8,%r7 diff --git a/lib/linux/arm-mes-mescc/crt1.c b/lib/linux/arm-mes-mescc/crt1.c index d279ee61..8576e3ec 100644 --- a/lib/linux/arm-mes-mescc/crt1.c +++ b/lib/linux/arm-mes-mescc/crt1.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2017,2018,2023 Jan (janneke) Nieuwenhuizen * Copyright © 2020 Danny Milosavljevic * * This file is part of GNU Mes. @@ -20,7 +20,6 @@ */ #include "mes/lib-mini.h" - int main (int argc, char *argv[], char *envp[]); void /* must not return */ @@ -36,21 +35,6 @@ environ = &argv[argc + 1] HOWEVER, the function entry already allocated space for locals on the stack (after saving lr and fp, which moved sp again). Hence, use fp instead of sp. */ - /* stdin = 0 */ - - asm ("!0 mov____$i8,%r0"); - asm ("mov____%r0,0x32 &__stdin"); - - /* stdout = 1 */ - - asm ("!1 mov____$i8,%r0"); - asm ("mov____%r0,0x32 &__stdout"); - - /* stderr = 2 */ - - asm ("!2 mov____$i8,%r0"); - asm ("mov____%r0,0x32 &__stderr"); - /* Add "environ" to main's arguments */ asm ("!8 ldr____%r0,(%fp,+#$i8)"); /* "argc" */ @@ -63,10 +47,7 @@ HOWEVER, the function entry already allocated space for locals on the stack (aft asm ("push___%r1"); /* argv */ asm ("push___%r0"); /* argc */ - /* environ = r2 */ - - asm ("mov____%r2,0x32 &environ"); - + __init_io (); main (); asm ("SYS_exit mov____$i8,%r7"); diff --git a/lib/linux/chmod.c b/lib/linux/chmod.c index a6d74a43..615d13c5 100644 --- a/lib/linux/chmod.c +++ b/lib/linux/chmod.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -22,11 +23,18 @@ #include #include #include +#include int chmod (char const *file_name, mode_t mask) { long long_file_name = cast_charp_to_long (file_name); long long_mask = cast_int_to_long (mask); +#if defined (SYS_chmod) return _sys_call2 (SYS_chmod, long_file_name, long_mask); +#elif defined (SYS_fchmodat) + return _sys_call3 (SYS_fchmodat, AT_FDCWD, long_file_name, long_mask); +#else +#error No usable chmod syscall +#endif } diff --git a/lib/linux/dup2.c b/lib/linux/dup2.c index 0139a0a7..70a62d08 100644 --- a/lib/linux/dup2.c +++ b/lib/linux/dup2.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -26,5 +27,11 @@ dup2 (int old, int new) { long long_old = old; long long_new = new; +#if defined (SYS_dup2) + return _sys_call2 (SYS_dup2, long_old, long_new); +#elif defined (SYS_dup3) return _sys_call3 (SYS_dup3, long_old, long_new, 0); +#else +#error No usable dup2 syscall +#endif } diff --git a/lib/linux/fork.c b/lib/linux/fork.c index 9f48466d..bb2c29f2 100644 --- a/lib/linux/fork.c +++ b/lib/linux/fork.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -20,10 +21,17 @@ #include #include +#include +#include int fork () { - /* We don't have a _sys_call5 but this works */ - return _sys_call6 (SYS_clone, 17, 0, 0, 0, 0, 0); +#if defined (SYS_fork) + return _sys_call (SYS_fork); +#elif defined (SYS_clone) + return _sys_call4 (SYS_clone, SIGCHLD, 0, NULL, 0); +#else +#error No usable clone syscall found +#endif } diff --git a/lib/linux/getdents.c b/lib/linux/getdents.c index 03717710..16563b42 100644 --- a/lib/linux/getdents.c +++ b/lib/linux/getdents.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -25,5 +26,11 @@ int getdents (int filedes, char *buffer, size_t nbytes) { +#if defined (SYS_getdents) return _sys_call3 (SYS_getdents, (int) filedes, (long) buffer, (long) nbytes); +#elif defined (SYS_getdents64) + return _sys_call3 (SYS_getdents64, (int) filedes, (long) buffer, (long) nbytes); +#else +#error No usable getdents syscall +#endif } diff --git a/lib/linux/link.c b/lib/linux/link.c index e2d66912..b89b181f 100644 --- a/lib/linux/link.c +++ b/lib/linux/link.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -20,9 +21,16 @@ #include #include +#include int link (char const *old_name, char const *new_name) { +#if defined (SYS_link) return _sys_call2 (SYS_link, (long) old_name, (long) new_name); +#elif defined (SYS_linkat) + return _sys_call4 (SYS_linkat, AT_FDCWD, (long) old_name, AT_FDCWD, (long) new_name); +#else +#error No usable link syscall +#endif } diff --git a/lib/linux/lseek.c b/lib/linux/lseek.c index c72a75cf..763adc62 100644 --- a/lib/linux/lseek.c +++ b/lib/linux/lseek.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -24,23 +24,23 @@ #include #include -#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */ off_t _lseek (int filedes, off_t offset, int whence) { - return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence); + long long_offset = offset; + return _sys_call3 (SYS_lseek, filedes, long_offset, whence); } -#endif off_t lseek (int filedes, off_t offset, int whence) { -#if !__MESC__ /* FIXME: We want bin/mes-mescc's x86-linux sha256sum to stay the same. */ +#if !__MESC__ && !__M2__ if (_lseek (filedes, 0, SEEK_CUR) == -1) return -1; #endif size_t skip = __buffered_read_clear (filedes); if (whence == SEEK_CUR) offset -= skip; - return _sys_call3 (SYS_lseek, (int) filedes, (long) offset, (int) whence); + long long_offset = offset; + return _sys_call3 (SYS_lseek, filedes, long_offset, whence); } diff --git a/lib/linux/lstat.c b/lib/linux/lstat.c index feebc6cb..0cdaa037 100644 --- a/lib/linux/lstat.c +++ b/lib/linux/lstat.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -20,10 +21,18 @@ #include #include +#include #include int lstat (char const *file_name, struct stat *statbuf) { +#if defined (SYS_lstat) return _sys_call2 (SYS_lstat, (long) file_name, (long) statbuf); +#elif defined (SYS_newfstatat) + return _sys_call4 (SYS_newfstatat, AT_FDCWD, (long) file_name, (long) statbuf, 0); +#else +#error No usable stat syscall +#endif + return 0; } diff --git a/lib/linux/malloc.c b/lib/linux/malloc.c index ea609d5d..e6f3c07e 100644 --- a/lib/linux/malloc.c +++ b/lib/linux/malloc.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018,2019,2021 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019,2021,2022 Jan (janneke) Nieuwenhuizen * Copyright © 2021 Danny Milosavljevic * * This file is part of GNU Mes. @@ -31,9 +31,11 @@ malloc (size_t size) { if (!__brk) __brk = cast_long_to_charp (brk (0)); +#if !__M2__ /* align what we give back. */ __brk = (char*) (((uintptr_t) __brk + sizeof (max_align_t) - 1) & -sizeof (max_align_t)); +#endif if (brk (__brk + size) == -1) return 0; char *p = __brk; diff --git a/lib/linux/mkdir.c b/lib/linux/mkdir.c index 59319329..e1ad59b4 100644 --- a/lib/linux/mkdir.c +++ b/lib/linux/mkdir.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -20,10 +21,17 @@ #include #include +#include #include int mkdir (char const *file_name, mode_t mode) { +#if defined (SYS_mkdir) return _sys_call2 (SYS_mkdir, (long) file_name, (long) mode); +#elif defined (SYS_mkdirat) + return _sys_call3 (SYS_mkdirat, AT_FDCWD, (long) file_name, (long) mode); +#else +#error No usable mkdir syscall +#endif } diff --git a/lib/linux/mknod.c b/lib/linux/mknod.c index 24a9b0c7..a410ca67 100644 --- a/lib/linux/mknod.c +++ b/lib/linux/mknod.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -21,9 +22,16 @@ #include #include #include +#include int mknod (char const *file_name, mode_t mode, dev_t dev) { +#if defined (SYS_mknod) return _sys_call3 (SYS_mknod, (long) file_name, (long) mode, (long) dev); +#elif defined (SYS_mknodat) + return _sys_call4 (SYS_mknodat, AT_FDCWD, (long) file_name, (long) mode, (long) dev); +#else +#error No usable mknod syscall +#endif } diff --git a/lib/linux/open.c b/lib/linux/open.c new file mode 100644 index 00000000..1919b88c --- /dev/null +++ b/lib/linux/open.c @@ -0,0 +1,62 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include +#include +#include +#include + +#if __M2__ +int +open (char *file_name, int flags, int mask) +{ +#if defined (SYS_open) + int r = _sys_call3 (SYS_open, file_name, flags, mask); +#elif defined (SYS_openat) + int r = _sys_call4 (SYS_openat, AT_FDCWD, file_name, flags, mask); +#else +#error No usable open syscall +#endif + if (r > 2) + __ungetc_clear (r); + return r; +} +#else // !__M2__ +int +open (char const *file_name, int flags, ...) +{ + va_list ap; + va_start (ap, flags); + int mask = va_arg (ap, int); +#if defined (SYS_open) + int r = _sys_call3 (SYS_open, (long) file_name, flags, mask); +#elif defined (SYS_openat) + int r = _sys_call4 (SYS_openat, AT_FDCWD, (long) file_name, flags, mask); +#else +#error No usable open syscall +#endif + va_end (ap); + if (r > 2) + __ungetc_clear (r); + return r; +} +#endif // !__M2__ diff --git a/lib/linux/pipe.c b/lib/linux/pipe.c index f6b3689a..ac916105 100644 --- a/lib/linux/pipe.c +++ b/lib/linux/pipe.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -21,9 +22,16 @@ #include #include #include +#include int pipe (int filedes[2]) { +#if defined (SYS_pipe) return _sys_call1 (SYS_pipe, (long) filedes); +#elif defined (SYS_pipe2) + return _sys_call2 (SYS_pipe2, (long) filedes, 0); +#else +#error No usable pipe syscall found +#endif } diff --git a/lib/linux/read.c b/lib/linux/read.c index a57cff4a..abe2b4f4 100644 --- a/lib/linux/read.c +++ b/lib/linux/read.c @@ -27,7 +27,9 @@ ssize_t read (int filedes, void *buffer, size_t size) { long long_filedes = filedes; - ssize_t bytes = _sys_call3 (SYS_read, long_filedes, (long) buffer, (long) size); + long long_buffer = cast_voidp_to_long (buffer); + ssize_t bytes = _sys_call3 (SYS_read, long_filedes, long_buffer, size); +#if !__M2__ if (__mes_debug () > 4) { if (bytes == 1) @@ -48,5 +50,6 @@ read (int filedes, void *buffer, size_t size) eputs ("\n"); } } +#endif return bytes; } diff --git a/lib/linux/readlink.c b/lib/linux/readlink.c index 96443273..61125290 100644 --- a/lib/linux/readlink.c +++ b/lib/linux/readlink.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -20,10 +21,17 @@ #include #include +#include #include ssize_t readlink (char const *file_name, char *buffer, size_t size) { +#if defined (SYS_readlink) return _sys_call3 (SYS_readlink, (long) file_name, (long) buffer, (long) size); +#elif defined (SYS_readlinkat) + return _sys_call4 (SYS_readlinkat, AT_FDCWD, (long) file_name, (long) buffer, (long) size); +#else +#error No usable readlink syscall +#endif } diff --git a/lib/linux/rename.c b/lib/linux/rename.c index 762c3093..7fb4191e 100644 --- a/lib/linux/rename.c +++ b/lib/linux/rename.c @@ -1,6 +1,7 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software * Copyright © 2018,2019,2022 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan * * This file is part of GNU Mes. * @@ -21,9 +22,16 @@ #include #include #include +#include int rename (char const *old_name, char const *new_name) { +#if defined (SYS_rename) return _sys_call2 (SYS_rename, (long) old_name, (long) new_name); +#elif defined (SYS_renameat2) + return _sys_call5 (SYS_renameat2, AT_FDCWD, (long) old_name, AT_FDCWD, (long) new_name, 0); +#else +#error No usable rename syscall +#endif } diff --git a/lib/linux/riscv64-mes-gcc/_exit.c b/lib/linux/riscv64-mes-gcc/_exit.c new file mode 100644 index 00000000..4b4b0a06 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/_exit.c @@ -0,0 +1,39 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit 93 + +// *INDENT-OFF* +void +_exit (int code) +{ + register long __a7 asm ("a7") = SYS_exit; + register long __a0 asm ("a0") = code; + asm volatile ( + "ecall\n\t" + : // no outputs + : "r" (__a0), "r" (__a7) + ); + // not reached + _exit (0); +} diff --git a/lib/linux/riscv64-mes-gcc/_write.c b/lib/linux/riscv64-mes-gcc/_write.c new file mode 100644 index 00000000..fd154e5f --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/_write.c @@ -0,0 +1,40 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +#define SYS_write 64 + +// *INDENT-OFF* +ssize_t +_write (int filedes, void const *buffer, size_t size) +{ + register long __a7 asm ("a7") = (long) SYS_write; + register long __a0 asm ("a0") = (long) filedes; + register long __a1 asm ("a1") = (long) buffer; + register long __a2 asm ("a2") = (long) size; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1), "r" (__a2) + ); + return (ssize_t)__a0; +} diff --git a/lib/linux/riscv64-mes-gcc/crt1.c b/lib/linux/riscv64-mes-gcc/crt1.c new file mode 100644 index 00000000..3f3d7ce8 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/crt1.c @@ -0,0 +1,66 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +int main (int argc, char *argv[], char *envp[]); + +/* gcc will generate the following preamble: + + addi sp,sp,-16 + sd s0,8(sp) + addi s0,sp,16 +*/ + +// *INDENT-OFF* +void +_start () +{ + asm ( + ".option push\n\t" + ".option norelax\n\t" + "lla gp, __global_pointer$\n\t" + ".option pop\n\t" + "andi sp, sp, ~15\n\t" // make sure sp conforms to ABI alignment + ); + + // environ is &argv[argc + 1] + asm ( + "lw t0, 0(s0)\n\t" + "addi t1, s0, 8\n\t" + "addi t0, t0, 1\n\t" + "slli t0, t0, 3\n\t" + "add t0, t1, t0\n\t" + + "lw a0, 0(s0)\n\t" // a0 argc + "addi a1, s0, 8\n\t" // a1 argv + "mv a2, t0\n\t" // a2 envp + "jal __init_io\n\t" + "jal main\n\t" + + "li a7, 93\n\t" // SYS_exit + "ecall\n\t" // exit(return value from main) + + "ebreak\n\t" + : //no outputs "" + : "r" (environ) + ); +} diff --git a/lib/linux/riscv64-mes-gcc/crti.c b/lib/linux/riscv64-mes-gcc/crti.c new file mode 100644 index 00000000..3dcb91f3 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/crti.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ diff --git a/lib/linux/riscv64-mes-gcc/crtn.c b/lib/linux/riscv64-mes-gcc/crtn.c new file mode 100644 index 00000000..3dcb91f3 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/crtn.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ diff --git a/lib/linux/riscv64-mes-gcc/exit-42.S b/lib/linux/riscv64-mes-gcc/exit-42.S new file mode 100644 index 00000000..13098ac6 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/exit-42.S @@ -0,0 +1,31 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +/** Code: */ + +SYS_exit = 93 /* Linux syscalls. */ + .globl _start /* Magic linker symbol: --entry-address. */ + + .text /* Program text. */ +_start: + li a7, SYS_exit /* System call function: exit, in a7. */ + li a0, 42 /* 1st parameter: exit status, in a0. */ + ecall /* Call system. */ + wfi /* Should not be reached. */ diff --git a/lib/linux/riscv64-mes-gcc/hello-mes.S b/lib/linux/riscv64-mes-gcc/hello-mes.S new file mode 100644 index 00000000..118faf18 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/hello-mes.S @@ -0,0 +1,45 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +/** Code: */ + +SYS_exit = 93 /* Linux syscalls. */ +SYS_write = 64 +stdout = 1 /* File descriptor */ + .globl _start /* Magic linker symbol: --entry-address. */ + + .text /* Program text. */ +hello: .ascii "Hello, GNU Mes!\n" +bye: +.equ string_size, (bye - hello) + +_start: + li a7, SYS_write /* System call function: write, in a7. */ + li a0, stdout /* 1st parameter: file descriptor, in a0. */ +.equ string_offset, (hello - .) + auipc a1, 0 /* Load pc for pc-relative address */ + addi a1, a1, string_offset /* 2nd parameter: address, in a1. */ + li a2, string_size /* 3rd parameter: byte count a2. */ + ecall /* Call system. */ + + li a7, SYS_exit /* System call function: exit, in a7. */ + li a0, 0 /* 1st parameter: exit status, in a0. */ + ecall /* Call system. */ + wfi /* Should not be reached. */ diff --git a/lib/linux/riscv64-mes-gcc/syscall-internal.c b/lib/linux/riscv64-mes-gcc/syscall-internal.c new file mode 100644 index 00000000..08302903 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/syscall-internal.c @@ -0,0 +1,62 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include + +// *INDENT-OFF* +static long +__sys_call_internal (long sys_call) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0"); + asm volatile ( + "ecall\n\t" + : "=r" (__a0) + : "r" (__a7) + ); + return __a0; +} + +static long +__sys_call2_internal (long sys_call, long one, long two) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1) + ); + return __a0; +} +// *INDENT-ON* + +/* Returns < 0 on error (errno-like value from kernel), or 0 on success */ +int +__raise (int signum) +{ + long pid = __sys_call_internal (SYS_getpid); + if (pid < 0) + return pid; + else + return __sys_call2_internal (SYS_kill, pid, signum); +} diff --git a/lib/linux/riscv64-mes-gcc/syscall.c b/lib/linux/riscv64-mes-gcc/syscall.c new file mode 100644 index 00000000..45d679c9 --- /dev/null +++ b/lib/linux/riscv64-mes-gcc/syscall.c @@ -0,0 +1,197 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +// *INDENT-OFF* +long +__sys_call (long sys_call) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0"); + asm volatile ( + "ecall\n\t" + : "=r" (__a0) + : "r" (__a7) + ); + return __a0; +} + +long +__sys_call1 (long sys_call, long one) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7) + ); + return __a0; +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1) + ); + return __a0; +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + register long __a2 asm ("a2") = three; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1), "r" (__a2) + ); + return __a0; +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + register long __a2 asm ("a2") = three; + register long __a3 asm ("a3") = four; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3) + ); + return __a0; +} + +long +__sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + register long __a2 asm ("a2") = three; + register long __a3 asm ("a3") = four; + register long __a4 asm ("a4") = five; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1), "r" (__a2), "r" (__a3), "r" (__a4) + ); + return __a0; +} +// *INDENT-ON* + +long +_sys_call (long sys_call) +{ + long r = __sys_call (sys_call); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call1 (long sys_call, long one) +{ + long r = __sys_call1 (sys_call, one); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call2 (long sys_call, long one, long two) +{ + long r = __sys_call2 (sys_call, one, two); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call3 (long sys_call, long one, long two, long three) +{ + long r = __sys_call3 (sys_call, one, two, three); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r = __sys_call4 (sys_call, one, two, three, four); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + long r = __sys_call5 (sys_call, one, two, three, four, five); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} diff --git a/lib/linux/riscv64-mes-m2/_exit.c b/lib/linux/riscv64-mes-m2/_exit.c new file mode 100644 index 00000000..73ef2dc4 --- /dev/null +++ b/lib/linux/riscv64-mes-m2/_exit.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2020,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +void +_exit (int status) +{ + asm ("rd_a0 rs1_fp !-8 ld"); + asm ("rd_a7 !93 addi # SYS_exit"); + asm ("ecall"); + // no need to read return value +} diff --git a/lib/linux/riscv64-mes-m2/_write.c b/lib/linux/riscv64-mes-m2/_write.c new file mode 100644 index 00000000..6941abf5 --- /dev/null +++ b/lib/linux/riscv64-mes-m2/_write.c @@ -0,0 +1,34 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2020,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +void +_write (int filedes, void const *buffer, size_t size) +{ + asm ("rd_a0 rs1_fp !-8 ld"); + asm ("rd_a1 rs1_fp !-16 ld"); + asm ("rd_a2 rs1_fp !-24 ld"); + asm ("rd_a7 !64 addi # SYS_write"); + asm ("ecall"); + asm ("rd_t0 rs1_a0 mv"); +} diff --git a/lib/linux/riscv64-mes-m2/crt1.M1 b/lib/linux/riscv64-mes-m2/crt1.M1 new file mode 100644 index 00000000..93ff5d10 --- /dev/null +++ b/lib/linux/riscv64-mes-m2/crt1.M1 @@ -0,0 +1,53 @@ +## Copyright (C) 2021 Andrius Štikonas +## Copyright (C) 2023 Janneke Nieuwenhuizen +## Copyright © 2023 Andrius Štikonas +## +## This file is part of stage0. +## +## stage0 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 3 of the License, or +## (at your option) any later version. +## +## stage0 is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with stage0. If not, see . + +:_start + rd_fp rs1_sp mv ; Protect stack pointer + + ; Prepare argv + rd_a0 rs1_fp !8 addi ; ARGV_address = FP + 8 + rd_sp rs1_sp !-8 addi + rs1_sp rs2_a0 sd ; Put argv on the stack + + ; Prepare envp + rd_a0 rs1_fp mv ; Address we need to load from + rd_a0 rs1_a0 ld ; Get ARGC + rd_a0 rs1_a0 !2 addi ; OFFSET = ARGC + 2 + rd_a0 rs1_a0 rs2_x3 slli ; OFFSET = OFFSET * WORDSIZE + rd_a0 rs1_fp rs2_a0 add ; ENVP_address = RSP + OFFSET + rd_sp rs1_sp !-8 addi + rs1_sp rs2_a0 sd ; Put envp on the stack + + ; Stack offset + rd_fp rs1_fp !8 addi + + ; Init libc + rd_ra $FUNCTION___init_io jal + + ; Call main function + rd_ra $FUNCTION_main jal + + ; Put return value on the stack so that _exit gets it + rd_sp rs1_sp !-16 addi + rs1_sp rs2_a0 sd + + ; Exit to kernel + rd_a0 rs1_sp ld + rd_a7 !93 addi ; Syscall for exit + ecall ; Exit with code in a0 diff --git a/lib/linux/riscv64-mes-m2/crt1.c b/lib/linux/riscv64-mes-m2/crt1.c new file mode 100644 index 00000000..da4c4824 --- /dev/null +++ b/lib/linux/riscv64-mes-m2/crt1.c @@ -0,0 +1,34 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +int __stdin; +int __stdout; +int __stderr; +char **environ; +int main (int argc, char **argv, char **envp); + +/* FIXME: this is going to be called `FUNCTION__start' */ +//#int +//#_start () +//#{ +//# .. +//#} diff --git a/lib/linux/riscv64-mes-m2/syscall.c b/lib/linux/riscv64-mes-m2/syscall.c new file mode 100644 index 00000000..3a1526be --- /dev/null +++ b/lib/linux/riscv64-mes-m2/syscall.c @@ -0,0 +1,183 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2020,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +long +__sys_call (long sys_call) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call1 (long sys_call, long one) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + asm ("rd_a0 rs1_fp !-16 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + asm ("rd_a0 rs1_fp !-16 ld"); + asm ("rd_a1 rs1_fp !-24 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + asm ("rd_a0 rs1_fp !-16 ld"); + asm ("rd_a1 rs1_fp !-24 ld"); + asm ("rd_a2 rs1_fp !-32 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + asm ("rd_a0 rs1_fp !-16 ld"); + asm ("rd_a1 rs1_fp !-24 ld"); + asm ("rd_a2 rs1_fp !-32 ld"); + asm ("rd_a3 rs1_fp !-40 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + asm ("rd_a7 rs1_fp !-8 ld"); + asm ("rd_a0 rs1_fp !-16 ld"); + asm ("rd_a1 rs1_fp !-24 ld"); + asm ("rd_a2 rs1_fp !-32 ld"); + asm ("rd_a3 rs1_fp !-40 ld"); + asm ("rd_a4 rs1_fp !-48 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +_sys_call (long sys_call) +{ + long r = __sys_call (sys_call); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call1 (long sys_call, long one) +{ + long r = __sys_call1 (sys_call, one); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call2 (long sys_call, long one, long two) +{ + long r = __sys_call2 (sys_call, one, two); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call3 (long sys_call, long one, long two, long three) +{ + long r = __sys_call3 (sys_call, one, two, three); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r = __sys_call4 (sys_call, one, two, three, four); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + long r = __sys_call5 (sys_call, one, two, three, four, five); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} diff --git a/lib/linux/riscv64-mes-mescc/_exit.c b/lib/linux/riscv64-mes-mescc/_exit.c new file mode 100644 index 00000000..1425e851 --- /dev/null +++ b/lib/linux/riscv64-mes-mescc/_exit.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" +#include "linux/riscv64/syscall.h" + +void +_exit (int status) +{ + asm ("rd_a0 rs1_fp !16 ld"); + asm (RISCV_SYSCALL(SYS_exit)); + asm ("ecall"); + // no need to read return value +} diff --git a/lib/linux/riscv64-mes-mescc/_write.c b/lib/linux/riscv64-mes-mescc/_write.c new file mode 100644 index 00000000..0f3df656 --- /dev/null +++ b/lib/linux/riscv64-mes-mescc/_write.c @@ -0,0 +1,35 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" +#include "linux/riscv64/syscall.h" + +void +_write (int filedes, void const *buffer, size_t size) +{ + asm ("rd_a0 rs1_fp !16 ld"); + asm ("rd_a1 rs1_fp !24 ld"); + asm ("rd_a2 rs1_fp !32 ld"); + asm (RISCV_SYSCALL(SYS_write)); + asm ("ecall"); + asm ("rd_t0 rs1_a0 mv"); +} diff --git a/lib/linux/riscv64-mes-mescc/crt1.c b/lib/linux/riscv64-mes-mescc/crt1.c new file mode 100644 index 00000000..dc9c222e --- /dev/null +++ b/lib/linux/riscv64-mes-mescc/crt1.c @@ -0,0 +1,60 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2018,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" +#include "linux/riscv64/syscall.h" + +int main (int argc, char *argv[], char *envp[]); + +/* mesc will generate the following preamble: + + push ra + push fp +*/ +int +_start () +{ + asm ("rd_t1 rs1_fp mv"); + asm ("rd_t1 rs1_t1 !0x18 addi"); // 0x10 to skip over pushed fp+ra, 0x8 to skip over argc + asm ("rd_t5 rs1_fp !0x10 addi"); // 0x10 to skip over pushed fp+ra + asm ("rd_t0 rs1_t5 ld"); + asm ("rd_t0 rs1_t0 !1 addi"); + asm ("rd_t5 !3 addi"); // skip over all arguments and the final NULL + asm ("rd_t0 rs1_t0 rs2_t5 sll"); + asm ("rd_t0 rs1_t0 rs2_t1 add"); + asm ("rd_sp rs1_sp !-8 addi"); // push envp onto stack + asm ("rs1_sp rs2_t0 sd"); + asm ("rd_sp rs1_sp !-8 addi"); // push argv onto stack + asm ("rs1_sp rs2_t1 sd"); + asm ("rd_t5 rs1_fp !0x10 addi"); // 0x10 to skip over pushed fp+ra + asm ("rd_t0 rs1_t5 ld"); + asm ("rd_sp rs1_sp !-8 addi"); // push argc onto stack + asm ("rs1_sp rs2_t0 sd"); + + __init_io (); + main (); + + asm ("rd_a0 rs1_t0 mv"); + asm (RISCV_SYSCALL(SYS_exit)); + asm ("ecall"); + asm ("ebreak"); +} diff --git a/lib/linux/riscv64-mes-mescc/syscall-internal.c b/lib/linux/riscv64-mes-mescc/syscall-internal.c new file mode 100644 index 00000000..b8e767e5 --- /dev/null +++ b/lib/linux/riscv64-mes-mescc/syscall-internal.c @@ -0,0 +1,57 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +static long +__sys_call_internal (long sys_call) +{ + asm ("rd_a7 rs1_fp !16 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +static long +__sys_call2_internal (long sys_call, long one, long two) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + asm ("rd_a1 rs1_fp !32 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +/* Return < 0 on error (errno-like value from kernel), or 0 on success */ +int +__raise (int signum) +{ + long pid = __sys_call_internal (SYS_getpid); + if (pid < 0) + return pid; + else + return __sys_call2_internal (SYS_kill, pid, signum); +} diff --git a/lib/linux/riscv64-mes-mescc/syscall.c b/lib/linux/riscv64-mes-mescc/syscall.c new file mode 100644 index 00000000..79f06613 --- /dev/null +++ b/lib/linux/riscv64-mes-mescc/syscall.c @@ -0,0 +1,183 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Andrius Štikonas + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +long +__sys_call (long sys_call) +{ + asm ("rd_a7 rs1_fp !16 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call1 (long sys_call, long one) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + asm ("rd_a1 rs1_fp !32 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + asm ("rd_a1 rs1_fp !32 ld"); + asm ("rd_a2 rs1_fp !40 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + asm ("rd_a1 rs1_fp !32 ld"); + asm ("rd_a2 rs1_fp !40 ld"); + asm ("rd_a3 rs1_fp !48 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +__sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + asm ("rd_a7 rs1_fp !16 ld"); + asm ("rd_a0 rs1_fp !24 ld"); + asm ("rd_a1 rs1_fp !32 ld"); + asm ("rd_a2 rs1_fp !40 ld"); + asm ("rd_a3 rs1_fp !48 ld"); + asm ("rd_a4 rs1_fp !56 ld"); + + asm ("ecall"); + + asm ("rd_t0 rs1_a0 mv"); +} + +long +_sys_call (long sys_call) +{ + long r = __sys_call (sys_call); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call1 (long sys_call, long one) +{ + long r = __sys_call1 (sys_call, one); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call2 (long sys_call, long one, long two) +{ + long r = __sys_call2 (sys_call, one, two); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call3 (long sys_call, long one, long two, long three) +{ + long r = __sys_call3 (sys_call, one, two, three); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r = __sys_call4 (sys_call, one, two, three, four); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + long r = __sys_call5 (sys_call, one, two, three, four, five); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} diff --git a/lib/linux/riscv64-mes-tcc/_exit.c b/lib/linux/riscv64-mes-tcc/_exit.c new file mode 100644 index 00000000..bad49694 --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/_exit.c @@ -0,0 +1,38 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +#define SYS_exit 93 + +// *INDENT-OFF* +void +_exit (int code) +{ + asm volatile ( + "addi a7, zero, 93\n\t" + "ld a0, s0, -24\n\t" + "ecall\n\t" + ); + // not reached + _exit (0); +} diff --git a/lib/linux/riscv64-mes-tcc/_write.c b/lib/linux/riscv64-mes-tcc/_write.c new file mode 100644 index 00000000..07d9ded3 --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/_write.c @@ -0,0 +1,38 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2019,2020 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include "mes/lib-mini.h" + +#define SYS_write 64 + +// *INDENT-OFF* +ssize_t +_write (int filedes, void const *buffer, size_t size) +{ + asm volatile ( + "addi a7, zero, 64\n\t" + "ld a0, s0, -24\n\t" + "ld a1, s0, -32\n\t" + "ld a2, s0, -40\n\t" + "ecall\n\t" + ); +} diff --git a/lib/linux/riscv64-mes-tcc/crt1.c b/lib/linux/riscv64-mes-tcc/crt1.c new file mode 100644 index 00000000..b91e9dfe --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/crt1.c @@ -0,0 +1,72 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2017,2018,2019,2020,2023 Jan (janneke) Nieuwenhuizen + * Copyright © 2019,2020 Danny Milosavljevic + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +//int main (int argc, char *argv[], char *envp[]); + +// *INDENT-OFF* +void +_start () +{ + asm ( + "lla gp, __global_pointer$\n\t" + "andi sp, sp, ~15\n\t" // make sure sp conforms to ABI alignment + ); + + // environ is &argv[argc + 1] + asm ( + "lw t0, s0, 0\n\t" + "addi t1, s0, 8\n\t" + "addi t0, t0, 1\n\t" + "slli t0, t0, 3\n\t" + "add t0, t1, t0\n\t" + + "lw a0, s0, 0\n\t" // a0 argc + "addi a1, s0, 8\n\t" // a1 argv + "mv a2, t0\n\t" // a2 envp + + // Push arguments to stack + "addi sp, sp, -32\n\t" + "sd sp, a0, 8\n\t" // argc + "sd sp, a1, 16\n\t" // argv + "sd sp, a2, 24\n\t" // envp + + + "jal ra, __init_io\n\t" + + // Recover stack + "ld a0, sp, 8\n\t" // a0 argc + "ld a1, sp, 16\n\t" // a0 argc + "ld a2, sp, 24\n\t" // a0 argc + "addi sp, sp, 32\n\t" + + "jal ra, main\n\t" + + "li a7, 93\n\t" // SYS_exit + "ecall\n\t" // exit(return value from main) + + "ebreak\n\t" + : //no outputs "" + : "r" (environ) + ); +} diff --git a/lib/linux/riscv64-mes-tcc/crti.c b/lib/linux/riscv64-mes-tcc/crti.c new file mode 100644 index 00000000..3dcb91f3 --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/crti.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ diff --git a/lib/linux/riscv64-mes-tcc/crtn.c b/lib/linux/riscv64-mes-tcc/crtn.c new file mode 100644 index 00000000..3dcb91f3 --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/crtn.c @@ -0,0 +1,19 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ diff --git a/lib/linux/riscv64-mes-tcc/exit-42.S b/lib/linux/riscv64-mes-tcc/exit-42.S new file mode 100644 index 00000000..22f9149a --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/exit-42.S @@ -0,0 +1,32 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +/** Code: */ + +SYS_exit = 93 /* Linux syscalls. */ + .globl _start /* Magic linker symbol: --entry-address. */ + + .text /* Program text. */ +_start: + li a7, SYS_exit /* System call function: exit, in a7. */ + li a0, 42 /* 1st parameter: exit status, in a0. */ + ecall /* Call system. */ + wfi /* Should not be reached. */ diff --git a/lib/linux/riscv64-mes-tcc/hello-mes.S b/lib/linux/riscv64-mes-tcc/hello-mes.S new file mode 100644 index 00000000..931b80b0 --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/hello-mes.S @@ -0,0 +1,46 @@ +/* + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +/** Code: */ + +SYS_exit = 93 /* Linux syscalls. */ +SYS_write = 64 +stdout = 1 /* File descriptor */ + .globl _start /* Magic linker symbol: --entry-address. */ + + .text /* Program text. */ +hello: .ascii "Hello, GNU Mes!\n" +bye: +.equ string_size, (bye - hello) + +_start: + li a7, SYS_write /* System call function: write, in a7. */ + li a0, stdout /* 1st parameter: file descriptor, in a0. */ +.equ string_offset, (hello - .) + auipc a1, 0 /* Load pc for pc-relative address */ + addi a1, a1, string_offset /* 2nd parameter: address, in a1. */ + li a2, string_size /* 3rd parameter: byte count a2. */ + ecall /* Call system. */ + + li a7, SYS_exit /* System call function: exit, in a7. */ + li a0, 0 /* 1st parameter: exit status, in a0. */ + ecall /* Call system. */ + wfi /* Should not be reached. */ diff --git a/lib/linux/riscv64-mes-tcc/syscall-internal.c b/lib/linux/riscv64-mes-tcc/syscall-internal.c new file mode 100644 index 00000000..9053e10e --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/syscall-internal.c @@ -0,0 +1,63 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include + +// *INDENT-OFF* +static long +__sys_call_internal (long sys_call) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0"); + asm volatile ( + "ecall\n\t" + : "=r" (__a0) + : "r" (__a7) + ); + return __a0; +} + +static long +__sys_call2_internal (long sys_call, long one, long two) +{ + register long __a7 asm ("a7") = sys_call; + register long __a0 asm ("a0") = one; + register long __a1 asm ("a1") = two; + asm volatile ( + "ecall\n\t" + : "+r" (__a0) + : "r" (__a7), "r" (__a1) + ); + return __a0; +} +// *INDENT-ON* + +/* Returns < 0 on error (errno-like value from kernel), or 0 on success */ +int +__raise (int signum) +{ + long pid = __sys_call_internal (SYS_getpid); + if (pid < 0) + return pid; + else + return __sys_call2_internal (SYS_kill, pid, signum); +} diff --git a/lib/linux/riscv64-mes-tcc/syscall.c b/lib/linux/riscv64-mes-tcc/syscall.c new file mode 100644 index 00000000..59ec8d7d --- /dev/null +++ b/lib/linux/riscv64-mes-tcc/syscall.c @@ -0,0 +1,179 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2021 W. J. van der Laan + * Copyright © 2023 Ekaitz Zarraga + * + * This file is part of GNU Mes. + * + * GNU Mes 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 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include + +// *INDENT-OFF* +long +__sys_call (long sys_call) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ecall\n\t" + ); +} + +long +__sys_call1 (long sys_call, long one) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ld a0, s0, -32\n\t" + "ecall\n\t" + ); +} + +long +__sys_call2 (long sys_call, long one, long two) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ld a0, s0, -32\n\t" + "ld a1, s0, -40\n\t" + "ecall\n\t" + ); +} + +long +__sys_call3 (long sys_call, long one, long two, long three) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ld a0, s0, -32\n\t" + "ld a1, s0, -40\n\t" + "ld a2, s0, -48\n\t" + "ecall\n\t" + ); +} + +long +__sys_call4 (long sys_call, long one, long two, long three, long four) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ld a0, s0, -32\n\t" + "ld a1, s0, -40\n\t" + "ld a2, s0, -48\n\t" + "ld a3, s0, -56\n\t" + "ecall\n\t" + ); +} + +long +__sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + asm volatile ( + "ld a7, s0, -24\n\t" + "ld a0, s0, -32\n\t" + "ld a1, s0, -40\n\t" + "ld a2, s0, -48\n\t" + "ld a3, s0, -56\n\t" + "ld a4, s0, -64\n\t" + "ecall\n\t" + ); +} +// *INDENT-ON* + +long +_sys_call (long sys_call) +{ + long r = __sys_call (sys_call); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call1 (long sys_call, long one) +{ + long r = __sys_call1 (sys_call, one); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call2 (long sys_call, long one, long two) +{ + long r = __sys_call2 (sys_call, one, two); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call3 (long sys_call, long one, long two, long three) +{ + long r = __sys_call3 (sys_call, one, two, three); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call4 (long sys_call, long one, long two, long three, long four) +{ + long r = __sys_call4 (sys_call, one, two, three, four); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} + +long +_sys_call5 (long sys_call, long one, long two, long three, long four, long five) +{ + long r = __sys_call5 (sys_call, one, two, three, four, five); + if (r < 0) + { + errno = -r; + r = -1; + } + else + errno = 0; + return r; +} diff --git a/lib/linux/riscv64-mes/elf64-0exit-42.hex2 b/lib/linux/riscv64-mes/elf64-0exit-42.hex2 new file mode 100644 index 00000000..79dd21a6 --- /dev/null +++ b/lib/linux/riscv64-mes/elf64-0exit-42.hex2 @@ -0,0 +1,34 @@ +### GNU Mes --- Maxwell Equations of Software +### Copyright © 2021 W. J. van der Laan +### +### This file is part of GNU Mes. +### +### GNU Mes 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 3 of the License, or (at +### your option) any later version. +### +### GNU Mes is distributed in the hope that it will be useful, but +### WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with GNU Mes. If not, see . + +### Commentary: + +# elf64-exit-42.hex2: `exit 42' for riscv64-linux written in hex2 +# assembly, for usage with elf64-0header.hex2. This produces a 160-byte +# binary (a0 hex). Inspiration was taken from GNU Gcc output of +# exit-42.S. + +### Code: + +# @80 +:ELF_text +93 08 d0 05 # li a7,93 +13 05 a0 02 # li a0,42 +73 00 00 00 # ecall +73 00 50 10 # wfi +:ELF_end diff --git a/lib/linux/riscv64-mes/elf64-0header.hex2 b/lib/linux/riscv64-mes/elf64-0header.hex2 new file mode 100644 index 00000000..f1afe421 --- /dev/null +++ b/lib/linux/riscv64-mes/elf64-0header.hex2 @@ -0,0 +1,84 @@ +### Copyright (C) 2016 Jeremiah Orians +### Copyright (C) 2017,2019 Jan (janneke) Nieuwenhuizen +### Copyright © 2021 W. J. van der Laan +### +### This file is part of GNU Mes. +### +### GNU Mes 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 3 of the License, or (at +### your option) any later version. +### +### GNU Mes is distributed in the hope that it will be useful, but +### WITHOUT ANY WARRANTY; without even the implied warranty of +### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +### GNU General Public License for more details. +### +### You should have received a copy of the GNU General Public License +### along with GNU Mes. If not, see . + +### Commentary: + +# elf64-0header.hex2: Simplest 64 bit elf header in hex2. Only a text +# segment, no data segment, no symbol tables. + +# stage0's hex2 format for riscv64 +# !