From 4ae1aa10d775f6780602d37632c8eda08c374d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gy=C3=B6rgy=20Kurucz?= Date: Mon, 25 Nov 2024 21:59:27 +0100 Subject: [PATCH] wip: add slbounce --- README.md | 2 +- packages/overlay.nix | 1 + packages/slbounce-Makefile.patch | 35 +++++++++++++ packages/slbounce.nix | 89 ++++++++++++++++++++++++++++++++ packages/x1e80100-linux.nix | 2 + 5 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 packages/slbounce-Makefile.patch create mode 100644 packages/slbounce.nix diff --git a/README.md b/README.md index 992f4f5..8f65790 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Note that I only have the Lenovo Yoga Slim 7x, so the repo will be focused aroun | Feature | Status | Notes | | ----------------------- | -----: | ------------------------------------------------------------------------------------------------------------ | | Battery Charging | ✅ | | -| Battery Indicator | ✅ | | +| Battery Indicator | ✅ | Not working in EL2. | | Bluetooth | ✅ | | | Camera | ❌ | | | Display | ✅ | | diff --git a/packages/overlay.nix b/packages/overlay.nix index 2a034de..cf7830b 100644 --- a/packages/overlay.nix +++ b/packages/overlay.nix @@ -8,4 +8,5 @@ final: prev: { { }; libqrtr = final.callPackage ./libqrtr.nix { }; pd-mapper = final.callPackage ./pd-mapper.nix { }; + slbounce = final.callPackage ./slbounce.nix { }; } diff --git a/packages/slbounce-Makefile.patch b/packages/slbounce-Makefile.patch new file mode 100644 index 0000000..981860a --- /dev/null +++ b/packages/slbounce-Makefile.patch @@ -0,0 +1,35 @@ +diff --git a/Makefile b/Makefile +index e2b57ed..1fada67 100644 +--- a/Makefile ++++ b/Makefile +@@ -92,15 +92,11 @@ DTBS := \ + + all: $(OUT_DIR)/sltest.efi $(OUT_DIR)/slbounce.efi $(OUT_DIR)/dtbhack.efi + +-.INTERMEDIATE: $(GNUEFI_DIR)/inc/elf.h +-$(GNUEFI_DIR)/inc/elf.h: +- ln -sf /usr/include/elf.h $(GNUEFI_DIR)/inc/elf.h +- +-$(LIBEFI_A): $(GNUEFI_DIR)/inc/elf.h ++$(LIBEFI_A): + @echo [ DEP ] $@ + @$(MAKE) -C$(GNUEFI_DIR) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH) lib + +-$(LIBGNUEFI_A): $(GNUEFI_DIR)/inc/elf.h ++$(LIBGNUEFI_A): + @echo [ DEP ] $@ + @$(MAKE) -C$(GNUEFI_DIR) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(ARCH) gnuefi + +diff --git a/README.md b/README.md +index 9b7e526..53a4b49 100644 +--- a/README.md ++++ b/README.md +@@ -44,7 +44,7 @@ Make sure `tcblaunch.exe` is placed in the root of the FS, then load the EFI dri + fs0:\> load slbounce.efi + ``` + +-The driver will replace `BS->ExitBootServices` in the system table with it's own ++The driver will replace `BS->ExitBootServices` in the system table with its own + function. It will call EBS and perform switch to EL2 right after. Thus your bootloader + (i.e. grub or linux's efi-stub) would experence the cpu swithing to EL2 when it calls + EBS. diff --git a/packages/slbounce.nix b/packages/slbounce.nix new file mode 100644 index 0000000..b0921f0 --- /dev/null +++ b/packages/slbounce.nix @@ -0,0 +1,89 @@ +{ + stdenv, + fetchzip, + fetchgit, + fetchFromGitHub, + fetchpatch, + python3, + dtc, +}: + +let + aarch64-system-register-xmls = fetchzip { + url = "https://developer.arm.com/-/media/developer/products/architecture/armv8-a-architecture/2020-06/SysReg_xml_v86A-2020-06.tar.gz"; + stripRoot = false; + hash = "sha256-wpWMIdR4v4sGZ0FEn/j5+AzkpPFOF7lUKIFpVl5AMEE="; + }; + arm64-sysreg-lib = stdenv.mkDerivation { + name = "arm64-sysreg-lib"; + src = fetchFromGitHub { + owner = "ashwio"; + repo = "arm64-sysreg-lib"; + sparseCheckout = [ "/" ]; + rev = "d421e249a026f6f14653cb6f9c4edd8c5d898595"; + hash = "sha256-vUuV8eddYAdwXGQe+L7lKiAwyqHPYmiOdVFKvwCMWkQ="; + }; + nativeBuildInputs = [ + (python3.withPackages (ps: [ ps.beautifulsoup4 ])) + ]; + buildPhase = '' + python ./run-build.py ${aarch64-system-register-xmls}/SysReg_xml_v86A-2020-06 + ''; + installPhase = '' + mkdir -p $out/include + cp -r include $out/ + ''; + }; + + gnu-efi = fetchFromGitHub { + owner = "ncroxon"; + repo = "gnu-efi"; + rev = "3.0.15"; + hash = "sha256-flQJIRPKd0geQRAtJSu4vravJG0lTB6BfeIqpUM5P2I="; + }; + + dtc-src = fetchgit { + url = "https://git.kernel.org/pub/scm/utils/dtc/dtc.git"; + rev = "v1.7.2"; + hash = "sha256-KZCzrvdWd6zfQHppjyp4XzqNCfH2UnuRneu+BNIRVAY="; + }; +in +stdenv.mkDerivation { + name = "slbounce"; + src = fetchFromGitHub { + owner = "TravMurav"; + repo = "slbounce"; + rev = "97b24ec89faa11827e7def220b0aa53dd5d5f447"; + hash = "sha256-ImZHsMwLSlo2smLV7aAkmN0JbxcQbkrO/WWcK5fMfpU="; + }; + nativeBuildInputs = [ dtc ]; + patches = [ + (fetchpatch { + url = "https://github.com/TravMurav/slbounce/commit/d930fcc584c818c2254cfdac6983af45d5935538.patch"; + hash = "sha256-lTR3qonIId5mpAduwxzsf9qXux4FCpf5sAOEE+ZdR3Y="; + }) + (fetchpatch { + url = "https://github.com/TravMurav/slbounce/commit/006eb5db9083530610e8323cf80b8c98c00c891e.patch"; + hash = "sha256-T1XeLanrVEv6CNxptaOvA/ojs7YibySfUn0XRfpn/Zk="; + }) + ./slbounce-Makefile.patch + ]; + postPatch = '' + rmdir external/{arm64-sysreg-lib,dtc} + ln -s ${arm64-sysreg-lib} external/arm64-sysreg-lib + ln -s ${dtc-src} external/dtc + + cp -r ${gnu-efi}/* external/gnu-efi/ + chmod -R u+w external/gnu-efi + ''; + makeFlags = [ + "CROSS_COMPILE=" + "all" + "dtbs" + ]; + installPhase = '' + mkdir -p $out + cp out/*.efi $out/ + cp -r out/dtbo $out/ + ''; +} diff --git a/packages/x1e80100-linux.nix b/packages/x1e80100-linux.nix index bbd62d0..f284e86 100644 --- a/packages/x1e80100-linux.nix +++ b/packages/x1e80100-linux.nix @@ -19,6 +19,8 @@ linuxPackagesFor (buildLinux { defconfig = "johan_defconfig"; structuredExtraConfig = with lib.kernel; { + VIRTUALIZATION = yes; + KVM = yes; MAGIC_SYSRQ = yes; EC_LENOVO_YOGA_SLIM7X = module; };