diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 0b614ef0..746adcc2 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -8,7 +8,7 @@ on: paths: - 'docs/**' - 'mkdocs.yml' - - '.github/workflows/**' + - '.github/workflows/docs.yml' defaults: run: diff --git a/.github/workflows/kernel.yml b/.github/workflows/kernel.yml new file mode 100644 index 00000000..1223b0b1 --- /dev/null +++ b/.github/workflows/kernel.yml @@ -0,0 +1,47 @@ +name: Kernel binary build + +on: + push: + branches: + - main + + paths: + - 'src/**' + - 'ext/**' + - 'Makefile.static' + - 'configure' + - '.github/workflows/kernel.yml' + +jobs: + kernel: + runs-on: ubuntu-latest + container: + image: ghcr.io/lutoma/xelix/toolchain:latest + + steps: + - name: Download PKGBUILD + run: 'wget -q https://raw.githubusercontent.com/lutoma/xelix/main/land/xelix-kernel/PKGBUILD' + + - name: Adjust dir permissions + run: 'sudo chown -R dev: .' + + - name: Import signing key + run: 'echo "${{ secrets.GPG_PRIVATE_KEY }}" | sudo -u dev gpg --import' + + - name: Run makepkg + run: 'sudo -u dev makepkg -Ad --sign' + + - name: Adjust package name + run: 'rename x86_64 i786 *' + + - name: 'Create package directory' + run: 'mkdir kernel-pkg' + + - name: Import SSH key + run: 'echo "${{ secrets.SSH_KEY }}" > /root/.ssh/id_ed25519 && chmod 600 /root/.ssh/id_ed25519' + + - name: Upload to repo server + run: rsync *.pkg.tar.gz* repoupdate@pkgs.xelix.org:/var/www/pkgs.xelix.org/core/i786/ + + - name: Update repository + run: ssh repoupdate@pkgs.xelix.org /usr/local/bin/repo-remote-update core i786 xelix-kernel *.pkg.tar.gz diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml new file mode 100644 index 00000000..7c396d03 --- /dev/null +++ b/.github/workflows/nightly.yaml @@ -0,0 +1,44 @@ +name: Build nightly image + +on: + workflow_dispatch: + schedule: + - cron: '35 4 * * *' + +jobs: + image: + runs-on: ubuntu-latest + container: + image: ghcr.io/lutoma/xelix/toolchain:latest + options: --privileged + + steps: + - name: Download build script + run: 'wget -q https://raw.githubusercontent.com/lutoma/xelix/main/util/build-image.sh' + + - name: Build image + run: bash build-image.sh xelix-nightly.img + + - name: Convert image + run: | + qemu-img convert -f raw xelix-nightly.img -O qcow2 xelix-nightly.qcow2 + qemu-img convert -f raw xelix-nightly.img -O vdi xelix-nightly.vdi + qemu-img convert -f raw xelix-nightly.img -O vmdk xelix-nightly.vmdk + qemu-img convert -f raw xelix-nightly.img -O vhdx xelix-nightly.vhdx + + - name: Import signing key + run: 'echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --import' + + - name: Sign images + run: | + gpg --detach-sign --armor xelix-nightly.qcow2 + gpg --detach-sign --armor xelix-nightly.vdi + gpg --detach-sign --armor xelix-nightly.vmdk + gpg --detach-sign --armor xelix-nightly.vhdx + + - name: Import SSH key + run: 'echo "${{ secrets.SSH_KEY }}" > /root/.ssh/id_ed25519 && chmod 600 /root/.ssh/id_ed25519' + + + - name: Upload to server + run: rsync -z --exclude xelix-nightly.img xelix-nightly.* repoupdate@pkgs.xelix.org:/var/www/pkgs.xelix.org diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml new file mode 100644 index 00000000..97183014 --- /dev/null +++ b/.github/workflows/toolchain.yml @@ -0,0 +1,69 @@ +name: Toolchain container build + +on: + push: + branches: + - main + + paths: + - 'land/binutils/**' + - 'land/gcc/**' + - 'land/newlib/**' + - 'Containerfile' + - '.github/workflows/toolchain.yml' + +jobs: + toolchain: + runs-on: ubuntu-latest + steps: + - name: Check out git repository + uses: actions/checkout@v4 + + - name: Prepare environment + id: prep + run: | + TAG=$(echo $GITHUB_SHA | head -c7) + IMAGE="ghcr.io/${{ github.repository }}/toolchain" + echo ::set-output name=tagged_image::${IMAGE}:${TAG} + echo ::set-output name=tag::${TAG} + + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: 'Login to GitHub Container Registry' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Cache Docker layers + uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx + + - name: Building image + uses: docker/build-push-action@v5 + with: + context: . + builder: ${{ steps.buildx.outputs.name }} + file: Containerfile + push: true + tags: | + ${{ steps.prep.outputs.tagged_image }} + ghcr.io/${{ github.repository }}/toolchain:latest + + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.gitignore b/.gitignore index dc18e71a..3a1d5ead 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,9 @@ tags src/lib/config.h xelix.map .bochsrc -/xpkg-build -.xpkg-status /site -.config -.config.old +/.config +/.config.old +/land/*/pkg +/land/*/src +/land/*/*.tar.* diff --git a/Containerfile b/Containerfile new file mode 100644 index 00000000..92fd4c8a --- /dev/null +++ b/Containerfile @@ -0,0 +1,148 @@ +FROM alpine:latest +LABEL maintainer="hello@lutoma.org" + +ARG TARGET=i786-pc-xelix + +ARG BINUTILS_VERSION=2.40 +ARG BINUTILS_URL=https://ftp.gnu.org/gnu/binutils +ARG BINUTILS_PACKAGE=binutils-${BINUTILS_VERSION}.tar.xz + +ARG GCC_VERSION=13.1.0 +ARG GCC_URL=https://ftp.gnu.org/gnu/gcc/gcc-${GCC_VERSION} +ARG GCC_PACKAGE=gcc-${GCC_VERSION}.tar.xz + +ARG NEWLIB_VERSION=3.2.0 +ARG NEWLIB_URL=https://sourceware.org/pub/newlib +ARG NEWLIB_PACKAGE=newlib-${NEWLIB_VERSION}.tar.gz + +ENV PATH="/toolchain/usr/bin:${PATH}" + +RUN apk --no-cache add wget musl-dev make gcc g++ m4 perl autoconf automake \ + patch libtool mpc1-dev gmp-dev mpfr-dev gawk texinfo file + +# Build outdated autoconf and automake versions for newlib +WORKDIR /usr/src +RUN wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz +RUN wget https://ftp.gnu.org/gnu/automake/automake-1.11.6.tar.xz +RUN tar xf autoconf-2.69.tar.gz +RUN tar xf automake-1.11.6.tar.xz + +WORKDIR /usr/src/autoconf-2.69 +RUN ./configure --program-suffix=-2.69 +RUN make all install + +WORKDIR /usr/src/automake-1.11.6 +RUN ./configure --program-suffix=-1.11 +RUN make all install +RUN ln -s /usr/local/share/aclocal-1.11 /usr/local/share/aclocal + +# Download sources and apply Xelix patches/support files +WORKDIR /usr/src +RUN wget -c ${BINUTILS_URL}/${BINUTILS_PACKAGE} +RUN wget -c ${GCC_URL}/${GCC_PACKAGE} +RUN wget -c ${NEWLIB_URL}/${NEWLIB_PACKAGE} + +RUN tar -xf ${BINUTILS_PACKAGE} +RUN tar -xf ${GCC_PACKAGE} +RUN tar -xf ${NEWLIB_PACKAGE} + +COPY land/binutils/binutils-${BINUTILS_VERSION}.patch /usr/src/ +RUN patch -p0 -dbinutils-${BINUTILS_VERSION}/ < binutils-${BINUTILS_VERSION}.patch +COPY land/binutils/elf_i386_xelix.sh binutils-${BINUTILS_VERSION}/ld/emulparams/ +COPY land/binutils/elf_x86_64_xelix.sh binutils-${BINUTILS_VERSION}/ld/emulparams/ + +RUN cd binutils-${BINUTILS_VERSION}/ld && aclocal +RUN cd binutils-${BINUTILS_VERSION}/ld && automake +RUN cd binutils-${BINUTILS_VERSION} && autoreconf-2.69 + +COPY land/gcc/gcc-${GCC_VERSION}.patch /usr/src/ +RUN patch -p0 < gcc-${GCC_VERSION}.patch +COPY land/gcc/xelix.h gcc-${GCC_VERSION}/gcc/config/ + +COPY land/newlib/newlib-${NEWLIB_VERSION}.patch /usr/src/ +RUN patch -p0 < newlib-${NEWLIB_VERSION}.patch + +COPY land/newlib/xelix newlib-${NEWLIB_VERSION}/newlib/libc/sys/xelix + +WORKDIR /usr/src/newlib-${NEWLIB_VERSION}/newlib/libc/sys/xelix/ +RUN aclocal-1.11 -I ../../../ -I ../../../../ +RUN autoconf-2.69 +RUN automake-1.11 --cygnus Makefile + +WORKDIR /usr/src/newlib-${NEWLIB_VERSION}/newlib/libc/sys/ +RUN aclocal-1.11 -I ../.. -I ../../.. +RUN autoconf-2.69 +RUN automake-1.11 --cygnus Makefile + +WORKDIR /build/binutils +RUN /usr/src/binutils-${BINUTILS_VERSION}/configure \ + --target=${TARGET} \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-nls \ + --disable-werror + +RUN make DESTDIR=/toolchain all install + +# GCC build uses newlib files, so configure that first +WORKDIR /build/newlib +RUN /usr/src/newlib-${NEWLIB_VERSION}/configure \ + --target=${TARGET} \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-newlib-mb \ + --enable-newlib-iconv \ + --enable-newlib-io-c99-formats \ + --enable-newlib-io-long-long \ + --enable-newlib-io-long-double + +WORKDIR /build/gcc +RUN /usr/src/gcc-${GCC_VERSION}/configure \ + --target=${TARGET} \ + --prefix=/usr \ + --sysconfdir /etc \ + --disable-nls \ + --enable-languages=c,c++ \ + --with-headers=/usr/src/newlib-${NEWLIB_VERSION}/newlib/libc/include \ + --without-docdir \ + --with-newlib + +RUN make -j$(nproc) all-gcc +RUN make -j$(nproc) all-target-libgcc +RUN make -j$(nproc) all-target-libstdc++-v3 + +RUN make DESTDIR=/toolchain install-gcc install-target-libgcc install-target-libstdc++-v3 +RUN ln -s i786-pc-xelix-gcc /toolchain/usr/bin/i786-pc-xelix-cc + +WORKDIR /build/newlib +RUN make -j$(nproc) all +RUN make DESTDIR=/toolchain install +RUN cp i786-pc-xelix/newlib/libc/sys/xelix/crti.o i786-pc-xelix/newlib/libc/sys/xelix/crtn.o /toolchain/usr/i786-pc-xelix/lib/ + +# Strip debug info from binaries (Reduces image size substantially) +RUN strip --strip-unneeded /toolchain/usr/bin/i786-pc-xelix-* /toolchain/usr/i786-pc-xelix/bin/* +RUN find /toolchain/usr/libexec/gcc/i786-pc-xelix/13.1.0 -type f -exec strip --strip-unneeded {} \; + +# Now build the actual image +FROM alpine:latest +WORKDIR /src +COPY --from=0 /toolchain / +COPY --from=0 /usr/local /usr/local + +RUN apk --no-cache add wget git make gcc g++ nasm m4 perl autoconf automake \ + patch libtool mpc1 gmp mpfr libarchive gettext gawk bash coreutils \ + texinfo file python3 tar findutils gzip xz meson ninja sudo curl pacman \ + fakeroot util-linux-misc openssh-client-default rsync nano bison flex \ + qemu-img grub-bios sfdisk e2fsprogs moreutils bison flex pkgconfig gperf \ + ripgrep tzdata-utils + +# Add non-root user for makepkg +RUN adduser --disabled-password --gecos '' dev +RUN echo 'dev ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers + +# For uploads in automated runs +RUN mkdir /root/.ssh +RUN ssh-keyscan pkgs.xelix.org >> /root/.ssh/known_hosts + +COPY land/pacman/pacman.linux.conf /etc/pacman.conf +CMD ["/bin/bash"] diff --git a/Kconfig b/Kconfig index 203aa0f7..dc4c6ab0 100644 --- a/Kconfig +++ b/Kconfig @@ -26,8 +26,8 @@ menu "Kernel stdlib" Store kernel log in memory and make them available as /sys/log, where it can be read by utilities like dmesg. Doesn't log debug messages. - config LOG_PRINT_LEVEL - int "TTY log level" + config LOG_CONSOLE_LEVEL + int "Default console log level" default 2 ---help--- 0 Disabled @@ -146,6 +146,10 @@ menu "File systems" bool "Enable VirtIO block device driver" default y + config ENABLE_FTREE + bool "Enable ftree file tracking (likely broken)" + default n + config ENABLE_EXT2 bool "Enable ext2 support" default y diff --git a/Makefile.static b/Makefile.static index eb4fc045..ccdd231e 100644 --- a/Makefile.static +++ b/Makefile.static @@ -13,13 +13,12 @@ else AS = nasm endif -PATH += :toolchain/local/bin CC := $(PREFIX)-gcc OBJCOPY := $(PREFIX)-objcopy QEMU := qemu-system-$(ARCH) LD := $(CC) -MAKE_CFLAGS += -std=gnu18 -pipe -g -O3 -ffreestanding -fno-omit-frame-pointer -fstack-protector-strong -Wall -Wframe-larger-than=1024 -Wcast-align $(INCLUDE) +MAKE_CFLAGS += -std=gnu2x -pipe -g -O3 -ffreestanding -fno-omit-frame-pointer -fstack-protector-strong -Wall -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wframe-larger-than=1024 -Wcast-align -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wnull-dereference $(INCLUDE) MAKE_LDFLAGS := -T src/boot/$(ARCH)-linker.ld -nostdlib -lgcc ifeq ($(shell uname -s), Darwin) diff --git a/configure b/configure index b43cad4f..8883768f 100755 --- a/configure +++ b/configure @@ -25,7 +25,7 @@ function w { FIND=$(command -v gfind || command -v find) # Update submodules -git submodule update --init 1> /dev/null +[ -x "$(command -v git)" ] && git submodule update --init 1> /dev/null # Make sure config.h exists on first build if [ ! -f ".config" ]; then diff --git a/land/base/PKGBUILD b/land/base/PKGBUILD new file mode 100644 index 00000000..eb6f907b --- /dev/null +++ b/land/base/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=base +pkgver=1 +pkgrel=2 +pkgdesc="The basic components of the Xelix operating system." +arch=('any') +url="https://xelix.org" +license=('GPL') +depennds=('xelix-kernel' 'coreutils' 'bash' 'xelix-utils') +makedepends=() +source=() +sha256sums=() + +package() { + install -d $pkgdir/boot + install -d $pkgdir/dev + install -d $pkgdir/etc + install -d $pkgdir/etc/init.d + install -d $pkgdir/home + install -d $pkgdir/home/root -m 700 + install -d $pkgdir/sys + install -d $pkgdir/tmp + install -d $pkgdir/usr + install -d $pkgdir/usr/bin + install -d $pkgdir/usr/include + install -d $pkgdir/usr/lib + install -d $pkgdir/usr/share + install -d $pkgdir/var + install -d $pkgdir/var/run + + rm $pkgdir/bin || true + ln -s usr/bin $pkgdir/bin + + rm $pkgdir/etc/mtab || true + ln -s /sys/mounts $pkgdir/etc/mtab + + cp -r ../etc $pkgdir/ +} diff --git a/land/base/etc/init.d/console-login b/land/base/etc/init.d/console-login new file mode 100644 index 00000000..cc840e9d --- /dev/null +++ b/land/base/etc/init.d/console-login @@ -0,0 +1,4 @@ +[Service] +Target=default +ExecStart=/usr/bin/login +Restart=always diff --git a/land/base/package.yml b/land/base/package.yml deleted file mode 100644 index 548b7558..00000000 --- a/land/base/package.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: base -version: 1.0.0 -sources: - - dir: etc -install: - - install -d $DESTDIR/boot - - install -d $DESTDIR/dev - - install -d $DESTDIR/etc - - install -d $DESTDIR/etc/init.d - - install -d $DESTDIR/home - - install -d $DESTDIR/home/root -m 700 - - install -d $DESTDIR/sys - - install -d $DESTDIR/tmp - - install -d $DESTDIR/usr - - install -d $DESTDIR/usr/bin - - install -d $DESTDIR/usr/include - - install -d $DESTDIR/usr/lib - - install -d $DESTDIR/usr/share - - install -d $DESTDIR/var - - install -d $DESTDIR/var/run - - - rm $DESTDIR/bin || true - - ln -s usr/bin $DESTDIR/bin - - - cp -r * $DESTDIR/etc/ - - rm $DESTDIR/etc/mtab || true - - ln -s /sys/mounts $DESTDIR/etc/mtab diff --git a/land/bash/PKGBUILD b/land/bash/PKGBUILD new file mode 100644 index 00000000..c6eff10b --- /dev/null +++ b/land/bash/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=bash +pkgver=5.0 +pkgrel=1 +epoch= +pkgdesc="" +arch=('i786') +url="https://www.gnu.org/software/bash/" +license=('GPL') +source=('https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz' 'bash-5.0.patch') +sha256sums=( + 'b4a80f2ac66170b2913efbfb9f2594f1f76c7b1afd11f799e22035d63077fb4d' + 'bcf1b6c4e9c5075aae1d2330b9512b714837597fc86e3048284bdadbfb1b2881') + +prepare() { + patch -p0 < $pkgname-$pkgver.patch + + cd $pkgname-$pkgver + # Multiple definitions needed due to conflicting definitions in termcap/libreadline + LDFLAGS="-Wl,--allow-multiple-definition" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --without-bash-malloc \ + --disable-job-control +} + +build() { + cd $pkgname-$pkgver + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/bash/package.yml b/land/bash/package.yml deleted file mode 100644 index 9cd9fa9a..00000000 --- a/land/bash/package.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: bash -version: 5.0 -sources: - - url: https://ftp.gnu.org/gnu/bash/bash-5.0.tar.gz -patches: - - bash-5.0.patch -configure: -# Multiple definitions needed due to confliction definitions in termcap/libreadline - - LDFLAGS="-Wl,--allow-multiple-definition" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --without-bash-malloc - --disable-job-control -make: - - make -install: - - make DESTDIR=$DESTDIR install diff --git a/land/binutils/PKGBUILD b/land/binutils/PKGBUILD new file mode 100644 index 00000000..d039793a --- /dev/null +++ b/land/binutils/PKGBUILD @@ -0,0 +1,50 @@ +pkgname=binutils +pkgver=2.40 +pkgrel=1 +pkgdesc="The GNU Binutils are a collection of binary tools." +arch=('i786') +url="https://www.gnu.org/software/binutils/" +license=('GPL') +source=( + 'https://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.gz' + 'binutils-2.40.patch' + 'elf_i386_xelix.sh' + 'elf_x86_64_xelix.sh' +) +sha256sums=( + 'd7f82c4047decf43a6f769ac32456a92ddb6932409a585c633cdd4e9df23d956' + 'SKIP' + 'SKIP' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch + cp ../elf_i386_xelix.sh ../elf_x86_64_xelix.sh ld/emulparams + find . -name "config.cache" -delete +} + +build() { + cd $pkgname-$pkgver + cd ld + aclocal + automake + cd .. + autoreconf-2.69 + + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-werror \ + --disable-plugins \ + --disable-nls + + make CPPFLAGS="$CPPFLAGS -D__int64_t_defined" +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/binutils/package.yml b/land/binutils/package.yml deleted file mode 100644 index 8f682141..00000000 --- a/land/binutils/package.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: binutils -version: 2.40 -sources: - - url: https://ftp.gnu.org/gnu/binutils/binutils-2.40.tar.gz -patch_skip_path: 0 -patches: - - binutils-2.40.patch -configure: - - find . -name "config.cache" -delete - - cp $PKGDIR/elf_i386_xelix.sh $PKGDIR/elf_x86_64_xelix.sh ld/emulparams/ - - cd ld && aclocal - - cd ld && automake - - autoreconf-2.69 - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-werror - --disable-plugins - --disable-nls -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libopcodes.la - - rm $DESTDIR/usr/lib/libbfd.la diff --git a/land/bzip2/PKGBUILD b/land/bzip2/PKGBUILD new file mode 100644 index 00000000..b9e242b1 --- /dev/null +++ b/land/bzip2/PKGBUILD @@ -0,0 +1,18 @@ +pkgname=bzip2 +pkgver=1.0.2 +pkgrel=2 +pkgdesc="bzip2 is a freely available, patent free (see below), high-quality data compressor." +arch=('i786') +url="https://sourceware.org/bzip2/" +source=('https://sourceware.org/pub/bzip2/bzip2-1.0.2.tar.gz') +sha256sums=('4b526afa73ca1ccd6f5f1f5fd23813f159f715c3d0e00688f1df54b51f443cdd') + +build() { + cd $pkgname-$pkgver + make CC=i786-pc-xelix-gcc libbz2.a bzip2 +} + +package() { + cd $pkgname-$pkgver + make PREFIX=$pkgdir/usr install +} diff --git a/land/bzip2/package.yml b/land/bzip2/package.yml deleted file mode 100644 index 4838e632..00000000 --- a/land/bzip2/package.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: bzip2 -version: 1.0.2 -sources: - - url: https://sourceware.org/pub/bzip2/bzip2-1.0.2.tar.gz -make: - - make CC=i786-pc-xelix-gcc libbz2.a bzip2 -install: - # make install fails if these hard links already exist… - - rm $DESTDIR/usr/bin/bzegrep $DESTDIR/usr/bin/bzless || true - - rm $DESTDIR/usr/bin/bzfgrep $DESTDIR/usr/bin/bzcmp || true - - make PREFIX=$DESTDIR/usr install diff --git a/land/ca-certs/PKGBUILD b/land/ca-certs/PKGBUILD new file mode 100644 index 00000000..222547d3 --- /dev/null +++ b/land/ca-certs/PKGBUILD @@ -0,0 +1,16 @@ +pkgname=ca-certs +pkgver=20231118 +pkgrel=1 +pkgdesc="The Mozilla CA certificates bundle" +arch=('any') +url="https://curl.se/docs/caextract.html" +source=('https://curl.se/ca/cacert.pem') +sha256sums=('SKIP') + +pkgver() { + date -d @$(stat -c %Y cacert.pem) +%Y%m%d +} + +package() { + install -m 644 -D cacert.pem $pkgdir/etc/ssl/cert.pem +} diff --git a/land/cairo/PKGBUILD b/land/cairo/PKGBUILD new file mode 100644 index 00000000..374543f9 --- /dev/null +++ b/land/cairo/PKGBUILD @@ -0,0 +1,46 @@ +pkgname=cairo +pkgver=1.16.0 +pkgrel=2 +pkgdesc="Cairo is a 2D graphics library with support for multiple output devices." +arch=('i786') +url="https://www.cairographics.org/" +makedepend=('zlib' 'libpng' 'freetype' 'pixman') +source=( + 'https://www.cairographics.org/releases/cairo-1.16.0.tar.xz' + 'cairo.patch' +) +sha256sums=( + '5e7b29b3f113ef870d1e3ecf8adf21f923396401604bda16d44be45e66052331' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../cairo.patch +} + +build() { + cd $pkgname-$pkgver + CFLAGS="$CFLAGS -DCAIRO_NO_MUTEX=1" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --disable-xcb \ + --disable-xcb-shm \ + --disable-xlib \ + --disable-xlib-xrender \ + --disable-gobject \ + --disable-fc + + # Disable tests that won't work in non-native environment + echo -e 'all:\n\ttrue\ninstall:\n\ttrue' > test/Makefile + echo -e 'all:\n\ttrue\ninstall:\n\ttrue' > perf/Makefile + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/cairo/package.yml b/land/cairo/package.yml deleted file mode 100644 index 814cf853..00000000 --- a/land/cairo/package.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: cairo -version: '1.16.0' -sources: - - url: https://www.cairographics.org/releases/cairo-1.16.0.tar.xz -dependencies: - - zlib - - libpng - - freetype - - fontconfig - - pixman -patch_skip_path: 0 -patches: - - cairo.patch -configure: - - CFLAGS="$CFLAGS -DCAIRO_NO_MUTEX=1 -g -I$DESTDIR/usr/include" - LDFLAGS="$LDFLAGS -I$DESTDIR/usr/lib -g" - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --localstatedir=/var - --disable-xcb - --disable-xcb-shm - --disable-xlib - --disable-xlib-xrender - --disable-gobject - --disable-fc - - - echo -e 'all:\n\ttrue\ninstall:\n\ttrue' > test/Makefile - - echo -e 'all:\n\ttrue\ninstall:\n\ttrue' > perf/Makefile - -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libcairo.la - - rm $DESTDIR/usr/lib/libcairo-script-interpreter.la diff --git a/land/coreutils/PKGBUILD b/land/coreutils/PKGBUILD new file mode 100644 index 00000000..41d8fa90 --- /dev/null +++ b/land/coreutils/PKGBUILD @@ -0,0 +1,46 @@ +pkgname=coreutils +pkgver=8.32 +pkgrel=3 +pkgdesc="The GNU Core Utilities are the basic file, shell and text manipulation utilities of the GNU operating system." +arch=('i786') +arch_override=('i786') +url="https://www.gnu.org/software/coreutils/" +license=('GPL') +makedepend=('openssl' 'libiconv' 'gmp') +source=( + 'https://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz' + 'coreutils-8.32.patch' + 'coreutils-8.32-patch-two.patch') +sha256sums=( + '4458d8de7849df44ccab15e16b1548b285224dbba5f08fac070c1c0e0bcc4cfa' + '927b1b9d90d09063e8e662e3b41f91f1d216cea0e97a5df247137b4970da1714' + '74d85891fbfd578f779749febfee5a1ca0db65a2349a47b8c5f6b1a38808c1bb') + +prepare() { + patch -p0 < $pkgname-$pkgver.patch + cd $pkgname-$pkgver + autoreconf + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-threads \ + --disable-acl \ + --disable-xattr \ + --disable-largefile \ + --enable-no-install-program=arch,coreutils,dmesg,mknod,uptime \ + --with-openssl + + # Needs to be applied after configure + patch -p1 < ../coreutils-8.32-patch-two.patch +} + +build() { + cd $pkgname-$pkgver + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/coreutils/package.yml b/land/coreutils/package.yml deleted file mode 100644 index a258ba3a..00000000 --- a/land/coreutils/package.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: coreutils -version: '8.32' -sources: - - url: https://ftp.gnu.org/gnu/coreutils/coreutils-8.32.tar.xz -dependencies: - - libiconv - - openssl - - libiconv - - gmp -patches: - - coreutils-8.32.patch -configure: - - autoreconf - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-threads - --disable-acl - --disable-xattr - --disable-largefile - --enable-no-install-program=arch,coreutils,dmesg,mknod - --with-openssl - - # Needs to be applied after configure - - patch -p1 < $PKGDIR/coreutils-8.32-patch-two.patch -make: - - make -install: - - make install diff --git a/land/curl/PKGBUILD b/land/curl/PKGBUILD new file mode 100644 index 00000000..62ceeaae --- /dev/null +++ b/land/curl/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=curl +pkgver=8.4.0 +pkgrel=3 +epoch= +pkgdesc="command line tool and library for transferring data with URLs" +arch=('i786') +makedepend=('openssl-quic' 'zlib' 'nghttp2' 'ngtcp2' 'nghttp3') +url="https://curl.se/" +license=('GPL') +source=('https://curl.se/download/curl-8.4.0.tar.xz') +sha256sums=('16c62a9c4af0f703d28bda6d7bbf37ba47055ad3414d70dec63e2e6336f2a82d') + +prepare() { + cd $pkgname-$pkgver + echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-threaded-resolver \ + --with-openssl \ + --with-zlib \ + --with-nghttp2 \ + --with-ngtcp2 \ + --with-nghttp3 + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/darkhttpd/PKGBUILD b/land/darkhttpd/PKGBUILD new file mode 100644 index 00000000..820646de --- /dev/null +++ b/land/darkhttpd/PKGBUILD @@ -0,0 +1,29 @@ +pkgname=darkhttpd +pkgver=1.13 +pkgrel=1 +pkgdesc="When you need a web server in a hurry." +arch=('i786') +url="https://github.com/emikulic/darkhttpd" +source=( + 'https://github.com/emikulic/darkhttpd/archive/refs/tags/v1.13.tar.gz' + 'darkhttpd-1.13.patch' +) +sha256sums=( + '1d88c395ac79ca9365aa5af71afe4ad136a4ed45099ca398168d4a2014dc0fc2' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + CC=i786-pc-xelix-gcc CFLAGS="-O3 -DNO_IPV6" make +} + +package() { + cd $pkgname-$pkgver + install -d $pkgdir/usr/bin/ + install -D darkhttpd $pkgdir/usr/bin/ +} diff --git a/land/darkhttpd/package.yml b/land/darkhttpd/package.yml deleted file mode 100644 index f06a441a..00000000 --- a/land/darkhttpd/package.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: darkhttpd -version: 1.13 -sources: - - url: https://github.com/emikulic/darkhttpd/archive/refs/tags/v1.13.tar.gz -patches: - - darkhttpd-1.13.patch -make: - - CC=i786-pc-xelix-gcc CFLAGS="-O3 -DNO_IPV6" make -install: - - install -D darkhttpd $DESTDIR/usr/bin/ diff --git a/land/dash/PKGBUILD b/land/dash/PKGBUILD new file mode 100644 index 00000000..389e9f43 --- /dev/null +++ b/land/dash/PKGBUILD @@ -0,0 +1,30 @@ +pkgname=dash +pkgver=0.5.10.2 +pkgrel=1 +pkgdesc="DASH is a POSIX-compliant implementation of /bin/sh that aims to be as small as possible." +arch=('i786') +url="http://gondor.apana.org.au/~herbert/dash/" +source=( + 'http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.10.2.tar.gz' + 'dash-0.5.10.2.patch' +) +sha256sums=( + '3c663919dc5c66ec991da14c7cf7e0be8ad00f3db73986a987c118862b5f6071' + 'SKIP' +) + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + patch -p1 < ../dash-0.5.10.2.patch + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/dash/package.yml b/land/dash/package.yml deleted file mode 100644 index db417e52..00000000 --- a/land/dash/package.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: dash -version: '0.5.10.2' -sources: - - url: http://gondor.apana.org.au/~herbert/dash/files/dash-0.5.10.2.tar.gz -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - - patch -p1 < $PKGDIR/dash-0.5.10.2.patch -make: - - make -install: - - make install diff --git a/land/dialog/PKGBUILD b/land/dialog/PKGBUILD new file mode 100644 index 00000000..c8817100 --- /dev/null +++ b/land/dialog/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=dialog +pkgver=1.3.20191210 +pkgrel=1 +pkgdesc="Display dialog boxes from shell scripts." +arch=('i786') +depends=('ncurses') +source=( + 'https://invisible-island.net/archives/dialog/dialog-1.3-20191210.tgz' + 'dialog-1.3-20191210.patch' +) +sha256sums=( + '10f7c02ee5dea311e61b0d3e29eb6e18bcedd6fb6672411484c1a37729cbd7a6' + 'SKIP' +) + +prepare() { + patch -p0 < dialog-1.3-20191210.patch +} + +build() { + cd dialog-1.3-20191210 + ./configure \ + --host=i786-pc-xelix \ + --disable-shared \ + --enable-static \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd dialog-1.3-20191210 + make DESTDIR=$pkgdir install +} diff --git a/land/dialog/package.yml b/land/dialog/package.yml deleted file mode 100644 index 695da6c7..00000000 --- a/land/dialog/package.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: dialog -version: 1.3-20191210 -sources: - - url: https://invisible-island.net/datafiles/release/dialog.tar.gz -dependencies: - - ncurses -patches: - - dialog-1.3-20191210.patch -configure: - - ./configure - --host=i786-pc-xelix - --disable-shared - --enable-static - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make DESTDIR=$DESTDIR install diff --git a/land/diffutils/PKGBUILD b/land/diffutils/PKGBUILD new file mode 100644 index 00000000..9fe4cf90 --- /dev/null +++ b/land/diffutils/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=diffutils +pkgver=3.6 +pkgrel=2 +pkgdesc="GNU Diffutils is a package of several programs related to finding differences between files." +arch=('i786') +url="https://www.gnu.org/software/diffutils/" +source=( + 'https://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz' + 'diffutils-3.6.patch' +) +sha256sums=( + 'd621e8bdd4b573918c8145f7ae61817d1be9deb4c8d2328a65cea8e11d783bd6' + 'SKIP' +) + +prepare() { + patch -p0 < diffutils-3.6.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install + + # Empty and conflicts with grep + rm $pkgdir/usr/lib/charset.alias +} diff --git a/land/diffutils/package.yml b/land/diffutils/package.yml deleted file mode 100644 index cb1cb811..00000000 --- a/land/diffutils/package.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: diffutils -version: '3.6' -sources: - - url: https://ftp.gnu.org/gnu/diffutils/diffutils-3.6.tar.xz -patches: - - diffutils-3.6.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make install diff --git a/land/dropbear/PKGBUILD b/land/dropbear/PKGBUILD new file mode 100644 index 00000000..ae445d2f --- /dev/null +++ b/land/dropbear/PKGBUILD @@ -0,0 +1,40 @@ +pkgname=dropbear +pkgver=2020.81 +pkgrel=1 +pkgdesc="Dropbear is a relatively small SSH server and client." +arch=('i786') +url="https://matt.ucc.asn.au/dropbear/dropbear.html" +makedepends=('zlib') +source=( + 'https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2' + 'dropbear.patch' +) +sha256sums=( + '48235d10b37775dbda59341ac0c4b239b82ad6318c31568b985730c788aac53b' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../dropbear.patch +} + +build() { + cd $pkgname-$pkgver + CFLAGS="$CFLAGS -DDROPBEAR_SVR_PASSWORD_AUTH=0" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --sbindir=/usr/bin \ + --disable-syslog \ + --disable-lastlog \ + --disable-harden \ + --enable-static + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/dropbear/package.yml b/land/dropbear/package.yml deleted file mode 100644 index 6ce96136..00000000 --- a/land/dropbear/package.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: dropbear -version: 2020.81 -sources: - - url: https://matt.ucc.asn.au/dropbear/releases/dropbear-2020.81.tar.bz2 -dependencies: - - zlib -patches: - - dropbear.patch -patch_skip_path: 0 -configure: - - CFLAGS="$CFLAGS -DDROPBEAR_SVR_PASSWORD_AUTH=0" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --sbindir=/usr/bin - --disable-syslog - --disable-lastlog - --disable-harden - --enable-static -make: - - make -install: - - make install diff --git a/land/e2fsprogs/PKGBUILD b/land/e2fsprogs/PKGBUILD new file mode 100644 index 00000000..fb3ab246 --- /dev/null +++ b/land/e2fsprogs/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=e2fsprogs +pkgver=1.45.5 +pkgrel=1 +pkgdesc="Filesystem utilities for use with the ext2 filesystem." +arch=('i786') +url="https://e2fsprogs.sourceforge.net/" +source=( + 'https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.45.5/e2fsprogs-1.45.5.tar.xz' + 'e2fsprogs.patch' +) +sha256sums=( + 'f9faccc0d90f73556e797dc7cc5979b582bd50d3f8609c0f2ad48c736d44aede' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../e2fsprogs.patch +} + +build() { + cd $pkgname-$pkgver + + autoconf + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --sbindir=/usr/bin \ + --disable-nls + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/e2fsprogs/package.yml b/land/e2fsprogs/package.yml deleted file mode 100644 index de7212f4..00000000 --- a/land/e2fsprogs/package.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: e2fsprogs -version: '1.45.5' -sources: - - url: https://mirrors.edge.kernel.org/pub/linux/kernel/people/tytso/e2fsprogs/v1.45.5/e2fsprogs-1.45.5.tar.xz -patch_skip_path: 0 -patches: - - e2fsprogs.patch -configure: - - autoconf - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --sbindir=/usr/bin - --disable-nls -make: - - make -install: - - make DESTDIR=$DESTDIR install diff --git a/land/ffmpeg/PKGBUILD b/land/ffmpeg/PKGBUILD new file mode 100644 index 00000000..9bc7a28a --- /dev/null +++ b/land/ffmpeg/PKGBUILD @@ -0,0 +1,46 @@ +pkgname=ffmpeg +pkgver=4.4 +pkgrel=1 +pkgdesc="FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata." +arch=('i786') +url="https://ffmpeg.org/" +license=('GPL') +makedepends=('flac' 'openssl' 'zlib' 'bzip2') +source=( + 'https://ffmpeg.org/releases/ffmpeg-4.4.tar.xz' + 'ffmpeg.patch' + 'xelixsnd.c' + 'xelixsnd.h' + 'xelixsnd_enc.c') +sha256sums=( + '06b10a183ce5371f915c6bb15b7b1fffbe046e8275099c96affc29e17645d909' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP') + +prepare() { + cp xelixsnd.c $pkgname-$pkgver/libavdevice/ + cp xelixsnd.h $pkgname-$pkgver/libavdevice/ + cp xelixsnd_enc.c $pkgname-$pkgver/libavdevice/ + cd $pkgname-$pkgver + patch -p0 < ../ffmpeg.patch +} + +build() { + cd $pkgname-$pkgver + CFLAGS="-D__have_long64=0 -D__int64_t_defined" ./configure \ + --arch=x86 \ + --target-os=xelix \ + --cross-prefix=i786-pc-xelix- \ + --prefix=/usr \ + --disable-shared \ + --disable-network \ + --disable-iconv + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/ffmpeg/package.yml b/land/ffmpeg/package.yml deleted file mode 100644 index 904f34ac..00000000 --- a/land/ffmpeg/package.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: ffmpeg -version: 4.4 -sources: - - url: https://ffmpeg.org/releases/ffmpeg-4.4.tar.xz -dependencies: - - flac - - openssl - - zlib - - bzip2 -patches: - - ffmpeg.patch -patch_skip_path: 0 -configure: - - cp $PKGDIR/xelixsnd.c libavdevice/ - - cp $PKGDIR/xelixsnd.h libavdevice/ - - cp $PKGDIR/xelixsnd_enc.c libavdevice/ - - CFLAGS="-D__have_long64=0 -D__int64_t_defined" ./configure - --arch=x86 - --target-os=xelix - --cross-prefix=i786-pc-xelix- - --prefix=/usr - --disable-shared - --disable-network - --disable-iconv -make: - - make -install: - - make install diff --git a/land/flac/PKGBUILD b/land/flac/PKGBUILD new file mode 100644 index 00000000..01b8a492 --- /dev/null +++ b/land/flac/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=flac +pkgver=1.3.3 +pkgrel=1 +pkgdesc="Free Lossless Audio Codec" +arch=('i786') +url="https://github.com/xiph/flac" +source=( + 'https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.3.tar.xz' + 'flac-1.3.3.patch' +) +sha256sums=( + '213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748' + 'SKIP' +) + +prepare() { + patch -p0 < flac-1.3.3.patch +} + +build() { + cd $pkgname-$pkgver + CPPFLAGS="$CPPFLAGS -D_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC=0 -D_GLIBCXX_USE_C99_STDLIB=0 -mno-sse" CFLAGS="$CFLAGS -mno-sse" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared \ + --disable-asm-optimizations \ + --disable-cpplibs \ + --without-ogg + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/flac/package.yml b/land/flac/package.yml deleted file mode 100644 index 3feb6127..00000000 --- a/land/flac/package.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: flac -version: 1.3.3 -sources: - - url: https://ftp.osuosl.org/pub/xiph/releases/flac/flac-1.3.3.tar.xz -patches: - - flac-1.3.3.patch -configure: - - CPPFLAGS="-D_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC=0 -D_GLIBCXX_USE_C99_STDLIB=0 -mno-sse" CFLAGS="-mno-sse" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-shared - --disable-asm-optimizations - --disable-cpplibs - --without-ogg -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libFLAC.la || true - - rm $DESTDIR/usr/lib/libFLAC++.la || true diff --git a/land/font-dejavu/PKGBUILD b/land/font-dejavu/PKGBUILD new file mode 100644 index 00000000..54d170ef --- /dev/null +++ b/land/font-dejavu/PKGBUILD @@ -0,0 +1,14 @@ +pkgname=font-dejavu +pkgver=2.37 +pkgrel=1 +pkgdesc="The DejaVu font family." +arch=('any') +url="https://dejavu-fonts.github.io/" +source=('http://sourceforge.net/projects/dejavu/files/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2') +sha256sums=('fa9ca4d13871dd122f61258a80d01751d603b4d3ee14095d65453b4e846e17d7') + +package() { + cd dejavu-fonts-ttf-2.37 + install -d -m 755 $pkgdir/usr/share/fonts + install -D ttf/* -m 644 $pkgdir/usr/share/fonts +} diff --git a/land/font-dejavu/package.yml b/land/font-dejavu/package.yml deleted file mode 100644 index 53a6fbef..00000000 --- a/land/font-dejavu/package.yml +++ /dev/null @@ -1,7 +0,0 @@ -name: font-dejavu -version: '2.37' -sources: - - url: http://sourceforge.net/projects/dejavu/files/dejavu/2.37/dejavu-fonts-ttf-2.37.tar.bz2 -install: - - install -d -m 755 $DESTDIR/usr/share/fonts - - install -D ttf/* -m 644 $DESTDIR/usr/share/fonts diff --git a/land/font-fira-code/PKGBUILD b/land/font-fira-code/PKGBUILD new file mode 100644 index 00000000..2801f52f --- /dev/null +++ b/land/font-fira-code/PKGBUILD @@ -0,0 +1,13 @@ +pkgname=font-fira-code +pkgver=2 +pkgrel=1 +pkgdesc="The Fira Code font family." +arch=('any') +url="https://github.com/tonsky/FiraCode" +source=('https://github.com/tonsky/FiraCode/releases/download/2/FiraCode_2.zip') +sha256sums=('60d5b1106b708cc134c521aae4e503bb1d2ec3c9bf8ad978f2c659820505d492') + +package() { + install -d -m 755 $pkgdir/usr/share/fonts + install -D ttf/* -m 644 $pkgdir/usr/share/fonts +} diff --git a/land/font-fira-code/package.yml b/land/font-fira-code/package.yml deleted file mode 100644 index 96288bb0..00000000 --- a/land/font-fira-code/package.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: font-fira-code -version: '2' -sources: - - url: https://github.com/tonsky/FiraCode/releases/download/2/FiraCode_2.zip - type: zip -install: - - install -D ttf/*.ttf -m 644 $DESTDIR/usr/share/fonts - - install -d -m 755 $DESTDIR/usr/share/fonts diff --git a/land/font-fira/PKGBUILD b/land/font-fira/PKGBUILD new file mode 100644 index 00000000..e304db49 --- /dev/null +++ b/land/font-fira/PKGBUILD @@ -0,0 +1,14 @@ +pkgname=font-fira +pkgver=4.202 +pkgrel=1 +pkgdesc="The Fira font family." +arch=('any') +url="http://mozilla.github.io/Fira/" +source=('https://github.com/mozilla/Fira/archive/4.202.tar.gz') +sha256sums=('d86269657387f144d77ba12011124f30f423f70672e1576dc16f918bb16ddfe4') + +package() { + cd Fira-4.202 + install -d -m 755 $pkgdir/usr/share/fonts + install -D ttf/* -m 644 $pkgdir/usr/share/fonts +} diff --git a/land/font-fira/package.yml b/land/font-fira/package.yml deleted file mode 100644 index 57604c2c..00000000 --- a/land/font-fira/package.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: font-fira -version: '2' -sources: - - url: https://github.com/mozilla/Fira/archive/4.202.tar.gz -install: - - install -d -m 755 $DESTDIR/usr/share/fonts - - install -D ttf/* -m 644 $DESTDIR/usr/share/fonts - diff --git a/land/font-roboto/PKGBUILD b/land/font-roboto/PKGBUILD new file mode 100644 index 00000000..77c89787 --- /dev/null +++ b/land/font-roboto/PKGBUILD @@ -0,0 +1,13 @@ +pkgname=font-roboto +pkgver=2.138 +pkgrel=1 +pkgdesc="The Roboto font family." +arch=('any') +url="https://github.com/googlefonts/roboto" +source=('https://github.com/googlefonts/roboto/releases/download/v2.138/roboto-unhinted.zip') +sha256sums=('70f64c718510a601fbcf752aafe644314dacaeb85474dc689c89787c4a72a728') + +package() { + install -d -m 755 $pkgdir/usr/share/fonts + install -D *.ttf -m 644 $pkgdir/usr/share/fonts +} diff --git a/land/font-roboto/package.yml b/land/font-roboto/package.yml deleted file mode 100644 index 02b4104e..00000000 --- a/land/font-roboto/package.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: font-roboto -version: '2.138' -sources: - - url: https://github.com/googlefonts/roboto/releases/download/v2.138/roboto-unhinted.zip - type: zip -install: - - install -d -m 755 $DESTDIR/usr/share/fonts - - install -D *.ttf -m 644 $DESTDIR/usr/share/fonts diff --git a/land/fontconfig/PKGBUILD b/land/fontconfig/PKGBUILD new file mode 100644 index 00000000..96922b0d --- /dev/null +++ b/land/fontconfig/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=fontconfig +pkgver=2.13.92 +pkgrel=1 +pkgdesc="Fontconfig is a library for configuring and customizing font access." +arch=('i786') +url="https://www.freedesktop.org/wiki/Software/fontconfig/" +makedepend=('libexpat' 'freetype' 'libpng' 'zlib' 'bzip2') +source=( + 'https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.92.tar.xz' + 'fontconfig.patch' +) +sha256sums=( + '506e61283878c1726550bc94f2af26168f1e9f2106eac77eaaf0b2cdfad66e4e' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../fontconfig.patch +} + +build() { + cd $pkgname-$pkgver + FREETYPE_LIBS="-lfreetype -lpng -lz -lbz2 -lm" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/fontconfig/package.yml b/land/fontconfig/package.yml deleted file mode 100644 index 580abbb3..00000000 --- a/land/fontconfig/package.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: fontconfig -version: '2.13.92' -sources: - - url: https://www.freedesktop.org/software/fontconfig/release/fontconfig-2.13.92.tar.xz -dependencies: - - libexpat - - freetype -patch_skip_path: 0 -patches: - - fontconfig.patch -configure: - - FREETYPE_LIBS="-lfreetype -lpng -lz -lm" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --localstatedir=/var -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libfontconfig.la diff --git a/land/freetype/PKGBUILD b/land/freetype/PKGBUILD new file mode 100644 index 00000000..f2efb1d9 --- /dev/null +++ b/land/freetype/PKGBUILD @@ -0,0 +1,34 @@ +pkgname=freetype +pkgver=2.9 +pkgrel=1 +pkgdesc="FreeType is a freely available software library to render fonts." +arch=('i786') +url="https://freetype.org/" +makedepends=('zlib' 'libpng') +source=( + 'https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz' + 'freetype-2.9.patch' +) +sha256sums=( + 'bf380e4d7c4f3b5b1c1a7b2bf3abb967bda5e9ab480d0df656e0e08c5019c5e6' + 'SKIP' +) + +prepare() { + patch -p0 < freetype-2.9.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/freetype/package.yml b/land/freetype/package.yml deleted file mode 100644 index 971cc3dc..00000000 --- a/land/freetype/package.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: freetype -version: '2.9' -sources: - - url: https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz -dependencies: - - zlib - - libpng -patches: - - freetype-2.9.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libfreetype.la diff --git a/land/gcc/package.yml b/land/gcc/package.yml deleted file mode 100644 index b2153f8c..00000000 --- a/land/gcc/package.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: gcc -version: '13.1.0' -sources: - - url: https://ftp.gnu.org/gnu/gcc/gcc-11.1.0/gcc-13.1.0.tar.gz -dependencies: - - mpc - - mpfr - - gmp -patches: - - gcc-13.1.0.patch -set_cflags_sysroot: false -configure: - - cp $PKGDIR/xelix.h gcc/config/ - - rm -r build || true - - mkdir build - - cd build && CPPFLAGS="$CPPFLAGS -DHAVE_SYS_WAIT_H -DHAVE_SYS_RESOURCE_H -DHAVE_DECL_SBRK -DHAVE_DECL_STRSIGNAL -D__int64_t_defined" ../configure - --host=i786-pc-xelix - --target=i786-pc-xelix - --disable-shared - --enable-static - --prefix=/usr - --sysconfdir=/etc - --libdir=/usr/lib - --libexecdir=/usr/lib - --mandir=/usr/share/man - --infodir=/usr/share/info - --enable-languages=c,c++ - --with-sysroot=$DESTDIR - --with-gmp=$DESTDIR/usr - --with-mpfr=$DESTDIR/usr - --with-mpc=$DESTDIR/usr -make: - - CPPFLAGS="$CPPFLAGS -DHAVE_SYS_WAIT_H -DHAVE_SYS_RESOURCE_H -DHAVE_DECL_SBRK -DHAVE_DECL_STRSIGNAL -D__int64_t_defined" make -C build all-gcc - - CPPFLAGS="$CPPFLAGS -DHAVE_SYS_WAIT_H -DHAVE_SYS_RESOURCE_H -DHAVE_DECL_SBRK -DHAVE_DECL_STRSIGNAL -D__int64_t_defined" make -C build all-target-libgcc -# - CPPFLAGS="$CPPFLAGS -DHAVE_SYS_WAIT_H -DHAVE_SYS_RESOURCE_H -DHAVE_DECL_SBRK -DHAVE_DECL_STRSIGNAL -D__int64_t_defined" make -C build all-target-libstdc++-v3 || true -install: - - make -C build install-gcc - - make -C build install-target-libgcc -# - make -C build install-target-libstdc++-v3 || true diff --git a/land/gettext/package.yml b/land/gettext/package.yml deleted file mode 100644 index c7049e4e..00000000 --- a/land/gettext/package.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: gettext -disabled: true -version: 0.20.1 -sources: - - url: https://ftp.gnu.org/gnu/gettext/gettext-0.20.1.tar.gz -dependencies: - - ncurses - - libxml2 -patches: - - gettext-0.20.1.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - - # Needs to be applied after configure - - patch -p0 < $PKGDIR/gettext-0.20.1-two.patch -make: - - make -install: - - make install diff --git a/land/gfxcompd/PKGBUILD b/land/gfxcompd/PKGBUILD new file mode 100644 index 00000000..9acd1a57 --- /dev/null +++ b/land/gfxcompd/PKGBUILD @@ -0,0 +1,23 @@ +pkgname=gfxcompd +pkgver=r2576.fb8939c5 +pkgrel=1 +epoch= +pkgdesc="The graphics compositor of Xelix" +arch=('i786') +url="https://github.com/lutoma/xelix/tree/main/land/gfxcompd" +license=('GPL') +depends=('font-roboto') +makedepends=('cairo' 'freetype' 'libpng') +source=() + +pkgver() { + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + make +} + +package() { + make DESTDIR=$pkgdir install +} diff --git a/land/gfxcompd/package.yml b/land/gfxcompd/package.yml deleted file mode 100644 index dfce2d71..00000000 --- a/land/gfxcompd/package.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: gfxcompd -version: 0.1.0 -sources: - - dir: src -dependencies: - - font-roboto - - cairo - - freetype - - libpng -make: - - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" make -install: - - make install diff --git a/land/gfxcompd/src/Makefile b/land/gfxcompd/src/Makefile index 0c2f246c..f8d0ed8f 100644 --- a/land/gfxcompd/src/Makefile +++ b/land/gfxcompd/src/Makefile @@ -1,7 +1,7 @@ PATH += :../../toolchain/local/bin/ CC := i786-pc-xelix-gcc LD := i786-pc-xelix-ld -CFLAGS += -std=gnu18 -fcommon -O3 -g -D_GNU_SOURCE -I$(DESTDIR)/usr/include/freetype2 +MAKE_CFLAGS += -std=gnu18 -fcommon -O3 -g -D_GNU_SOURCE -I$(DESTDIR)/usr/include/freetype2 DESTDIR ?= ../../../mnt .PHONY: all @@ -12,7 +12,7 @@ clean: rm -f gfxcompd gfxcompd: main.o mouse.o window.o bus.o text.o render.o bar.o - $(CC) $(CFLAGS) -o $@ $^ -lcairo -lpixman-1 -lfreetype -lpng -lz -lm -lbz2 + $(CC) $(CFLAGS) $(MAKE_CFLAGS) -o $@ $^ $(LDFLAGS) -lcairo -lpixman-1 -lfreetype -lpng -lz -lm -lbz2 libxelixgfx.a: libxelixgfx.o ar rcs $@ $^ diff --git a/land/gfxcompd/src/render.c b/land/gfxcompd/src/render.c index 4ea21da4..f426ea84 100644 --- a/land/gfxcompd/src/render.c +++ b/land/gfxcompd/src/render.c @@ -119,18 +119,31 @@ void render_init() { main_buffer = malloc(gfx_handle.size); if(!main_buffer) { - printf("Could not allocate main_buffer\n"); - exit(1); + fprintf(stderr, "Could not allocate main_buffer\n"); + exit(EXIT_FAILURE); }; + cairo_format_t format; + switch(gfx_handle.bpp) { + case 32: + format = CAIRO_FORMAT_RGB24; + break; + case 16: + format = CAIRO_FORMAT_RGB16_565; + break; + default: + fprintf(stderr, "Unsupported pixel depth\n"); + exit(EXIT_FAILURE); + } + main_surface = cairo_image_surface_create_for_data( - main_buffer, CAIRO_FORMAT_ARGB32, gfx_handle.width, + main_buffer, format, gfx_handle.width, gfx_handle.height, gfx_handle.pitch); cr = cairo_create(main_surface); // Create background surface and fill with gray color - cairo_surface_t* bg_surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, gfx_handle.width, gfx_handle.height); + cairo_surface_t* bg_surface = cairo_image_surface_create(format, gfx_handle.width, gfx_handle.height); cairo_t* bg_cr = cairo_create(bg_surface); cairo_set_source_rgb(bg_cr, 0.2, 0.2, 0.2); cairo_paint(bg_cr); diff --git a/land/git/PKGBUILD b/land/git/PKGBUILD new file mode 100644 index 00000000..03e5337e --- /dev/null +++ b/land/git/PKGBUILD @@ -0,0 +1,44 @@ +pkgname=git +pkgver=2.42.1 +pkgrel=3 +pkgdesc="Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency." +arch=('i786') +makedepend=('openssl' 'pcre2' 'curl' 'libexpat' 'zlib') +url="https://git-scm.com/" +source=( + 'https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.42.1.tar.xz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + '8e46fa96bf35a65625d85fde50391e39bc0620d1bb39afb70b96c4a237a1a4f7' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch +} + + +build() { + cd $pkgname-$pkgver + ac_cv_fread_reads_directories=n \ + ac_cv_snprintf_returns_bogus=n \ + NO_MMAP=y \ + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-pthreads \ + --with-openssl \ + --with-libpcre2 \ + --with-curl \ + --with-expat + + make -j$(nproc) +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/git/git-2.42.1.patch b/land/git/git-2.42.1.patch new file mode 100644 index 00000000..33bcd11e --- /dev/null +++ b/land/git/git-2.42.1.patch @@ -0,0 +1,80 @@ +--- compat/disk.h ++++ compat/disk.h.new +@@ -35,6 +35,7 @@ + strbuf_humanise_bytes(out, avail2caller.QuadPart); + strbuf_addch(out, '\n'); + #else ++#ifndef __xelix__ + struct statvfs stat; + + strbuf_realpath(&buf, ".", 1); +@@ -48,6 +49,7 @@ + strbuf_addf(out, "Available space on '%s': ", buf.buf); + strbuf_humanise_bytes(out, (off_t)stat.f_bsize * (off_t)stat.f_bavail); + strbuf_addf(out, " (mount flags 0x%lx)\n", stat.f_flag); ++#endif + #endif + + cleanup: +--- git-compat-util.h ++++ git-compat-util.h.new +@@ -278,7 +278,9 @@ + #include + #include + #include ++#ifndef __xelix__ + #include ++#endif + #include + #ifndef NO_SYS_SELECT_H + #include +@@ -400,7 +402,7 @@ + #include + #endif + +-#ifdef HAVE_SYSINFO ++#ifndef __xelix__ + # include + #endif + +--- builtin/gc.c ++++ builtin/gc.c.new +@@ -262,7 +262,7 @@ + + static uint64_t total_ram(void) + { +-#if defined(HAVE_SYSINFO) ++#if 0 + struct sysinfo si; + + if (!sysinfo(&si)) +--- Makefile ++++ Makefile.new +@@ -2078,9 +2078,9 @@ + BASIC_CFLAGS += -DHAVE_SYNC_FILE_RANGE + endif + +-ifdef NEEDS_LIBRT +- EXTLIBS += -lrt +-endif ++#ifdef NEEDS_LIBRT ++# EXTLIBS += -lrt ++#endif + + ifdef HAVE_BSD_SYSCTL + BASIC_CFLAGS += -DHAVE_BSD_SYSCTL +--- progress.c ++++ progress.c.new +@@ -102,8 +102,12 @@ + + static int is_foreground_fd(int fd) + { ++#ifndef __xelix__ + int tpgrp = tcgetpgrp(fd); + return tpgrp < 0 || tpgrp == getpgid(0); ++#else ++ return 1; ++#endif + } + + static void display(struct progress *progress, uint64_t n, const char *done) diff --git a/land/gmp/PKGBUILD b/land/gmp/PKGBUILD new file mode 100644 index 00000000..c2456620 --- /dev/null +++ b/land/gmp/PKGBUILD @@ -0,0 +1,34 @@ +pkgname=gmp +pkgver=6.2.0 +pkgrel=1 +pkgdesc="GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating-point numbers." +arch=('i786') +url="https://gmplib.org" +source=( + 'https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz' + 'gmp-6.2.0.patch' +) +sha256sums=( + '258e6cd51b3fbdfc185c716d55f82c08aff57df0c6fbd143cf6ed561267a1526' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../gmp-6.2.0.patch +} + +build() { + cd $pkgname-$pkgver + CC=i786-pc-xelix-gcc ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/gmp/package.yml b/land/gmp/package.yml deleted file mode 100644 index 3c2d01e8..00000000 --- a/land/gmp/package.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: gmp -version: '6.2.0' -sources: - - url: https://gmplib.org/download/gmp/gmp-6.2.0.tar.xz -patch_skip_path: 0 -patches: - - gmp-6.2.0.patch -configure: - - CC=i786-pc-xelix-gcc ./configure - --host=i786-pc-xelix - --target=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-shared -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libgmp.la diff --git a/land/grep/PKGBUILD b/land/grep/PKGBUILD new file mode 100644 index 00000000..91f169a6 --- /dev/null +++ b/land/grep/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=grep +pkgver=3.1 +pkgrel=2 +pkgdesc="Grep searches one or more input files for lines containing a match to a specified pattern." +arch=('i786') +url="https://www.gnu.org/software/grep/" +source=( + 'https://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz' + 'grep-3.1.patch' +) +sha256sums=( + 'db625c7ab3bb3ee757b3926a5cfa8d9e1c3991ad24707a83dde8a5ef2bf7a07e' + 'SKIP' +) + +prepare() { + patch -p0 < ../grep-3.1.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install + + # Empty and conflicts with diffutils + rm $pkgdir/usr/lib/charset.alias +} diff --git a/land/grep/package.yml b/land/grep/package.yml deleted file mode 100644 index 48a4da51..00000000 --- a/land/grep/package.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: grep -version: 3.1 -sources: - - url: https://ftp.gnu.org/gnu/grep/grep-3.1.tar.xz -patches: - - grep-3.1.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - # Install segfaults because it tries to run the cross-compiled binary… still installs though - - make install || false diff --git a/land/gzip/PKGBUILD b/land/gzip/PKGBUILD new file mode 100644 index 00000000..5fe41e2b --- /dev/null +++ b/land/gzip/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=gzip +pkgver=1.9 +pkgrel=1 +pkgdesc="gzip is a single-file/stream lossless data compression utility, where the resulting compressed file generally has the suffix .gz." +arch=('i786') +url="https://www.gzip.org/" +source=( + 'https://ftp.gnu.org/gnu/gzip/gzip-1.9.tar.xz' + 'gzip-1.9.patch' +) +sha256sums=( + 'ae506144fc198bd8f81f1f4ad19ce63d5a2d65e42333255977cf1dcf1479089a' + 'SKIP' +) + +prepare() { + patch -p0 < gzip-1.9.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/gzip/package.yml b/land/gzip/package.yml deleted file mode 100644 index 81868dc3..00000000 --- a/land/gzip/package.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: gzip -version: 1.9 -sources: - - url: https://ftp.gnu.org/gnu/gzip/gzip-1.9.tar.xz -patches: - - gzip-1.9.patch -configure: - - ./configure --host=i786-pc-xelix --prefix=/usr --sysconfdir=/etc -make: - - make -install: - - make install diff --git a/land/htop/PKGBUILD b/land/htop/PKGBUILD new file mode 100644 index 00000000..f527fbd0 --- /dev/null +++ b/land/htop/PKGBUILD @@ -0,0 +1,42 @@ +pkgname=htop +pkgver=3.0.5 +pkgrel=1 +pkgdesc="An interactive process viewer" +arch=('i786') +url="https://htop.dev/" +depends=('ncurses') +source=( + 'https://github.com/htop-dev/htop/archive/refs/tags/3.0.5.tar.gz' + 'htop.patch' +) +sha256sums=( + '4c2629bd50895bd24082ba2f81f8c972348aa2298cc6edc6a21a7fa18b73990c' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../htop.patch + + cp -r ../../xelix . +} + +build() { + cd $pkgname-$pkgver + ./autogen.sh + echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --program-transform-name= \ + --disable-unicode \ + --disable-linux_affinity + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/htop/package.yml b/land/htop/package.yml deleted file mode 100644 index c68bad83..00000000 --- a/land/htop/package.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: htop -version: 3.0.5 -sources: - - url: https://github.com/htop-dev/htop/archive/refs/tags/3.0.5.tar.gz -dependencies: - - ncurses -patch_skip_path: 0 -patches: - - htop.patch -configure: - - cp -r $PKGDIR/xelix . - - ./autogen.sh - - 'echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub' - - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --program-transform-name= - --disable-unicode - --disable-linux_affinity -make: - - make -install: - - make DESTDIR=$DESTDIR install diff --git a/land/less/PKGBUILD b/land/less/PKGBUILD new file mode 100644 index 00000000..acaa8bfb --- /dev/null +++ b/land/less/PKGBUILD @@ -0,0 +1,24 @@ +pkgname=less +pkgver=551 +pkgrel=1 +pkgdesc="Less is a free, open-source file pager." +arch=('i786') +depends=('ncurses') +url="http://greenwoodsoftware.com/less/" +source=('http://www.greenwoodsoftware.com/less/less-551.tar.gz') +sha256sums=('ff165275859381a63f19135a8f1f6c5a194d53ec3187f94121ecd8ef0795fe3d') + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/less/package.yml b/land/less/package.yml deleted file mode 100644 index 9ea22dd9..00000000 --- a/land/less/package.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: less -version: 551 -sources: - - url: http://www.greenwoodsoftware.com/less/less-551.tar.gz -dependencies: - - ncurses -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make DESTDIR=$DESTDIR install diff --git a/land/libarchive/PKGBUILD b/land/libarchive/PKGBUILD new file mode 100644 index 00000000..a3827bb2 --- /dev/null +++ b/land/libarchive/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=libarchive +pkgver=3.7.2 +pkgrel=1 +pkgdesc="Multi-format archive and compression library" +arch=('i786') +makedepends=('libxml2' 'openssl' 'bzip2' 'zlib' 'libiconv' 'xz') +url="https://www.libarchive.org/" +source=( + 'https://github.com/libarchive/libarchive/releases/download/v3.7.2/libarchive-3.7.2.tar.xz' + 'libarchive-3.7.2.patch' +) +sha256sums=( + '04357661e6717b6941682cde02ad741ae4819c67a260593dfb2431861b251acb' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../libarchive-3.7.2.patch +} + +build() { + cd $pkgname-$pkgver + LIBS="-lxml2 -lz -llzma -lm" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/libarchive/libarchive-3.7.2.patch b/land/libarchive/libarchive-3.7.2.patch new file mode 100644 index 00000000..968b9201 --- /dev/null +++ b/land/libarchive/libarchive-3.7.2.patch @@ -0,0 +1,44 @@ +--- build/autoconf/config.sub 2023-11-12 01:07:32.604168131 +0100 ++++ build/autoconf/config.sub 2023-11-12 01:07:40.876166826 +0100 +@@ -1754,7 +1754,7 @@ case $os in + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \ +- | fiwix* ) ++ | fiwix* | xelix*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) +--- libarchive/archive_write_set_format_iso9660.c 2023-07-29 19:27:43.000000000 +0200 ++++ libarchive/archive_write_set_format_iso9660.c.new 2023-11-12 01:53:04.009872470 +0100 +@@ -2503,18 +2503,7 @@ static long + get_gmoffset(struct tm *tm) + { + long offset; +- +-#if defined(HAVE__GET_TIMEZONE) +- _get_timezone(&offset); +-#elif defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) +- offset = _timezone; +-#else +- offset = timezone; +-#endif +- offset *= -1; +- if (tm->tm_isdst) +- offset += 3600; +- return (offset); ++ return 0; + } + #endif + +--- libarchive/archive_random.c 2023-09-12 00:05:19.000000000 +0200 ++++ libarchive/archive_random.c.new 2023-11-12 01:54:04.170545328 +0100 +@@ -30,6 +30,8 @@ __FBSDID("$FreeBSD$"); + #include + #endif + ++#undef HAVE_PTHREAD_H ++ + #if !defined(HAVE_ARC4RANDOM_BUF) && (!defined(_WIN32) || defined(__CYGWIN__)) + + #ifdef HAVE_FCNTL diff --git a/land/libedit/PKGBUILD b/land/libedit/PKGBUILD new file mode 100644 index 00000000..0d8cb9af --- /dev/null +++ b/land/libedit/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=libedit +pkgver=20191231.3.1 +pkgrel=1 +pkgdesc="This is an autotool- and libtoolized port of the NetBSD Editline library (libedit)." +arch=('i786') +depends=('ncurses') +url="https://thrysoee.dk/editline/" +source=( + 'https://thrysoee.dk/editline/libedit-20191231-3.1.tar.gz' + 'libedit-20191231-3.1.patch' +) +sha256sums=( + 'dbb82cb7e116a5f8025d35ef5b4f7d4a3cdd0a3909a146a39112095a2d229071' + 'SKIP' +) + +prepare() { + patch -p0 < libedit-20191231-3.1.patch +} + +build() { + cd libedit-20191231-3.1 + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared \ + --disable-widec + + make +} + +package() { + cd libedit-20191231-3.1 + make DESTDIR=$pkgdir install +} diff --git a/land/libedit/package.yml b/land/libedit/package.yml deleted file mode 100644 index 4a4b2db8..00000000 --- a/land/libedit/package.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: libedit -version: 20191231-3.1 -sources: - - url: https://thrysoee.dk/editline/libedit-20191231-3.1.tar.gz -dependencies: - - ncurses -patches: - - libedit-20191231-3.1.patch -configure: - - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-shared - --disable-widec -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libedit.la diff --git a/land/libevent/PKGBUILD b/land/libevent/PKGBUILD new file mode 100644 index 00000000..49d9f0d3 --- /dev/null +++ b/land/libevent/PKGBUILD @@ -0,0 +1,39 @@ +pkgname=libevent +pkgver=2.1.12 +pkgrel=1 +pkgdesc="The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached" +arch=('i786') +url="https://libevent.org/" +makedepend=('openssl') +source=( + 'https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz' + 'libevent-2.1.12.patch' +) +sha256sums=( + '92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb' + 'SKIP' +) + +prepare() { + cd libevent-2.1.12-stable + patch -p0 < ../libevent-2.1.12.patch +} + +build() { + cd libevent-2.1.12-stable + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared \ + --disable-samples \ + --disable-thread-support \ + --disable-libevent-regress + + make +} + +package() { + cd libevent-2.1.12-stable + make DESTDIR=$pkgdir install +} diff --git a/land/libexpat/PKGBUILD b/land/libexpat/PKGBUILD new file mode 100644 index 00000000..ae8b12d7 --- /dev/null +++ b/land/libexpat/PKGBUILD @@ -0,0 +1,34 @@ +pkgname=libexpat +pkgver=2.2.9 +pkgrel=1 +pkgdesc="Fast streaming XML parser written in C99 with >90% test coverage" +arch=('i786') +url="https://libexpat.github.io/" +source=( + 'https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.xz' + 'libexpat.patch' +) +sha256sums=( + '1ea6965b15c2106b6bbe883397271c80dfa0331cdf821b2c319591b55eadc0a4' + 'SKIP' +) + +prepare() { + cd expat-2.2.9 + patch -p0 < ../libexpat.patch +} + +build() { + cd expat-2.2.9 + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd expat-2.2.9 + make DESTDIR=$pkgdir install +} diff --git a/land/libexpat/package.yml b/land/libexpat/package.yml deleted file mode 100644 index 2986ca4f..00000000 --- a/land/libexpat/package.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: libexpat -version: '2.2.9' -sources: - - url: https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.xz -patch_skip_path: 0 -patches: - - libexpat.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libexpat.la diff --git a/land/libiconv/libiconv.patch b/land/libiconv/libiconv.patch deleted file mode 100644 index 082388db..00000000 --- a/land/libiconv/libiconv.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- build-aux/config.sub 2020-01-30 00:50:56.402769882 +0100 -+++ build-aux/config.sub 2020-01-30 00:51:08.986070324 +0100 -@@ -1367,7 +1367,7 @@ case $os in - | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ -- | midnightbsd* | amdhsa* | unleashed* | emscripten*) -+ | midnightbsd* | amdhsa* | unleashed* | emscripten* | xelix*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - qnx*) ---- libcharset/build-aux/config.sub 2020-01-30 00:51:17.956046980 +0100 -+++ libcharset/build-aux/config.sub 2020-01-30 00:51:25.249361387 +0100 -@@ -1367,7 +1367,7 @@ case $os in - | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ - | skyos* | haiku* | rdos* | toppers* | drops* | es* \ - | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ -- | midnightbsd* | amdhsa* | unleashed* | emscripten*) -+ | midnightbsd* | amdhsa* | unleashed* | emscripten* | xelix*) - # Remember, each alternative MUST END IN *, to match a version number. - ;; - qnx*) diff --git a/land/libiconv/package.yml b/land/libiconv/package.yml deleted file mode 100644 index 09be2a91..00000000 --- a/land/libiconv/package.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: libiconv -version: '1.16' -sources: - - url: https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz -patch_skip_path: 0 -patches: - - libiconv.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libcharset.la - - rm $DESTDIR/usr/lib/libiconv.la diff --git a/land/libpng/PKGBUILD b/land/libpng/PKGBUILD new file mode 100644 index 00000000..d251784f --- /dev/null +++ b/land/libpng/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=libpng +pkgver=1.6.37 +pkgrel=1 +pkgdesc="libpng is the official PNG reference library." +arch=('i786') +makedepend=('zlib') +url="http://www.libpng.org/pub/png/libpng.html" +source=( + 'http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz?download' + 'libpng.patch' +) +sha256sums=( + '505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-hardware-optimizations + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/libpng/package.yml b/land/libpng/package.yml deleted file mode 100644 index ca5c2c00..00000000 --- a/land/libpng/package.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: libpng -version: '1.6.37' -sources: - - url: http://prdownloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz?download -dependencies: - - zlib -patch_skip_path: 0 -patches: - - libpng.patch -configure: - - CPPFLAGS="$CPPFLAGS -I$DESTDIR/usr/include" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --enable-hardware-optimizations -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libpng16.la $DESTDIR/usr/lib/libpng.la diff --git a/land/libtextstyle/PKGBUILD b/land/libtextstyle/PKGBUILD new file mode 100644 index 00000000..0f114ca6 --- /dev/null +++ b/land/libtextstyle/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=libtextstyle +pkgver=0.8 +pkgrel=1 +pkgdesc="GNU libtextstyle provides an easy way to add styling to programs that produce output to a console or terminal emulator window." +arch=('i786') +depend=('ncurses') +url="https://www.gnu.org/software/gettext/libtextstyle/manual/libtextstyle.html" +source=( + 'https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz' + "$pkgname.patch" +) +sha256sums=( + '5cd91ef7683111af2734095e00f4ee4995c916cf32ea38e314aee251f8683216' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/libtextstyle/package.yml b/land/libtextstyle/package.yml deleted file mode 100644 index 9bff3391..00000000 --- a/land/libtextstyle/package.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: libtextstyle -version: '0.8' -sources: - - url: https://alpha.gnu.org/gnu/gettext/libtextstyle-0.8.tar.gz -dependencies: - - ncurses -patch_skip_path: 0 -patches: - - libtextstyle.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libtextstyle.la diff --git a/land/libxml2/PKGBUILD b/land/libxml2/PKGBUILD new file mode 100644 index 00000000..d45a9499 --- /dev/null +++ b/land/libxml2/PKGBUILD @@ -0,0 +1,38 @@ +pkgname=libxml2 +pkgver=2.9.9 +pkgrel=2 +pkgdesc="libxml2 is an XML toolkit implemented in C, originally developed for the GNOME Project." +arch=('i786') +makedepend=('zlib' 'xz') +url="https://gitlab.gnome.org/GNOME/libxml2" +source=( + 'https://download.gnome.org/sources/libxml2/2.9/libxml2-2.9.9.tar.xz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + '58a5c05a2951f8b47656b676ce1017921a29f6b1419c45e3baed0d6435ba03f5' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --without-threads \ + --without-http \ + --without-ftp \ + --without-python + + make -j$(nproc) +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/libxml2/package.yml b/land/libxml2/package.yml deleted file mode 100644 index 452569e9..00000000 --- a/land/libxml2/package.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: libxml2 -version: 2.9.9 -sources: - - url: ftp://xmlsoft.org/libxml2/libxml2-2.9.9.tar.gz -dependencies: - - zlib - - xz -patches: - - libxml2-2.9.9.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --without-threads - --without-http - --without-python -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libxml2.la diff --git a/land/mpc/PKGBUILD b/land/mpc/PKGBUILD new file mode 100644 index 00000000..e2125365 --- /dev/null +++ b/land/mpc/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=mpc +pkgver=1.2.0 +pkgrel=1 +pkgdesc="GNU MPC is a C library for the arithmetic of complex numbers with arbitrarily high precision and correct rounding of the result." +arch=('i786') +makedepend=('gmp' 'mpfr') +url="https://www.multiprecision.org" +source=( + "https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver.tar.gz" + "$pkgname-$pkgver.patch" +) +sha256sums=( + 'e90f2d99553a9c19911abdb4305bf8217106a957e3994436428572c8dfe8fda6' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/mpc/package.yml b/land/mpc/package.yml deleted file mode 100644 index c4ba968a..00000000 --- a/land/mpc/package.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: mpc -version: '1.2.0' -sources: - - url: https://ftp.gnu.org/gnu/mpc/mpc-1.2.0.tar.gz -dependencies: - - gmp - - mpfr -patch_skip_path: 0 -patches: - - mpc-1.2.0.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-shared - --with-gmp-include=$DESTDIR/usr/include - --with-gmp-lib=$DESTDIR/usr/lib - --with-mpfr-include=$DESTDIR/usr/include - --with-mpfr-lib=$DESTDIR/usr/lib -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libmpc.la diff --git a/land/mpfr/PKGBUILD b/land/mpfr/PKGBUILD new file mode 100644 index 00000000..49ec8d9a --- /dev/null +++ b/land/mpfr/PKGBUILD @@ -0,0 +1,35 @@ +pkgname=mpfr +pkgver=4.1.0 +pkgrel=1 +pkgdesc="The MPFR library is a C library for multiple-precision floating-point computations with correct rounding." +arch=('i786') +depend=('gmp') +url="https://www.mpfr.org" +source=( + "https://ftp.gnu.org/gnu/$pkgname/$pkgname-$pkgver/$pkgname-$pkgver.tar.xz" + "$pkgname-$pkgver.patch" +) +sha256sums=( + '0c98a3f1732ff6ca4ea690552079da9c597872d30e96ec28414ee23c95558a7f' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-shared + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/mpfr/package.yml b/land/mpfr/package.yml deleted file mode 100644 index ba96e217..00000000 --- a/land/mpfr/package.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: mpfr -version: 4.1.0 -sources: - - url: https://ftp.gnu.org/gnu/mpfr/mpfr-4.1.0.tar.xz -dependencies: - - gmp -patch_skip_path: 0 -patches: - - mpfr-4.1.0.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-shared - --with-gmp-include=$DESTDIR/usr/include - --with-gmp-lib=$DESTDIR/usr/lib -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libmpfr.la diff --git a/land/nano/PKGBUILD b/land/nano/PKGBUILD new file mode 100644 index 00000000..966e08bf --- /dev/null +++ b/land/nano/PKGBUILD @@ -0,0 +1,40 @@ +pkgname=nano +pkgver=4.2 +pkgrel=1 +pkgdesc="GNU nano is a small and friendly text editor." +arch=('i786') +depend=('ncurses') +url="https://www.nano-editor.org" +source=( + 'https://www.nano-editor.org/dist/v4/nano-4.2.tar.xz' + "$pkgname-$pkgver.patch" + 'nanorc' +) +sha256sums=( + '1143defce62e391b241252ffdb6e5c1ded56cfe26d46ee81b796abe0ccc45df9' + 'SKIP' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --disable-largefile \ + --disable-threads \ + --disable-speller \ + --disable-mouse + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/nano/nanorc b/land/nano/nanorc index 4a927c60..8ea1ab41 100644 --- a/land/nano/nanorc +++ b/land/nano/nanorc @@ -1,5 +1,6 @@ set linenumbers set titlecolor black,white set statuscolor black,white +set keycolor black,white set tabsize 4 include "/usr/share/nano/*.nanorc" diff --git a/land/nano/package.yml b/land/nano/package.yml deleted file mode 100644 index 42f76233..00000000 --- a/land/nano/package.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: nano -version: '4.2' -sources: - - url: https://www.nano-editor.org/dist/v4/nano-4.2.tar.xz - - file: nanorc -dependencies: - - ncurses -patches: - - nano-4.2.patch -configure: - - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --disable-largefile - --disable-threads - --disable-speller - --disable-mouse -make: - - make -install: - - cp nanorc $DESTDIR/etc/nanorc - - make install diff --git a/land/ncurses/PKGBUILD b/land/ncurses/PKGBUILD new file mode 100644 index 00000000..8dc2826a --- /dev/null +++ b/land/ncurses/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=ncurses +pkgver=6.1 +pkgrel=1 +pkgdesc="The ncurses (new curses) library is a free software emulation of curses in System V Release 4.0 (SVr4), and more." +arch=('i786') +url="https://invisible-island.net/ncurses/announce.html" +source=( + 'https://invisible-island.net/archives/ncurses/ncurses-6.1.tar.gz' + "$pkgname-$pkgver.patch" + 'xelix.terminfo' +) +sha256sums=( + 'aa057eeeb4a14d470101eff4597d5833dcef5965331be3528c08d99cebaa0d17' + 'SKIP' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --without-cxx-binding + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install + tic -o $pkgdir/usr/share/terminfo ../xelix.terminfo +} diff --git a/land/ncurses/package.yml b/land/ncurses/package.yml deleted file mode 100644 index 1e47d621..00000000 --- a/land/ncurses/package.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: ncurses -version: 6.1 -sources: - - url: ftp://ftp.gnu.org/gnu/ncurses/ncurses-6.1.tar.gz -patches: - - ncurses-6.1.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --without-cxx-binding -make: - - make -install: - - make install - - tic -o $DESTDIR/usr/share/terminfo $PKGDIR/xelix.terminfo diff --git a/land/newlib/package.yml b/land/newlib/package.yml deleted file mode 100644 index 0ee71775..00000000 --- a/land/newlib/package.yml +++ /dev/null @@ -1,41 +0,0 @@ -name: newlib -version: 3.2.0 -sources: - - url: http://sourceware.org/pub/newlib/newlib-3.2.0.tar.gz -patches: - - newlib-3.2.0.patch -set_cflags_sysroot: false -set_cflags_include: false -set_ldflags_libpath: false -configure: - - cp -r $PKGDIR/xelix newlib/libc/sys/ - - - cd newlib/libc/sys/xelix/ && aclocal-1.11 -I ../../../ -I ../../../../ - - cd newlib/libc/sys/xelix/ && autoconf-2.69 - - cd newlib/libc/sys/xelix/ && automake-1.11 --cygnus Makefile - - - cd newlib/libc/sys/ && aclocal-1.11 -I ../.. -I ../../.. - - cd newlib/libc/sys/ && autoconf-2.69 - - cd newlib/libc/sys/ && automake-1.11 --cygnus Makefile - - - ./configure - --target=i786-pc-xelix - --prefix=/usr - --exec-prefix=/usr - --sysconfdir=/etc - --enable-newlib-mb - --enable-newlib-iconv - --enable-newlib-io-c99-formats - --enable-newlib-io-long-long - --enable-newlib-io-long-double -make: - - make -install: - # Work around newlib build setup issues - - make DESTDIR=/tmp/newlib-install install - - cp -r /tmp/newlib-install/usr/i786-pc-xelix/* $DESTDIR/usr/ - - cp i786-pc-xelix/newlib/libc/sys/xelix/crti.o i786-pc-xelix/newlib/libc/sys/xelix/crtn.o $DESTDIR/usr/lib/ - - rm -r /tmp/newlib-install - - # Some GNU packages expect xlocale.h to exist - - ln -s locale.h $DESTDIR/usr/include/xlocale.h || true diff --git a/land/newlib/xelix/include/termios.h b/land/newlib/xelix/include/termios.h index d02fb7b9..d0056532 100644 --- a/land/newlib/xelix/include/termios.h +++ b/land/newlib/xelix/include/termios.h @@ -196,6 +196,8 @@ struct termios { #define TIOCGSOFTCAR 0x4014 #define TIOCSSOFTCAR 0x4015 +#define TCSLOGLEVEL 0x5000 + /* termios functions */ #ifndef _KERNEL_ speed_t cfgetispeed(const struct termios *); diff --git a/land/newlib/xelix/sys/socket.h b/land/newlib/xelix/sys/socket.h index e1c9e3ed..27c99054 100644 --- a/land/newlib/xelix/sys/socket.h +++ b/land/newlib/xelix/sys/socket.h @@ -89,6 +89,20 @@ struct sockaddr { char sa_data[]; }; +#define _SS_MAXSIZE 128U +#define _SS_ALIGNSIZE (sizeof(int64_t)) +#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof(unsigned char) - sizeof(sa_family_t)) +#define _SS_PAD2SIZE (_SS_MAXSIZE - sizeof(unsigned char) - sizeof(sa_family_t) - \ + _SS_PAD1SIZE - _SS_ALIGNSIZE) + +struct sockaddr_storage { + unsigned char ss_len; /* address length */ + sa_family_t ss_family; /* address family */ + char __ss_pad1[_SS_PAD1SIZE]; + int64_t __ss_align; /* force desired structure storage alignment */ + char __ss_pad2[_SS_PAD2SIZE]; +}; + struct msghdr { void* msg_name; socklen_t msg_namelen; diff --git a/land/nghttp2/PKGBUILD b/land/nghttp2/PKGBUILD new file mode 100644 index 00000000..9ebcedf6 --- /dev/null +++ b/land/nghttp2/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=nghttp2 +pkgver=1.58.0 +pkgrel=1 +epoch= +pkgdesc="This is an implementation of the Hypertext Transfer Protocol version 2 in C." +arch=('i786') +arch_override=('i786') +url="https://nghttp2.org" +license=('GPL') +makedepend=() +source=('https://github.com/nghttp2/nghttp2/releases/download/v1.58.0/nghttp2-1.58.0.tar.xz') +sha256sums=('4a68a3040da92fd9872c056d0f6b0cd60de8410de10b578f8ade9ecc14d297e0') + +prepare() { + cd $pkgname-$pkgver + echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-lib-only + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/nghttp3/PKGBUILD b/land/nghttp3/PKGBUILD new file mode 100644 index 00000000..46bc294d --- /dev/null +++ b/land/nghttp3/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=nghttp3 +pkgver=1.0.0 +pkgrel=2 +epoch= +pkgdesc="HTTP/3 library written in C" +arch=('i786') +arch_override=('i786') +url="https://nghttp2.org/nghttp3/" +license=('GPL') +makedepend=('openssl-quic') +source=('https://github.com/ngtcp2/nghttp3/releases/download/v1.0.0/nghttp3-1.0.0.tar.xz') +sha256sums=('2d982fadb92ba6488cd5ef3dadc9d2c901084c812553aea9ab1c4bfa1215f77a') + +prepare() { + cd $pkgname-$pkgver + echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub +} + +build() { + cd $pkgname-$pkgver + CPPFLAGS="$CPPFLAGS -D__int64_t_defined" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --enable-lib-only + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/ngtcp2/PKGBUILD b/land/ngtcp2/PKGBUILD new file mode 100644 index 00000000..2e6b539b --- /dev/null +++ b/land/ngtcp2/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=ngtcp2 +pkgver=1.0.1 +pkgrel=1 +epoch= +pkgdesc="ngtcp2 project is an effort to implement IETF QUIC protocol." +arch=('i786') +arch_override=('i786') +url="https://nghttp2.org/ngtcp2/" +license=('GPL') +makedepend=('openssl-quic') +source=('https://github.com/ngtcp2/ngtcp2/releases/download/v1.0.1/ngtcp2-1.0.1.tar.xz') +sha256sums=('21c898fa5543d3f2dc203fd0a300a8a7cb70fec21ad7f7a3ec6e119ba4850451') + +prepare() { + cd $pkgname-$pkgver + echo -e "#!/bin/sh\necho i786-pc-xelix" > config.sub +} + +build() { + cd $pkgname-$pkgver + CPPFLAGS="$CPPFLAGS -D__int64_t_defined" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --with-openssl + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/openssl-quic/50-xelix.conf b/land/openssl-quic/50-xelix.conf new file mode 100644 index 00000000..fb5258a4 --- /dev/null +++ b/land/openssl-quic/50-xelix.conf @@ -0,0 +1,14 @@ +## -*- mode: perl; -*- + +( + "xelix-x86" => { + inherit_from => [ "BASE_unix" ], + CC => "gcc", + CFLAGS => "-fomit-frame-pointer -O3 -Wall", + bn_ops => "BN_LLONG", + asm_arch => 'x86', + perlasm_scheme => "elf", + thread_scheme => undef, + dso_scheme => undef, + } +); diff --git a/land/openssl-quic/PKGBUILD b/land/openssl-quic/PKGBUILD new file mode 100644 index 00000000..8ea1af20 --- /dev/null +++ b/land/openssl-quic/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=openssl-quic +pkgver=3.1.4 +pkgrel=2 +pkgdesc="A robust, commercial-grade, full-featured toolkit for general-purpose cryptography and secure communication." +arch=('i786') +provides=('openssl') +replaces=('openssl') +makedepend=('zlib') +url="https://www.openssl.org/" +source=( + 'https://github.com/quictls/openssl/archive/refs/tags/openssl-3.1.4-quic1.tar.gz' + "$pkgname-$pkgver.patch" + '50-xelix.conf' +) +sha256sums=( + '4bf990243d6aa39b8befa0c399834415842912ef67f88bef98e74dc619469618' + 'SKIP' + 'SKIP' +) + +prepare() { + cd openssl-openssl-3.1.4-quic1 + patch -p0 < ../$pkgname-$pkgver.patch + cp ../50-xelix.conf Configurations +} + +build() { + cd openssl-openssl-3.1.4-quic1 + CROSS_COMPILE=i786-pc-xelix- ./Configure xelix-x86 no-shared no-threads no-dso 386 no-sse2 no-tests --prefix=/usr --openssldir=/etc/ssl -DDSO_NONE + make -j$(nproc) +} + +package() { + cd openssl-openssl-3.1.4-quic1 + make DESTDIR=$pkgdir install +} diff --git a/land/openssl-quic/openssl-quic-3.1.4.patch b/land/openssl-quic/openssl-quic-3.1.4.patch new file mode 100644 index 00000000..a4c40f4b --- /dev/null +++ b/land/openssl-quic/openssl-quic-3.1.4.patch @@ -0,0 +1,198 @@ +--- crypto/dso/dso_lib.c ++++ crypto/dso/dso_lib.c.new +@@ -12,6 +12,7 @@ + + static DSO *DSO_new_method(DSO_METHOD *meth) + { ++#ifndef __xelix__ + DSO *ret; + + ret = OPENSSL_zalloc(sizeof(*ret)); +@@ -42,15 +43,19 @@ + } + + return ret; ++#endif + } + + DSO *DSO_new(void) + { ++#ifndef __xelix__ + return DSO_new_method(NULL); ++#endif + } + + int DSO_free(DSO *dso) + { ++#ifndef __xelix__ + int i; + + if (dso == NULL) +@@ -82,6 +87,7 @@ + CRYPTO_THREAD_lock_free(dso->lock); + OPENSSL_free(dso); + return 1; ++#endif + } + + int DSO_flags(DSO *dso) +@@ -91,6 +97,8 @@ + + int DSO_up_ref(DSO *dso) + { ++#ifndef __xelix__ ++ + int i; + + if (dso == NULL) { +@@ -104,10 +112,12 @@ + REF_PRINT_COUNT("DSO", dso); + REF_ASSERT_ISNT(i < 2); + return ((i > 1) ? 1 : 0); ++#endif + } + + DSO *DSO_load(DSO *dso, const char *filename, DSO_METHOD *meth, int flags) + { ++#ifndef __xelix__ + DSO *ret; + int allocated = 0; + +@@ -158,10 +168,12 @@ + if (allocated) + DSO_free(ret); + return NULL; ++#endif + } + + DSO_FUNC_TYPE DSO_bind_func(DSO *dso, const char *symname) + { ++#ifndef __xelix__ + DSO_FUNC_TYPE ret = NULL; + + if ((dso == NULL) || (symname == NULL)) { +@@ -178,6 +190,7 @@ + } + /* Success */ + return ret; ++#endif + } + + /* +@@ -191,6 +204,8 @@ + */ + long DSO_ctrl(DSO *dso, int cmd, long larg, void *parg) + { ++#ifndef __xelix__ ++ + if (dso == NULL) { + ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER); + return -1; +@@ -216,19 +231,24 @@ + return -1; + } + return dso->meth->dso_ctrl(dso, cmd, larg, parg); ++#endif + } + + const char *DSO_get_filename(DSO *dso) + { ++#ifndef __xelix__ + if (dso == NULL) { + ERR_raise(ERR_LIB_DSO, ERR_R_PASSED_NULL_PARAMETER); + return NULL; + } + return dso->filename; ++#endif + } + + int DSO_set_filename(DSO *dso, const char *filename) + { ++#ifndef __xelix__ ++ + char *copied; + + if ((dso == NULL) || (filename == NULL)) { +@@ -248,10 +268,12 @@ + OPENSSL_free(dso->filename); + dso->filename = copied; + return 1; ++#endif + } + + char *DSO_merge(DSO *dso, const char *filespec1, const char *filespec2) + { ++#ifndef __xelix__ + char *result = NULL; + + if (dso == NULL || filespec1 == NULL) { +@@ -265,10 +287,12 @@ + result = dso->meth->dso_merger(dso, filespec1, filespec2); + } + return result; ++#endif + } + + char *DSO_convert_filename(DSO *dso, const char *filename) + { ++#ifndef __xelix__ + char *result = NULL; + + if (dso == NULL) { +@@ -295,10 +319,13 @@ + } + } + return result; ++#endif + } + + int DSO_pathbyaddr(void *addr, char *path, int sz) + { ++#ifndef __xelix__ ++ + DSO_METHOD *meth = DSO_METHOD_openssl(); + + if (meth->pathbyaddr == NULL) { +@@ -306,10 +333,12 @@ + return -1; + } + return (*meth->pathbyaddr) (addr, path, sz); ++#endif + } + + DSO *DSO_dsobyaddr(void *addr, int flags) + { ++#ifndef __xelix__ + DSO *ret = NULL; + char *filename = NULL; + int len = DSO_pathbyaddr(addr, NULL, 0); +@@ -324,10 +353,12 @@ + + OPENSSL_free(filename); + return ret; ++#endif + } + + void *DSO_global_lookup(const char *name) + { ++#ifndef __xelix__ + DSO_METHOD *meth = DSO_METHOD_openssl(); + + if (meth->globallookup == NULL) { +@@ -335,4 +366,5 @@ + return NULL; + } + return (*meth->globallookup) (name); ++#endif + } +--- crypto/asn1/a_time.c ++++ crypto/asn1/a_time.c.new +@@ -7,6 +7,8 @@ + * https://www.openssl.org/source/license.html + */ + ++#define __DJGPP__ ++ + /*- + * This is an implementation of the ASN1 Time structure which is: + * Time ::= CHOICE { diff --git a/land/openssl/openssl-1.1.1d.patch b/land/openssl/openssl-1.1.1d.patch deleted file mode 100644 index 2ac125ca..00000000 --- a/land/openssl/openssl-1.1.1d.patch +++ /dev/null @@ -1,74 +0,0 @@ ---- openssl-1.1.1d/Configurations/10-main.conf 2019-05-28 15:12:21.000000000 +0200 -+++ openssl-1.1.1d/Configurations/10-main.conf 2019-10-09 03:00:43.867226129 +0200 -@@ -1572,6 +1572,20 @@ my %targets = ( - shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)", - }, - -+ "xelix-x86" => { -+ inherit_from => [ "BASE_unix" ], -+ inherit_from => [ asm("x86_elf_asm") ], -+ CC => "gcc", -+ CFLAGS => "-O3 -fomit-frame-pointer -Wall", -+ bn_ops => "BN_LLONG", -+ thread_scheme => "(unknown)", -+ dso_scheme => "(unknown)", -+ shared_target => "gnu-shared", -+ shared_cflag => "-fPIC", -+ shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)", -+ }, -+ -+ - ##### VxWorks for various targets - "vxworks-ppc60x" => { - inherit_from => [ "BASE_unix" ], ---- openssl-1.1.1d/crypto/dso/dso_lib.c 2019-05-28 15:12:21.000000000 +0200 -+++ openssl-1.1.1d/crypto/dso/dso_lib.c 2020-01-10 13:13:20.036417430 +0100 -@@ -14,6 +14,7 @@ static DSO_METHOD *default_DSO_meth = NU - - static DSO *DSO_new_method(DSO_METHOD *meth) - { -+#if 0 - DSO *ret; - - if (default_DSO_meth == NULL) { -@@ -52,6 +53,8 @@ static DSO *DSO_new_method(DSO_METHOD *m - } - - return ret; -+#endif -+ return NULL; - } - - DSO *DSO_new(void) -@@ -309,6 +312,8 @@ char *DSO_convert_filename(DSO *dso, con - - int DSO_pathbyaddr(void *addr, char *path, int sz) - { -+ return -1; -+#if 0 - DSO_METHOD *meth = default_DSO_meth; - if (meth == NULL) - meth = DSO_METHOD_openssl(); -@@ -317,6 +322,7 @@ int DSO_pathbyaddr(void *addr, char *pat - return -1; - } - return (*meth->pathbyaddr) (addr, path, sz); -+#endif - } - - DSO *DSO_dsobyaddr(void *addr, int flags) -@@ -339,6 +345,8 @@ DSO *DSO_dsobyaddr(void *addr, int flags - - void *DSO_global_lookup(const char *name) - { -+ return NULL; -+#if 0 - DSO_METHOD *meth = default_DSO_meth; - if (meth == NULL) - meth = DSO_METHOD_openssl(); -@@ -347,4 +355,5 @@ void *DSO_global_lookup(const char *name - return NULL; - } - return (*meth->globallookup) (name); -+#endif - } diff --git a/land/openssl/package.yml b/land/openssl/package.yml deleted file mode 100644 index 5c565055..00000000 --- a/land/openssl/package.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: openssl -version: 1.1.1d -sources: - - url: https://www.openssl.org/source/openssl-1.1.1d.tar.gz -patches: - - openssl-1.1.1d.patch -configure: - - CROSS_COMPILE=i786-pc-xelix- ./Configure xelix-x86 no-shared no-threads no-hw no-dso no-asm 386 no-sse2 no-zlib no-tests --prefix=/usr -make: - - make -install: - # wtf openssl - - make DESTDIR=$DESTDIR install diff --git a/land/pacman/Makefile.xelix b/land/pacman/Makefile.xelix new file mode 100644 index 00000000..ad8b88bc --- /dev/null +++ b/land/pacman/Makefile.xelix @@ -0,0 +1,22 @@ +.PHONY: all +all: pacman + +%.o: %.c + i786-pc-xelix-gcc $(CFLAGS) -Isrc/common -Ilib/libalpm -D_FILE_OFFSET_BITS=64 -std=gnu99 -O0 -g -include xelixconfig.h -o $@ -c $< + +libalpm.a: lib/libalpm/add.o lib/libalpm/alpm.o lib/libalpm/alpm_list.o lib/libalpm/backup.o lib/libalpm/base64.o lib/libalpm/be_local.o lib/libalpm/be_package.o lib/libalpm/be_sync.o lib/libalpm/conflict.o lib/libalpm/db.o lib/libalpm/deps.o lib/libalpm/diskspace.o lib/libalpm/dload.o lib/libalpm/error.o lib/libalpm/filelist.o lib/libalpm/graph.o lib/libalpm/group.o lib/libalpm/handle.o lib/libalpm/hook.o lib/libalpm/log.o lib/libalpm/package.o lib/libalpm/pkghash.o lib/libalpm/rawstr.o lib/libalpm/remove.o lib/libalpm/signing.o lib/libalpm/sync.o lib/libalpm/trans.o lib/libalpm/util.o lib/libalpm/version.o + ar rcs $@ $< + +pacman: libalpm.a src/pacman/callback.o src/pacman/check.o src/pacman/conf.o src/pacman/database.o src/pacman/deptest.o src/pacman/files.o src/pacman/package.o src/pacman/pacman.o src/pacman/query.o src/pacman/remove.o src/pacman/sighandler.o src/pacman/sync.o src/pacman/upgrade.o src/pacman/util.o src/pacman/ini.c src/pacman/util-common.c + i786-pc-xelix-gcc -o $@ src/pacman/callback.o src/pacman/check.o src/pacman/conf.o src/pacman/database.o src/pacman/deptest.o src/pacman/files.o src/pacman/package.o src/pacman/pacman.o src/pacman/query.o src/pacman/remove.o src/pacman/sighandler.o src/pacman/sync.o src/pacman/upgrade.o src/pacman/util.o src/pacman/ini.c src/pacman/util-common.c lib/libalpm/add.o lib/libalpm/alpm.o lib/libalpm/alpm_list.o lib/libalpm/backup.o lib/libalpm/base64.o lib/libalpm/be_local.o lib/libalpm/be_package.o lib/libalpm/be_sync.o lib/libalpm/conflict.o lib/libalpm/db.o lib/libalpm/deps.o lib/libalpm/diskspace.o lib/libalpm/dload.o lib/libalpm/error.o lib/libalpm/filelist.o lib/libalpm/graph.o lib/libalpm/group.o lib/libalpm/handle.o lib/libalpm/hook.o lib/libalpm/log.o lib/libalpm/package.o lib/libalpm/pkghash.o lib/libalpm/rawstr.o lib/libalpm/remove.o lib/libalpm/signing.o lib/libalpm/sync.o lib/libalpm/trans.o lib/libalpm/util.o lib/libalpm/version.o -L. $(LDFLAGS) -larchive -lcurl -lnghttp2 -lnghttp3 -lngtcp2 -lssl -lcrypto -lbz2 -lxml2 -llzma -lz -lm + +.PHONY: clean +clean: + find . -iname "*.o" -delete + +.PHONY: install +install: + install -d $(DESTDIR)/usr/lib + install -D libalpm.a $(DESTDIR)/usr/lib + install -d $(DESTDIR)/usr/bin + install -D pacman $(DESTDIR)/usr/bin diff --git a/land/pacman/PKGBUILD b/land/pacman/PKGBUILD new file mode 100644 index 00000000..e2229e48 --- /dev/null +++ b/land/pacman/PKGBUILD @@ -0,0 +1,39 @@ +pkgname=pacman +pkgver=6.0.2 +pkgrel=4 +pkgdesc="Pacman - package management combining a simple binary package format with an easy-to-use build system." +arch=('i786') +makedepend=('libarchive' 'curl' 'openssl' 'nghttp2' 'nghttp3' 'ngtcp2' 'bzip2' 'libxml2' 'xz' 'zlib') +url="https://gitlab.archlinux.org/pacman/pacman" +source=( + 'https://gitlab.archlinux.org/pacman/pacman/-/archive/v6.0.2/pacman-v6.0.2.tar.gz' + "$pkgname-$pkgver.patch" + 'Makefile.xelix' + 'xelixconfig.h' + 'pacman.conf' +) +sha256sums=( + 'e39eab7f2cbd7cd802f56bc33e677df22a31caf7887ec4fae4d2b1649a95e410' + 'SKIP' + 'SKIP' + 'SKIP' + 'SKIP' +) + +prepare() { + cd $pkgname-v$pkgver + patch -p1 < ../$pkgname-$pkgver.patch + cp ../Makefile.xelix ../xelixconfig.h . +} + +build() { + cd $pkgname-v$pkgver + make -f Makefile.xelix +} + +package() { + cd $pkgname-v$pkgver + make -f Makefile.xelix DESTDIR=$pkgdir install + install -d $pkgdir/etc + install -D ../pacman.conf $pkgdir/etc +} diff --git a/land/pacman/pacman-6.0.2.patch b/land/pacman/pacman-6.0.2.patch new file mode 100644 index 00000000..c398e9a1 --- /dev/null +++ b/land/pacman/pacman-6.0.2.patch @@ -0,0 +1,158 @@ +diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c +index 6293b753..343b458b 100644 +--- a/lib/libalpm/diskspace.c ++++ b/lib/libalpm/diskspace.c +@@ -219,6 +219,7 @@ static alpm_mountpoint_t *match_mount_point(const alpm_list_t *mount_points, + static int calculate_removed_size(alpm_handle_t *handle, + const alpm_list_t *mount_points, alpm_pkg_t *pkg) + { ++ #ifndef __xelix__ + size_t i; + alpm_filelist_t *filelist = alpm_pkg_get_files(pkg); + +@@ -274,6 +275,7 @@ static int calculate_removed_size(alpm_handle_t *handle, + mp->blocks_needed -= remove_size; + mp->used |= USED_REMOVE; + } ++ #endif + + return 0; + } +@@ -281,6 +283,7 @@ static int calculate_removed_size(alpm_handle_t *handle, + static int calculate_installed_size(alpm_handle_t *handle, + const alpm_list_t *mount_points, alpm_pkg_t *pkg) + { ++ #ifndef __xelix__ + size_t i; + alpm_filelist_t *filelist = alpm_pkg_get_files(pkg); + +@@ -333,12 +336,14 @@ static int calculate_installed_size(alpm_handle_t *handle, + mp->blocks_needed += install_size; + mp->used |= USED_INSTALL; + } ++ #endif + + return 0; + } + + static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp) + { ++ #ifndef __xelix__ + /* cushion is roughly min(5% capacity, 20MiB) */ + fsblkcnt_t fivepc = (mp->fsp.f_blocks / 20) + 1; + fsblkcnt_t twentymb = (20 * 1024 * 1024 / mp->fsp.f_bsize) + 1; +@@ -355,12 +360,14 @@ static int check_mountpoint(alpm_handle_t *handle, alpm_mountpoint_t *mp) + mp->mount_dir, (intmax_t)needed, (uintmax_t)mp->fsp.f_bavail); + return 1; + } ++ #endif + return 0; + } + + int _alpm_check_downloadspace(alpm_handle_t *handle, const char *cachedir, + size_t num_files, const off_t *file_sizes) + { ++ #ifndef __xelix__ + alpm_list_t *mount_points; + alpm_mountpoint_t *cachedir_mp; + char resolved_cachedir[PATH_MAX]; +@@ -414,6 +421,7 @@ finish: + if(error) { + RET_ERR(handle, ALPM_ERR_DISK_SPACE, -1); + } ++ #endif + + return 0; + } +diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h +index 8dac7bb6..413223b8 100644 +--- a/lib/libalpm/diskspace.h ++++ b/lib/libalpm/diskspace.h +@@ -53,7 +53,7 @@ typedef struct __alpm_mountpoint_t { + enum mount_used_level used; + int read_only; + enum mount_fsinfo fsinfo_loaded; +- FSSTATSTYPE fsp; ++ void* fsp; + } alpm_mountpoint_t; + + int _alpm_check_diskspace(alpm_handle_t *handle); +diff --git a/lib/libalpm/log.c b/lib/libalpm/log.c +index c4d291cb..ee97a4f7 100644 +--- a/lib/libalpm/log.c ++++ b/lib/libalpm/log.c +@@ -76,6 +76,7 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix, + + va_start(args, fmt); + ++ #ifndef __xelix__ + if(handle->usesyslog) { + /* we can't use a va_list more than once, so we need to copy it + * so we can use the original when calling vfprintf below. */ +@@ -84,6 +85,7 @@ int SYMEXPORT alpm_logaction(alpm_handle_t *handle, const char *prefix, + vsyslog(LOG_WARNING, fmt, args_syslog); + va_end(args_syslog); + } ++ #endif + + if(handle->logstream) { + if(_alpm_log_leader(handle->logstream, prefix) < 0 +diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c +index 299d287e..60a10fb4 100644 +--- a/lib/libalpm/util.c ++++ b/lib/libalpm/util.c +@@ -613,7 +613,11 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[], + /* Flush open fds before fork() to avoid cloning buffers */ + fflush(NULL); + ++ #ifdef __xelix__ ++ if(1) { ++ #else + if(socketpair(AF_UNIX, SOCK_STREAM, 0, child2parent_pipefd) == -1) { ++ #endif + _alpm_log(handle, ALPM_LOG_ERROR, _("could not create pipe (%s)\n"), strerror(errno)); + retval = 1; + goto cleanup; +diff --git a/src/common/util-common.c b/src/common/util-common.c +index 3f547d3b..6a1ca445 100644 +--- a/src/common/util-common.c ++++ b/src/common/util-common.c +@@ -188,7 +188,7 @@ size_t strtrim(char *str) + return end - pch; + } + +-#ifndef HAVE_STRNLEN ++#ifndef __xelix__ + /* A quick and dirty implementation derived from glibc */ + /** Determines the length of a fixed-size string. + * @param s string to be measured +diff --git a/src/pacman/conf.c b/src/pacman/conf.c +index 12fee64c..915b41ec 100644 +--- a/src/pacman/conf.c ++++ b/src/pacman/conf.c +@@ -1059,7 +1059,7 @@ static int process_include(const char *value, void *data, + "config file %s, line %d: include globbing out of space\n", + file, linenum); + break; +- case GLOB_ABORTED: ++ case GLOB_ERR: + pm_printf(ALPM_LOG_DEBUG, + "config file %s, line %d: include globbing read error for %s\n", + file, linenum, value); +diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c +index e398855a..56a765e6 100644 +--- a/src/pacman/pacman.c ++++ b/src/pacman/pacman.c +@@ -1170,10 +1170,12 @@ int main(int argc, char *argv[]) + cleanup(EXIT_FAILURE); + } + ++ #ifndef __xelix__ + if(!freopen(ctermid(NULL), "r", stdin)) { + pm_printf(ALPM_LOG_ERROR, _("failed to reopen stdin for reading: (%s)\n"), + strerror(errno)); + } ++ #endif + + if(!target_found) { + pm_printf(ALPM_LOG_ERROR, _("argument '-' specified with empty stdin\n")); diff --git a/land/pacman/pacman.conf b/land/pacman/pacman.conf new file mode 100644 index 00000000..f59ec646 --- /dev/null +++ b/land/pacman/pacman.conf @@ -0,0 +1,80 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +Color +#NoProgressBar +#CheckSpace +#VerbosePkgLists +#ParallelDownloads = 5 + +# PGP signature checking +#SigLevel = Optional DatabaseOptional +#LocalFileSigLevel = Optional +#RemoteFileSigLevel = Optional + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# An example of a disabled remote package repository with multiple servers +# available. To enable, uncomment the following lines. You can add preferred +# servers immediately after the header and they will be used before the +# default mirrors. +#[core] +#SigLevel = Required +#Server = ftp://ftp.example.com/foobar/$repo/os/$arch/ +# The file referenced here should contain a list of 'Server = ' lines. +#Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/packages + +[core] +Server = https://pkgs.xelix.org/core/i786/ diff --git a/land/pacman/pacman.linux.conf b/land/pacman/pacman.linux.conf new file mode 100644 index 00000000..8bd9741e --- /dev/null +++ b/land/pacman/pacman.linux.conf @@ -0,0 +1,80 @@ +# +# /etc/pacman.conf +# +# See the pacman.conf(5) manpage for option and repository directives + +# +# GENERAL OPTIONS +# +[options] +# The following paths are commented out with their default values listed. +# If you wish to use different paths, uncomment and update the paths. +#RootDir = / +#DBPath = /var/lib/pacman/ +#CacheDir = /var/cache/pacman/pkg/ +#LogFile = /var/log/pacman.log +#GPGDir = /etc/pacman.d/gnupg/ +#HookDir = /etc/pacman.d/hooks/ +HoldPkg = pacman +#XferCommand = /usr/bin/curl -L -C - -f -o %o %u +#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u +#CleanMethod = KeepInstalled +Architecture = auto + +# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup +#IgnorePkg = +#IgnoreGroup = + +#NoUpgrade = +#NoExtract = + +# Misc options +#UseSyslog +Color +#NoProgressBar +#CheckSpace +#VerbosePkgLists +#ParallelDownloads = 5 + +# PGP signature checking +SigLevel = Never +LocalFileSigLevel = Never +RemoteFileSigLevel = Never + +# +# REPOSITORIES +# - can be defined here or included from another file +# - pacman will search repositories in the order defined here +# - local/custom mirrors can be added here or in separate files +# - repositories listed first will take precedence when packages +# have identical names, regardless of version number +# - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture +# +# Repository entries are of the format: +# [repo-name] +# Server = ServerName +# Include = IncludePath +# +# The header [repo-name] is crucial - it must be present and +# uncommented to enable the repo. +# + +# An example of a disabled remote package repository with multiple servers +# available. To enable, uncomment the following lines. You can add preferred +# servers immediately after the header and they will be used before the +# default mirrors. +#[core] +#SigLevel = Required +#Server = ftp://ftp.example.com/foobar/$repo/os/$arch/ +# The file referenced here should contain a list of 'Server = ' lines. +#Include = /etc/pacman.d/mirrorlist + +# An example of a custom package repository. See the pacman manpage for +# tips on creating your own repositories. +#[custom] +#SigLevel = Optional TrustAll +#Server = file:///home/packages + +[core] +Server = https://pkgs.xelix.org/core/i786/ diff --git a/land/pacman/xelixconfig.h b/land/pacman/xelixconfig.h new file mode 100644 index 00000000..fde51f22 --- /dev/null +++ b/land/pacman/xelixconfig.h @@ -0,0 +1,73 @@ +#pragma once + +#define CACHEDIR "/var/cache/pacman/pkg/" + +#define CONFFILE "/etc/pacman.conf" + +#define DBPATH "/var/lib/pacman/" + +#undef ENABLE_NLS + +#define FSSTATSTYPE struct statvfs + +#define GPGDIR "/etc/pacman.d/gnupg/" + +#undef HAVE_GETMNTENT + +#define HAVE_LIBCURL 1 + +#undef HAVE_LIBGPGME + +#define HAVE_LIBSSL 1 + +#define HAVE_MNTENT_H + +#define HAVE_STRNDUP 1 + +#define HAVE_STRNLEN 1 + +#define HAVE_STRSEP 1 + +#undef HAVE_STRUCT_STATFS_F_FLAGS + +#define HAVE_STRUCT_STATVFS_F_FLAG + +#define HAVE_STRUCT_STAT_ST_BLKSIZE + +#define HAVE_SWPRINTF 1 + +#define HAVE_SYS_MOUNT_H + +#define HAVE_SYS_PARAM_H + +#undef HAVE_SYS_STATVFS_H + +#define HAVE_SYS_TYPES_H + +#define HAVE_TCFLUSH 1 + +#define HAVE_TERMIOS_H + +#define HOOKDIR "/etc/pacman.d/hooks/" + +#define LDCONFIG "/sbin/ldconfig" + +#define LIB_VERSION "13.0.1" + +#define LOCALEDIR "/usr/share/locale" + +#define LOGFILE "/var/log/pacman.log" + +#define PACKAGE "pacman" + +#define PACKAGE_VERSION "6.0.1" + +#define PACMAN_DEBUG 1 + +#define ROOTDIR "/" + +#define SCRIPTLET_SHELL "/bin/sh" + +#define SYSHOOKDIR "/usr/share/libalpm/hooks/" + +#define _GNU_SOURCE diff --git a/land/pciutils/PKGBUILD b/land/pciutils/PKGBUILD new file mode 100644 index 00000000..e5a2657c --- /dev/null +++ b/land/pciutils/PKGBUILD @@ -0,0 +1,53 @@ +pkgname=pciutils +pkgver=3.6.2 +pkgrel=1 +pkgdesc="A library for portable access to PCI bus configuration registers and several utilities based on this library." +arch=('i786') +makedepend=('zlib') +url="https://github.com/pciutils/pciutils" +source=( + 'https://github.com/pciutils/pciutils/archive/v3.6.2.tar.gz' + "$pkgname-$pkgver.patch" + 'xelix-device.c' +) +sha256sums=( + 'd84d7096a71890f0ddddc50e88ac5a3bc7412bf48d8100fc15857a411564687d' + 'SKIP' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch + cp xelix-device.c $pkgname-$pkgver/lib +} + +build() { + cd $pkgname-$pkgver + make \ + CROSS_COMPILE=i786-pc-xelix- \ + HOST=pc-xelix \ + CFLAGS="$CFLAGS -I$SYSROOT/usr/include" \ + LDFLAGS="$LDFLAGS -L$SYSROOT/usr/lib" \ + DNS=no \ + ZLIB=yes \ + PREFIX=/usr \ + BINDIR=/usr/bin \ + SBINDIR=/usr/bin \ + DESTDIR=$pkgdir +} + +package() { + cd $pkgname-$pkgver + make \ + CROSS_COMPILE=i786-pc-xelix- \ + HOST=pc-xelix \ + CFLAGS="$CFLAGS -I$SYSROOT/usr/include" \ + LDFLAGS="$LDFLAGS -L$SYSROOT/usr/lib" \ + DNS=no \ + ZLIB=yes \ + PREFIX=/usr \ + BINDIR=/usr/bin \ + SBINDIR=/usr/bin \ + DESTDIR=$pkgdir \ + install +} diff --git a/land/pciutils/package.yml b/land/pciutils/package.yml deleted file mode 100644 index a3e2c41a..00000000 --- a/land/pciutils/package.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: pciutils -version: 3.6.2 -sources: - - url: https://github.com/pciutils/pciutils/archive/v3.6.2.tar.gz -dependencies: - - zlib -patches: - - pciutils-3.6.2.patch -configure: - - cp $PKGDIR/xelix-device.c lib/ -make: - - make - CROSS_COMPILE=i786-pc-xelix- - HOST=pc-xelix - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" - LDFLAGS="$LDFLAGS -L$DESTDIR/usr/lib" - DNS=no - ZLIB=yes - PREFIX=/usr - BINDIR=/usr/bin - SBINDIR=/usr/bin - DESTDIR=$DESTDIR -install: - - make - CROSS_COMPILE=i786-pc-xelix- - HOST=pc-xelix - CFLAGS="$CFLAGS" - LDFLAGS="$LDFLAGS" - DNS=no - ZLIB=yes - PREFIX=/usr - BINDIR=/usr/bin - SBINDIR=/usr/bin - DESTDIR=$DESTDIR - install diff --git a/land/pcre2/PKGBUILD b/land/pcre2/PKGBUILD new file mode 100644 index 00000000..f08d458e --- /dev/null +++ b/land/pcre2/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=pcre2 +pkgver=10.32 +pkgrel=1 +pkgdesc="The PCRE2 library is a set of C functions that implement regular expression pattern matching using the same syntax and semantics as Perl 5." +arch=('i786') +url="https://github.com/PCRE2Project/pcre2" +source=( + 'https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.32/pcre2-10.32.tar.bz2' + "$pkgname-$pkgver.patch" +) +sha256sums=( + 'f29e89cc5de813f45786580101aaee3984a65818631d4ddbda7b32f699b87c2e' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/pcre2/package.yml b/land/pcre2/package.yml deleted file mode 100644 index b6d422e8..00000000 --- a/land/pcre2/package.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: pcre2 -version: 10.32 -sources: - - url: https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.32/pcre2-10.32.tar.bz2 -patches: - - pcre2-10.32.patch -configure: - - ./configure --host=i786-pc-xelix --prefix=/usr --sysconfdir=/etc -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/libpcre2-8.la - - rm $DESTDIR/usr/lib/libpcre2-posix.la diff --git a/land/pixman/PKGBUILD b/land/pixman/PKGBUILD new file mode 100644 index 00000000..1cc384ac --- /dev/null +++ b/land/pixman/PKGBUILD @@ -0,0 +1,37 @@ +pkgname=pixman +pkgver=0.38.4 +pkgrel=1 +pkgdesc="Pixman is a low-level software library for pixel manipulation, providing features such as image compositing and trapezoid rasterization." +arch=('i786') +url="https://pixman.org" +source=( + 'https://cairographics.org/releases/pixman-0.38.4.tar.gz' + "$pkgname.patch" +) +sha256sums=( + 'da66d6fd6e40aee70f7bd02e4f8f76fc3f006ec879d346bae6a723025cfbdde7' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname.patch +} + +build() { + cd $pkgname-$pkgver + CFLAGS="-DPIXMAN_NO_TLS" ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --disable-mmx \ + --disable-vmx + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/pixman/package.yml b/land/pixman/package.yml deleted file mode 100644 index aecd9f83..00000000 --- a/land/pixman/package.yml +++ /dev/null @@ -1,20 +0,0 @@ -name: pixman -version: '0.38.4' -sources: - - url: https://cairographics.org/releases/pixman-0.38.4.tar.gz -patch_skip_path: 0 -patches: - - pixman.patch -configure: - - CFLAGS="-g -DPIXMAN_NO_TLS" LDFLAGS="-g" ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --localstatedir=/var - --disable-mmx - --disable-vmx -make: - - make -install: - - make DESTDIR=$DESTDIR install - - rm $DESTDIR/usr/lib/libpixman-1.la diff --git a/land/tar/PKGBUILD b/land/tar/PKGBUILD new file mode 100644 index 00000000..e0603634 --- /dev/null +++ b/land/tar/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=tar +pkgver=1.32 +pkgrel=1 +pkgdesc="GNU Tar provides the ability to create tar archives, as well as various other kinds of manipulation." +arch=('i786') +url="https://www.gnu.org/software/tar/" +source=( + 'https://ftp.gnu.org/gnu/tar/tar-1.32.tar.xz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + 'd0d3ae07f103323be809bc3eac0dcc386d52c5262499fe05511ac4788af1fdd8' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/tar/package.yml b/land/tar/package.yml deleted file mode 100644 index 0e7f46ec..00000000 --- a/land/tar/package.yml +++ /dev/null @@ -1,15 +0,0 @@ -name: tar -version: '1.32' -sources: - - url: https://ftp.gnu.org/gnu/tar/tar-1.32.tar.xz -patches: - - tar-1.32.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make install diff --git a/land/tmux/PKGBUILD b/land/tmux/PKGBUILD new file mode 100644 index 00000000..88b26c6d --- /dev/null +++ b/land/tmux/PKGBUILD @@ -0,0 +1,34 @@ +pkgname=tmux +pkgver=3.3a +pkgrel=1 +pkgdesc="tmux is a terminal multiplexer: it enables a number of terminals to be created, accessed, and controlled from a single screen." +arch=('i786') +url="https://github.com/tmux/tmux" +source=( + 'https://github.com/tmux/tmux/releases/download/3.3a/tmux-3.3a.tar.gz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + 'e4fd347843bd0772c4f48d6dde625b0b109b7a380ff15db21e97c11a4dcdf93f' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/tz/package.yml b/land/tz/package.yml deleted file mode 100644 index 3e1184c2..00000000 --- a/land/tz/package.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: tz -version: '2019c' -sources: - - url: https://data.iana.org/time-zones/releases/tzdb-2019c.tar.lz -patch_skip_path: 0 -patches: - - tz.patch -make: - - make CC=i786-pc-xelix-gcc -install: - - make CC=i786-pc-xelix-gcc ZIC=zic DESTDIR=$DESTDIR install diff --git a/land/tzdb/PKGBUILD b/land/tzdb/PKGBUILD new file mode 100644 index 00000000..1885cb01 --- /dev/null +++ b/land/tzdb/PKGBUILD @@ -0,0 +1,29 @@ +pkgname=tzdb +pkgver=2019a +pkgrel=2 +pkgdesc="The Time Zone Database (often called tz or zoneinfo) contains code and data that represent the history of local time for many representative locations around the globe." +arch=('i786') +url="https://www.iana.org/time-zones" +source=( + "https://data.iana.org/time-zones/releases/tzdb-$pkgver.tar.lz" + "tz.patch" +) +sha256sums=( + '16d10794dd8de8eb21abbf21e74020b5e1b0227ea1f094299b0b4467954eecc7' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../tz.patch +} + +build() { + cd $pkgname-$pkgver + make CC=i786-pc-xelix-gcc ZICDIR=/usr/bin +} + +package() { + cd $pkgname-$pkgver + make CC=i786-pc-xelix-gcc ZIC=zic ZICDIR=/usr/bin DESTDIR=$pkgdir install +} diff --git a/land/tz/tz.patch b/land/tzdb/tz.patch similarity index 100% rename from land/tz/tz.patch rename to land/tzdb/tz.patch diff --git a/land/vim/PKGBUILD b/land/vim/PKGBUILD new file mode 100644 index 00000000..d6a2fa51 --- /dev/null +++ b/land/vim/PKGBUILD @@ -0,0 +1,36 @@ +pkgname=vim +pkgver=8.1 +pkgrel=1 +pkgdesc="Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient." +arch=('i786') +makedepend=('ncurses') +url="https://www.vim.org/" +source=('ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2') +sha256sums=('8b69fbd01c877dd8ecbbeca1dc66e5e927228d631ac4c2174b9307eb5c827c86') + +build() { + cd vim81 + + ac_cv_sizeof_int=4 \ + vim_cv_getcwd_broken=no \ + vim_cv_memmove_handles_overlap=yes \ + vim_cv_stat_ignores_slash=yes \ + vim_cv_tgetent=zero \ + vim_cv_terminfo=yes \ + vim_cv_toupper_broken=no \ + vim_cv_tty_group=world \ + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --with-tlib=ncurses + + cd src && sh osdef.sh && cd .. + make +} + +package() { + cd vim81 + make DESTDIR=$pkgdir install + ln -s vim $pkgdir/usr/bin/vi +} diff --git a/land/vim/package.yml b/land/vim/package.yml deleted file mode 100644 index 3573d48c..00000000 --- a/land/vim/package.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: vim -version: 8.1 -sources: - - url: ftp://ftp.vim.org/pub/vim/unix/vim-8.1.tar.bz2 -dependencies: - - ncurses -configure: - - ac_cv_sizeof_int=4 - vim_cv_getcwd_broken=no - vim_cv_memmove_handles_overlap=yes - vim_cv_stat_ignores_slash=yes - vim_cv_tgetent=zero - vim_cv_terminfo=yes - vim_cv_toupper_broken=no - vim_cv_tty_group=world - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --with-tlib=ncurses - - cd src && sh osdef.sh -make: - - make -install: - - make install - - ln -s vim $DESTDIR/usr/bin/vi diff --git a/land/wget/PKGBUILD b/land/wget/PKGBUILD new file mode 100644 index 00000000..fe0cd81f --- /dev/null +++ b/land/wget/PKGBUILD @@ -0,0 +1,40 @@ +pkgname=wget +pkgver=1.20.3 +pkgrel=3 +pkgdesc="GNU Wget is a free software package for retrieving files using HTTP, HTTPS, FTP and FTPS, the most widely used Internet protocols. " +arch=('i786') +makedepend=('zlib' 'pcre2' 'openssl') +url="https://www.gnu.org/software/wget/" +source=( + 'https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz' + "$pkgname-$pkgver.patch" + "$pkgname-$pkgver-two.patch" +) +sha256sums=( + '31cccfc6630528db1c8e3a06f6decf2a370060b982841cfab2b8677400a5092e' + 'SKIP' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc \ + --with-ssl=openssl \ + --disable-threads \ + --without-libpsl + + patch -p1 < ../$pkgname-$pkgver-two.patch + make -j$(nproc) +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/wget/package.yml b/land/wget/package.yml deleted file mode 100644 index b49d95b2..00000000 --- a/land/wget/package.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: wget -version: 1.20.3 -sources: - - url: https://ftp.gnu.org/gnu/wget/wget-1.20.3.tar.gz -dependencies: - - zlib - - pcre2 - - openssl -patches: - - wget-1.20.3.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc - --with-ssl=openssl - --disable-threads - --without-libpsl - - # Needs to be applied after configure - - patch -p1 < $PKGDIR/wget-1.20.3-two.patch -make: - - make -install: - - make install diff --git a/land/wget/wget-1.20.3.patch b/land/wget/wget-1.20.3.patch index 881e41f2..1ba651a1 100644 --- a/land/wget/wget-1.20.3.patch +++ b/land/wget/wget-1.20.3.patch @@ -268,25 +268,24 @@ diff -rupN wget-1.20.3/src/ptimer.c wget-1.20.3/src/ptimer.c + return 0; return IMPL_resolution (); } -diff -rupN wget-1.20.3/src/retr.c wget-1.20.3/src/retr.c ---- wget-1.20.3/src/retr.c 2018-12-26 20:58:39.000000000 +0100 -+++ wget-1.20.3/src/retr.c 2019-10-09 08:44:14.435631938 +0200 -@@ -254,6 +254,7 @@ fd_read_body (const char *downloaded_fil - wgint *qtyread, wgint *qtywritten, double *elapsed, int flags, - FILE *out2) +--- wget-1.20.3/src/utils.c ++++ wget-1.20.3/src/utils.c +@@ -113,6 +113,10 @@ + #include "exits.h" + #include "c-strcase.h" + ++#ifdef __xelix__ ++# undef ITIMER_REAL ++#endif ++ + _Noreturn static void + memfatal (const char *context, long attempted_size) { -+ fprintf(stderr, "fd_read_body\n"); - int ret = 0; - #undef max - #define max(a,b) ((a) > (b) ? (a) : (b)) -diff -rupN wget-1.20.3/src/utils.c wget-1.20.3/src/utils.c ---- wget-1.20.3/src/utils.c 2018-12-26 20:58:39.000000000 +0100 -+++ wget-1.20.3/src/utils.c 2019-10-09 09:03:29.170539288 +0200 -@@ -430,13 +430,17 @@ concat_strings (const char *str0, ...) +@@ -431,13 +435,17 @@ static char * fmttime (time_t t, const char *fmt) { -+ return "stub"; ++ return ""; +/* static char output[32]; + @@ -298,6 +297,5 @@ diff -rupN wget-1.20.3/src/utils.c wget-1.20.3/src/utils.c return output; +*/ } - + /* Return pointer to a static char[] buffer in which zero-terminated - diff --git a/land/which/PKGBUILD b/land/which/PKGBUILD new file mode 100644 index 00000000..e5b24bf0 --- /dev/null +++ b/land/which/PKGBUILD @@ -0,0 +1,23 @@ +pkgname=which +pkgver=2.21 +pkgrel=1 +pkgdesc="A utility that is used to find which executable (or alias or shell function) is executed when entered on the shell prompt. " +arch=('i786') +url="https://savannah.gnu.org/projects/which" +source=('https://ftp.gnu.org/gnu/which/which-2.21.tar.gz') +sha256sums=('f4a245b94124b377d8b49646bf421f9155d36aa7614b6ebf83705d3ffc76eaad') + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/which/package.yml b/land/which/package.yml deleted file mode 100644 index deab2121..00000000 --- a/land/which/package.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: which -version: 2.21 -sources: - - url: https://ftp.gnu.org/gnu/which/which-2.21.tar.gz -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make install diff --git a/land/xelix-kernel/PKGBUILD b/land/xelix-kernel/PKGBUILD new file mode 100644 index 00000000..e9f9836d --- /dev/null +++ b/land/xelix-kernel/PKGBUILD @@ -0,0 +1,27 @@ +pkgname=xelix-kernel +pkgver=git +pkgrel=1 +epoch= +pkgdesc="The Xelix kernel binary" +arch=('i786') +url="https://github.com/lutoma/xelix" +license=('GPL') +source=('xelix::git+https://github.com/lutoma/xelix.git') +sha256sums=('SKIP') + +pkgver() { + cd xelix + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + cd xelix + ./configure + make +} + +package() { + cd xelix + install -d $pkgdir/boot + install -D xelix.bin $pkgdir/boot +} diff --git a/land/xelix-utils/PKGBUILD b/land/xelix-utils/PKGBUILD new file mode 100644 index 00000000..3cf4ac02 --- /dev/null +++ b/land/xelix-utils/PKGBUILD @@ -0,0 +1,23 @@ +pkgname=xelix-utils +pkgver=r2576.fb8939c5 +pkgrel=2 +epoch= +pkgdesc="A suite of Xelix-specific standard system utilities." +arch=('i786') +url="https://github.com/lutoma/xelix/tree/main/land/xelix-utils" +license=('GPL') +depends=('font-fira-code' 'gfxcompd') +makedepends=('flac' 'freetype' 'libpng') +source=() + +pkgver() { + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + CFLAGS="$CFLAGS -I$SYSROOT/usr/include/freetype2" make +} + +package() { + make DESTDIR=$pkgdir install +} diff --git a/land/xelix-utils/package.yml b/land/xelix-utils/package.yml deleted file mode 100644 index 7531f05b..00000000 --- a/land/xelix-utils/package.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: xelix-utils -version: 0.1.0 -sources: - - dir: src -dependencies: - - font-fira-code - - gfxcompd - - flac - - freetype - - libpng -make: - - CFLAGS="$CFLAGS -I$DESTDIR/usr/include" make -install: - - make install diff --git a/land/xelix-utils/src/Makefile b/land/xelix-utils/src/Makefile index 52ee5742..be047469 100644 --- a/land/xelix-utils/src/Makefile +++ b/land/xelix-utils/src/Makefile @@ -20,7 +20,7 @@ play: play.c $(CC) $(CFLAGS) -o $@ play.c -L. -lFLAC -lm -lutil gfxterm: gfxterm.c tmt.c tmt.h - $(CC) $(CFLAGS) -o $@ tmt.c gfxterm.c -I$(DESTDIR)/usr/include -I$(DESTDIR)/usr/include/freetype2 -lxelixgfx -lfreetype -lpng -lz -lm -lbz2 + $(CC) $(CFLAGS) -o $@ tmt.c gfxterm.c -lxelixgfx -lfreetype -lpng -lz -lm -lbz2 png: png.c $(CC) $(CFLAGS) -o $@ png.c -lxelixgfx -lpng -lz -lm diff --git a/land/xelix-utils/src/init.c b/land/xelix-utils/src/init.c index af631845..00eba964 100644 --- a/land/xelix-utils/src/init.c +++ b/land/xelix-utils/src/init.c @@ -26,8 +26,10 @@ #include #include #include +#include #include #include +#include #include "util.h" #include "ini.h" @@ -158,14 +160,16 @@ static char* get_target() { } - int main() { if(getpid() != 1) { fprintf(stderr, "This program needs to be run as PID 1.\n"); return -1; } - open("/dev/console", O_RDONLY); + int console_fd = open("/dev/console", O_RDONLY); + int level = 0; + ioctl(console_fd, TCSLOGLEVEL, &level); + sigset_t set; sigfillset(&set); sigprocmask(SIG_SETMASK, &set, NULL); diff --git a/land/xz/PKGBUILD b/land/xz/PKGBUILD new file mode 100644 index 00000000..13810b15 --- /dev/null +++ b/land/xz/PKGBUILD @@ -0,0 +1,33 @@ +pkgname=xz +pkgver=5.2.4 +pkgrel=1 +pkgdesc="XZ Utils is free general-purpose data compression software with a high compression ratio." +arch=('i786') +url="https://tukaani.org/xz/" +source=( + 'https://tukaani.org/xz/xz-5.2.4.tar.xz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + '9717ae363760dedf573dad241420c5fea86256b65bc21d2cf71b2b12f0544f4b' + 'SKIP' +) + +prepare() { + patch -p0 < $pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/xz/package.yml b/land/xz/package.yml deleted file mode 100644 index 0af4a799..00000000 --- a/land/xz/package.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: xz -version: '5.2.4' -sources: - - url: https://tukaani.org/xz/xz-5.2.4.tar.xz -patches: - - xz-5.2.4.patch -configure: - - ./configure - --host=i786-pc-xelix - --prefix=/usr - --sysconfdir=/etc -make: - - make -install: - - make install - - rm $DESTDIR/usr/lib/liblzma.la diff --git a/land/zlib/PKGBUILD b/land/zlib/PKGBUILD new file mode 100644 index 00000000..729d2ffb --- /dev/null +++ b/land/zlib/PKGBUILD @@ -0,0 +1,19 @@ +pkgname=zlib +pkgver=1.2.11 +pkgrel=1 +pkgdesc="A Massively Spiffy Yet Delicately Unobtrusive Compression Library" +arch=('i786') +url="https://zlib.net" +source=('https://zlib.net/fossils/zlib-1.2.11.tar.gz') + +sha256sums=('c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1') + +build() { + cd $pkgname-$pkgver + CC=i786-pc-xelix-gcc ./configure --static --prefix=/usr --sysconfdir=/etc +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/land/zlib/package.yml b/land/zlib/package.yml deleted file mode 100644 index e24b8c1e..00000000 --- a/land/zlib/package.yml +++ /dev/null @@ -1,10 +0,0 @@ -name: zlib -version: 1.2.11 -sources: - - url: https://zlib.net/fossils/zlib-1.2.11.tar.gz -configure: - - CC=i786-pc-xelix-gcc ./configure --static --prefix=/usr --sysconfdir=/etc -make: - - make -install: - - make install diff --git a/land/zsh/PKGBUILD b/land/zsh/PKGBUILD new file mode 100644 index 00000000..97cb881f --- /dev/null +++ b/land/zsh/PKGBUILD @@ -0,0 +1,34 @@ +pkgname=zsh +pkgver=5.9 +pkgrel=1 +pkgdesc="Zsh is a shell designed for interactive use, although it is also a powerful scripting language." +arch=('i786') +url="ttps://www.zsh.org" +source=( + 'https://www.zsh.org/pub/zsh-5.9.tar.xz' + "$pkgname-$pkgver.patch" +) +sha256sums=( + '9b8d1ecedd5b5e81fbf1918e876752a7dd948e05c1a0dba10ab863842d45acd5' + 'SKIP' +) + +prepare() { + cd $pkgname-$pkgver + patch -p0 < ../$pkgname-$pkgver.patch +} + +build() { + cd $pkgname-$pkgver + ./configure \ + --host=i786-pc-xelix \ + --prefix=/usr \ + --sysconfdir=/etc + + make +} + +package() { + cd $pkgname-$pkgver + make DESTDIR=$pkgdir install +} diff --git a/src/block/block.c b/src/block/block.c index 63df19a4..a0036a8c 100644 --- a/src/block/block.c +++ b/src/block/block.c @@ -186,7 +186,7 @@ void vfs_block_register_dev(char* name, uint64_t start_offset, } } -void block_init() { +void block_init(void) { ide_init(); #ifdef CONFIG_ENABLE_VIRTIO_BLOCK diff --git a/src/block/block.h b/src/block/block.h index 61811b9f..8a0c3e05 100644 --- a/src/block/block.h +++ b/src/block/block.h @@ -53,4 +53,4 @@ struct vfs_block_dev* vfs_block_get_dev(const char* path); void vfs_block_register_dev(char* name, uint64_t start_offset, vfs_block_read_cb read_cb, vfs_block_write_cb write_cb, void* meta); -void block_init(); +void block_init(void); diff --git a/src/block/i386-ide.c b/src/block/i386-ide.c index d865c54f..e4d1d737 100644 --- a/src/block/i386-ide.c +++ b/src/block/i386-ide.c @@ -53,22 +53,22 @@ struct ide_dev { uint8_t slave; }; -void inportsm(unsigned short port, unsigned char * data, unsigned long size) { +static void inportsm(unsigned short port, unsigned char * data, unsigned long size) { asm volatile ("rep insw" : "+D" (data), "+c" (size) : "d" (port) : "memory"); } -void outportsm(unsigned short port, unsigned char * data, unsigned long size) { +static void outportsm(unsigned short port, unsigned char * data, unsigned long size) { asm volatile ("rep outsw" : "+S" (data), "+c" (size) : "d" (port)); } -void ata_io_wait(struct ide_dev* dev) { +static void ata_io_wait(struct ide_dev* dev) { inb(dev->bus + ATA_REG_ALTSTATUS); inb(dev->bus + ATA_REG_ALTSTATUS); inb(dev->bus + ATA_REG_ALTSTATUS); inb(dev->bus + ATA_REG_ALTSTATUS); } -int ata_wait(struct ide_dev* dev, int advanced) { +static int ata_wait(struct ide_dev* dev, int advanced) { uint8_t status = 0; ata_io_wait(dev); @@ -85,15 +85,15 @@ int ata_wait(struct ide_dev* dev, int advanced) { return 0; } -void ata_select(struct ide_dev* dev) { +static void ata_select(struct ide_dev* dev) { outb(dev->bus + ATA_REG_HDDEVSEL, 0xA0); } -void ata_wait_ready(struct ide_dev* dev) { +static void ata_wait_ready(struct ide_dev* dev) { while (inb(dev->bus + ATA_REG_STATUS) & ATA_SR_BSY); } -struct ide_dev* ide_init_device(uint16_t bus) { +static struct ide_dev* ide_init_device(uint16_t bus) { struct ide_dev* dev = zmalloc(sizeof(struct ide_dev)); dev->bus = bus; dev->slave = 0; @@ -158,7 +158,7 @@ static inline int do_read(struct ide_dev* dev, uint64_t lba, void* buf) { } -uint64_t ide_read_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t num_blocks, void* buf) { +static uint64_t ide_read_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t num_blocks, void* buf) { struct ide_dev* dev = (struct ide_dev*)block_dev->meta; for(int i = 0; i < num_blocks; i++) { @@ -192,7 +192,7 @@ static inline int do_write(struct ide_dev* dev, uint64_t lba, void* buf) { return 0; } -uint64_t ide_write_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t num_blocks, void* buf) { +static uint64_t ide_write_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t num_blocks, void* buf) { struct ide_dev* dev = (struct ide_dev*)block_dev->meta; for(int i = 0; i < num_blocks; i++) { @@ -204,7 +204,7 @@ uint64_t ide_write_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t nu return num_blocks; } -void ide_init() { +void ide_init(void) { struct ide_dev* dev = ide_init_device(0x1F0); vfs_block_register_dev("ide1", 0, ide_read_cb, ide_write_cb, (void*)dev); } diff --git a/src/block/i386-ide.h b/src/block/i386-ide.h index acafb9bc..33feeaf5 100644 --- a/src/block/i386-ide.h +++ b/src/block/i386-ide.h @@ -103,7 +103,7 @@ #define ATA_READ 0x00 #define ATA_WRITE 0x01 -void ide_init(); +void ide_init(void); bool ide_read_sector(uint16_t bus, uint8_t slave, uint32_t lba, uint8_t * buf); void ide_write_sector(uint16_t bus, uint8_t slave, uint32_t lba, uint8_t * buf); //void ide_write_sector_retry(uint16_t bus, uint8_t slave, uint32_t lba, uint8_t * buf); diff --git a/src/block/null.c b/src/block/null.c index 3f0667d2..1dde0102 100644 --- a/src/block/null.c +++ b/src/block/null.c @@ -17,6 +17,7 @@ * along with Xelix. If not, see . */ +#include #include #include diff --git a/src/block/part.c b/src/block/part.c index e4d017f7..5d26aa12 100644 --- a/src/block/part.c +++ b/src/block/part.c @@ -17,6 +17,7 @@ * along with Xelix. If not, see . */ +#include #include #include #include diff --git a/src/block/part.h b/src/block/part.h index 99c63765..5cefb8e8 100644 --- a/src/block/part.h +++ b/src/block/part.h @@ -18,6 +18,8 @@ * along with Xelix. If not, see . */ +#include + bool part_read(uint32_t lba, uint8_t * buf); void part_write(uint32_t lba, uint8_t * buf); void vfs_part_probe(struct vfs_block_dev* dev); diff --git a/src/block/random.c b/src/block/random.c index 0ca28eba..f351d10f 100644 --- a/src/block/random.c +++ b/src/block/random.c @@ -17,6 +17,7 @@ * along with Xelix. If not, see . */ +#include #include #define UPPER_MASK 0x80000000 @@ -36,7 +37,7 @@ void block_random_seed(uint64_t seed) { } } -static inline uint64_t getnum() { +static inline uint64_t getnum(void) { uint64_t y; // mag[x] = x * 0x9908b0df for x = 0,1 static uint64_t mag[2] = {0x0, 0x9908b0df}; @@ -87,7 +88,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return size; } -void block_random_init() { +void block_random_init(void) { struct vfs_callbacks sfs_cb = { .read = sfs_read, }; diff --git a/src/block/random.h b/src/block/random.h index 1412dc0d..0659719f 100644 --- a/src/block/random.h +++ b/src/block/random.h @@ -19,4 +19,4 @@ */ void block_random_seed(uint64_t seed); -void block_random_init(); +void block_random_init(void); diff --git a/src/block/virtio.c b/src/block/virtio.c index f25ecc27..69907601 100644 --- a/src/block/virtio.c +++ b/src/block/virtio.c @@ -19,6 +19,7 @@ #ifdef CONFIG_ENABLE_VIRTIO_BLOCK +#include #include #include #include @@ -63,12 +64,12 @@ static void int_handler(task_t* task, isf_t* state, int num) { inb(dev->pci_dev->iobase + 0x13); } -static uint64_t send_request(struct virtio_dev* dev, int type, uint64_t lba, uint64_t num_blocks, void* buf) { +static uint64_t send_request(struct virtio_dev* rdev, int type, uint64_t lba, uint64_t num_blocks, void* buf) { if(num_blocks < 1) { return -1; } - if(!(dev->status & VIRTIO_PCI_STATUS_DRIVER_OK)) { + if(!(rdev->status & VIRTIO_PCI_STATUS_DRIVER_OK)) { return -1; } @@ -95,7 +96,7 @@ static uint64_t send_request(struct virtio_dev* dev, int type, uint64_t lba, uin int user_buffer_flag = (type == VIRTIO_BLK_T_IN) ? VIRTQ_DESC_F_WRITE : 0; int flags[] = {0, user_buffer_flag, VIRTQ_DESC_F_WRITE}; - if(virtio_write(dev, 0, 3, buffers, lengths, flags) < 0) { + if(virtio_write(rdev, 0, 3, buffers, lengths, flags) < 0) { return -1; } @@ -134,30 +135,35 @@ static uint64_t write_cb(struct vfs_block_dev* block_dev, uint64_t lba, uint64_t return send_request(dev, VIRTIO_BLK_T_OUT, lba, num_blocks, buf); } -void virtio_block_init() { - pci_device_t** devices = (pci_device_t**)kmalloc(sizeof(void*)); - uint32_t ndevices = pci_search(devices, vendor_device_combos, 1); - log(LOG_INFO, "virtio_block: Discovered %d devices.\n", ndevices); +static int pci_cb(pci_device_t* pci_dev) { + if(pci_check_vendor(pci_dev, vendor_device_combos) != 0) { + return 1; + } - if(ndevices) { - dev = virtio_init_dev(devices[0], 0, 1); - if(!dev) { - return; - } + log(LOG_INFO, "virtio_block: Discovered device %p\n", pci_dev); - if(dev->features & VIRTIO_BLK_F_RO) { - log(LOG_INFO, "virtio_block: Device is read-only\n"); - } + dev = virtio_init_dev(pci_dev, 0, 1); + if(!dev) { + return 1; + } + + if(dev->features & VIRTIO_BLK_F_RO) { + log(LOG_INFO, "virtio_block: Device is read-only\n"); + } - dev->queues[0].available->flags = VIRTQ_AVAIL_F_NO_INTERRUPT; - dev->queues[0].used->flags = VIRTQ_USED_F_NO_NOTIFY; - int_register(IRQ(dev->pci_dev->interrupt_line), int_handler, false); + dev->queues[0].available->flags = VIRTQ_AVAIL_F_NO_INTERRUPT; + dev->queues[0].used->flags = VIRTQ_USED_F_NO_NOTIFY; + int_register(IRQ(dev->pci_dev->interrupt_line), int_handler, false); - dev->status |= VIRTIO_PCI_STATUS_DRIVER_OK; - virtio_write_status(dev); + dev->status |= VIRTIO_PCI_STATUS_DRIVER_OK; + virtio_write_status(dev); - vfs_block_register_dev("vioblk1", (uint64_t)0, read_cb, write_cb, NULL); - } + vfs_block_register_dev("vioblk1", (uint64_t)0, read_cb, write_cb, NULL); + return 0; +} + +void virtio_block_init(void) { + pci_walk(pci_cb); } #endif /* ENABLE_VIRTIO_BLOCK */ diff --git a/src/block/virtio.h b/src/block/virtio.h index 323adacd..79a41da5 100644 --- a/src/block/virtio.h +++ b/src/block/virtio.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void virtio_block_init(); +void virtio_block_init(void); diff --git a/src/boot/i386-multiboot.c b/src/boot/i386-multiboot.c index f1418155..28fd54f8 100644 --- a/src/boot/i386-multiboot.c +++ b/src/boot/i386-multiboot.c @@ -68,15 +68,15 @@ static char* tag_type_names[] = { "image_phys_addr" // 21 }; -struct multiboot_tag_mmap* multiboot_get_mmap() { +struct multiboot_tag_mmap* multiboot_get_mmap(void) { return mmap_info; } -struct multiboot_tag_basic_meminfo* multiboot_get_meminfo() { +struct multiboot_tag_basic_meminfo* multiboot_get_meminfo(void) { return mem_info; } -struct multiboot_tag_framebuffer* multiboot_get_framebuffer() { +struct multiboot_tag_framebuffer* multiboot_get_framebuffer(void) { return &framebuffer_info; } @@ -90,7 +90,7 @@ char* multiboot_get_strtab(size_t* length) { return strtab; } -char* multiboot_get_cmdline() { +char* multiboot_get_cmdline(void) { return cmdline; } @@ -119,7 +119,7 @@ static int extract_symtab(struct multiboot_tag_elf_sections* multiboot_tag) { return r; } -void multiboot_init() { +void multiboot_init(void) { if(multiboot_magic != MULTIBOOT2_BOOTLOADER_MAGIC) { panic("Bootloader is not multiboot2 compliant (eax 0x%x != 0x%x).\n", multiboot_magic, MULTIBOOT2_BOOTLOADER_MAGIC); diff --git a/src/boot/init.c b/src/boot/init.c index be65e1d9..ee02641b 100644 --- a/src/boot/init.c +++ b/src/boot/init.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -46,6 +47,8 @@ #include #endif +void xelix_main(void); + // Used in lib/errno.h uint32_t __dummy_errno; @@ -89,7 +92,7 @@ void xelix_main(void) { log(LOG_INFO, "Starting %s\n", init_path); char* __env[] = { NULL }; - char* __argv[] = { vfs_basename(init_path), NULL }; + char* __argv[] = { basename(init_path), NULL }; task_t* init = task_new(NULL, 0, init_path, __env, 0, __argv, 1); if(!init) { diff --git a/src/boot/multiboot.h b/src/boot/multiboot.h index e94b203c..b5f533cc 100644 --- a/src/boot/multiboot.h +++ b/src/boot/multiboot.h @@ -330,13 +330,13 @@ struct multiboot_tag_load_base_addr #endif /* ! ASM_FILE */ -void multiboot_init(); -struct multiboot_tag_mmap* multiboot_get_mmap(); -struct multiboot_tag_basic_meminfo* multiboot_get_meminfo(); -struct multiboot_tag_framebuffer* multiboot_get_framebuffer(); +void multiboot_init(void); +struct multiboot_tag_mmap* multiboot_get_mmap(void); +struct multiboot_tag_basic_meminfo* multiboot_get_meminfo(void); +struct multiboot_tag_framebuffer* multiboot_get_framebuffer(void); struct elf_sym* multiboot_get_symtab(size_t* length); char* multiboot_get_strtab(size_t* length); -char* multiboot_get_cmdline(); +char* multiboot_get_cmdline(void); #endif /* ! MULTIBOOT_HEADER */ diff --git a/src/bsp/i386-pci.c b/src/bsp/i386-pci.c index 32efc356..2e5fa7b1 100644 --- a/src/bsp/i386-pci.c +++ b/src/bsp/i386-pci.c @@ -1,7 +1,5 @@ -/* pci.c: PCI stack - * Copyright © 2011 Barbers - * Copyright © 2011 Fritz Grimpen - * Copyright © 2011-2018 Lukas Martini +/* pci.c: PCI support functions + * Copyright © 2011-2023 Lukas Martini * * This file is part of Xelix. * @@ -20,127 +18,139 @@ */ #include -#include +#include +#include #include +#include #include -#include -#include +#include -#define PCI_CONFIG_DATA 0x0CFC -#define PCI_CONFIG_ADDRESS 0x0CF8 +#define PORT_CONFIG_ADDR 0x0CF8 +#define PORT_CONFIG_DATA 0x0CFC -#define get_header_type(device) ((uint16_t)pci_config_read(device, 0xe) & 127) +#define CONFIG_HEADER_DEVICE 2 +#define CONFIG_HEADER_REVISION 8 +#define CONFIG_HEADER_PROG_IF 9 +#define CONFIG_HEADER_SUBCLASS 10 +#define CONFIG_HEADER_CLASS 11 +#define CONFIG_HEADER_TYPE 15 +#define CONFIG_HEADER_INT_LINE 0x3c +#define CONFIG_HEADER_INT_PIN 0x3d #define get_address(bus, dev, func, offset) (0x80000000 | (bus << 16) | \ (dev << 11) | (func << 8) | (offset & 0xFC)) -static pci_device_t* first_device = NULL; +static pci_device_t* pci_devices = NULL; -uint32_t _pci_config_read(uint8_t bus, uint8_t dev, uint8_t func, - uint8_t offset) { +uint32_t pci_config_read(pci_device_t* dev, uint8_t offset, int size) { + uint32_t addr = get_address(dev->bus, dev->dev, dev->func, offset); + outl(PORT_CONFIG_ADDR, addr); - outl(PCI_CONFIG_ADDRESS, get_address(bus, dev, func, offset)); - if(!(offset % 4)) { - return inl(PCI_CONFIG_DATA); + switch(size) { + case 4: + return inl(PORT_CONFIG_DATA); + case 2: + return inw(PORT_CONFIG_DATA + (offset & 2)); + case 1: + return inb(PORT_CONFIG_DATA + (offset & 3)); + default: + return -1; } - - return (inl(PCI_CONFIG_DATA) >> ((offset % 4) * 8)) & 0xffff; } -void _pci_config_write(uint8_t bus, uint8_t dev, uint8_t func, - uint8_t offset, uint32_t val) { - - outl(PCI_CONFIG_ADDRESS, get_address(bus, dev, func, offset)); - outl(PCI_CONFIG_DATA, val); +void pci_config_write(pci_device_t* dev, uint8_t offset, uint32_t val) { + uint32_t addr = get_address(dev->bus, dev->dev, dev->func, offset); + outl(PORT_CONFIG_ADDR, addr); + outl(PORT_CONFIG_DATA, val); } -uint32_t pci_get_BAR(pci_device_t* device, uint8_t bar) { - if(bar > 5) { - return 0; - } +uint32_t pci_get_bar(pci_device_t* device, uint8_t bar) { + assert(bar <= 5); - uint8_t header_type = get_header_type(device); - if(header_type == 0x2 || (header_type == 0x1 && bar < 2)) { + if(unlikely(device->header_type == 0x2 || (device->header_type == 0x1 && bar < 2))) { return 0; } uint8_t _register = 0x10 + 0x4 * bar; - return pci_config_read(device, _register); + return pci_config_read(device, _register, 4); } -static uint32_t get_IO_base(pci_device_t* device) { - uint8_t bars = 6 - get_header_type(device) * 4; +static inline void try_load_device(uint8_t bus, uint8_t dev, uint8_t func) { + outl(PORT_CONFIG_ADDR, get_address(bus, dev, func, 0)); + uint16_t vendor = inw(PORT_CONFIG_DATA); + + /* Non-existant pdevs should have all config bits pulled high, but on + * some chipsets (emulators?) they were zero. + */ + if(vendor == 0xffff || vendor == 0) { + return; + } - for(int i = 0; i < bars; i++) { - uint32_t bar = pci_get_BAR(device, i); - if(bar & 0x1) { - return bar & 0xfffffffc; + pci_device_t* pdev = kmalloc(sizeof(pci_device_t)); + + pdev->bus = bus; + pdev->dev = dev; + pdev->func = func; + pdev->vendor = vendor; + pdev->header_type = pci_config_read(pdev, CONFIG_HEADER_TYPE, 1); + pdev->device = pci_config_read(pdev, CONFIG_HEADER_DEVICE, 2); + pdev->revision = pci_config_read(pdev, CONFIG_HEADER_REVISION, 1); + pdev->prog_if = pci_config_read(pdev, CONFIG_HEADER_PROG_IF, 1); + pdev->subclass = pci_config_read(pdev, CONFIG_HEADER_SUBCLASS, 1); + pdev->class = pci_config_read(pdev, CONFIG_HEADER_CLASS, 1); + + if(pdev->header_type == 0) { + pdev->interrupt_line = pci_config_read(pdev, CONFIG_HEADER_INT_LINE, 1); + pdev->interrupt_pin = pci_config_read(pdev, CONFIG_HEADER_INT_PIN, 1); + + for(int i = 0; i < 6; i++) { + uint32_t bar = pci_get_bar(pdev, i); + if(bar & 0x1 && !pdev->iobase) { + pdev->iobase = bar & 0xfffffff0; + } else if(!(bar & 0x1) && !pdev->membase) { + pdev->membase = bar & 0xfffffff0; + } } } - return 0; -} + pdev->next = pci_devices; + pci_devices = pdev; -// TODO Make sure this actually works -static uint32_t get_mem_base(pci_device_t* device) { - uint8_t bars = 6 - get_header_type(device) * 4; + log(LOG_INFO, " %02d:%02d.%d: %04x:%04x rev %-2x class %04x iobase %-4x type %-2x int %-2d pin %d\n", + pdev->bus, pdev->dev, pdev->func, pdev->vendor, + pdev->device, pdev->revision, pdev->class, + pdev->iobase, pdev->header_type, pdev->interrupt_line, + pdev->interrupt_pin); +} - for(int i = 0; i < bars; i++) { - uint32_t bar = pci_get_BAR(device, i++); - if(!(bar & 0x1)) { - return bar & 0xfffffff0; +int pci_walk(int (*callback)(pci_device_t* dev)) { + for(pci_device_t* dev = pci_devices; dev; dev = dev->next) { + int ret = callback(dev); + if(ret < 1) { + return ret; } } return 0; } -static void load_device(pci_device_t *device, uint8_t bus, uint8_t dev, uint8_t func) { - device->bus = bus; - device->dev = dev; - device->func = func; - - device->vendor = (uint16_t)pci_config_read(device, 0); - device->device = (uint16_t)pci_config_read(device, 2); - device->revision = (uint16_t)pci_config_read(device, 0x8); - device->class = (uint16_t)(pci_config_read(device, 0x8) >> 16); - device->iobase = get_IO_base(device); - device->membase = get_mem_base(device); - device->header_type = get_header_type(device); - device->interrupt_pin = (uint16_t)pci_config_read(device, 0x3d); - device->interrupt_line = (uint16_t)pci_config_read(device, 0x3c); -} - -/* Searches a PCI device by vendor and device IDs. - * rdev should be an empty allocated array, the size of which should be specified in max. - * vendor_device_combos should be a NULL-terminated array of the format +/* Checks a PCI device against an array of vendor + device ID combos. * * static uint32_t vendor_device_combos[][2] = { * {vendor_id, device_id}, * {vendor_id, device_id}, - * {NULL} + * {(uint32_t)NULL} * }; */ -uint32_t pci_search(pci_device_t** rdev, const uint32_t vendor_device_combos[][2], uint32_t max) { - if(!vendor_device_combos[0] || !vendor_device_combos[0][0]) { - return 0; - } - - int devices_found = 0; - for(int i = 0; vendor_device_combos[i][0]; i++) { - pci_device_t* dev = first_device; - for(; dev && devices_found < max; dev = dev->next) { - if (dev->vendor != vendor_device_combos[i][0] || - dev->device != vendor_device_combos[i][1]) - continue; - - rdev[devices_found] = dev; - devices_found++; +int pci_check_vendor(pci_device_t* dev, const uint32_t combos[][2]) { + for(int i = 0; combos[i][0]; i++) { + if(dev->vendor == combos[i][0] && dev->device == combos[i][1]) { + return 0; } } - return devices_found; + return -1; } static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { @@ -149,42 +159,24 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { } size_t rsize = 0; - pci_device_t* dev = first_device; + pci_device_t* dev = pci_devices; for(; dev; dev = dev->next) { + uint16_t combined_class = dev->class << 8 | dev->subclass; sysfs_printf("%02d:%02d.%d %04x:%04x %-2x %-2x %-4x %-2x %-2d %d\n", dev->bus, dev->dev, dev->func, dev->vendor, dev->device, - dev->class, dev->revision, dev->iobase, + combined_class, dev->revision, dev->iobase, dev->header_type, dev->interrupt_line, dev->interrupt_pin); } return rsize; } -void pci_init() { +void pci_init(void) { log(LOG_INFO, "PCI devices:\n"); - for(uint8_t bus = 0; bus < PCI_MAX_BUS; bus++) { - for(uint8_t dev = 0; dev < PCI_MAX_DEV; dev++) { - for(uint8_t func = 0; func < PCI_MAX_FUNC; func++) { - uint16_t vendor = (uint16_t)_pci_config_read(bus, dev, func, 0); - - /* Devices which don't exist should have a vendor of 0xffff, - * however, some weird chipsets also wrongly set it to zero. - * XXX: ???? - */ - if (vendor == 0xffff || vendor == 0) - continue; - - pci_device_t* pdev = kmalloc(sizeof(pci_device_t)); - load_device(pdev, bus, dev, func); - - pdev->next = first_device; - first_device = pdev; - - log(LOG_INFO, " %02d:%02d.%d: %04x:%04x rev %-2x class %04x iobase %-4x type %-2x int %-2d pin %d\n", - pdev->bus, pdev->dev, pdev->func, pdev->vendor, - pdev->device, pdev->revision, pdev->class, - pdev->iobase, pdev->header_type, pdev->interrupt_line, - pdev->interrupt_pin); + for(uint8_t bus = 0; bus < 255; bus++) { + for(uint8_t dev = 0; dev < 32; dev++) { + for(uint8_t func = 0; func < 8; func++) { + try_load_device(bus, dev, func); } } } diff --git a/src/bsp/i386-pci.h b/src/bsp/i386-pci.h index 380b9654..c30eb876 100644 --- a/src/bsp/i386-pci.h +++ b/src/bsp/i386-pci.h @@ -1,7 +1,7 @@ #pragma once /* Copyright © 2011 Fritz Grimpen - * Copyright © 2011-2018 Lukas Martini + * Copyright © 2011-2023 Lukas Martini * * This file is part of Xelix. * @@ -19,11 +19,6 @@ * along with Xelix. If not, see . */ - -#define PCI_MAX_BUS 255 -#define PCI_MAX_DEV 32 -#define PCI_MAX_FUNC 8 - enum pci_class { // Devices built before class codes (i.e. pre PCI 2.0) PCI_CLASS_OLD = 0x00, @@ -66,6 +61,8 @@ typedef struct pci_device { uint8_t revision; enum pci_class class; + uint16_t subclass; + uint16_t prog_if; uint32_t iobase; uint32_t membase; uint8_t header_type; @@ -76,17 +73,11 @@ typedef struct pci_device { struct pci_device* next; } pci_device_t; -#define pci_expand_dev(device) device->bus, device->dev, device->func -#define pci_config_read(device, offset) _pci_config_read(pci_expand_dev(device), offset) -#define pci_config_write(device, offset, val) \ - _pci_config_write(pci_expand_dev(device), offset, val) - -uint32_t _pci_config_read(uint8_t bus, uint8_t dev, uint8_t func, uint8_t offset); -void _pci_config_write(uint8_t bus, uint8_t dev, uint8_t func, - uint8_t offset, uint32_t val); - +uint32_t pci_config_read(pci_device_t* dev, uint8_t offset, int size); +void pci_config_write(pci_device_t* dev, uint8_t offset, uint32_t val); -uint32_t pci_search(pci_device_t** rdev, const uint32_t vendor_device_combos[][2], uint32_t max); -uint32_t pci_get_BAR(pci_device_t* device, uint8_t bar); -void pci_init(); +int pci_walk(int (*callback)(pci_device_t* dev)); +int pci_check_vendor(pci_device_t* dev, const uint32_t combos[][2]); +uint32_t pci_get_bar(pci_device_t* device, uint8_t bar); +void pci_init(void); diff --git a/src/bsp/timer.c b/src/bsp/timer.c index 8995e36e..c863d5a4 100644 --- a/src/bsp/timer.c +++ b/src/bsp/timer.c @@ -51,7 +51,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { } // Initialize the PIT -void timer_init() { +void timer_init(void) { // preemptability setting here also affects scheduler, so leave set to false int_register(IRQ(0), &timer_callback, false); rate = CONFIG_PIT_RATE; @@ -74,7 +74,7 @@ void timer_init() { log(LOG_DEBUG, "pit: Timer frequency %d\n", rate); } -void timer_init2() { +void timer_init2(void) { struct vfs_callbacks sfs_cb = { .read = sfs_read, }; diff --git a/src/bsp/timer.h b/src/bsp/timer.h index feda15d8..25bca2d2 100644 --- a/src/bsp/timer.h +++ b/src/bsp/timer.h @@ -23,7 +23,7 @@ #define timer_tick (timer_get_tick()) #define timer_rate (timer_get_rate()) -void timer_init(); -void timer_init2(); +void timer_init(void); +void timer_init2(void); uint32_t timer_get_tick(void); uint32_t timer_get_rate(void); diff --git a/src/fs/ext2/cb.c b/src/fs/ext2.c similarity index 66% rename from src/fs/ext2/cb.c rename to src/fs/ext2.c index 743cbc46..ccad1a47 100644 --- a/src/fs/ext2/cb.c +++ b/src/fs/ext2.c @@ -1,5 +1,5 @@ -/* cb.c: ext2 VFS callbacks - * Copyright © 2013-2019 Lukas Martini +/* ext2.c: ext2 VFS callbacks + * Copyright © 2013-2023 Lukas Martini * * This file is part of Xelix. * @@ -20,18 +20,20 @@ #ifdef CONFIG_ENABLE_EXT2 #include "ext2_internal.h" -#include "misc.h" -#include "inode.h" -#include "dirent.h" +#include "ext2_misc.h" +#include "ext2_inode.h" +#include "ext2_dirent.h" #include #include #include #include +#include #include #include #include #include +static vfs_file_t* ext2_open(struct vfs_callback_ctx* ctx, uint32_t flags); static struct inode* get_inode_and_check_owner(struct ext2_fs* fs, struct vfs_callback_ctx* ctx, struct dirent** dirent) { *dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); @@ -57,7 +59,7 @@ static struct inode* get_inode_and_check_owner(struct ext2_fs* fs, struct vfs_ca return inode; } -int ext2_chmod(struct vfs_callback_ctx* ctx, uint32_t mode) { +static int ext2_chmod(struct vfs_callback_ctx* ctx, uint32_t mode) { struct dirent* dirent = NULL; struct ext2_fs* fs = ctx->mp->instance; struct inode* inode = get_inode_and_check_owner(fs, ctx, &dirent); @@ -72,7 +74,7 @@ int ext2_chmod(struct vfs_callback_ctx* ctx, uint32_t mode) { return 0; } -int ext2_chown(struct vfs_callback_ctx* ctx, uint16_t uid, uint16_t gid) { +static int ext2_chown(struct vfs_callback_ctx* ctx, uint16_t uid, uint16_t gid) { struct dirent* dirent = NULL; struct ext2_fs* fs = ctx->mp->instance; struct inode* inode = get_inode_and_check_owner(fs, ctx, &dirent); @@ -92,7 +94,7 @@ int ext2_chown(struct vfs_callback_ctx* ctx, uint16_t uid, uint16_t gid) { return 0; } -int ext2_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest) { +static int ext2_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest) { struct ext2_fs* fs = ctx->mp->instance; struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); if(!dirent) { @@ -127,17 +129,20 @@ int ext2_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest) { return 0; } -int ext2_mkdir(struct vfs_callback_ctx* ctx, uint32_t mode) { +static int ext2_mkdir(struct vfs_callback_ctx* ctx, uint32_t mode) { struct ext2_fs* fs = ctx->mp->instance; - char* base_name = NULL; - char* base_path = ext2_chop_path(ctx->path, &base_name); - if(!base_path || ! base_name) { - sc_errno = EINVAL; + + // Duplicate path as basedir() is destructive + char* dup_path = strdup(ctx->path); + if(!dup_path) { return -1; } + const char* base_path = dirname(dup_path); + // Ensure parent directory exists and permissions are ok struct dirent* parent = ext2_dirent_find(fs, base_path, NULL, ctx->task); + kfree(dup_path); if(!parent) { sc_errno = ENOENT; return -1; @@ -194,7 +199,7 @@ int ext2_mkdir(struct vfs_callback_ctx* ctx, uint32_t mode) { } ext2_inode_write(fs, inode, inode_num); - ext2_dirent_add(fs, parent->inode, inode_num, vfs_basename(ctx->path), EXT2_DIRENT_FT_DIR); + ext2_dirent_add(fs, parent->inode, inode_num, basename(ctx->path), EXT2_DIRENT_FT_DIR); // Add . and .. dirents ext2_dirent_add(fs, inode_num, inode_num, ".", EXT2_DIRENT_FT_DIR); @@ -209,7 +214,7 @@ int ext2_mkdir(struct vfs_callback_ctx* ctx, uint32_t mode) { return 0; } -int ext2_utimes(struct vfs_callback_ctx* ctx, struct timeval times[2]) { +static int ext2_utimes(struct vfs_callback_ctx* ctx, struct timeval times[2]) { struct ext2_fs* fs = ctx->mp->instance; struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); if(!dirent) { @@ -313,7 +318,7 @@ static int do_unlink(struct ext2_fs* fs, char* path, bool is_dir, task_t* task) } } - ext2_dirent_rm(fs, dir_ino, vfs_basename(path)); + ext2_dirent_rm(fs, dir_ino, basename(path)); link_count--; inode->link_count--; @@ -372,25 +377,33 @@ static int do_unlink(struct ext2_fs* fs, char* path, bool is_dir, task_t* task) return 0; } -int ext2_unlink(struct vfs_callback_ctx* ctx) { +static int ext2_unlink(struct vfs_callback_ctx* ctx) { struct ext2_fs* fs = ctx->mp->instance; return do_unlink(fs, ctx->path, false, ctx->task); } -int ext2_rmdir(struct vfs_callback_ctx* ctx) { +static int ext2_rmdir(struct vfs_callback_ctx* ctx) { struct ext2_fs* fs = ctx->mp->instance; return do_unlink(fs, ctx->path, true, ctx->task); } -int ext2_link(struct vfs_callback_ctx* ctx, const char* new_path) { - char* new_name; +static int ext2_link(struct vfs_callback_ctx* ctx, const char* new_path) { struct ext2_fs* fs = ctx->mp->instance; - char* new_dir_path = ext2_chop_path(new_path, &new_name); + + // Duplicate path as basedir() is destructive + char* dup_path = strdup(new_path); + if(!dup_path) { + return -1; + } + + char* new_name = basename(dup_path); + char* new_dir_path = dirname(dup_path); + struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); struct dirent* dir_dirent = ext2_dirent_find(fs, new_dir_path, NULL, ctx->task); + kfree(dup_path); if(!dirent || !dir_dirent) { - kfree(new_dir_path); kfree(dirent); kfree(dir_dirent); sc_errno = ENOENT; @@ -399,7 +412,6 @@ int ext2_link(struct vfs_callback_ctx* ctx, const char* new_path) { // Directory hard links are not allowed in ext2 if(dirent->type == EXT2_DIRENT_FT_DIR) { - kfree(new_dir_path); kfree(dirent); kfree(dir_dirent); sc_errno = EACCES; @@ -407,13 +419,12 @@ int ext2_link(struct vfs_callback_ctx* ctx, const char* new_path) { } ext2_dirent_add(fs, dir_dirent->inode, dirent->inode, new_name, dirent->type); - kfree(new_dir_path); kfree(dirent); kfree(dir_dirent); return 0; } -int ext2_access(struct vfs_callback_ctx* ctx, uint32_t amode) { +static int ext2_access(struct vfs_callback_ctx* ctx, uint32_t amode) { struct ext2_fs* fs = ctx->mp->instance; struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); if(!dirent) { @@ -451,7 +462,7 @@ int ext2_access(struct vfs_callback_ctx* ctx, uint32_t amode) { return 0; } -int ext2_readlink(struct vfs_callback_ctx* ctx, char* buf, size_t size) { +static int ext2_readlink(struct vfs_callback_ctx* ctx, char* buf, size_t size) { struct ext2_fs* fs = ctx->mp->instance; struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); if(!dirent) { @@ -488,7 +499,7 @@ int ext2_readlink(struct vfs_callback_ctx* ctx, char* buf, size_t size) { } -size_t ext2_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { +static size_t ext2_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { struct ext2_fs* fs = ctx->mp->instance; if(!ctx->fp || !ctx->fp->inode || !fs) { log(LOG_ERR, "ext2: ext2_read_file called without file system struct, fp or inode.\n"); @@ -545,7 +556,7 @@ size_t ext2_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return size; } -size_t ext2_write(struct vfs_callback_ctx* ctx, void* source, size_t size) { +static size_t ext2_write(struct vfs_callback_ctx* ctx, void* source, size_t size) { struct ext2_fs* fs = ctx->mp->instance; if(!ctx || !ctx->fp || !ctx->fp->inode) { log(LOG_ERR, "ext2: ext2_write_file called without fp or fp missing inode.\n"); @@ -595,7 +606,7 @@ size_t ext2_write(struct vfs_callback_ctx* ctx, void* source, size_t size) { } -size_t ext2_getdents(struct vfs_callback_ctx* ctx, void* buf, size_t size) { +static size_t ext2_getdents(struct vfs_callback_ctx* ctx, void* buf, size_t size) { struct ext2_fs* fs = ctx->mp->instance; struct inode* inode = kmalloc(fs->superblock->inode_size); @@ -640,7 +651,7 @@ size_t ext2_getdents(struct vfs_callback_ctx* ctx, void* buf, size_t size) { return offset; } -int ext2_build_path_tree(struct vfs_callback_ctx* ctx) { +static int ext2_build_path_tree(struct vfs_callback_ctx* ctx) { struct ext2_fs* fs = ctx->mp->instance; struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); if(!dirent) { @@ -650,4 +661,225 @@ int ext2_build_path_tree(struct vfs_callback_ctx* ctx) { return 0; } + +static vfs_file_t* handle_symlink(struct vfs_callback_ctx* ctx, struct inode* inode, uint32_t flags) { + /* For symlinks with up to 60 chars length, the path is stored in the + * inode in the area where normally the block pointers would be. + * Otherwise in the file itself. + */ + if(inode->size > 60) { + log(LOG_WARN, "ext2: Symlinks with length >60 are not supported right now.\n"); + kfree(inode); + return NULL; + } + + char* sym_path = (char*)inode->blocks; + if(sym_path[0] != '/') { + + char* dup_path = strdup(ctx->path); + if(!dup_path) { + return NULL; + } + + char* base_path = dirname(dup_path); + ctx->path = vfs_normalize_path(sym_path, base_path); + kfree(dup_path); + } else { + ctx->path = strdup(sym_path); + } + + // FIXME Should be vfs_open to make symlinks across mount points possible + vfs_file_t* r = ext2_open(ctx, flags); + return r; +} + +static vfs_file_t* ext2_open(struct vfs_callback_ctx* ctx, uint32_t flags) { + struct ext2_fs* fs = ctx->mp->instance; + if(!ctx->path || !strcmp(ctx->path, "")) { + sc_errno = EINVAL; + return NULL; + } + + // Duplicate path as basedir() is destructive + char* dup_path = strdup(ctx->path); + if(!dup_path) { + return NULL; + } + + const char* parent_dir = dirname(dup_path); + + // Look up the parent directory first and fail if it cannot be found. + // This is important to ensure files can only be created in existing + // directories. below + struct dirent* parent_dirent = ext2_dirent_find(fs, parent_dir, NULL, ctx->task); + kfree(dup_path); + if(!parent_dirent || !parent_dirent->inode) { + sc_errno = ENOENT; + return NULL; + } + + uint32_t parent_inode = parent_dirent->inode; + kfree(parent_dirent); + + // FIXME Most of this just resolves the same path as above. Should take a + // shortcut here / reuse existing data with ext2_dirent_search + struct dirent* dirent = ext2_dirent_find(fs, ctx->path, NULL, ctx->task); + if(!dirent && (sc_errno != ENOENT || !(flags & O_CREAT))) { + sc_errno = ENOENT; + return NULL; + } + + uint32_t inode_num; + struct inode* inode = kmalloc(fs->superblock->inode_size); + + if(!dirent || !dirent->inode) { + inode_num = ext2_inode_new(fs, inode, FT_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + ext2_dirent_add(fs, parent_inode, inode_num, basename(ctx->path), EXT2_DIRENT_FT_REG_FILE); + + if(ctx->task) { + inode->uid = ctx->task->euid; + inode->gid = ctx->task->egid; + } + } else { + inode_num = dirent->inode; + kfree(dirent); + + if((flags & O_CREAT) && (flags & O_EXCL)) { + kfree(inode); + sc_errno = EEXIST; + return NULL; + } + + if(!ext2_inode_read(fs, inode, inode_num)) { + kfree(inode); + sc_errno = ENOENT; + return NULL; + } + + if((flags & O_WRONLY) || (flags & O_RDWR)) { + if(ext2_inode_check_perm(PERM_CHECK_WRITE, inode, ctx->task) < 0) { + kfree(inode); + sc_errno = EACCES; + return NULL; + } + } + } + + uint16_t ft = vfs_mode_to_filetype(inode->mode); + if(ft == FT_IFDIR && (flags & O_WRONLY || flags & O_RDWR)) { + kfree(inode); + sc_errno = EISDIR; + return NULL; + } + + if(ft == FT_IFLNK) { + vfs_file_t* r = handle_symlink(ctx, inode, flags); + kfree(inode); + return r; + } + kfree(inode); + + vfs_file_t* fp = vfs_alloc_fileno(ctx->task, 3); + if(!fp) { + return NULL; + } + + fp->type = ft; + fp->inode = inode_num; + memcpy(&fp->callbacks, fs->callbacks, sizeof(struct vfs_callbacks)); + + sc_errno = 0; + return fp; +} + +struct vfs_callbacks cb = { + .open = ext2_open, + .stat = ext2_stat, + .read = ext2_read, + .write = ext2_write, + .getdents = ext2_getdents, + .unlink = ext2_unlink, + .chmod = ext2_chmod, + .chown = ext2_chown, + .symlink = NULL, + .mkdir = ext2_mkdir, + .utimes = ext2_utimes, + .rmdir = ext2_rmdir, + .link = ext2_link, + .readlink = ext2_readlink, + .access = ext2_access, + .build_path_tree = ext2_build_path_tree, +}; + +int ext2_mount(struct vfs_block_dev* dev, const char* path) { + struct ext2_fs* fs = zmalloc(sizeof(struct ext2_fs)); + fs->dev = dev; + + // Main superblock always has an offset of 1024 + fs->superblock = (struct superblock*)kmalloc(1024); + if(vfs_block_read(fs->dev, 2, 2, (uint8_t*)fs->superblock) < 0 || + fs->superblock->magic != SUPERBLOCK_MAGIC) { + log(LOG_ERR, "ext2: Invalid magic\n"); + + kfree(fs); + sc_errno = EINVAL; + return -1; + } + + if(unlikely(fs->superblock->revision != 1)) { + log(LOG_ERR, "ext2: Only revision 1 is supported.\n"); + + kfree(fs); + sc_errno = EINVAL; + return -1; + } + + log(LOG_INFO, "ext2: Mounting /dev/%s - ext2 revision %d, block size %d, %d blockgroups\n", + dev->name, fs->superblock->revision, bl_off(1), fs->superblock->blockgroup_num); + log(LOG_INFO, "ext2: Blocks: %d free / %d total\n", + fs->superblock->free_blocks, fs->superblock->block_count); + log(LOG_INFO, "ext2: Inodes: %d free / %d total\n", + fs->superblock->free_inodes, fs->superblock->inode_count); + + if(fs->superblock->state != SUPERBLOCK_STATE_CLEAN) { + log(LOG_ERR, "ext2: File system on /dev/%s is not marked as clean. " + "Please run fsck.ext2 on it.\n", dev->name); + + kfree(fs); + sc_errno = EINVAL; + return -1; + } + + // TODO Compare superblocks to each other? + + fs->blockgroup_table = kmalloc(bl_off(blockgroup_table_size)); + if(!vfs_block_sread(fs->dev, bl_off(blockgroup_table_start), + bl_off(blockgroup_table_size), (uint8_t*)fs->blockgroup_table)) { + + kfree(fs->superblock); + kfree(fs->blockgroup_table); + kfree(fs); + return -1; + } + + // Cache root inode + struct inode* root_inode_buf = kmalloc(fs->superblock->inode_size); + if(!ext2_inode_read(fs, root_inode_buf, ROOT_INODE)) { + log(LOG_ERR, "ext2: Could not read root inode.\n"); + kfree(fs->superblock); + kfree(fs->blockgroup_table); + kfree(root_inode_buf); + kfree(fs); + return -1; + } + + fs->root_inode = root_inode_buf; + fs->superblock->mount_count++; + fs->superblock->mount_time = time_get(); + fs->callbacks = &cb; + write_superblock(); + vfs_mount_register(dev, path, (void*)fs, "ext2", &cb); + return 0; +} + #endif /* CONFIG_ENABLE_EXT2 */ diff --git a/src/fs/ext2/ext2.h b/src/fs/ext2.h similarity index 100% rename from src/fs/ext2/ext2.h rename to src/fs/ext2.h diff --git a/src/fs/ext2/block.c b/src/fs/ext2/block.c deleted file mode 100644 index 6e7fb37c..00000000 --- a/src/fs/ext2/block.c +++ /dev/null @@ -1,53 +0,0 @@ -/* ext2.c: Implementation of the extended file system, version 2 - * Copyright © 2013-2019 Lukas Martini - * - * This file is part of Xelix. - * - * Xelix 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. - * - * Xelix 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 Xelix. If not, see . - */ - -#ifdef CONFIG_ENABLE_EXT2 - -#include "ext2_internal.h" -#include "misc.h" -#include -#include -#include -#include -#include -#include - -uint32_t ext2_block_new(struct ext2_fs* fs, uint32_t neighbor) { - uint32_t pref_blockgroup = inode_to_blockgroup(neighbor); - - struct blockgroup* blockgroup = fs->blockgroup_table + pref_blockgroup; - if(!blockgroup || !blockgroup->inode_table) { - log(LOG_ERR, "ext2: Could not locate entry %d in blockgroup table\n", pref_blockgroup); - return 0; - } - - uint32_t block_num = ext2_bitmap_search_and_claim(fs, blockgroup->block_bitmap); - if(!block_num) { - log(LOG_ERR, "ext2: Could not find free block in preferred blockgroup %d.\n", pref_blockgroup); - return 0; - } - - fs->superblock->free_blocks--; - blockgroup->free_blocks--; - write_superblock(); - write_blockgroup_table(); - return block_num; - -} -#endif /* CONFIG_ENABLE_EXT2 */ diff --git a/src/fs/ext2/cb.h b/src/fs/ext2/cb.h deleted file mode 100644 index cd61e94e..00000000 --- a/src/fs/ext2/cb.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -/* Copyright © 2013-2019 Lukas Martini - * - * This file is part of Xelix. - * - * Xelix 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. - * - * Xelix 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 Xelix. If not, see . - */ - -#include - -int ext2_chmod(struct vfs_callback_ctx* ctx, uint32_t mode); -int ext2_chown(struct vfs_callback_ctx* ctx, uint16_t uid, uint16_t gid); -int ext2_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest); -int ext2_mkdir(struct vfs_callback_ctx* ctx, uint32_t mode); -int ext2_utimes(struct vfs_callback_ctx* ctx, struct timeval times[2]); -int ext2_unlink(struct vfs_callback_ctx* ctx); -int ext2_rmdir(struct vfs_callback_ctx* ctx); -int ext2_link(struct vfs_callback_ctx* ctx, const char* new_path); -int ext2_access(struct vfs_callback_ctx* ctx, uint32_t amode); -int ext2_readlink(struct vfs_callback_ctx* ctx, char* buf, size_t size); -size_t ext2_read(struct vfs_callback_ctx* ctx, void* dest, size_t size); -size_t ext2_write(struct vfs_callback_ctx* ctx, void* source, size_t size); -size_t ext2_getdents(struct vfs_callback_ctx* ctx, void* dest, size_t size); -int ext2_build_path_tree(struct vfs_callback_ctx* ctx); diff --git a/src/fs/ext2/mount.c b/src/fs/ext2/mount.c deleted file mode 100644 index bdb24200..00000000 --- a/src/fs/ext2/mount.c +++ /dev/null @@ -1,115 +0,0 @@ -/* mount.c: Ext2 filesystem mounting - * Copyright © 2013-2020 Lukas Martini - * - * This file is part of Xelix. - * - * Xelix 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. - * - * Xelix 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 Xelix. If not, see . - */ - -#ifdef CONFIG_ENABLE_EXT2 - -#include "ext2_internal.h" -#include "inode.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "cb.h" - - -struct vfs_callbacks cb = { - .open = ext2_open, - .stat = ext2_stat, - .read = ext2_read, - .write = ext2_write, - .getdents = ext2_getdents, - .unlink = ext2_unlink, - .chmod = ext2_chmod, - .chown = ext2_chown, - .symlink = NULL, - .mkdir = ext2_mkdir, - .utimes = ext2_utimes, - .rmdir = ext2_rmdir, - .link = ext2_link, - .readlink = ext2_readlink, - .access = ext2_access, - .build_path_tree = ext2_build_path_tree, -}; - -int ext2_mount(struct vfs_block_dev* dev, const char* path) { - struct ext2_fs* fs = zmalloc(sizeof(struct ext2_fs)); - fs->dev = dev; - - // Main superblock always has an offset of 1024 - fs->superblock = (struct superblock*)kmalloc(1024); - if(vfs_block_read(fs->dev, 2, 2, (uint8_t*)fs->superblock) < 0 || - fs->superblock->magic != SUPERBLOCK_MAGIC) { - log(LOG_ERR, "ext2: Invalid magic\n"); - - kfree(fs); - return -1; - } - - log(LOG_INFO, "ext2: Mounting /dev/%s - ext2 revision %d, block size %d, %d blockgroups\n", - dev->name, fs->superblock->revision, bl_off(1), fs->superblock->blockgroup_num); - log(LOG_INFO, "ext2: Blocks: %d free / %d total\n", - fs->superblock->free_blocks, fs->superblock->block_count); - log(LOG_INFO, "ext2: Inodes: %d free / %d total\n", - fs->superblock->free_inodes, fs->superblock->inode_count); - - if(fs->superblock->state != SUPERBLOCK_STATE_CLEAN) { - log(LOG_ERR, "ext2: File system on /dev/%s is not marked as clean. " - "Please run fsck.ext2 on it.\n", dev->name); - - kfree(fs); - return -1; - } - - // TODO Compare superblocks to each other? - - fs->blockgroup_table = kmalloc(bl_off(blockgroup_table_size)); - if(!vfs_block_sread(fs->dev, bl_off(blockgroup_table_start), - bl_off(blockgroup_table_size), (uint8_t*)fs->blockgroup_table)) { - - kfree(fs->superblock); - kfree(fs->blockgroup_table); - kfree(fs); - return -1; - } - - // Cache root inode - struct inode* root_inode_buf = kmalloc(fs->superblock->inode_size); - if(!ext2_inode_read(fs, root_inode_buf, ROOT_INODE)) { - log(LOG_ERR, "ext2: Could not read root inode.\n"); - kfree(fs->superblock); - kfree(fs->blockgroup_table); - kfree(root_inode_buf); - kfree(fs); - return -1; - } - - fs->root_inode = root_inode_buf; - fs->superblock->mount_count++; - fs->superblock->mount_time = time_get(); - fs->callbacks = &cb; - write_superblock(); - vfs_mount_register(dev, path, (void*)fs, "ext2", &cb); - return 0; -} - -#endif /* CONFIG_ENABLE_EXT2 */ diff --git a/src/fs/ext2/open.c b/src/fs/ext2/open.c deleted file mode 100644 index 71f81791..00000000 --- a/src/fs/ext2/open.c +++ /dev/null @@ -1,137 +0,0 @@ -/* ext2.c: Implementation of the extended file system, version 2 - * Copyright © 2013-2019 Lukas Martini - * - * This file is part of Xelix. - * - * Xelix 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. - * - * Xelix 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 Xelix. If not, see . - */ - -#ifdef CONFIG_ENABLE_EXT2 - -#include "ext2_internal.h" -#include "misc.h" -#include "inode.h" -#include "dirent.h" -#include -#include -#include -#include -#include -#include - -static vfs_file_t* handle_symlink(struct vfs_callback_ctx* ctx, struct inode* inode, uint32_t flags) { - /* For symlinks with up to 60 chars length, the path is stored in the - * inode in the area where normally the block pointers would be. - * Otherwise in the file itself. - */ - if(inode->size > 60) { - log(LOG_WARN, "ext2: Symlinks with length >60 are not supported right now.\n"); - kfree(inode); - return 0; - } - - char* sym_path = (char*)inode->blocks; - if(sym_path[0] != '/') { - char* base_path = ext2_chop_path(ctx->path, NULL); - ctx->path = vfs_normalize_path(sym_path, base_path); - kfree(base_path); - } else { - ctx->path = strdup(sym_path); - } - - // FIXME Should be vfs_open to make symlinks across mount points possible - vfs_file_t* r = ext2_open(ctx, flags); - return r; -} - -// The public open interface to the virtual file system -vfs_file_t* ext2_open(struct vfs_callback_ctx* ctx, uint32_t flags) { - struct ext2_fs* fs = ctx->mp->instance; - if(!ctx->path || !strcmp(ctx->path, "")) { - log(LOG_ERR, "ext2: ext2_read_file called with empty path.\n"); - sc_errno = EINVAL; - return NULL; - } - - uint32_t dir_inode = 0; - struct dirent* dirent = ext2_dirent_find(fs, ctx->path, &dir_inode, ctx->task); - if(!dirent && (sc_errno != ENOENT || !(flags & O_CREAT))) { - sc_errno = ENOENT; - return NULL; - } - - uint32_t inode_num = dirent ? dirent->inode : 0; - struct inode* inode = kmalloc(fs->superblock->inode_size); - - if(!inode_num) { - debug("ext2_open: Could not find inode, creating one.\n"); - inode_num = ext2_inode_new(fs, inode, FT_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); - ext2_dirent_add(fs, dir_inode, inode_num, vfs_basename(ctx->path), EXT2_DIRENT_FT_REG_FILE); - - if(ctx->task) { - inode->uid = ctx->task->euid; - inode->gid = ctx->task->egid; - } - } else { - kfree(dirent); - - if((flags & O_CREAT) && (flags & O_EXCL)) { - kfree(inode); - sc_errno = EEXIST; - return NULL; - } - - if(!ext2_inode_read(fs, inode, inode_num)) { - kfree(inode); - sc_errno = ENOENT; - return NULL; - } - - if((flags & O_WRONLY) || (flags & O_RDWR)) { - if(ext2_inode_check_perm(PERM_CHECK_WRITE, inode, ctx->task) < 0) { - kfree(inode); - sc_errno = EACCES; - return NULL; - } - } - } - - uint16_t ft = vfs_mode_to_filetype(inode->mode); - if(ft == FT_IFDIR && (flags & O_WRONLY || flags & O_RDWR)) { - kfree(inode); - sc_errno = EISDIR; - return NULL; - } - - if(ft == FT_IFLNK) { - vfs_file_t* r = handle_symlink(ctx, inode, flags); - kfree(inode); - return r; - } - kfree(inode); - - vfs_file_t* fp = vfs_alloc_fileno(ctx->task, 3); - if(!fp) { - return NULL; - } - - fp->type = ft; - fp->inode = inode_num; - memcpy(&fp->callbacks, fs->callbacks, sizeof(struct vfs_callbacks)); - - sc_errno = 0; - return fp; -} - -#endif /* CONFIG_ENABLE_EXT2 */ diff --git a/src/fs/ext2/dirent.c b/src/fs/ext2_dirent.c similarity index 97% rename from src/fs/ext2/dirent.c rename to src/fs/ext2_dirent.c index d955f600..85f4eba1 100644 --- a/src/fs/ext2/dirent.c +++ b/src/fs/ext2_dirent.c @@ -1,4 +1,4 @@ -/* ext2.c: Implementation of the extended file system, version 2 +/* ext2_dirent.c: Ext2 directory handling * Copyright © 2013-2019 Lukas Martini * * This file is part of Xelix. @@ -20,9 +20,9 @@ #ifdef CONFIG_ENABLE_EXT2 #include "ext2_internal.h" -#include "misc.h" -#include "inode.h" -#include "dirent.h" +#include "ext2_misc.h" +#include "ext2_inode.h" +#include "ext2_dirent.h" #include #include #include @@ -106,7 +106,11 @@ struct dirent* ext2_dirent_find(struct ext2_fs* fs, const char* path, uint32_t* struct inode* inode = kmalloc(fs->superblock->inode_size); struct dirent* dirent = NULL; struct dirent* result = NULL; + + #ifdef CONFIG_ENABLE_FTREE struct ftree_file* ft_root = NULL; + #endif + if(unlikely(!ext2_inode_read(fs, inode, ROOT_INODE))) { goto bye; } @@ -138,6 +142,7 @@ struct dirent* ext2_dirent_find(struct ext2_fs* fs, const char* path, uint32_t* } + #ifdef CONFIG_ENABLE_FTREE vfs_stat_t stat = { .st_dev = 1, .st_ino = dirent->inode, @@ -155,6 +160,8 @@ struct dirent* ext2_dirent_find(struct ext2_fs* fs, const char* path, uint32_t* }; ft_root = vfs_ftree_insert(ft_root, pch, &stat); + #endif + pch = strtok_r(NULL, "/", &sp); } result = dirent; diff --git a/src/fs/ext2/dirent.h b/src/fs/ext2_dirent.h similarity index 100% rename from src/fs/ext2/dirent.h rename to src/fs/ext2_dirent.h diff --git a/src/fs/ext2/inode.c b/src/fs/ext2_inode.c similarity index 98% rename from src/fs/ext2/inode.c rename to src/fs/ext2_inode.c index 08dfe517..db27d45a 100644 --- a/src/fs/ext2/inode.c +++ b/src/fs/ext2_inode.c @@ -1,4 +1,4 @@ -/* ext2.c: Implementation of the extended file system, version 2 +/* ext2_inode.c: Ext2 inode handling * Copyright © 2013-2019 Lukas Martini * * This file is part of Xelix. @@ -20,8 +20,8 @@ #ifdef CONFIG_ENABLE_EXT2 #include "ext2_internal.h" -#include "misc.h" -#include "inode.h" +#include "ext2_misc.h" +#include "ext2_inode.h" #include #include #include @@ -29,6 +29,7 @@ #include #include + static uint64_t find_inode(struct ext2_fs* fs, uint32_t inode_num) { uint32_t blockgroup_num = inode_to_blockgroup(inode_num); debug("Reading inode struct %d in blockgroup %d\n", inode_num, blockgroup_num); diff --git a/src/fs/ext2/inode.h b/src/fs/ext2_inode.h similarity index 89% rename from src/fs/ext2/inode.h rename to src/fs/ext2_inode.h index d792a42f..a44b6b4b 100644 --- a/src/fs/ext2/inode.h +++ b/src/fs/ext2_inode.h @@ -33,15 +33,14 @@ struct inode { uint16_t link_count; uint32_t block_count; uint32_t flags; - uint32_t reserved1; + uint32_t osd1; uint32_t blocks[15]; - uint32_t version; - uint32_t file_acl; - uint32_t dir_acl; - uint32_t fragment_address; - uint8_t fragment_number; - uint8_t fragment_size; - uint16_t reserved2[5]; + uint32_t generation; + uint32_t attrs_low; + uint32_t size_high; + uint32_t unused; + uint32_t osd2[3]; + uint16_t inode_size; } __attribute__((packed)); struct ext2_blocknum_resolver_cache { @@ -65,5 +64,4 @@ uint8_t* ext2_inode_data_rw(struct ext2_fs* fs, struct inode* inode, uint32_t wr uint32_t ext2_resolve_inode(const char* path, uint32_t* parent_ino); -vfs_file_t* ext2_open(struct vfs_callback_ctx* ctx, uint32_t flags); void ext2_dump_inode(struct inode* buf); diff --git a/src/fs/ext2/ext2_internal.h b/src/fs/ext2_internal.h similarity index 99% rename from src/fs/ext2/ext2_internal.h rename to src/fs/ext2_internal.h index 9998e367..e587181e 100644 --- a/src/fs/ext2/ext2_internal.h +++ b/src/fs/ext2_internal.h @@ -19,7 +19,7 @@ */ #include "ext2.h" -#include "inode.h" +#include "ext2_inode.h" #include #include #include diff --git a/src/fs/ext2/misc.c b/src/fs/ext2_misc.c similarity index 71% rename from src/fs/ext2/misc.c rename to src/fs/ext2_misc.c index a5341766..9f464156 100644 --- a/src/fs/ext2/misc.c +++ b/src/fs/ext2_misc.c @@ -1,4 +1,4 @@ -/* ext2.c: Implementation of the extended file system, version 2 +/* ext2_misc.c: Miscellaneous ext2 helpers * Copyright © 2018-2019 Lukas Martini * * This file is part of Xelix. @@ -20,7 +20,7 @@ #ifdef CONFIG_ENABLE_EXT2 #include "ext2_internal.h" -#include "misc.h" +#include "ext2_misc.h" #include #include #include @@ -63,20 +63,27 @@ void ext2_bitmap_free(struct ext2_fs* fs, uint32_t bitmap_block, uint32_t bit) { kfree(bitmap); } -char* ext2_chop_path(const char* path, char** ent) { - char* base_path = strdup(path); - char* c = base_path + strlen(path); - for(; c > base_path; c--) { - if(*c == '/') { - *c = 0; +uint32_t ext2_block_new(struct ext2_fs* fs, uint32_t neighbor) { + uint32_t pref_blockgroup = inode_to_blockgroup(neighbor); - if(ent) { - *ent = c+1; - } - break; - } + struct blockgroup* blockgroup = fs->blockgroup_table + pref_blockgroup; + if(!blockgroup || !blockgroup->inode_table) { + log(LOG_ERR, "ext2: Could not locate entry %d in blockgroup table\n", pref_blockgroup); + return 0; } - return base_path; + + uint32_t block_num = ext2_bitmap_search_and_claim(fs, blockgroup->block_bitmap); + if(!block_num) { + log(LOG_ERR, "ext2: Could not find free block in preferred blockgroup %d.\n", pref_blockgroup); + return 0; + } + + fs->superblock->free_blocks--; + blockgroup->free_blocks--; + write_superblock(); + write_blockgroup_table(); + return block_num; + } #endif /* CONFIG_ENABLE_EXT2 */ diff --git a/src/fs/ext2/misc.h b/src/fs/ext2_misc.h similarity index 95% rename from src/fs/ext2/misc.h rename to src/fs/ext2_misc.h index 584ba7a0..4d94efc2 100644 --- a/src/fs/ext2/misc.h +++ b/src/fs/ext2_misc.h @@ -29,5 +29,3 @@ int ext2_inode_check_perm(enum inode_check_op, struct inode* inode, task_t* task uint32_t ext2_bitmap_search_and_claim(struct ext2_fs* fs, uint32_t bitmap_block); void ext2_bitmap_free(struct ext2_fs* fs, uint32_t bitmap_block, uint32_t bit); -char* ext2_chop_path(const char* path, char** ent); - diff --git a/src/fs/ftree.c b/src/fs/ftree.c index 9b0a17d1..e6e39268 100644 --- a/src/fs/ftree.c +++ b/src/fs/ftree.c @@ -17,6 +17,8 @@ * along with Xelix. If not, see . */ +#ifdef CONFIG_ENABLE_FTREE + #include #include #include @@ -127,7 +129,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return sfs_iter(ctx, dest, size, 0, ftree_root, 0); } -void vfs_ftree_init() { +void vfs_ftree_init(void) { ftree_root = zmalloc(sizeof(struct ftree_file)); strlcpy(ftree_root->path, "/", ARRAY_SIZE(ftree_root->path)); ftree_root->stat.st_dev = 1; @@ -150,3 +152,5 @@ void vfs_ftree_init() { }; sysfs_add_file("vfs_ftree", &sfs_cb); } + +#endif diff --git a/src/fs/ftree.h b/src/fs/ftree.h index 12004240..9a7d1223 100644 --- a/src/fs/ftree.h +++ b/src/fs/ftree.h @@ -33,4 +33,4 @@ struct ftree_file* vfs_ftree_insert(struct ftree_file* root, char* name, vfs_sta struct ftree_file* vfs_ftree_insert_path(char* path, vfs_stat_t* stat); const struct ftree_file* vfs_ftree_find(const struct ftree_file* root, char* name); const struct ftree_file* vfs_ftree_find_path(char* path); -void vfs_ftree_init(); +void vfs_ftree_init(void); diff --git a/src/fs/mount.c b/src/fs/mount.c index 4d38cd5b..df85d521 100644 --- a/src/fs/mount.c +++ b/src/fs/mount.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/fs/sysfs.c b/src/fs/sysfs.c index 6ea1d0f0..64c23fc8 100644 --- a/src/fs/sysfs.c +++ b/src/fs/sysfs.c @@ -86,7 +86,7 @@ int sysfs_build_path_tree(struct vfs_callback_ctx* ctx) { } else { stat.st_dev = 2; stat.st_ino = 1; - if(is_root) { + if(!file || is_root) { stat.st_mode = FT_IFDIR | S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH; } else { stat.st_mode = file ? file->type : FT_IFDIR; @@ -109,7 +109,10 @@ int sysfs_build_path_tree(struct vfs_callback_ctx* ctx) { stat.st_ctime = t; } + #ifdef CONFIG_ENABLE_FTREE vfs_ftree_insert_path(ctx->orig_path, &stat); + #endif + return 0; } @@ -129,7 +132,7 @@ int sysfs_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest) { dest->st_dev = 2; dest->st_ino = 1; - if(is_root) { + if(!file || is_root) { dest->st_mode = FT_IFDIR | S_IXUSR | S_IRUSR | S_IXGRP | S_IRGRP | S_IXOTH | S_IROTH; } else { dest->st_mode = file ? file->type : FT_IFDIR; @@ -306,7 +309,7 @@ void sysfs_rm_dev(struct sysfs_file* fp) { remove_file(&dev_files, fp); } -void sysfs_init() { +void sysfs_init(void) { //sys_root = vfs_ftree_insert(NULL, "sys", stat); //dev_root = vfs_ftree_insert(NULL, "dev", stat); vfs_mount_register(NULL, "/sys", &sys_files, "sysfs", &callbacks); diff --git a/src/fs/sysfs.h b/src/fs/sysfs.h index 9cccf1cb..8d77d89e 100644 --- a/src/fs/sysfs.h +++ b/src/fs/sysfs.h @@ -36,10 +36,11 @@ struct sysfs_file* sysfs_add_file(char* name, struct vfs_callbacks* cb); struct sysfs_file* sysfs_add_dev(char* name, struct vfs_callbacks* cb); void sysfs_rm_file(struct sysfs_file* fp); void sysfs_rm_dev(struct sysfs_file* fp); -void sysfs_init(); +void sysfs_init(void); vfs_file_t* sysfs_open(struct vfs_callback_ctx* ctx, uint32_t flags); int sysfs_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest); int sysfs_access(struct vfs_callback_ctx* ctx, uint32_t amode); int sysfs_readlink(struct vfs_callback_ctx* ctx, char* buf, size_t size); +size_t sysfs_getdents(struct vfs_callback_ctx* ctx, void* dest, size_t size); int sysfs_build_path_tree(struct vfs_callback_ctx* ctx); diff --git a/src/fs/vfs.c b/src/fs/vfs.c index 2977fae2..fea595e9 100644 --- a/src/fs/vfs.c +++ b/src/fs/vfs.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include #include @@ -219,7 +219,7 @@ int vfs_open(task_t* task, const char* orig_path, uint32_t flags) { strcpy(fp->mount_path, ctx->path); // Allow for this to be overriden by callback - if(!fp->mount_path) { + if(!strlen(fp->mount_path)) { fp->mount_instance = ctx->mp->instance; } @@ -349,6 +349,10 @@ int vfs_fcntl(task_t* task, int fd, int cmd, int arg3) { if(cmd == F_DUPFD) { vfs_file_t* fp2 = vfs_alloc_fileno(task, MAX(3, arg3)); + if(!fp2) { + return -1; + } + __sync_add_and_fetch(&fp->refs, 1); fp2->dup_target = fp->num; return fp2->num; @@ -692,7 +696,7 @@ int vfs_link(task_t* task, const char* orig_path, const char* orig_new_path) { return r; } -void vfs_init() { +void vfs_init(void) { char* root_path = cmdline_get("root"); if(!root_path) { panic("vfs: Could not get root device path - Make sure root= " @@ -700,7 +704,11 @@ void vfs_init() { } log(LOG_INFO, "vfs: initializing, root=%s\n", root_path); + + #ifdef CONFIG_ENABLE_FTREE vfs_ftree_init(); + #endif + sysfs_init(); vfs_mount_init(root_path); diff --git a/src/fs/vfs.h b/src/fs/vfs.h index 238f779a..30da5593 100644 --- a/src/fs/vfs.h +++ b/src/fs/vfs.h @@ -215,7 +215,7 @@ int vfs_link(struct task* task, const char* orig_path, const char* orig_new_path int vfs_readlink(struct task* task, const char* orig_path, char* buf, size_t size); int vfs_rmdir(struct task* task, const char* orig_path); int vfs_stat(struct task* task, char* path, vfs_stat_t* dest); -void vfs_init(); +void vfs_init(void); // legacy int vfs_fstat(struct task* task, int fd, vfs_stat_t* dest); @@ -259,9 +259,3 @@ static inline char* vfs_flags_verbose(uint32_t flags) { return mode; } - -static inline char* vfs_basename(char* path) { - char* bname = path + strlen(path); - while(*(bname - 1) != '/' && bname >= path) { bname--; } - return bname; -} diff --git a/src/gfx/fbtext.c b/src/gfx/fbtext.c index 15a7d975..19fed980 100644 --- a/src/gfx/fbtext.c +++ b/src/gfx/fbtext.c @@ -34,19 +34,10 @@ #define BOOT_LOGO_PADDING 10 #define BOOT_LOGO_PADDING_BELOW 30 -#define PIXEL_PTR(dbuf, x, y) \ - ((uint32_t*)((uintptr_t)(dbuf) \ - + (y)*gfx_handle->ul_desc.pitch \ - + (x)*(gfx_handle->ul_desc.bpp / 8))) - -#define CHAR_PTR(dbuf, x, y) PIXEL_PTR(dbuf, x * gfx_font.width, \ - y * gfx_font.height) - -static struct { - uint32_t last_x; - uint32_t last_y; - uint32_t* last_data; -} cursor_data = {0, 0, 0}; +#define PIXEL_PTR(dbuf, x, y) \ + ((uintptr_t)(dbuf) \ + + (y)*gfx_handle->ul_desc.pitch \ + + (x)*(gfx_handle->ul_desc.bpp / 8)) // Font from ter-u16n.psf gets linked into the binary extern const struct { @@ -63,99 +54,149 @@ extern const struct { static struct gfx_handle* gfx_handle = NULL; static bool initialized = false; +static unsigned int font_width_aligned = 0; +static unsigned int font_width_bytes = 0; +static unsigned int font_height_pitch = 0; +static unsigned int pixel_bytes = 0; +static unsigned int num_cols = 0; +static unsigned int num_rows = 0; + +static inline uint16_t color_convert16_565(int color) { + uint16_t red = (color & 0xff0000) >> 16; + uint16_t green = (color & 0xff00) >> 8; + uint16_t blue = color & 0xff; + return (red >> 3 << 11) + (green >> 2 << 5) + (blue >> 3); +} + +static inline void setpixel(uintptr_t ptr, uint32_t col) { + if(gfx_handle->ul_desc.bpp == 32) { + *(uint32_t*)ptr = col; + } else if(gfx_handle->ul_desc.bpp == 16) { + *(uint16_t*)ptr = (uint16_t)col; + } +} void gfx_fbtext_write(uint32_t x, uint32_t y, wchar_t chr, uint32_t col_fg, uint32_t col_bg) { - if(chr > gfx_font.num_glyphs) { + if(unlikely(chr > gfx_font.num_glyphs)) { chr = 0; } - if(chr == ' ') { + uintptr_t cy_ptr = (uintptr_t)(gfx_handle->ul_desc.addr) + + y * font_height_pitch + + x * font_width_bytes; + + if(chr == ' ' && col_bg == 0) { for(int i = 0; i < gfx_font.height; i++) { - void* mdest = PIXEL_PTR(gfx_handle->ul_desc.addr, x * gfx_font.width, y * gfx_font.height + i); - memset32(mdest, col_bg, gfx_font.width); + memset((void*)cy_ptr, 0, font_width_bytes); + cy_ptr += gfx_handle->ul_desc.pitch; } return; } - const uint8_t* bitmap = (uint8_t*)&gfx_font + if(gfx_handle->ul_desc.bpp == 16) { + col_fg = color_convert16_565(col_fg); + col_bg = color_convert16_565(col_bg); + } + + const uint8_t* glyph = (const uint8_t*)&gfx_font + gfx_font.header_size + chr * gfx_font.bytes_per_glyph; - if(unlikely(!bitmap)) { - return; - } + int bit_offset = 0; + unsigned int bit_index = 0; + int bit_remainder = 7; - x *= gfx_font.width; - y *= gfx_font.height; + for(uint32_t cy = 0; cy < gfx_font.height; cy++) { + uintptr_t cx_ptr = cy_ptr; - for(int cy = 0; cy < gfx_font.height; cy++) { - uintptr_t cy_ptr = (uintptr_t)(gfx_handle->ul_desc.addr) - + (y + cy)*gfx_handle->ul_desc.pitch + - + (x)*(gfx_handle->ul_desc.bpp / 8); + for(uint32_t cx = 0; cx < gfx_font.width; cx++) { + if(bit_remainder < 0) { + bit_index++; + bit_remainder = 7; + } - for(int cx = 0; cx < gfx_font.width; cx++) { - uintptr_t cx_ptr = cy_ptr + cx*(gfx_handle->ul_desc.bpp / 8); + int fg = bit_get(glyph[bit_index], bit_remainder); + setpixel(cx_ptr, fg ? col_fg : col_bg); - int fg = bitmap[cy] & (1 << (gfx_font.width - cx - 1)); - *(uint32_t*)cx_ptr = fg ? col_fg : col_bg; + bit_remainder--; + cx_ptr += pixel_bytes; } + + bit_offset += font_width_aligned; + bit_index++; + bit_remainder = 7; + cy_ptr += gfx_handle->ul_desc.pitch; } } -void gfx_fbtext_set_cursor(uint32_t x, uint32_t y, bool restore) { +void gfx_fbtext_draw_cursor(uint32_t x, uint32_t y) { x *= gfx_font.width; y *= gfx_font.height; - if(!cursor_data.last_data) { - cursor_data.last_data = zmalloc(gfx_font.height * sizeof(uint32_t)); - } else { - if(restore) { - for(int i = 0; i < gfx_font.height; i++) { - *PIXEL_PTR(gfx_handle->ul_desc.addr, cursor_data.last_x, cursor_data.last_y + i) = cursor_data.last_data[i]; - } - } - } - - for(int i = 0; i < gfx_font.height; i++) { - cursor_data.last_data[i] = *PIXEL_PTR(gfx_handle->ul_desc.addr, x, y + i); - } - - cursor_data.last_x = x; - cursor_data.last_y = y; - for(int i = 0; i < gfx_font.height; i++) { int color = 0xffffff; if(i == 0 || i == gfx_font.height - 1) { color = 0x000000; } - *PIXEL_PTR(gfx_handle->ul_desc.addr, x, y + i) = color; + setpixel(PIXEL_PTR(gfx_handle->ul_desc.addr, x, y + i), color); + } +} + +void gfx_fbtext_clear(uint32_t x, uint32_t y, uint32_t cols, uint32_t rows) { + size_t clear_size = font_width_bytes * cols; + uintptr_t offset = (uintptr_t)(gfx_handle->ul_desc.addr) + + y * font_height_pitch + + x * font_width_bytes; + + for(size_t i = 0; i < gfx_font.height * rows; i++) { + memset((void*)offset, 0, clear_size); + offset += gfx_handle->ul_desc.pitch; } } +void gfx_fbtext_scroll(unsigned int num) { + size_t lines = num * font_height_pitch; + size_t size = gfx_handle->ul_desc.size - lines; + void* from_ptr = gfx_handle->ul_desc.addr + lines; + memmove(gfx_handle->ul_desc.addr, from_ptr, size); + gfx_fbtext_clear(0, num_rows - 1, num_cols, 1); +} + // Switch GFX output to fbtext. This is used during kernel panics -void gfx_fbtext_show() { +void gfx_fbtext_show(void) { if(!initialized) { return; } gfx_handle_enable(gfx_handle); } -void gfx_fbtext_init() { +void gfx_fbtext_init(void) { gfx_handle = gfx_handle_init(VM_KERNEL); if(!gfx_handle) { log(LOG_ERR, "fbtext: Could not get gfx handle\n"); return; } - memset32(gfx_handle->ul_desc.addr, 0x000000, gfx_handle->ul_desc.size / 4); - int cols = gfx_handle->ul_desc.width / gfx_font.width; - int rows = gfx_handle->ul_desc.height / gfx_font.height; + if(gfx_handle->ul_desc.bpp != 32 && gfx_handle->ul_desc.bpp != 16) { + log(LOG_ERR, "fbtext: Unsupported framebufer depth %d\n", + gfx_handle->ul_desc.bpp); + return; + } - log(LOG_DEBUG, "fbtext: font width %d/%d height %d/%d flags %d\n", gfx_font.width, cols, gfx_font.height, rows, gfx_font.flags); + //memset(gfx_handle->ul_desc.addr, 0, gfx_handle->ul_desc.size); + num_cols = gfx_handle->ul_desc.width / gfx_font.width; + num_rows = gfx_handle->ul_desc.height / gfx_font.height; + log(LOG_DEBUG, "fbtext: font size %ux%u cols/rows %ux%u flags %u\n", + gfx_font.width, gfx_font.height, num_cols, num_rows, gfx_font.flags); + + font_width_aligned = ALIGN(gfx_font.width, 8); + font_height_pitch = gfx_font.height * gfx_handle->ul_desc.pitch; + pixel_bytes = gfx_handle->ul_desc.bpp / 8; + font_width_bytes = pixel_bytes * gfx_font.width; initialized = true; - tty_console_init(cols, rows); + + tty_console_init(num_cols, num_rows); gfx_fbtext_show(); - log_dump(); } diff --git a/src/gfx/fbtext.h b/src/gfx/fbtext.h index 19b09aa7..466b7596 100644 --- a/src/gfx/fbtext.h +++ b/src/gfx/fbtext.h @@ -20,8 +20,9 @@ #include -void gfx_fbtext_init(); -void gfx_fbtext_show(); -void gfx_fbtext_hide_logo(); +void gfx_fbtext_init(void); +void gfx_fbtext_show(void); void gfx_fbtext_write(uint32_t x, uint32_t y, wchar_t chr, uint32_t col_fg, uint32_t col_bg); -void gfx_fbtext_set_cursor(uint32_t x, uint32_t y, bool restore); +void gfx_fbtext_draw_cursor(uint32_t x, uint32_t y); +void gfx_fbtext_clear(uint32_t x, uint32_t y, uint32_t cols, uint32_t rows); +void gfx_fbtext_scroll(unsigned int num); diff --git a/src/gfx/gfx.c b/src/gfx/gfx.c index f2b66353..ffdf7cb5 100644 --- a/src/gfx/gfx.c +++ b/src/gfx/gfx.c @@ -144,7 +144,7 @@ static int sfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg) { return -1; } -void gfx_init() { +void gfx_init(void) { fb_desc = multiboot_get_framebuffer(); if(!fb_desc) { panic("Could not initialize graphics handling - No multiboot framebuffer"); @@ -152,13 +152,15 @@ void gfx_init() { } // Map the framebuffer into the kernel paging context - size_t vmem_size = fb_desc->common.framebuffer_height * fb_desc->common.framebuffer_pitch; + void* alloc_phys = (void*)(uintptr_t)fb_desc->common.framebuffer_addr; + size_t alloc_size = fb_desc->common.framebuffer_height * fb_desc->common.framebuffer_pitch; + size_t alloc_pages = ALIGN(alloc_size, PAGE_SIZE) / PAGE_SIZE; // FIXME use proper APIs - mem_page_alloc_at(&mem_phys_alloc_ctx, (void*)(uintptr_t)fb_desc->common.framebuffer_addr, ALIGN(vmem_size, PAGE_SIZE) / PAGE_SIZE); + mem_page_alloc_at(&mem_phys_alloc_ctx, alloc_phys, alloc_pages); vm_alloc_t framebuffer_mem; - if(!vm_alloc(VM_KERNEL, &framebuffer_mem, ALIGN(vmem_size, PAGE_SIZE) / PAGE_SIZE, (void*)(uintptr_t)fb_desc->common.framebuffer_addr, VM_RW)) { + if(!vm_alloc(VM_KERNEL, &framebuffer_mem, alloc_pages, alloc_phys, VM_RW)) { panic("gfx: Could not vm_alloc framebuffer"); } diff --git a/src/gfx/gfx.h b/src/gfx/gfx.h index 808d61b0..6b72ceba 100644 --- a/src/gfx/gfx.h +++ b/src/gfx/gfx.h @@ -55,4 +55,4 @@ void gfx_blit_all(struct gfx_handle* handle); void gfx_blit(struct gfx_handle* handle, size_t x, size_t y, size_t width, size_t height); void gfx_handle_enable(struct gfx_handle* handle); struct gfx_handle* gfx_handle_init(struct vm_ctx* ctx); -void gfx_init(); +void gfx_init(void); diff --git a/src/gfx/gfxbus.c b/src/gfx/gfxbus.c index 98a3cbde..8f27d403 100644 --- a/src/gfx/gfxbus.c +++ b/src/gfx/gfxbus.c @@ -21,6 +21,7 @@ * once those are implemented */ +#include #include #include #include @@ -78,9 +79,9 @@ static int sfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg) { task_t* task = ctx->task; int flags[] = {VM_USER | VM_RW | VM_ZERO, VM_USER | VM_RW}; - struct vm_ctx* ctx[] = {&master_task->vmem, &task->vmem}; + struct vm_ctx* vm_ctx[] = {&master_task->vmem, &task->vmem}; - void* addr = vm_alloc_many(2, ctx, NULL, RDIV(size, PAGE_SIZE), NULL, flags); + void* addr = vm_alloc_many(2, vm_ctx, NULL, RDIV(size, PAGE_SIZE), NULL, flags); if(!addr) { return -1; } @@ -95,7 +96,7 @@ static int sfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg) { } -void tty_gfxbus_init() { +void tty_gfxbus_init(void) { struct vfs_callbacks sfs_cb = { .ioctl = sfs_ioctl, .read = sfs_read, diff --git a/src/gfx/gfxbus.h b/src/gfx/gfxbus.h index e33b2e2e..fa8612e5 100644 --- a/src/gfx/gfxbus.h +++ b/src/gfx/gfxbus.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void tty_gfxbus_init(); +void tty_gfxbus_init(void); diff --git a/src/gfx/mouse.c b/src/gfx/mouse.c index ccbb0a56..79cc36a3 100644 --- a/src/gfx/mouse.c +++ b/src/gfx/mouse.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -36,7 +37,7 @@ struct mouse_event { static struct buffer* buf = NULL; -static inline void intr_handler() { +static inline void intr_handler(struct task* task, isf_t* state, int num) { static uint8_t mouse_cycle = 0; static struct mouse_event ev; static uint8_t status; @@ -88,7 +89,7 @@ static inline void mouse_write(uint8_t cmd) { outb(0x60, cmd); } -static inline uint8_t mouse_read() { +static inline uint8_t mouse_read(void) { mouse_wait(0); return inb(0x60); } @@ -113,7 +114,7 @@ static int sfs_poll(struct vfs_callback_ctx* ctx, int events) { return 0; } -void gfx_mouse_init() { +void gfx_mouse_init(void) { buf = buffer_new(10); if(!buf) { return; diff --git a/src/gfx/mouse.h b/src/gfx/mouse.h index ee048cc3..7433b48e 100644 --- a/src/gfx/mouse.h +++ b/src/gfx/mouse.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void gfx_mouse_init(); +void gfx_mouse_init(void); diff --git a/src/int/i386-idt.c b/src/int/i386-idt.c index cbe97e9f..ad5f8aeb 100644 --- a/src/int/i386-idt.c +++ b/src/int/i386-idt.c @@ -48,7 +48,7 @@ static void set_gate(uint8_t num, void (*handler)(void), uint8_t flags) { idt_entries[num].flags = flags; } -void idt_init() { +void idt_init(void) { lidt_pointer.limit = sizeof(struct idt_entry) * 256 -1; lidt_pointer.base = (uint32_t)&idt_entries; diff --git a/src/int/i386-idt.h b/src/int/i386-idt.h index e015deec..8e9b783c 100644 --- a/src/int/i386-idt.h +++ b/src/int/i386-idt.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void idt_init(); +void idt_init(void); diff --git a/src/int/int.c b/src/int/int.c index 2106f1f9..e22ec8e8 100644 --- a/src/int/int.c +++ b/src/int/int.c @@ -26,6 +26,8 @@ #define debug(args...) log(LOG_DEBUG, "interrupts: " args) +isf_t* __fastcall int_dispatch(uint32_t intr, isf_t* state); + struct interrupt_reg int_handlers[512][10]; uint8_t sse_state[512] __aligned(16) UL_VISIBLE("bss"); uint8_t* int_sse_target UL_VISIBLE("data") = sse_state; @@ -33,8 +35,10 @@ uint8_t* int_sse_target UL_VISIBLE("data") = sse_state; // Called by architecture-specific assembly handlers isf_t* __fastcall int_dispatch(uint32_t intr, isf_t* state) { memcpy(state->sse_state, sse_state, 512); + scheduler_store_isf(state); + struct interrupt_reg* reg = int_handlers[intr]; - volatile task_t* task = scheduler_get_current(); + task_t* task = scheduler_get_current(); #ifdef CONFIG_INTERRUPTS_DEBUG debug("state before:\n"); @@ -81,7 +85,7 @@ isf_t* __fastcall int_dispatch(uint32_t intr, isf_t* state) { return state; } -void int_init() { +void int_init(void) { idt_init(); bzero(int_handlers, sizeof(int_handlers)); int_enable(); diff --git a/src/int/int.h b/src/int/int.h index 59a1b95e..79b5c82f 100644 --- a/src/int/int.h +++ b/src/int/int.h @@ -99,4 +99,4 @@ static inline void dump_isf(uint32_t level, isf_t* state) { log(level, " ESI=0x%-10x EDI=0x%-10x EBP=0x%-10x ESP=0x%-10x\n", state->esi, state->edi, state->ebp, state->esp); } -void int_init(); +void int_init(void); diff --git a/src/lib/cmdline.c b/src/lib/cmdline.c index 390050c9..b0e3782b 100644 --- a/src/lib/cmdline.c +++ b/src/lib/cmdline.c @@ -61,7 +61,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return rsize; } -void cmdline_init() { +void cmdline_init(void) { char* cmdline = strdup(cmdline_string()); size_t len = strlen(cmdline); diff --git a/src/lib/cmdline.h b/src/lib/cmdline.h index 8f38ea57..aa4e6d79 100644 --- a/src/lib/cmdline.h +++ b/src/lib/cmdline.h @@ -24,4 +24,4 @@ char* cmdline_get(const char* key); bool cmdline_get_bool(const char* key); -void cmdline_init(); +void cmdline_init(void); diff --git a/src/lib/libgen.h b/src/lib/libgen.h new file mode 100644 index 00000000..f529a722 --- /dev/null +++ b/src/lib/libgen.h @@ -0,0 +1,51 @@ +#pragma once + +/* Copyright © 2023 Lukas Martini + * + * This file is part of Xelix. + * + * Xelix 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. + * + * Xelix 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 Xelix. If not, see . + */ + +static inline char* basename(char* path) { + if(!path || !*path) { + return "."; + } + + if(!strcmp(path, "/")) { + return path; + } + + char* name = strrchr(path, '/'); + return name ? name + 1 : path; +} + + +static inline char* dirname(char* path) { + if(!path) { + return "."; + } + + if(!strcmp(path, "/")) { + return path; + } + + char* end = strrchr(path, '/'); + if(!end) { + return "."; + } + + *end = '\0'; + return path; +} diff --git a/src/lib/list.c b/src/lib/list.c index 1f1d59ad..35281b21 100644 --- a/src/lib/list.c +++ b/src/lib/list.c @@ -35,7 +35,7 @@ struct list_node void *data; }; -struct list *list_new() +struct list *list_new(void) { struct list *list = kmalloc(sizeof(struct list)); list->length = 0; diff --git a/src/lib/list.h b/src/lib/list.h index 4cb92fe4..f56d3cba 100644 --- a/src/lib/list.h +++ b/src/lib/list.h @@ -21,7 +21,7 @@ typedef struct list list_t; -struct list *list_new(); +struct list *list_new(void); struct list *list_alloc(void * (*allocator)(int len)); void *list_append(struct list *l, void *data); diff --git a/src/lib/log.c b/src/lib/log.c index 9d1eef06..ffc270f7 100644 --- a/src/lib/log.c +++ b/src/lib/log.c @@ -45,6 +45,7 @@ static void* buffer = (void*)&early_buffer; static size_t buffer_size = PAGE_SIZE; static size_t log_size = 0; static size_t log_entries = 0; +static int console_log_level = CONFIG_LOG_CONSOLE_LEVEL; static void store(uint8_t level, char* string, size_t len) { size_t new_size = log_size + len + sizeof(struct log_entry); @@ -119,14 +120,12 @@ void log(uint8_t level, const char *fmt, ...) { } #endif - #if CONFIG_LOG_PRINT_LEVEL != 0 - if(level >= CONFIG_LOG_PRINT_LEVEL) { + if(console_log_level != 0 && level >= console_log_level) { printf(fmt_string); } - #endif } -void log_dump() { +void log_dump(void) { struct log_entry* entry = (struct log_entry*)buffer; log(LOG_INFO, "log: Dumping early log, %d entries\n", log_entries); for(int i = 0; i < log_entries; i++) { @@ -135,6 +134,11 @@ void log_dump() { } } +void log_set_console_level(int level) { + console_log_level = level; + log(LOG_INFO, "log: Console log level changed to %d\n", level); +} + static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { if(ctx->fp->offset >= log_size) { return 0; @@ -148,7 +152,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return size; } -void log_init() { +void log_init(void) { #ifdef CONFIG_LOG_STORE struct vfs_callbacks sfs_cb = { .read = sfs_read, diff --git a/src/lib/log.h b/src/lib/log.h index bcea4873..377c44c2 100644 --- a/src/lib/log.h +++ b/src/lib/log.h @@ -26,5 +26,6 @@ #define LOG_ERR 4 void log(uint8_t level, const char *fmt, ...); -void log_dump(); -void log_init(); +void log_dump(void); +void log_set_console_level(int level); +void log_init(void); diff --git a/src/lib/md5.c b/src/lib/md5.c index 54576470..2d8d4451 100644 --- a/src/lib/md5.c +++ b/src/lib/md5.c @@ -58,7 +58,7 @@ static uint8_t PADDING[] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* * Rotates a 32-bit word left by n bits */ -uint32_t rotateLeft(uint32_t x, uint32_t n){ +static uint32_t rotateLeft(uint32_t x, uint32_t n){ return (x << n) | (x >> (32 - n)); } diff --git a/src/lib/panic.c b/src/lib/panic.c index a2fe3db2..f890f903 100644 --- a/src/lib/panic.c +++ b/src/lib/panic.c @@ -32,6 +32,8 @@ #include #include +void __stack_chk_fail(void); + static spinlock_t lock; // Should seed this using RNG uintptr_t __stack_chk_guard = 0xcafed00d; diff --git a/src/lib/spinlock.h b/src/lib/spinlock.h index 70aa4fb4..14bcc9ff 100644 --- a/src/lib/spinlock.h +++ b/src/lib/spinlock.h @@ -21,7 +21,7 @@ #include #include -extern void scheduler_yield(); +extern void scheduler_yield(void); /* See https://gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/Atomic-Builtins.html for * documentation on the GCC builtin atomic function used here. diff --git a/src/lib/strcasecmp.c b/src/lib/strcasecmp.c index 685668e7..3b3c1d5d 100644 --- a/src/lib/strcasecmp.c +++ b/src/lib/strcasecmp.c @@ -69,7 +69,6 @@ static const u_char charmap[] = { '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', }; -#undef strcasecmp int strcasecmp(const char *s1, const char *s2) { const u_char *cm = charmap; const u_char *us1 = (const u_char *)s1; @@ -80,7 +79,6 @@ int strcasecmp(const char *s1, const char *s2) { return (cm[*us1] - cm[*--us2]); } -#undef strncasecmp int strncasecmp(const char *s1, const char *s2, size_t n) { if (n != 0) { const u_char *cm = charmap; diff --git a/src/lib/string.c b/src/lib/string.c index e81cb734..6ebe9f5e 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -22,18 +22,14 @@ #include #include -#undef strlen -size_t strlen(const char* str) -{ +size_t strlen(const char* str) { const char *s; for (s = str; *s != 0 && *s != -1; ++s); return(s - str); } -#undef strnlen -size_t strnlen(const char *s, size_t maxlen) -{ +size_t strnlen(const char *s, size_t maxlen) { size_t len; for (len = 0; len < maxlen; len++, s++) { @@ -43,9 +39,7 @@ size_t strnlen(const char *s, size_t maxlen) return (len); } -#undef strcpy -char* strcpy(char* dest, const char* src) -{ +char* strcpy(char* dest, const char* src) { char* save = dest; while((*dest++ = *src++)); return save; @@ -56,8 +50,7 @@ char* strcpy(char* dest, const char* src) * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ -size_t strlcpy(char *dst, const char *src, size_t siz) -{ +size_t strlcpy(char *dst, const char *src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; @@ -78,26 +71,20 @@ size_t strlcpy(char *dst, const char *src, size_t siz) return(s - src - 1); /* count does not include NUL */ } -#undef strncpy -char* strncpy(char* dst, const char* src, size_t n) -{ +char* strncpy(char* dst, const char* src, size_t n) { char* p = dst; while (n-- && (*dst++ = *src++)); return p; } -#undef strcmp -int strcmp(const char* s1, const char* s2) -{ +int strcmp(const char* s1, const char* s2) { for(; *s1 == *s2; ++s1, ++s2) if(*s1 == 0) return 0; return *(unsigned char *)s1 < *(unsigned char *)s2 ? -1 : 1; } -#undef strncmp -int strncmp(const char *s1, const char *s2, register size_t n) -{ +int strncmp(const char *s1, const char *s2, register size_t n) { register unsigned char u1, u2; while (n-- > 0) { @@ -111,16 +98,12 @@ int strncmp(const char *s1, const char *s2, register size_t n) return 0; } - -#undef strcat -char* strcat(char *dest, const char *src) -{ +char* strcat(char *dest, const char *src) { strcpy(dest + strlen(dest), src); return dest; } -char* substr(char* src, size_t start, size_t len) -{ +char* substr(char* src, size_t start, size_t len) { char *dest = (char*)kmalloc(len+1); if (dest) { memcpy(dest, src+start, len); @@ -129,8 +112,7 @@ char* substr(char* src, size_t start, size_t len) return dest; } -char* strtok_r(char* s, const char* delim, char** last) -{ +char* strtok_r(char* s, const char* delim, char** last) { char *spanp; int c, sc; char *tok; @@ -176,8 +158,7 @@ char* strtok_r(char* s, const char* delim, char** last) /* Return index of first match of item in list. */ -int find_substr(char* list, char* item) -{ +int find_substr(char* list, char* item) { int t; char* p, *p2; @@ -194,16 +175,13 @@ int find_substr(char* list, char* item) return -1; /* 2nd return */ } -#undef strndup -char* strndup(const char* old, size_t num) -{ +char* strndup(const char* old, size_t num) { char* new = kmalloc(sizeof(char) * (num + 1)); strlcpy(new, old, num + 1); return new; } #if !defined(__i386__) -#undef memset void memset(void* ptr, uint8_t fill, uint32_t size) { uint8_t* p = (uint8_t*) ptr; uint8_t* max = p+size; @@ -213,7 +191,6 @@ void memset(void* ptr, uint8_t fill, uint32_t size) { } } -#undef memcpy void* memcpy(void* dest, const void* src, uint32_t size) { uint8_t* from = (uint8_t*) src; uint8_t* to = (uint8_t*) dest; @@ -230,7 +207,6 @@ void* memcpy(void* dest, const void* src, uint32_t size) { } #endif -#undef memcmp int32_t memcmp(const void *s1, const void *s2, size_t n) { const unsigned char *us1 = (const unsigned char *) s1; const unsigned char *us2 = (const unsigned char *) s2; @@ -244,7 +220,6 @@ int32_t memcmp(const void *s1, const void *s2, size_t n) { return 0; } -#undef memmove void* memmove(void *dst, const void *src, size_t len) { size_t i; @@ -314,8 +289,7 @@ void* memmove(void *dst, const void *src, size_t len) { return dst; } -#undef strchr -char *strchr(const char *p, int ch) { +char* strchr(const char *p, int ch) { char c; c = ch; @@ -327,6 +301,17 @@ char *strchr(const char *p, int ch) { } } +char* strrchr(const char *p, int ch) { + char* save; + + for (save = NULL;; ++p) { + if (*p == ch) + save = (char *)p; + if (!*p) + return(save); + } +} + int asprintf(char **strp, const char *fmt, ...) { va_list ap; va_start(ap, fmt); diff --git a/src/lib/string.h b/src/lib/string.h index 2de7bc0b..19f69f36 100644 --- a/src/lib/string.h +++ b/src/lib/string.h @@ -23,28 +23,32 @@ #define bzero(b,len) (memset((b), '\0', (len)), (void) 0) #define strdup(string) strndup(string, strlen(string)) -#define strcmp __builtin_strcmp -#define strcasecmp __builtin_strcasecmp -#define strncasecmp __builtin_strncasecmp -#define strncmp __builtin_strncmp -#define strcat __builtin_strcat -#define strcpy __builtin_strcpy -#define strncpy __builtin_strncpy -#define strlen __builtin_strlen -#define strnlen __builtin_strnlen -#define strndup __builtin_strndup -#define memset __builtin_memset -#define memcpy __builtin_memcpy -#define memcmp __builtin_memcmp -#define memmove __builtin_memmove -#define strchr __builtin_strchr +// string.c +size_t strlen(const char* str); +size_t strnlen(const char *s, size_t maxlen); +char* strcpy(char* dest, const char* src); size_t strlcpy(char *dst, const char *src, size_t siz); -char* strtok_r(char* s, const char* delim, char** last); +char* strncpy(char* dst, const char* src, size_t n); +int strcmp(const char* s1, const char* s2); +int strncmp(const char *s1, const char *s2, register size_t n); +char* strcat(char *dest, const char *src); char* substr(char* src, size_t start, size_t len); +char* strtok_r(char* s, const char* delim, char** last); int find_substr(char* list, char* item); +char* strndup(const char* old, size_t num); +void memset(void* ptr, uint8_t fill, uint32_t size); +void* memcpy(void* dest, const void* src, uint32_t size); +int32_t memcmp(const void *s1, const void *s2, size_t n); +void* memmove(void *dst, const void *src, size_t len); +char *strchr(const char *p, int ch); +char* strrchr(const char *p, int ch); int asprintf(char **strp, const char *fmt, ...); +// strcasecmp.c +int strcasecmp(const char *s1, const char *s2); +int strncasecmp(const char *s1, const char *s2, size_t n); + static inline void *memset32(uint32_t *s, uint32_t v, size_t n) { long d0, d1; asm volatile("rep stosl" diff --git a/src/lib/time.c b/src/lib/time.c index 85993942..5a9b46b0 100644 --- a/src/lib/time.c +++ b/src/lib/time.c @@ -36,7 +36,7 @@ int century_register = 0x00; time_t last_timestamp = 0; uint64_t last_tick = 0; -static int in_progress() { +static int in_progress(void) { outb(0x70, 0x0A); return (inb(0x71) & 0x80); } @@ -46,7 +46,7 @@ static uint8_t get_register(int reg) { return inb(0x71); } -static time_t read_rtc() { +static time_t read_rtc(void) { uint8_t century = 0; uint8_t second; uint8_t minute; @@ -153,7 +153,7 @@ static time_t read_rtc() { return t; } -uint32_t time_get() { +uint32_t time_get(void) { uint32_t stick = timer_tick; if(stick <= last_tick + timer_rate) { return last_timestamp; @@ -181,7 +181,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return rsize; } -void time_init() { +void time_init(void) { last_timestamp = read_rtc(); last_tick = timer_tick; log(LOG_INFO, "time: Initial last_timestamp is %u at tick %llu\n", last_timestamp, last_tick); diff --git a/src/lib/time.h b/src/lib/time.h index f30462df..fe5f9779 100644 --- a/src/lib/time.h +++ b/src/lib/time.h @@ -20,7 +20,7 @@ #include -extern void scheduler_yield(); +extern void scheduler_yield(void); struct task; typedef uint32_t time_t; @@ -29,9 +29,9 @@ struct timeval { int32_t tv_usec; }; -uint32_t time_get(); +uint32_t time_get(void); int time_get_timeval(struct task* task, struct timeval* tv); -void time_init(); +void time_init(void); #define sleep(t) sleep_ticks((t) * timer_rate) static inline void __attribute__((optimize("O0"))) sleep_ticks(time_t timeout) { diff --git a/src/lib/version.c b/src/lib/version.c index 195cc704..22bec7ef 100644 --- a/src/lib/version.c +++ b/src/lib/version.c @@ -18,6 +18,7 @@ */ #include +#include static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { if(ctx->fp->offset) { @@ -29,7 +30,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return rsize; } -void version_init() { +void version_init(void) { struct vfs_callbacks sfs_cb = { .read = sfs_read, }; diff --git a/src/lib/version.h b/src/lib/version.h index d5b4b15d..9f4ed276 100644 --- a/src/lib/version.h +++ b/src/lib/version.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void version_init(); +void version_init(void); diff --git a/src/mem/i386-gdt.c b/src/mem/i386-gdt.c index ed2bc638..9d518d4b 100644 --- a/src/mem/i386-gdt.c +++ b/src/mem/i386-gdt.c @@ -102,7 +102,7 @@ void gdt_set_tss(void* addr) { gdt_flush(&pointer); } -void gdt_init() { +void gdt_init(void) { pointer.limit = (sizeof(uint64_t) * 6) - 1; pointer.base = descs; diff --git a/src/mem/i386-gdt.h b/src/mem/i386-gdt.h index f0c04c7c..62b66e97 100644 --- a/src/mem/i386-gdt.h +++ b/src/mem/i386-gdt.h @@ -25,4 +25,4 @@ #define GDT_SEG_DATA_PL3 0x23 void gdt_set_tss(void* addr); -void gdt_init(); +void gdt_init(void); diff --git a/src/mem/i386-paging.c b/src/mem/i386-paging.c index a2bfe987..5ff3f631 100644 --- a/src/mem/i386-paging.c +++ b/src/mem/i386-paging.c @@ -127,7 +127,7 @@ void paging_rm_context(struct paging_context* ctx) { pfree((uintptr_t)ctx / PAGE_SIZE, 1); } -void paging_init() { +void paging_init(void) { paging_kernel_ctx = ALIGN(KERNEL_END, PAGE_SIZE); bzero(paging_kernel_ctx, sizeof(struct paging_context)); paging_alloc_end = (void*)paging_kernel_ctx + sizeof(struct paging_context); diff --git a/src/mem/kmalloc.c b/src/mem/kmalloc.c index 7956bfe0..1c5a102f 100644 --- a/src/mem/kmalloc.c +++ b/src/mem/kmalloc.c @@ -296,6 +296,10 @@ void* __attribute__((alloc_size(1))) _kmalloc(size_t sz, bool align, bool zero D struct mem_block* new = split_block(header, alignment_offset - sizeof(struct mem_block) - sizeof(struct footer)); + if(!new) { + return NULL; + } + new->type = TYPE_USED; free_block(header, true); header = new; diff --git a/src/mem/kmalloc.h b/src/mem/kmalloc.h index fab78b65..8da6b504 100644 --- a/src/mem/kmalloc.h +++ b/src/mem/kmalloc.h @@ -57,5 +57,5 @@ extern bool kmalloc_ready; kfree(arr); \ } while(0) -void kmalloc_init(); +void kmalloc_init(void); void kmalloc_get_stats(uint32_t* total, uint32_t* used); diff --git a/src/mem/mem.c b/src/mem/mem.c index 21a69a5f..2f3b9a45 100644 --- a/src/mem/mem.c +++ b/src/mem/mem.c @@ -60,7 +60,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return rsize; } -void mem_init() { +void mem_init(void) { // Init phys page allocator. kernel vm has already been initialized in i386-paging.c. if(mem_page_alloc_new(&mem_phys_alloc_ctx) < 0) { panic("mem: Initialization of phys page allocator failed.\n"); @@ -112,7 +112,7 @@ void mem_init() { } -void mem_late_init() { +void mem_late_init(void) { /* In physical memory, block out all lower memory up to the end of early * allocations from paging.c. Since the early allocations follow * KERNEL_END, this implicitly includes the kernel binary. diff --git a/src/mem/mem.h b/src/mem/mem.h index f2d4c31f..d8bc1b98 100644 --- a/src/mem/mem.h +++ b/src/mem/mem.h @@ -29,5 +29,5 @@ extern struct mem_page_alloc_ctx mem_phys_alloc_ctx; //#define pfree(num, size) (mem_page_free(&mem_phys_alloc_ctx, num, size)) #define pfree(num, size) -void mem_init(); -void mem_late_init(); +void mem_init(void); +void mem_late_init(void); diff --git a/src/mem/paging.h b/src/mem/paging.h index 7ae80d05..228342da 100644 --- a/src/mem/paging.h +++ b/src/mem/paging.h @@ -49,4 +49,4 @@ struct vmem_range; void paging_set_range(struct paging_context* ctx, void* virt_addr, void* phys_addr, size_t size, int flags); void paging_clear_range(struct paging_context* ctx, void* virt_addr, size_t size); void paging_rm_context(struct paging_context* ctx); -void paging_init(); +void paging_init(void); diff --git a/src/mem/vm.c b/src/mem/vm.c index ef3f07a1..48e38df2 100644 --- a/src/mem/vm.c +++ b/src/mem/vm.c @@ -47,7 +47,7 @@ static int have_malloc_ranges = 50; */ #define CLEANUP_FLAGS(x) ((x) & (VM_RW | VM_USER | VM_FREE | VM_TFORK | VM_NOCOW)) -static inline vm_alloc_t* new_range() { +static inline vm_alloc_t* new_range(void) { /* During initialization, kmalloc_init calls vm_alloc once to get its * memory space to allocate from. The zmalloc call below would fail since * kmalloc is not ready yet. Another call to vm_alloc can then happen in @@ -347,17 +347,14 @@ void* vm_map(struct vm_ctx* ctx, vm_alloc_t* vmem, struct vm_ctx* src_ctx, debug(" vm_map: map pass %d for %p\n", pages_mapped, src_aligned + pages_offset); vm_alloc_t* src_range = get_range(src_ctx, src_aligned + pages_offset, false); if(!src_range) { - // FIXME Temp to map around broken execve - if(flags & VM_MAP_UNDERALLOC_WORKAROUND) { - pages_mapped++; + debug("No range!\n"); + + if(pages_mapped > 0 && flags & VM_MAP_LESS_OK) { break; } - - debug("No range!\n"); return NULL; } - if(!src_range->phys) { panic("vm: Attempt to vm_map sharded memory\n"); } @@ -384,8 +381,6 @@ void* vm_map(struct vm_ctx* ctx, vm_alloc_t* vmem, struct vm_ctx* src_ctx, pages_mapped++; } while(pages_mapped < size_pages); - assert(pages_mapped == size_pages); - if(vmem) { memcpy(vmem, range, sizeof(vm_alloc_t)); } diff --git a/src/mem/vm.h b/src/mem/vm.h index 3f805ba9..61c3a530 100644 --- a/src/mem/vm.h +++ b/src/mem/vm.h @@ -27,6 +27,8 @@ #define VM_BITMAP_SIZE 0xfffff000 / PAGE_SIZE #define VM_KERNEL (&vm_kernel_ctx) +/* Flags for struct vm_alloc */ + // Writable #define VM_RW 1 @@ -47,16 +49,20 @@ // Zero out address space after allocation #define VM_ZERO 32 +#define VM_DEBUG 4096 + +/* Flags to vm_map */ +/* These must not conflict with the VM_* flags above. */ + // vm_map: Only map user-readable pages #define VM_MAP_USER_ONLY 512 // Fixed allocation in vm_alloc_at #define VM_FIXED 1024 -// temp -#define VM_MAP_UNDERALLOC_WORKAROUND 2048 +// Don't fail if not all of `size` could be mapped as long as at least one page succeeded. +#define VM_MAP_LESS_OK 2048 -#define VM_DEBUG 4096 #define vm_alloc(ctx, vmem, size, phys, flags) vm_alloc_at(ctx, vmem, size, NULL, phys, flags) diff --git a/src/net/conv.c b/src/net/conv.c index 51ab1c72..e3882f9c 100644 --- a/src/net/conv.c +++ b/src/net/conv.c @@ -29,13 +29,11 @@ int net_bsd_to_pico_addr(union pico_address *addr, const struct sockaddr *_saddr } if (socklen == SOCKSIZE6) { - struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)_saddr; + const struct sockaddr_in6 *saddr = (const struct sockaddr_in6 *)_saddr; memcpy(&addr->ip6.addr, &saddr->sin6_addr.s6_addr, 16); - saddr->sin6_family = AF_INET6; } else { - struct sockaddr_in *saddr = (struct sockaddr_in *)_saddr; + const struct sockaddr_in *saddr = (const struct sockaddr_in *)_saddr; addr->ip4.addr = saddr->sin_addr.s_addr; - saddr->sin_family = AF_INET; } return 0; } @@ -46,10 +44,10 @@ uint16_t net_bsd_to_pico_port(const struct sockaddr *_saddr, socklen_t socklen) } if (socklen == SOCKSIZE6) { - struct sockaddr_in6 *saddr = (struct sockaddr_in6 *)_saddr; + const struct sockaddr_in6 *saddr = (const struct sockaddr_in6 *)_saddr; return saddr->sin6_port; } else { - struct sockaddr_in *saddr = (struct sockaddr_in *)_saddr; + const struct sockaddr_in *saddr = (const struct sockaddr_in *)_saddr; return saddr->sin_port; } } diff --git a/src/net/i386-ne2k.c b/src/net/i386-ne2k.c index 27e681bf..eb229be0 100644 --- a/src/net/i386-ne2k.c +++ b/src/net/i386-ne2k.c @@ -124,7 +124,7 @@ static void pdma_write(int addr, const void* data, size_t len) { set_dma_la(addr, len); ioutb(R_CR, CR_START | CR_DMA_WRITE); - uint8_t *p = (uint8_t*)data; + const uint8_t *p = (const uint8_t*)data; for(size_t i = 0; i < len; i++) { ioutb(0x10, p[i]); } @@ -140,7 +140,7 @@ static void pdma_read(int addr, void* data, size_t len) { } } -static void receive() { +static void receive(void) { // Mask receipt interrupts ioutb(R_IMR, 0x3a); @@ -212,7 +212,15 @@ static void int_handler(task_t* task, isf_t* state, int num) { ioutb(R_ISR, isr &~ 1); } -static void enable() { +static int pci_cb(pci_device_t* _dev) { + if(pci_check_vendor(_dev, vendor_device_combos) != 0) { + return 1; + } + + // FIXME Support multiple devices + dev = _dev; + log(LOG_INFO, "ne2k: Discovered device %p\n", dev); + // Reset ioutb(0x1F, iinb(0x1F)); while ((iinb(R_ISR) & 0x80) == 0); @@ -258,17 +266,12 @@ static void enable() { ioutb(R_CR, CR_START); net_dev = net_add_device("ne2k", nmac, send); -} -void ne2k_init() { - pci_device_t** devices = (pci_device_t**)kmalloc(sizeof(void*)); - uint32_t ndevices = pci_search(devices, vendor_device_combos, 1); + return 0; +} - log(LOG_INFO, "ne2k: Discovered %d devices.\n", ndevices); - dev = devices[0]; - if(ndevices) { - enable(); - } +void ne2k_init(void) { + pci_walk(pci_cb); } #endif /* ENABLE_NE2K */ diff --git a/src/net/i386-ne2k.h b/src/net/i386-ne2k.h index 76de8631..0f5c795a 100644 --- a/src/net/i386-ne2k.h +++ b/src/net/i386-ne2k.h @@ -18,6 +18,6 @@ #ifdef CONFIG_ENABLE_NE2K -void ne2k_init(); +void ne2k_init(void); #endif /* CONFIG_ENABLE_NE2K */ diff --git a/src/net/i386-rtl8139.c b/src/net/i386-rtl8139.c index a666c8a5..2965558c 100644 --- a/src/net/i386-rtl8139.c +++ b/src/net/i386-rtl8139.c @@ -325,8 +325,7 @@ static void enable(struct rtl8139_card *card) */ } -void rtl8139_init() -{ +void rtl8139_init(void) { memset(rtl8139_cards, 0, RTL8139_MAX_CARDS * sizeof(struct rtl8139_card)); pci_device_t** devices = (pci_device_t**)kmalloc(sizeof(void*) * RTL8139_MAX_CARDS); diff --git a/src/net/i386-rtl8139.h b/src/net/i386-rtl8139.h index 5f2b3db2..9af58789 100644 --- a/src/net/i386-rtl8139.h +++ b/src/net/i386-rtl8139.h @@ -19,4 +19,4 @@ */ -void rtl8139_init(); +void rtl8139_init(void); diff --git a/src/net/net.c b/src/net/net.c index ed6b83a4..53b61a3b 100644 --- a/src/net/net.c +++ b/src/net/net.c @@ -39,7 +39,7 @@ spinlock_t net_pico_lock; static bool initialized = false; static uint32_t dhcp_xid; -void dhcp_cb(void* cli, int code) { +static void dhcp_cb(void* cli, int code) { if(code & PICO_DHCP_ERROR) { log(LOG_INFO, "net: DHCP failed.\n"); return; diff --git a/src/net/net.h b/src/net/net.h index 890be865..515abfab 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -32,4 +32,5 @@ extern spinlock_t net_pico_lock; void net_receive(struct net_device* dev, void* data, size_t len); struct net_device* net_add_device(char* name, uint8_t mac[6], net_send_callback_t* write_cb); -void net_init(); + +void net_init(void); diff --git a/src/net/socket.c b/src/net/socket.c index d9368139..ab8e5b60 100644 --- a/src/net/socket.c +++ b/src/net/socket.c @@ -291,7 +291,7 @@ int net_vfs_close_cb(vfs_file_t* fp) { return 0; } -vfs_file_t* new_socket_fd(task_t* task, struct pico_socket* pico_sock, int state) { +static vfs_file_t* new_socket_fd(task_t* task, struct pico_socket* pico_sock, int state) { struct socket* sock = (struct socket*)zmalloc(sizeof(struct socket)); sock->pico_socket = pico_sock; sock->state = state; diff --git a/src/net/virtio_net.c b/src/net/virtio_net.c index 759b2a59..3685b5f1 100644 --- a/src/net/virtio_net.c +++ b/src/net/virtio_net.c @@ -149,43 +149,47 @@ static void int_handler(task_t* task, isf_t* state, int num) { } } -void virtio_net_init() -{ - pci_device_t** devices = (pci_device_t**)kmalloc(sizeof(void*)); - uint32_t ndevices = pci_search(devices, vendor_device_combos, 1); - log(LOG_INFO, "virtio_net: Discovered %d devices.\n", ndevices); - - if(ndevices) { - dev = virtio_init_dev(devices[0], FEATURES_WANT, 2); - if(!dev) { - return; - } +static int pci_cb(pci_device_t* pci_dev) { + if(pci_check_vendor(pci_dev, vendor_device_combos) != 0) { + return 1; + } - log(LOG_DEBUG, "virtio_net: Negotiated features (0x%x): ", dev->features); - for(int i = 0; i < 16; i++) { - if(bit_get(dev->features, i)) { - // FIXME should use log - serial_printf("%s ", feature_flags_verbose[i]); - } - } - serial_printf("\n"); + log(LOG_INFO, "virtio_net: Discovered device %p\n", pci_dev); - dev->queues[QUEUE_TX1].available->flags = VIRTQ_AVAIL_F_NO_INTERRUPT; - virtio_provide_descs(dev, QUEUE_RX1, 50, 1500); - int_register(IRQ(dev->pci_dev->interrupt_line), int_handler, false); + dev = virtio_init_dev(pci_dev, FEATURES_WANT, 2); + if(!dev) { + return 1; + } - uint8_t mac[6] = {0x52, 0x54, 0x00, 0x12, 0x34, 0x56}; - if(dev->features & VIRTIO_NET_F_MAC) { - for(int i = 0; i < 6; i++) { - mac[i] = inb(dev->pci_dev->iobase + 0x14 + i); - } + log(LOG_DEBUG, "virtio_net: Negotiated features (0x%x): ", dev->features); + for(int i = 0; i < 16; i++) { + if(bit_get(dev->features, i)) { + // FIXME should use log + serial_printf("%s ", feature_flags_verbose[i]); } + } + serial_printf("\n"); - dev->status |= VIRTIO_PCI_STATUS_DRIVER_OK; - virtio_write_status(dev); + dev->queues[QUEUE_TX1].available->flags = VIRTQ_AVAIL_F_NO_INTERRUPT; + virtio_provide_descs(dev, QUEUE_RX1, 50, 1500); + int_register(IRQ(dev->pci_dev->interrupt_line), int_handler, false); - net_dev = net_add_device("vionet", mac, send); + uint8_t mac[6] = {0x52, 0x54, 0x00, 0x12, 0x34, 0x56}; + if(dev->features & VIRTIO_NET_F_MAC) { + for(int i = 0; i < 6; i++) { + mac[i] = inb(dev->pci_dev->iobase + 0x14 + i); + } } + + dev->status |= VIRTIO_PCI_STATUS_DRIVER_OK; + virtio_write_status(dev); + + net_dev = net_add_device("vionet", mac, send); + return 0; +} + +void virtio_net_init(void) { + pci_walk(pci_cb); } #endif /* ENABLE_VIRTIO_NET */ diff --git a/src/net/virtio_net.h b/src/net/virtio_net.h index 83c81190..b18b8ebd 100644 --- a/src/net/virtio_net.h +++ b/src/net/virtio_net.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void virtio_net_init(); +void virtio_net_init(void); diff --git a/src/sound/i386-ac97.c b/src/sound/i386-ac97.c index 43285a1a..0987d18d 100644 --- a/src/sound/i386-ac97.c +++ b/src/sound/i386-ac97.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -66,7 +67,7 @@ #define AC97_X_SR_CELV (1 << 1) /* Current equals last valid */ #define AC97_X_SR_LVBCI (1 << 2) /* Last valid buffer completion interrupt */ #define AC97_X_SR_BCIS (1 << 3) /* Buffer completion interrupt status */ -#define AC97_X_SR_FIFOE (1 << 3) /* FIFO error */ +#define AC97_X_SR_FIFOE (1 << 4) /* FIFO error */ /* PCM out control register flags */ #define AC97_X_CR_RPBM (1 << 0) /* Run/pause bus master */ @@ -106,11 +107,10 @@ struct ac97_card { int buf_next_write; }; -static struct ac97_card ac97_cards[AC97_MAX_CARDS]; -static int cards = 0; +static struct ac97_card main_card; static void interrupt_handler(task_t* task, isf_t* state, int num) { - struct ac97_card* card = &ac97_cards[0]; + struct ac97_card* card = &main_card; /*// Find the card this IRQ is coming from for(int i = 0; i < cards; i++) { if(likely(state->interrupt == IRQ(ac97_cards[i].device->interrupt_line))) { @@ -138,7 +138,7 @@ static void interrupt_handler(task_t* task, isf_t* state, int num) { } } -void ac97_set_volume(struct ac97_card* card, int volume) { +static void ac97_set_volume(struct ac97_card* card, int volume) { // Set volume level of the various mixers // 0 = loud, 63 = almost silent outw(card->nambar + PORT_NAM_MASTER_VOLUME, (volume<<8) | volume); @@ -164,7 +164,11 @@ static void set_sample_rate(struct ac97_card* card) { } static size_t sfs_write(struct vfs_callback_ctx* ctx, void* source, size_t size) { - struct ac97_card* card = &ac97_cards[0]; + struct ac97_card* card = &main_card; + if(unlikely(!card)) { + sc_errno = EINVAL; + return -1; + } int bno = card->buf_next_write; card->buf_next_write = (card->buf_next_write + 1) % NUM_BUFFERS; @@ -192,7 +196,17 @@ static size_t sfs_write(struct vfs_callback_ctx* ctx, void* source, size_t size) return size; } -static void enable_card(struct ac97_card* card) { +static int pci_cb(pci_device_t* dev) { + if(pci_check_vendor(dev, vendor_device_combos) != 0) { + return 1; + } + + log(LOG_INFO, "ac97: Discovered device %p\n", dev); + + // FIXME support multiple cards + struct ac97_card* card = &main_card; + card->device = dev; + int_register(IRQ(card->device->interrupt_line), interrupt_handler, false); // Enable bus master, disable MSE @@ -200,8 +214,8 @@ static void enable_card(struct ac97_card* card) { sleep_ticks(30); // Get correct PCI bars for the sound chip control io ports - card->nambar = pci_get_BAR(card->device, 0) & 0xFFFFFFFC; - card->nabmbar = pci_get_BAR(card->device, 1) & 0xFFFFFFFC; + card->nambar = pci_get_bar(card->device, 0) & 0xFFFFFFFC; + card->nabmbar = pci_get_bar(card->device, 1) & 0xFFFFFFFC; card->playing_buffer = -1; // Turn power on / disable cold reset @@ -224,7 +238,7 @@ static void enable_card(struct ac97_card* card) { if(i > 60) { log(LOG_INFO, "ac97: Warm reset was not successful. Bailing.\n"); - return; + return 0; } sleep_ticks(10); @@ -240,7 +254,7 @@ static void enable_card(struct ac97_card* card) { for(int i = 0; i < NUM_BUFFERS; i++) { if(!vm_alloc(VM_KERNEL, &card->buffers[i], 4, NULL, VM_RW)) { - return; + return 0; } card->descs[i].buf = card->buffers[i].phys; } @@ -251,23 +265,12 @@ static void enable_card(struct ac97_card* card) { .write = sfs_write, }; sysfs_add_dev("dsp1", &sfs_cb); -} - -void ac97_init() { - memset(ac97_cards, 0, AC97_MAX_CARDS * sizeof(struct ac97_card)); - pci_device_t** devices = (pci_device_t**)kmalloc(sizeof(pci_device_t*) * AC97_MAX_CARDS); - uint32_t num_devices = pci_search(devices, vendor_device_combos, AC97_MAX_CARDS); - log(LOG_INFO, "ac97: Discovered %d devices.\n", num_devices); - for(int i = 0; i < num_devices; ++i) { - ac97_cards[i].device = devices[i]; - cards++; + return 0; +} - enable_card(&ac97_cards[i]); - log(LOG_INFO, "ac97: %d:%d.%d, iobase 0x%x, irq %d\n", - devices[i]->bus, devices[i]->dev, devices[i]->func, - devices[i]->iobase, devices[i]->interrupt_line); - } +void ac97_init(void) { + pci_walk(pci_cb); } #endif /* ENABLE_AC97 */ diff --git a/src/sound/i386-ac97.h b/src/sound/i386-ac97.h index 49213038..87d2c116 100644 --- a/src/sound/i386-ac97.h +++ b/src/sound/i386-ac97.h @@ -19,4 +19,4 @@ */ void ac97_play(char* file); -void ac97_init(); +void ac97_init(void); diff --git a/src/tasks/elf.c b/src/tasks/elf.c index 53beae63..f4a4bc4d 100644 --- a/src/tasks/elf.c +++ b/src/tasks/elf.c @@ -40,7 +40,11 @@ static char elf_magic[16] = {0x7f, 'E', 'L', 'F', 01, 01, 01, 0, 0, 0, 0, 0, 0, static inline void* bin_read(int fd, size_t offset, size_t size, void* inbuf, task_t* task) { void* buf = inbuf ? inbuf : kmalloc(size); - vfs_seek(task, fd, offset, VFS_SEEK_SET); + if(vfs_seek(task, fd, offset, VFS_SEEK_SET) < 0 ) { + debug("elf: bin_read: vfs_seek failed\n"); + return NULL; + } + size_t read = vfs_read(task, fd, buf, size); if(likely(read == size)) { return buf; @@ -146,7 +150,12 @@ static inline int load_file(task_t* task, char* path) { if(phead->type == PT_INTERP) { char* interp = bin_read(fd, phead->offset, phead->filesz, NULL, task); debug("elf: Binary has interpreter %s\n", interp); - return load_file(task, interp); + vfs_close(task, fd); + kfree(phead_start); + kfree(header); + int ret = load_file(task, interp); + kfree(interp); + return ret; } phead = (elf_program_header_t*)((uintptr_t)phead + header->phentsize); diff --git a/src/tasks/exception.c b/src/tasks/exception.c index 7a24dd4a..ca608cb8 100644 --- a/src/tasks/exception.c +++ b/src/tasks/exception.c @@ -21,6 +21,7 @@ #include #include #include +#include #include // Page fault error code flags @@ -121,6 +122,6 @@ static void int_handler(task_t* task, isf_t* state, int num) { task_signal(task, NULL, exc.signal); } -void task_exception_init() { +void task_exception_init(void) { int_register_bulk(0, 31, int_handler, true); } diff --git a/src/tasks/exception.h b/src/tasks/exception.h index 22055a56..195610ff 100644 --- a/src/tasks/exception.h +++ b/src/tasks/exception.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void task_exception_init(); +void task_exception_init(void); diff --git a/src/tasks/execdata.c b/src/tasks/execdata.c index 7555392b..335f0043 100644 --- a/src/tasks/execdata.c +++ b/src/tasks/execdata.c @@ -18,6 +18,7 @@ */ #include +#include #include #include #include diff --git a/src/tasks/mem.c b/src/tasks/mem.c index ef30bf3e..bc14aff6 100644 --- a/src/tasks/mem.c +++ b/src/tasks/mem.c @@ -1,5 +1,5 @@ /* mem.c: Task memory allocation & management - * Copyright © 2011-2020 Lukas Martini + * Copyright © 2011-2023 Lukas Martini * * This file is part of Xelix. * @@ -33,28 +33,37 @@ #define MAP_ANONYMOUS 4 #define MAP_FIXED 8 +static int task_stack_grow(task_t* task, size_t alloc_size) { + if(task->stack_size + alloc_size > PAGE_SIZE * 512) { + sc_errno = ENOMEM; + return -1; + } + + uintptr_t stack_lower = TASK_STACK_LOCATION - task->stack_size; + if(!vm_alloc_at(&task->vmem, NULL, RDIV(alloc_size, PAGE_SIZE), (void*)(stack_lower - alloc_size), NULL, + VM_USER | VM_RW | VM_FREE | VM_NOCOW | VM_TFORK | VM_ZERO | VM_FIXED)) { + return -1; + } + + task->stack_size += alloc_size; + return 0; +} + /* Called on task page faults. If the fault is in the pages below the current * lower end of the stack, expand the stack (up to 512 pages total), and return * control to the task. otherwise, return -1 so the fault gets raised. */ int task_page_fault_cb(task_t* task, void* _addr) { - uintptr_t addr = (uintptr_t)_addr; addr = ALIGN_DOWN(addr, PAGE_SIZE); - uintptr_t stack_lower = TASK_STACK_LOCATION - task->stack_size; - if(addr >= stack_lower || addr <= TASK_STACK_LOCATION - PAGE_SIZE * 512) { + uintptr_t stack_lower = TASK_STACK_LOCATION - task->stack_size; + if(addr >= stack_lower) { return -1; } int alloc_size = stack_lower - addr + PAGE_SIZE; - if(!vm_alloc_at(&task->vmem, NULL, RDIV(alloc_size, PAGE_SIZE), (void*)(stack_lower - alloc_size), NULL, - VM_USER | VM_RW | VM_FREE | VM_NOCOW | VM_TFORK | VM_ZERO | VM_FIXED)) { - return -1; - } - - task->stack_size += alloc_size; - return 0; + return task_stack_grow(task, alloc_size); } // Free a task and all associated memory diff --git a/src/tasks/scheduler.c b/src/tasks/scheduler.c index 9d9a11e9..62dd907e 100644 --- a/src/tasks/scheduler.c +++ b/src/tasks/scheduler.c @@ -29,7 +29,7 @@ static struct scheduler_qentry* current_entry = NULL; struct scheduler_qentry idle_qentry; enum scheduler_state scheduler_state; -task_t* scheduler_get_current() { +task_t* scheduler_get_current(void) { return current_entry ? current_entry->task : NULL; } @@ -175,6 +175,19 @@ static inline struct scheduler_qentry* find_runnable_qentry(struct scheduler_qen return qe; } +void scheduler_store_isf(isf_t* last_regs) { + if(unlikely(scheduler_state != SCHEDULER_INITIALIZED || !current_entry)) { + return; + } + + // Save CPU register state of previous task + if(current_entry->task) { + memcpy(current_entry->task->state, last_regs, sizeof(isf_t)); + } else if(current_entry->worker) { + memcpy(current_entry->worker->state, last_regs, sizeof(isf_t)); + } +} + isf_t* scheduler_select(isf_t* last_regs) { int_disable(); @@ -188,15 +201,6 @@ isf_t* scheduler_select(isf_t* last_regs) { return NULL; } - // Save CPU register state of previous task - if(last_regs) { - if(current_entry->task) { - memcpy(current_entry->task->state, last_regs, sizeof(isf_t)); - } else if(current_entry->worker) { - memcpy(current_entry->worker->state, last_regs, sizeof(isf_t)); - } - } - struct scheduler_qentry* qe = find_runnable_qentry(current_entry); if(qe) { current_entry = qe; @@ -284,7 +288,7 @@ static void __attribute__((fastcall, noreturn)) do_idle(worker_t* worker) { } } -void scheduler_init() { +void scheduler_init(void) { worker_t* idle_worker = worker_new("kidle", &do_idle); idle_qentry.task = NULL; idle_qentry.worker = idle_worker; diff --git a/src/tasks/scheduler.h b/src/tasks/scheduler.h index d1d7c100..0f6ff8df 100644 --- a/src/tasks/scheduler.h +++ b/src/tasks/scheduler.h @@ -40,7 +40,8 @@ extern enum scheduler_state scheduler_state; void scheduler_add(task_t *task); void scheduler_add_worker(worker_t* worker); task_t* scheduler_find(uint32_t pid); -task_t* scheduler_get_current(); -void scheduler_yield(); +void scheduler_store_isf(isf_t* last_regs); +task_t* scheduler_get_current(void); +void scheduler_yield(void); isf_t* scheduler_select(isf_t* lastRegs); -void scheduler_init(); +void scheduler_init(void); diff --git a/src/tasks/signal.c b/src/tasks/signal.c index 0df31b79..dc1a6aec 100644 --- a/src/tasks/signal.c +++ b/src/tasks/signal.c @@ -162,7 +162,7 @@ int task_sigaction(task_t* task, int sig, const struct sigaction* act, } if(act) { - memcpy(tbl_entry, (struct sigaction*)act, sizeof(struct sigaction)); + memcpy(tbl_entry, (const struct sigaction*)act, sizeof(struct sigaction)); } return 0; diff --git a/src/tasks/syscall.c b/src/tasks/syscall.c index 973e988b..ad8bdec2 100644 --- a/src/tasks/syscall.c +++ b/src/tasks/syscall.c @@ -97,21 +97,29 @@ static void int_handler(task_t* task, isf_t* state, int num) { continue; } + int map_flags = VM_RW | VM_MAP_USER_ONLY; + /* Get pointer size - From an argument if SCA_SIZE_IN_* is set, * otherwise use the default value */ - if(flags[i] & SCA_STRING) { - // FIXME FIXME FIXME Pass proper string sizes for SCA_STRING arguments!!! - ptr_sizes[i] = PAGE_SIZE - args[i] % PAGE_SIZE + PAGE_SIZE; + int multiplicator = MAX(1, def.ptr_size); + if(flags[i] & SCA_SIZE_IN_0) { + ptr_sizes[i] = multiplicator * args[0]; + } else if(flags[i] & SCA_SIZE_IN_1) { + ptr_sizes[i] = multiplicator * args[1]; + } else if(flags[i] & SCA_SIZE_IN_2) { + ptr_sizes[i] = multiplicator * args[2]; + } else if(flags[i] & (SCA_STRING | SCA_FLEX_SIZE)) { + /* If there is no SIZE_IN_* flag, attempt to map up to two pages, + * but don't fail if only one could be mapped. This is used for + * strings. Later on, code will scan the mapped area to make + * sure the string is NULL-terminated. + */ + ptr_sizes[i] = PAGE_SIZE * 2; + map_flags |= VM_MAP_LESS_OK; + } else { ptr_sizes[i] = def.ptr_size; - if(flags[i] & SCA_SIZE_IN_0) { - ptr_sizes[i] = MAX(1, ptr_sizes[i]) * args[0]; - } else if(flags[i] & SCA_SIZE_IN_1) { - ptr_sizes[i] = MAX(1, ptr_sizes[i]) * args[1]; - } else if(flags[i] & SCA_SIZE_IN_2) { - ptr_sizes[i] = MAX(1, ptr_sizes[i]) * args[2]; - } } if(unlikely((flags[i] & SCA_POINTER) && !ptr_sizes[i] && !(flags[i] & SCA_NULLOK))) { @@ -126,9 +134,8 @@ static void int_handler(task_t* task, isf_t* state, int num) { call_fail(); } - // FIXME Remove workaround args[i] = (uint32_t)vm_map(VM_KERNEL, &vmem[i], &task->vmem, - (void*)args[i], ptr_sizes[i], VM_RW | VM_MAP_USER_ONLY | VM_MAP_UNDERALLOC_WORKAROUND); + (void*)args[i], ptr_sizes[i], map_flags); if(unlikely(!args[i])) { @@ -251,7 +258,7 @@ static size_t sfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size) { return rsize; } -void syscall_init() { +void syscall_init(void) { struct vfs_callbacks sfs_cb = { .read = sfs_read, }; diff --git a/src/tasks/syscall.h b/src/tasks/syscall.h index 9ba2728e..312d244f 100644 --- a/src/tasks/syscall.h +++ b/src/tasks/syscall.h @@ -32,6 +32,7 @@ #define SCA_SIZE_IN_0 16 #define SCA_SIZE_IN_1 32 #define SCA_SIZE_IN_2 64 +#define SCA_FLEX_SIZE 128 #ifdef __i386__ #define SCREG_CALLNUM eax @@ -64,4 +65,4 @@ struct syscall_definition { }; char** syscall_copy_array(task_t* task, char** array, uint32_t* count); -void syscall_init(); +void syscall_init(void); diff --git a/src/tasks/syscalls.h b/src/tasks/syscalls.h index d9f1a546..f28f2c16 100644 --- a/src/tasks/syscalls.h +++ b/src/tasks/syscalls.h @@ -199,9 +199,8 @@ const struct syscall_definition syscall_table[] = { SCA_STRING, SCA_POINTER | SCA_SIZE_IN_2, SCA_INT, 0}, // 32 - /* FIXME Size incorrect */ {"execve", (syscall_cb)task_execve, 0, - SCA_STRING, SCA_POINTER, SCA_POINTER, PAGE_SIZE}, + SCA_STRING, SCA_POINTER | SCA_FLEX_SIZE, SCA_POINTER | SCA_FLEX_SIZE, 0}, // 33 {"sigaction", (syscall_cb)task_sigaction, 0, diff --git a/src/tty/console.c b/src/tty/console.c index 911cc755..421feed3 100644 --- a/src/tty/console.c +++ b/src/tty/console.c @@ -23,71 +23,121 @@ #include #include #include +#include #include "tmt.h" struct cache_entry { wchar_t chr; - int fg; - int bg; + uint32_t fg; + uint32_t bg; }; +// RGBA colors: Black, red, green, yellow, blue, magenta, cyan, white, max +static const uint32_t colors[] = {0x00000000, 0xfffd6883, 0xffadda78, 0xfff9cc6c, + 0xffa8a9eb, 0xfff38d70, 0x85dacc, 0xfffff1f3, 0xffffffff}; + TMT* vt; +size_t cursor_x = 0; +size_t cursor_y = 0; static struct cache_entry* cache; static uint32_t cache_pitch; -static inline uint32_t convert_color(int color, int bg) { - if(color < 1 || color > 8) { - return (bg ? 0x00000000 : 0xfffff1f3); - } - - // RGBA colors: Black, red, green, yellow, blue, magenta, cyan, white, max - const uint32_t colors[] = {0x00000000, 0xfffd6883, 0xffadda78, 0xfff9cc6c, - 0xffa8a9eb, 0xfff38d70, 0x85dacc, 0xfffff1f3, 0xffffffff}; - return colors[color - 1]; -} static size_t term_write_cb(struct term* term, const void* _source, size_t size) { - char* source = (char*)_source; + const char* source = (const char*)_source; tmt_write(vt, source, size); return size; } -static inline void write_char(int col, int row, TMTCHAR chr) { +static inline int set_cache(int col, int row, wchar_t chr, uint32_t fg, uint32_t bg) { struct cache_entry* ent = cache + col + row * cache_pitch; - if(ent->chr == chr.c && ent->fg == chr.a.fg && ent->bg == chr.a.bg) { - return; + + // Check for a match. Ignore foreground color for spaces. + if(ent->chr == chr && ent->bg == bg && + (ent->chr == ' ' || ent->fg == fg)) { + return 0; } - uint32_t fg = convert_color(chr.a.fg, 0); - uint32_t bg = convert_color(chr.a.bg, 1); - gfx_fbtext_write(col, row, chr.c, fg, bg); + ent->chr = chr; + ent->fg = fg; + ent->bg = bg; + return 1; +} + +static inline uint32_t normalize_color(int fg, int orig) { + if(orig < 1 || orig > 8) { + return fg ? 0xfffff1f3 : 0x00000000; + } - ent->chr = chr.c; - ent->fg = chr.a.fg; - ent->bg = chr.a.bg; + return colors[orig - 1]; } -void tmt_callback(tmt_msg_t m, TMT *vt, const void *a, void *p) { - const TMTSCREEN* s = tmt_screen(vt); - const TMTPOINT* c = tmt_cursor(vt); + //serial_printf("do_clear, clearing %d at %d\n", empty_length, empty_start); +#define DO_CLEAR() \ + if(empty_length) { \ + gfx_fbtext_clear(empty_start, row, empty_length, 1); \ + empty_length = 0; \ + } + +static inline void write_row(const TMTSCREEN* s, const TMTLINE* l, int row) { + size_t empty_length = 0; + unsigned int empty_start; + + for(size_t col = 0; col < s->ncol; col++) { + const TMTCHAR* chr = &l->chars[col]; + + // Normalize colors + int fg = normalize_color(1, chr->a.fg); + int bg = normalize_color(0, chr->a.bg); + + // Skip char if it's already on screen + if(!set_cache(col, row, chr->c, fg, bg)) { + DO_CLEAR(); + continue; + } + + + // Skip spaces so we can clear them as a block if there + // are more contiguous to this one + if(chr->c == ' ' && bg == 0) { + if(empty_length == 0) { + empty_start = col; + } + + empty_length++; + } else { + DO_CLEAR(); + gfx_fbtext_write(col, row, chr->c, fg, bg); + } + } + + DO_CLEAR(); +} + +static void tmt_callback(tmt_msg_t m, TMT *callback_vt, const void *a, void *p) { + const TMTSCREEN* s = tmt_screen(callback_vt); + const TMTPOINT* c = tmt_cursor(callback_vt); switch(m) { case TMT_MSG_UPDATE: - for (size_t row = 0; row < s->nline; row++){ - if (s->lines[row]->dirty){ - for (size_t col = 0; col < s->ncol; col++) { - TMTCHAR chr = s->lines[row]->chars[col]; - write_char(col, row, chr); - } + for(size_t row = 0; row < s->nline; row++) { + if(s->lines[row]->dirty){ + write_row(s, s->lines[row], row); } } - tmt_clean(vt); + tmt_clean(callback_vt); break; case TMT_MSG_ANSWER: term_input(term_console, a, strlen(a)); break; case TMT_MSG_MOVED: - gfx_fbtext_set_cursor(c->c, c->r, true); + // Redraw char at previous position + struct cache_entry* ent = cache + cursor_x + cursor_y * cache_pitch; + gfx_fbtext_write(cursor_x, cursor_y, ent->chr, ent->fg, ent->bg); + + cursor_x = c->c; + cursor_y = c->r; + gfx_fbtext_draw_cursor(cursor_x, cursor_y); break; default: } @@ -109,4 +159,6 @@ void tty_console_init(int cols, int rows) { if(!vt) { panic("Could not open TMT virtual terminal."); } + + log_dump(); } diff --git a/src/tty/keyboard.c b/src/tty/keyboard.c index 752eec73..00f72d74 100644 --- a/src/tty/keyboard.c +++ b/src/tty/keyboard.c @@ -214,7 +214,7 @@ static vfs_file_t* sfs_open(struct vfs_callback_ctx* ctx, uint32_t flags) { return fp; } -void tty_keyboard_init() { +void tty_keyboard_init(void) { buf = buffer_new(10); if(!buf) { return; diff --git a/src/tty/keyboard.h b/src/tty/keyboard.h index f0544068..1346cc6e 100644 --- a/src/tty/keyboard.h +++ b/src/tty/keyboard.h @@ -33,4 +33,4 @@ struct tty_input_state { uint16_t code; }; -void tty_keyboard_init(); +void tty_keyboard_init(void); diff --git a/src/tty/pty.c b/src/tty/pty.c index 0a5d7a57..dc1af362 100644 --- a/src/tty/pty.c +++ b/src/tty/pty.c @@ -138,7 +138,7 @@ static vfs_file_t* ptmx_open(struct vfs_callback_ctx* ctx, uint32_t flags) { return fd1; } -void pty_init() { +void pty_init(void) { struct vfs_callbacks ptmx_cb = { .open = ptmx_open, }; diff --git a/src/tty/pty.h b/src/tty/pty.h index 59c0b522..df7ef976 100644 --- a/src/tty/pty.h +++ b/src/tty/pty.h @@ -18,4 +18,4 @@ * along with Xelix. If not, see . */ -void pty_init(); +void pty_init(void); diff --git a/src/tty/serial.c b/src/tty/serial.c index 5bb66cba..d1fa43a5 100644 --- a/src/tty/serial.c +++ b/src/tty/serial.c @@ -30,12 +30,12 @@ void serial_send(const char c, void* unused) { outb(PORT, c); } -char serial_recv() { +char serial_recv(void) { while(!CAN_RECV); return inb(PORT); } -void serial_init() { +void serial_init(void) { // from http://wiki.osdev.org/Serial_Ports // set up with divisor = 3 and 8 data bits, no parity, one stop bit // IRQs enabled @@ -62,7 +62,7 @@ static size_t sfs_write(struct vfs_callback_ctx* ctx, void* src, size_t size) { return size; } -void serial_init2() { +void serial_init2(void) { struct vfs_callbacks sfs_cb = { .read = sfs_read, .write = sfs_write, diff --git a/src/tty/serial.h b/src/tty/serial.h index d1d43460..e8e31cb0 100644 --- a/src/tty/serial.h +++ b/src/tty/serial.h @@ -22,7 +22,7 @@ #define serial_printf(fmt, args...) fctprintf(serial_send, NULL, fmt, ## args) -void serial_init(); -void serial_init2(); -char serial_recv(); +void serial_init(void); +void serial_init2(void); +char serial_recv(void); void serial_send(const char c, void* unused); diff --git a/src/tty/term.c b/src/tty/term.c index fa899cdc..19582751 100644 --- a/src/tty/term.c +++ b/src/tty/term.c @@ -104,7 +104,7 @@ static void handle_canon(struct term* term, char chr) { } size_t term_input(struct term* term, const void* _source, size_t size) { - char* source = (char*)_source; + const char* source = (const char*)_source; for(size_t i = 0; i < size; i++) { char chr = source[i]; @@ -211,6 +211,7 @@ int term_vfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg) { */ switch(request) { case TIOCGPTN: + case TCSLOGLEVEL: arg_size = sizeof(int); break; case TIOCGWINSZ: @@ -242,6 +243,16 @@ int term_vfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg) { // FIXME pty only *(int*)arg = term->pts_fd; break; + case TCSLOGLEVEL: + // Console only + if(term->num) { + vm_free(&alloc); + sc_errno = EINVAL; + return -1; + } + + log_set_console_level(*(int*)arg); + break; case TCGETS: memcpy(arg, &term->termios, sizeof(struct termios)); break; @@ -313,7 +324,7 @@ struct term* term_new(char* name, term_write_cb_t* write_cb) { } static vfs_file_t* term_vfs_open(struct vfs_callback_ctx* ctx, uint32_t flags) { - if(!ctx->task) { + if(!ctx->task || !term_console) { sc_errno = ENOENT; return NULL; } @@ -332,7 +343,7 @@ static vfs_file_t* term_vfs_open(struct vfs_callback_ctx* ctx, uint32_t flags) { return fp; } -void term_init() { +void term_init(void) { tty_keyboard_init(); sysfs_add_dev("tty", &term_cb); diff --git a/src/tty/term.h b/src/tty/term.h index e95188d9..10206057 100644 --- a/src/tty/term.h +++ b/src/tty/term.h @@ -171,6 +171,8 @@ #define TIOCSSOFTCAR 0x4015 #define TIOCGPTN 0x4016 +#define TCSLOGLEVEL 0x5000 + struct termios { uint32_t c_iflag; uint32_t c_oflag; @@ -216,4 +218,4 @@ size_t term_vfs_read(struct vfs_callback_ctx* ctx, void* dest, size_t size); int term_vfs_stat(struct vfs_callback_ctx* ctx, vfs_stat_t* dest); int term_vfs_ioctl(struct vfs_callback_ctx* ctx, int request, void* _arg); int term_vfs_poll(struct vfs_callback_ctx* ctx, int events); -void term_init(); +void term_init(void); diff --git a/util/build-image.sh b/util/build-image.sh index 7db4396f..c2b0c9c6 100755 --- a/util/build-image.sh +++ b/util/build-image.sh @@ -1,35 +1,39 @@ -#!/bin/env bash +#!/usr/bin/env bash set -e set -x -if [ "$#" -ne 2 ]; then - echo "Usage: $0 " +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " exit 1 fi -image_dir=$1 -dest=$2 - -sudo modprobe nbd max_part=8 +dest=$1 qemu-img create -f raw "$dest" 10G -sudo losetup -P /dev/loop2 "$dest" +losetup -P /dev/loop5 "$dest" -cat <image root>" +else +export SYSROOT=$1 +export PKG_CONFIG_DIR="$SYSROOT" +export PKG_CONFIG_LIBDIR="$SYSROOT/usr/lib/pkgconfig:$SYSROOT/usr/share/pkgconfig" +export PKG_CONFIG_SYSROOT_DIR="$SYSROOT" +export CFLAGS="-O3 -I$SYSROOT/usr/include --sysroot $SYSROOT" +export CPPFLAGS="$CFLAGS -D__STDC_ISO_10646__ -D_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC=0 -D_GLIBCXX_USE_C99_STDLIB=0" +export LDFLAGS="-L$SYSROOT/usr/lib" + +fix_config_sub() { + echo "Replacing file $1" + echo -e "#!/bin/sh\necho i786-pc-xelix" +} +fi diff --git a/util/xpkg/.gitignore b/util/xpkg/.gitignore deleted file mode 100644 index bee8a64b..00000000 --- a/util/xpkg/.gitignore +++ /dev/null @@ -1 +0,0 @@ -__pycache__ diff --git a/util/xpkg/package.py b/util/xpkg/package.py deleted file mode 100644 index b9db64c2..00000000 --- a/util/xpkg/package.py +++ /dev/null @@ -1,207 +0,0 @@ -from toposort import toposort_flatten -from pathlib import Path -from copy import copy -import time -import subprocess -import shutil -import yaml -import os - -default_pkg = None -sources_dir = None -build_dir = None -image_dir = None - -root_dir = (Path(__file__) / '..' / '..' / '..').resolve() -pkg_dir = root_dir / 'land' -dest_dir = root_dir / 'xpkg-build' - -sources_dir = dest_dir / 'sources' -build_dir = dest_dir / 'pkgs' -image_dir = dest_dir / 'image' - -for path in (dest_dir, sources_dir, build_dir, image_dir): - try: - os.mkdir(path) - except FileExistsError: - pass - -with open(pkg_dir / 'default.yml') as file: - default_pkg = yaml.safe_load(file) - - -class Package: - name = None - version = None - - config = None - pkg_dependencies = set() - base_dependencies = set() - sources = list() - patches = list() - - pkg_dir = None - build_dir = None - env = dict() - cmds_configure = list() - cmds_make = list() - cmds_install = list() - - def __init__(self, path): - self.config_path = path - self.base_dependencies = set(default_pkg.get('base_dependencies', set())) - - with open(path, 'r') as file: - self.config = yaml.safe_load(file) - - self.name = self.config['name'] - self.version = self.config['version'] - self.sources = self.config.get('sources', list()) - self.patches = self.config.get('patches', list()) - self.pkg_dependencies = set(self.config.get('dependencies', set())) - - self.cmds_configure = self.config.get('configure', list()) - self.cmds_make = self.config.get('make', list()) - self.cmds_install = self.config.get('install', list()) - - self.env = {**default_pkg.get('env', dict()), **self.config.get('env', dict())} - - @property - def pkg_dir(self): - return self.config_path.parent - - @property - def build_dir(self): - return build_dir / self.name - - @property - def dependencies(self): - return self.base_dependencies | self.pkg_dependencies - - @property - def last_build(self): - try: - with open(self.build_dir / '.xpkg-status', 'r') as file: - return yaml.safe_load(file)['last_build'] - except FileNotFoundError: - return 0 - - @property - def has_changed(self): - stat = os.stat(self.config_path) - return stat.st_mtime >= self.last_build - - def info(self, str): - print(f'\n\033[33m{self.name}: {str}\033[m') - - def write_status(self, status): - with open(self.build_dir / '.xpkg-status', 'w') as file: - yaml.dump(status, file) - - def run_cmds(self, cmds, **kwargs): - env = copy(self.env) - env['PKGDIR'] = self.pkg_dir - env['DESTDIR'] = image_dir - - env['SYSROOT'] = image_dir - env['PKG_CONFIG_DIR'] = image_dir - env['PKG_CONFIG_LIBDIR'] = f'{image_dir / "usr" / "lib"/ "pkgconfig"}:{image_dir / "usr" / "share" / "pkgconfig"}' - env['PKG_CONFIG_SYSROOT_DIR'] = image_dir - - env['PATH'] = f'{root_dir / "toolchain" / "local" / "bin"}:{os.environ.get("PATH", "")}' - env['CPPFLAGS'] = '-D__STDC_ISO_10646__ -D_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC=0 -D_GLIBCXX_USE_C99_STDLIB=0' - - if self.config.get('set_cflags_include', True): - env['CFLAGS'] = f'-I{image_dir / "usr" / "include"} -O3' - - if self.config.get('set_ldflags_libpath', True): - env['LDFLAGS'] = f'-L{image_dir / "usr" / "lib"}' - - if self.config.get('set_cflags_sysroot', True): - env['CFLAGS'] += f' --sysroot {image_dir}' - env['CPPFLAGS'] += f' --sysroot {image_dir}' - - if 'cwd' not in kwargs: - kwargs['cwd'] = str(self.build_dir) - - for cmd in cmds: - print(f'\033[36m{cmd}\033[m') - proc = subprocess.run(cmd, shell=True, env=env, **kwargs) - - if proc.returncode != 0: - print(f'Command {cmd} failed, aborting.') - exit(1) - - def download(self): - if not self.sources: - return - - self.info(f'Downloading sources') - dest = build_dir / self.name - - try: - os.mkdir(dest) - except FileExistsError: - shutil.rmtree(dest) - os.mkdir(dest) - - for source in self.sources: - if 'url' in source.keys(): - filename = source['url'].split('/')[-1] - if os.access(sources_dir / filename, os.R_OK): - print(f'{filename} is already downloaded') - else: - self.run_cmds([f'wget --continue "{source["url"]}"'], cwd=sources_dir) - - source_type = source.get('type', 'tar.xz') - if source_type == 'tar.xz': - extract_cmd = f'tar xf "{sources_dir / filename}" -C {dest} --strip-components=1' - elif source_type == 'zip': - extract_cmd = f'unzip "{sources_dir / filename}" -d {dest}' - else: - Exception('Unknown source type') - - self.run_cmds([extract_cmd], cwd=sources_dir) - elif 'dir' in source.keys(): - self.run_cmds([f'cp -r {self.pkg_dir / source["dir"]}/* {dest}'], cwd=sources_dir) - elif 'file' in source.keys(): - self.run_cmds([f'cp -r {self.pkg_dir / source["file"]} {dest}'], cwd=sources_dir) - - def patch(self): - if self.patches: - self.info(f'Applying patches') - skip_path = self.config.get('patch_skip_path', 1) - - patch_cmds = map(lambda x: f'patch -p{skip_path} < {self.pkg_dir}/{x}', self.patches) - self.run_cmds(patch_cmds) - - def configure(self): - if self.cmds_configure: - self.info(f'Configuring') - self.run_cmds(self.cmds_configure) - - def build(self): - if self.cmds_make: - self.info(f'Compiling') - self.run_cmds(self.cmds_make) - - self.write_status({'last_build': int(time.time())}) - - def install(self): - if self.cmds_install: - self.info(f'Installing') - self.run_cmds(self.cmds_install) - - -def load_packages(): - packages = dict() - deps = dict() - - for path in pkg_dir.glob('*/package.yml'): - pkg = Package(path) - packages[pkg.name] = pkg - deps[pkg.name] = pkg.dependencies - - pkg_names = toposort_flatten(deps) - pkgs = list(map(lambda x: packages[x], pkg_names)) - return pkgs diff --git a/util/xpkg/poetry.lock b/util/xpkg/poetry.lock deleted file mode 100644 index 4188d327..00000000 --- a/util/xpkg/poetry.lock +++ /dev/null @@ -1,50 +0,0 @@ -[[package]] -category = "main" -description = "Composable command line interface toolkit" -name = "click" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" -version = "7.0" - -[[package]] -category = "main" -description = "YAML parser and emitter for Python" -name = "pyyaml" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" -version = "5.3" - -[[package]] -category = "main" -description = "Implements a topological sort algorithm." -name = "toposort" -optional = false -python-versions = "*" -version = "1.5" - -[metadata] -content-hash = "e75e19be8955ef327af6dd96d7e1af66cfaecfe45881b8b31c7c039c6caf80e2" -python-versions = "^3.8" - -[metadata.files] -click = [ - {file = "Click-7.0-py2.py3-none-any.whl", hash = "sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13"}, - {file = "Click-7.0.tar.gz", hash = "sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"}, -] -pyyaml = [ - {file = "PyYAML-5.3-cp27-cp27m-win32.whl", hash = "sha256:940532b111b1952befd7db542c370887a8611660d2b9becff75d39355303d82d"}, - {file = "PyYAML-5.3-cp27-cp27m-win_amd64.whl", hash = "sha256:059b2ee3194d718896c0ad077dd8c043e5e909d9180f387ce42012662a4946d6"}, - {file = "PyYAML-5.3-cp35-cp35m-win32.whl", hash = "sha256:4fee71aa5bc6ed9d5f116327c04273e25ae31a3020386916905767ec4fc5317e"}, - {file = "PyYAML-5.3-cp35-cp35m-win_amd64.whl", hash = "sha256:dbbb2379c19ed6042e8f11f2a2c66d39cceb8aeace421bfc29d085d93eda3689"}, - {file = "PyYAML-5.3-cp36-cp36m-win32.whl", hash = "sha256:e3a057b7a64f1222b56e47bcff5e4b94c4f61faac04c7c4ecb1985e18caa3994"}, - {file = "PyYAML-5.3-cp36-cp36m-win_amd64.whl", hash = "sha256:74782fbd4d4f87ff04159e986886931456a1894c61229be9eaf4de6f6e44b99e"}, - {file = "PyYAML-5.3-cp37-cp37m-win32.whl", hash = "sha256:24521fa2890642614558b492b473bee0ac1f8057a7263156b02e8b14c88ce6f5"}, - {file = "PyYAML-5.3-cp37-cp37m-win_amd64.whl", hash = "sha256:1cf708e2ac57f3aabc87405f04b86354f66799c8e62c28c5fc5f88b5521b2dbf"}, - {file = "PyYAML-5.3-cp38-cp38-win32.whl", hash = "sha256:70024e02197337533eef7b85b068212420f950319cc8c580261963aefc75f811"}, - {file = "PyYAML-5.3-cp38-cp38-win_amd64.whl", hash = "sha256:cb1f2f5e426dc9f07a7681419fe39cee823bb74f723f36f70399123f439e9b20"}, - {file = "PyYAML-5.3.tar.gz", hash = "sha256:e9f45bd5b92c7974e59bcd2dcc8631a6b6cc380a904725fce7bc08872e691615"}, -] -toposort = [ - {file = "toposort-1.5-py2.py3-none-any.whl", hash = "sha256:d80128b83b411d503b0cdb4a8f172998bc1d3b434b6402a349b8ebd734d51a80"}, - {file = "toposort-1.5.tar.gz", hash = "sha256:dba5ae845296e3bf37b042c640870ffebcdeb8cd4df45adaa01d8c5476c557dd"}, -] diff --git a/util/xpkg/pyproject.toml b/util/xpkg/pyproject.toml deleted file mode 100644 index fe14691e..00000000 --- a/util/xpkg/pyproject.toml +++ /dev/null @@ -1,17 +0,0 @@ -[tool.poetry] -name = "xpkg" -version = "0.1.0" -description = "" -authors = ["Lukas Martini "] - -[tool.poetry.dependencies] -python = "^3.8" -PyYAML = "^5.3" -toposort = "^1.5" -click = "^7.0" - -[tool.poetry.dev-dependencies] - -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" diff --git a/util/xpkg/xpkg b/util/xpkg/xpkg deleted file mode 100755 index a16cfd63..00000000 --- a/util/xpkg/xpkg +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/bin/env python3 - -# This file is part of Xelix. -# -# Xelix 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. -# -# Xelix 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 Xelix. If not, see . - -import click -from package import load_packages -from operator import attrgetter - - -@click.command() -@click.argument('package_names', nargs=-1) -@click.option('-a', '--all', is_flag=True, help='Select all available packages.') -@click.option('-e', '--exclude', multiple=True, - help='When using --all, a list of packages not to compile.') -@click.option('-f', '--force', is_flag=True, - help='Force rebuild of package(s) even if they are up to date.') -@click.option('-n', '--no-install-stale', is_flag=True, - help='Don\'t (re)install packages that have not been updated.') -@click.option('-k', '--keep-builddir', is_flag=True, - help='Don\'t delete build directory of previous build.') -@click.option('-c', '--skip-configure', is_flag=True, - help='Skip configure step (mostly useful with --keep_builddir).') -#@click.option('-t', '--toolchain', is_flag=True, -# help='Compile for local toolchain instead of cross-compiling') -def build(package_names, all, exclude, force, no_install_stale, keep_builddir, skip_configure): - - if not package_names and not all: - click.echo('Please provide the names of packages to build or use --all.', err=True) - exit(1) - - pkgs = load_packages() - if not all: - pkgs = filter(lambda x: x.name in package_names, pkgs) - - pkgs = filter(lambda x: x.name not in exclude, pkgs) - pkgs = list(pkgs) - - if(len(pkgs) < 1): - click.echo('Found no packages to install.', err=True) - exit(1) - - print(f'Installing {len(pkgs)} packages:') - print(', '.join(map(attrgetter('name'), pkgs))) - print() - - for pkg in pkgs: - if not pkg.config.get('disabled', False) \ - and (pkg.has_changed or force) and not keep_builddir: - pkg.download() - - for pkg in pkgs: - if not pkg.config.get('disabled', False): - has_changed = pkg.has_changed - rebuilt = False - - if has_changed or force: - if not keep_builddir: - pkg.patch() - - if not skip_configure: - pkg.configure() - - pkg.build() - rebuilt = True - - if rebuilt or not no_install_stale or pkg.has_changed: - pkg.install() - - -if __name__ == '__main__': - build()