summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO19
-rw-r--r--Makefile28
-rw-r--r--PKGBUILD24
-rw-r--r--poweroff.c10
-rw-r--r--readme4
-rw-r--r--reboot.c10
6 files changed, 95 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..0cfe3303bb7
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,19 @@
+pkgbase = powerofforreboot.efi
+ pkgdesc = Utilities to be used from within a UEFI boot manager or shell
+ pkgver = 20190517
+ pkgrel = 1
+ arch = i686
+ arch = x86_64
+ license = GPL
+ makedepends = gnu-efi-libs
+ source = Makefile
+ source = poweroff.c
+ source = reboot.c
+ source = readme
+ sha512sums = 927cc21ebd903a2615743489ba727b797a4c2f8eb933b490a6d4c64d8311ca1db771cac98259cbe2ecd28d35f9a23e87eb4ffd2596d5434a8d9f46d0d23ef39c
+ sha512sums = 101fbb26dfce18513463af53d43c357066e4bc1277866146a8b1893367196792a5a0ef428d59a692cd71c90baeeed8f90cfafaa44a2a2539f21b4f2243d12ea0
+ sha512sums = 09876c713d9196e1e9bc365e27348756411d4cdce5c0ed721daea679ad6bfc05b4066cd2a6c051972b374f58b5a7dce864b8562bd313c4ed95abbe0ca61fdcf6
+ sha512sums = d4651e2a1520781f9c942289c55b67fc64021279e6d656e9e266f232a8969065d13ae3159ee2db5ebe35a282c0544bb5e88dd5e1c0b869e71deecb6fb6e4ffea
+
+pkgname = powerofforreboot.efi
+
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000000..6dd34c15d8a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,28 @@
+ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
+
+EFIINC = /usr/include/efi
+EFIINCS = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
+LIB = /usr/lib
+EFILIB = /usr/lib
+EFI_CRT_OBJS = $(EFILIB)/crt0-efi-$(ARCH).o
+EFI_LDS = $(EFILIB)/elf_$(ARCH)_efi.lds
+
+CPPFLAGS =
+CFLAGS = $(EFIINCS) -fno-stack-protector -fpic \
+ -fshort-wchar -mno-red-zone -Wall
+ifeq ($(ARCH),x86_64)
+ CFLAGS += -DEFI_FUNCTION_WRAPPER
+endif
+
+LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared \
+ -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)
+
+all: poweroff.efi reboot.efi
+
+%.so: %.o
+ ld $(LDFLAGS) $^ -o $@ -lefi -lgnuefi
+
+%.efi: %.so
+ objcopy -j .text -j .sdata -j .data -j .dynamic \
+ -j .dynsym -j .rel -j .rela -j .reloc \
+ --target=efi-app-$(ARCH) $^ $@
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..6d0d8f94d8d
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,24 @@
+# Maintainer: < Ron Varburg AT yahoo com >
+
+pkgname=powerofforreboot.efi
+pkgver=20190517
+pkgrel=1
+pkgdesc="Utilities to be used from within a UEFI boot manager or shell"
+license=('GPL')
+arch=('i686' 'x86_64')
+makedepends=('gnu-efi-libs')
+source=('Makefile' 'poweroff.c' 'reboot.c' 'readme')
+sha512sums=('927cc21ebd903a2615743489ba727b797a4c2f8eb933b490a6d4c64d8311ca1db771cac98259cbe2ecd28d35f9a23e87eb4ffd2596d5434a8d9f46d0d23ef39c' # Makefile
+ '101fbb26dfce18513463af53d43c357066e4bc1277866146a8b1893367196792a5a0ef428d59a692cd71c90baeeed8f90cfafaa44a2a2539f21b4f2243d12ea0' # poweroff.c
+ '09876c713d9196e1e9bc365e27348756411d4cdce5c0ed721daea679ad6bfc05b4066cd2a6c051972b374f58b5a7dce864b8562bd313c4ed95abbe0ca61fdcf6' # reboot.c
+ 'd4651e2a1520781f9c942289c55b67fc64021279e6d656e9e266f232a8969065d13ae3159ee2db5ebe35a282c0544bb5e88dd5e1c0b869e71deecb6fb6e4ffea' # readme
+ )
+
+build() {
+ make
+}
+
+package() {
+ install --directory ${pkgdir}/usr/share/${pkgname}
+ install --mode=-x,go=r --target-directory=${pkgdir}/usr/share/${pkgname} *.efi readme
+}
diff --git a/poweroff.c b/poweroff.c
new file mode 100644
index 00000000000..2230d27b089
--- /dev/null
+++ b/poweroff.c
@@ -0,0 +1,10 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+EFIAPI
+efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
+ InitializeLib(ImageHandle, SystemTable);
+ return uefi_call_wrapper(SystemTable->RuntimeServices->ResetSystem, 4,
+ EfiResetShutdown, EFI_SUCCESS, sizeof(NULL), NULL);
+}
diff --git a/readme b/readme
new file mode 100644
index 00000000000..e6eac524c45
--- /dev/null
+++ b/readme
@@ -0,0 +1,4 @@
+This package contains source code, *.c, and helper files, to create efi utilities. The utilities are efi executables to poweroff, or reboot, the machine.
+Expected usage of the utilities is by uefi boot managers that do not provide these utilities. The utilities can also be run from within a uefi shell. The user is expected to copy the *.efi files to the ESP, and set the boot manager to use them. The exact path depends on the user choice. The exact procedure for setting the boot manager depends on the boot manager.
+
+SPDX-License-Identifier: GPL-2.0
diff --git a/reboot.c b/reboot.c
new file mode 100644
index 00000000000..2bfd2531a07
--- /dev/null
+++ b/reboot.c
@@ -0,0 +1,10 @@
+#include <efi.h>
+#include <efilib.h>
+
+EFI_STATUS
+EFIAPI
+efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
+ InitializeLib(ImageHandle, SystemTable);
+ return uefi_call_wrapper(SystemTable->RuntimeServices->ResetSystem, 4,
+ EfiResetCold, EFI_SUCCESS, sizeof(NULL), NULL);
+}