From f247bf1e2a2ec9ae248dc98cbb58e24cf157ddad Mon Sep 17 00:00:00 2001 From: Jonathan Bakker Date: Wed, 9 Dec 2020 20:18:00 -0800 Subject: [PATCH] non-free/sgx-ddk-um: new aport (MR 1868) From TI, they must not be redistributed in a modified form. They are built against GLIBC 2.29 To be functional, they need to be paired with a special build of Mesa. There are subpackages for each different soc and only one soc can be installed at a time. The Exynos S5PV210 subpackage uses the same SGX540-120 as the ti443x blobs, but needs a binary edit to be loaded. Due to the license restrictions, it must be done in a post-install script. --- non-free/sgx-ddk-um/APKBUILD | 81 +++++++++++++++++++ non-free/sgx-ddk-um/pvrsrvinit.c | 29 +++++++ .../sgx-ddk-um/sgx-ddk-um-openrc.post-install | 3 + .../sgx-ddk-um/sgx-ddk-um-openrc.post-upgrade | 1 + .../sgx-ddk-um-s5pv210.post-install | 7 ++ .../sgx-ddk-um-s5pv210.post-upgrade | 1 + non-free/sgx-ddk-um/sgx-ddk-um.initd | 18 +++++ 7 files changed, 140 insertions(+) create mode 100644 non-free/sgx-ddk-um/APKBUILD create mode 100644 non-free/sgx-ddk-um/pvrsrvinit.c create mode 100644 non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-install create mode 120000 non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-upgrade create mode 100644 non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-install create mode 120000 non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-upgrade create mode 100644 non-free/sgx-ddk-um/sgx-ddk-um.initd diff --git a/non-free/sgx-ddk-um/APKBUILD b/non-free/sgx-ddk-um/APKBUILD new file mode 100644 index 000000000..fbdfec8e1 --- /dev/null +++ b/non-free/sgx-ddk-um/APKBUILD @@ -0,0 +1,81 @@ +# Maintainer: Jonathan Bakker +pkgname=sgx-ddk-um +pkgver=1.17.494857 +_commit=551665bf9c321bc3e7721416e6ebbc9f65c18155 +pkgrel=0 +pkgdesc="(WARNING: runs as root) Proprietary userspace libraries for PowerVR SGX GPUs" +url="https://git.ti.com/cgit/graphics/omap5-sgx-ddk-um-linux" +arch="armhf armv7 aarch64" +license="proprietary" +options="!check !strip" # no test suite available +depends="libc6-compat" +subpackages=" + $pkgname-s5pv210:s5pv210 + $pkgname-ti335x:soc + $pkgname-ti343x:soc + $pkgname-ti437x:soc + $pkgname-ti443x:soc + $pkgname-ti654x:soc + $pkgname-openrc + " + +source=" + https://git.ti.com/cgit/graphics/omap5-sgx-ddk-um-linux/snapshot/omap5-sgx-ddk-um-linux-$_commit.tar.gz + pvrsrvinit.c + sgx-ddk-um.initd + " +builddir="$srcdir/omap5-sgx-ddk-um-linux-$_commit" + +copy_soc_files() { + local soc_libs=$1 + local soc_name=$2 + local soc_path="$subpkgdir/usr/lib" + cd $builddir + mkdir -p $soc_path + + cp -a targetfs/$soc_libs/lib/libglslcompiler.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libGLESv1_PVR_MESA.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libGLESv2_PVR_MESA.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libpvr2d.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libdbm.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libsrv_um.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libpvr_dri_support.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libPVRScopeServices.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libsrv_init.so* $soc_path/ + cp -a targetfs/$soc_libs/lib/libusc.so* $soc_path/ +} + +build() { + gcc -o "$builddir"/pvrsrvinit "$srcdir"/pvrsrvinit.c -ldl +} + +package() { + install -dm755 "$pkgdir"/bin + install -Dm755 "$builddir"/pvrsrvinit "$pkgdir"/bin/pvrsrvinit + install -Dm755 "$srcdir"/sgx-ddk-um.initd "$pkgdir"/etc/init.d/sgx-ddk-um +} + +s5pv210() { + provides=sgx-ddk-um-soc=1.17.494857 + install="$subpkgname.post-install $subpkgname.post-upgrade" + depends=sgx-ddk-um + + copy_soc_files ti443x s5pv210 +} + +openrc() { + install="$subpkgname.post-install $subpkgname.post-upgrade" + default_openrc +} + +soc() { + local n=${subpkgname##sgx-ddk-um-} + provides=sgx-ddk-um-soc=1.17.494857 + depends=sgx-ddk-um-openrc + + copy_soc_files $n $n +} + +sha512sums="49e5d381d7e045dbbf71290eab440a49befd91794368d334a23238229fc7d3fc98f2492a62bf4b6eb71229c7238baf8842038a96c5cff4fdfef60ba7e8f9540d omap5-sgx-ddk-um-linux-551665bf9c321bc3e7721416e6ebbc9f65c18155.tar.gz +94b09f7c1d6df33f15bb4e88e145630f4218ceb9cda7fec0e1307eca9b5b9522ad5bf1d9d51a44b0325ec5e74a93fd8ba23e082236d2690eeb3e84cb92f7fa1a pvrsrvinit.c +4e3fc0bba02953cf00fd3b094c96bd794ef7668d2f188ada9be92856e7802d310ad43e8cdb9e8c9e6d94732eaf7e94c0ad723b5d55847bc28fa66e1e89eff39a sgx-ddk-um.initd" diff --git a/non-free/sgx-ddk-um/pvrsrvinit.c b/non-free/sgx-ddk-um/pvrsrvinit.c new file mode 100644 index 000000000..95c1f3f7e --- /dev/null +++ b/non-free/sgx-ddk-um/pvrsrvinit.c @@ -0,0 +1,29 @@ +#include +#include + +int main() +{ + int ret; + int (*SrvInit)(void); + void *handle = dlopen("libsrv_init.so", RTLD_LAZY); + if (!handle) { + fprintf(stderr, "failed to open libsrv_init.so\n"); + return -1; + } + + SrvInit = dlsym(handle, "SrvInit"); + if (!SrvInit) { + fprintf(stderr, "failed to find SrvInit symbol\n"); + return -1; + } + + ret = SrvInit(); + + if (ret) { + fprintf(stderr, "failed to initialize server\n"); + } + + dlclose(handle); + + return ret; +} diff --git a/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-install b/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-install new file mode 100644 index 000000000..352326c65 --- /dev/null +++ b/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-install @@ -0,0 +1,3 @@ +#!/bin/sh + +rc-update add sgx-ddk-um default diff --git a/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-upgrade b/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-upgrade new file mode 120000 index 000000000..129b45157 --- /dev/null +++ b/non-free/sgx-ddk-um/sgx-ddk-um-openrc.post-upgrade @@ -0,0 +1 @@ +sgx-ddk-um-openrc.post-install \ No newline at end of file diff --git a/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-install b/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-install new file mode 100644 index 000000000..69241a726 --- /dev/null +++ b/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-install @@ -0,0 +1,7 @@ +#!/bin/sh + +# special patching for s5pv210, overwriting omapdrm with exynos +printf "exynos\x00" > /tmp/exynos +dd if=/tmp/exynos of=/usr/lib/libsrv_um.so.1.17.4948957 obs=1 seek=110644 conv=notrunc +dd if=/tmp/exynos of=/usr/lib/libdbm.so.1.17.4948957 obs=1 seek=5960 conv=notrunc +rm /tmp/exynos diff --git a/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-upgrade b/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-upgrade new file mode 120000 index 000000000..5ba39f6c6 --- /dev/null +++ b/non-free/sgx-ddk-um/sgx-ddk-um-s5pv210.post-upgrade @@ -0,0 +1 @@ +sgx-ddk-um-s5pv210.post-install \ No newline at end of file diff --git a/non-free/sgx-ddk-um/sgx-ddk-um.initd b/non-free/sgx-ddk-um/sgx-ddk-um.initd new file mode 100644 index 000000000..f36340bfb --- /dev/null +++ b/non-free/sgx-ddk-um/sgx-ddk-um.initd @@ -0,0 +1,18 @@ +#!/sbin/openrc-run + +description="Initialize PowerVR SGX server" + +depend() { + need dev localmount + after hwdrivers modules dev-mount +} + +start() { + for i in {0..5} ; do + if /bin/pvrsrvinit ; then + return 0 + fi + sleep 5 + done +} +