From 6b6db5002493c12fe319f3c07c6ea3218080e038 Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sun, 6 Dec 2015 16:22:51 -0500 Subject: [PATCH] Work around keyboard input problem in gptsync on some Macs. Minor reformatting/cleanup of Makefiles. --- Make.common | 32 ++++---------------------------- NEWS.txt | 4 ++++ filesystems/Make.gnuefi | 2 -- filesystems/Make.tiano | 7 +++++-- gptsync/os_efi.c | 16 +++++++--------- refind/Make.tiano | 6 +++--- refind/Makefile | 18 +++++++++++------- 7 files changed, 34 insertions(+), 51 deletions(-) diff --git a/Make.common b/Make.common index 563cdbf..d46be77 100644 --- a/Make.common +++ b/Make.common @@ -113,8 +113,6 @@ FORMAT_DRIVER = --target=efi-bsdrv-$(ARCH) # ifeq ($(ARCH),x86_64) -# CFLAGS += -DEFI_FUNCTION_WRAPPER -# GNUEFI_CFLAGS += -DEFIX64 GNUEFI_LDFLAGS += -znocombreloc -zdefs ARCH_CFLAGS = -DEFIX64 -DEFI_FUNCTION_WRAPPER -m64 -mno-red-zone @@ -128,23 +126,14 @@ endif UC_ARCH = X64 FILENAME_CODE = x64 LD_CODE = elf_x86_64 - -# ifeq ($(HOSTARCH),ia32) -# ARCH3264 = -m64 -# -# GNUEFILIB := $(GNUEFILIB)64 -# EFILIB := $(EFILIB)64 -# EFICRT0 := $(EFICRT0)64 -# endif endif ifeq ($(ARCH),ia32) -# GNUEFI_CFLAGS += -DEFI32 -malign-double GNUEFI_LDFLAGS += -znocombreloc -zdefs + # In practice, cross-compiling filesystem drivers works, but not the main + # rEFInd binary.... ifeq ($(HOSTARCH),x86_64) -# ARCH3264 = -m32 - GNUEFILIB := $(GNUEFILIB)32 EFILIB := $(EFILIB)32 EFICRT0 := $(EFICRT0)32 @@ -161,7 +150,6 @@ endif endif ifeq ($(ARCH), aarch64) -# CFLAGS += -fno-stack-check GNUEFI_CFLAGS += -DEFIAARCH64 FORMAT = -O binary FORMAT_DRIVER = -O binary @@ -181,24 +169,12 @@ ifeq ($(ARCH), aarch64) LD_CODE = aarch64elf endif -# ifneq (,$(findstring FreeBSD,$(OS))) -# ifeq ($(ARCH),x86_64) -# LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_fbsd_efi.lds -# else -# LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds -# endif -# else -# LDSCRIPT = $(EFICRT0)/elf_$(ARCH)_efi.lds -# endif - -# -# general rules -# - +# GNU-EFI compilation path uses .o files for compiled object code %.o: %.c $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(GNUEFI_CFLAGS) $(LOCAL_GNUEFI_CFLAGS) \ -D__MAKEWITH_GNUEFI -DREFIND_VERSION=$(REFIND_VERSION) -c $< -o $@ +# TianoCore compilation path uses .obj files for compiled object code %.obj: %.c $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(TIANO_INCLUDE_DIRS) -DNO_BUILTIN_VA_FUNCS \ -D__MAKEWITH_TIANO -DREFIND_VERSION=$(REFIND_VERSION) -c $< -o $@ diff --git a/NEWS.txt b/NEWS.txt index d39db5f..0beac95 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -6,6 +6,10 @@ it; but it should make future extensions to additional platforms or building in different environments easier. +- Added workaround to gptsync for issue with some Macs' EFIs that caused + the program to skip through all prompts accepting the default option. + This would normally cause gptsync to do nothing. + - Added type code 53746F72-6167-11AA-AA11-00306543ECAC (Apple Core Storage, gdisk type AF05) to list of partition types recognized by gptsync. diff --git a/filesystems/Make.gnuefi b/filesystems/Make.gnuefi index cfa6695..71d397f 100644 --- a/filesystems/Make.gnuefi +++ b/filesystems/Make.gnuefi @@ -13,8 +13,6 @@ SRCDIR = . VPATH = $(SRCDIR) HOSTARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) -# Note: IA64 options are untested; taken from Debian's rEFIt package. - LOCAL_GNUEFI_CFLAGS = -DFSTYPE=$(DRIVERNAME) -I$(SRCDIR) ifeq ($(HOSTARCH),x86_64) LOCAL_GNUEFI_CFLAGS += "-DEFIAPI=__attribute__((ms_abi))" diff --git a/filesystems/Make.tiano b/filesystems/Make.tiano index 2c30d54..537c0e0 100644 --- a/filesystems/Make.tiano +++ b/filesystems/Make.tiano @@ -45,7 +45,9 @@ BUILDME = $(DRIVERNAME)_$(FILENAME_CODE).efi ENTRYPOINT = _ModuleEntryPoint %.obj: %.c - $(CC) $(ARCH_CFLAGS) $(CFLAGS) $(TIANO_INCLUDE_DIRS) -DFSTYPE=$(DRIVERNAME) -DNO_BUILTIN_VA_FUNCS -D__MAKEWITH_TIANO -c $< -o $@ + $(CC) $(ARCH_CFLAGS) $(CFLAGS) $(TIANO_INCLUDE_DIRS) \ + -DFSTYPE=$(DRIVERNAME) -DNO_BUILTIN_VA_FUNCS \ + -D__MAKEWITH_TIANO -c $< -o $@ ifneq (,$(filter %.efi,$(BUILDME))) @@ -54,7 +56,8 @@ DLL_TARGET = $(subst .efi,.dll,$(BUILDME)) all: $(BUILDME) $(DLL_TARGET): $(OBJS) fsw_$(DRIVERNAME).obj - $(LD) -o $(DRIVERNAME)_$(FILENAME_CODE).dll $(TIANO_LDFLAGS) --start-group $(ALL_EFILIBS) $(OBJS) fsw_$(DRIVERNAME).obj --end-group + $(LD) -o $(DRIVERNAME)_$(FILENAME_CODE).dll $(TIANO_LDFLAGS) \ + --start-group $(ALL_EFILIBS) $(OBJS) fsw_$(DRIVERNAME).obj --end-group $(BUILDME): $(DLL_TARGET) $(OBJCOPY) --strip-unneeded -R .eh_frame $(DLL_TARGET) diff --git a/gptsync/os_efi.c b/gptsync/os_efi.c index 51293d8..e857f71 100644 --- a/gptsync/os_efi.c +++ b/gptsync/os_efi.c @@ -125,15 +125,13 @@ UINTN input_boolean(CHARN *prompt, BOOLEAN *bool_out) Print(prompt); - if (ReadAllKeyStrokes()) { // remove buffered key strokes - refit_call1_wrapper(BS->Stall, 500000); // 0.5 seconds delay - ReadAllKeyStrokes(); // empty the buffer again - } - - refit_call3_wrapper(BS->WaitForEvent, 1, &ST->ConIn->WaitForKey, &Index); - Status = refit_call2_wrapper(ST->ConIn->ReadKeyStroke, ST->ConIn, &Key); - if (EFI_ERROR(Status)) - return 1; + ReadAllKeyStrokes(); // Remove buffered key strokes + do { + refit_call3_wrapper(BS->WaitForEvent, 1, &ST->ConIn->WaitForKey, &Index); + Status = refit_call2_wrapper(ST->ConIn->ReadKeyStroke, ST->ConIn, &Key); + if (EFI_ERROR(Status) && Status != EFI_NOT_READY) + return 1; + } while (Status == EFI_NOT_READY); if (Key.UnicodeChar == 'y' || Key.UnicodeChar == 'Y') { Print(L"Yes\n"); diff --git a/refind/Make.tiano b/refind/Make.tiano index 6120c2f..1ef88e6 100644 --- a/refind/Make.tiano +++ b/refind/Make.tiano @@ -46,13 +46,13 @@ $(AR_TARGET): $(OBJS) $(DLL_TARGET)_$(FILENAME_CODE).dll: $(OBJS) ../libeg/libeg.lib ../EfiLib/EfiLib.lib ../mok/mok.lib $(LD) -o $(DLL_TARGET)_$(FILENAME_CODE).dll $(TIANO_LDFLAGS) \ - --start-group $(ALL_EFILIBS) $(OBJS) ../libeg/libeg.lib \ - ../EfiLib/EfiLib.lib ../mok/mok.lib --end-group + --start-group $(ALL_EFILIBS) $(OBJS) ../libeg/libeg.lib \ + ../EfiLib/EfiLib.lib ../mok/mok.lib --end-group $(BUILDME): $(DLL_TARGET)_$(FILENAME_CODE).dll $(OBJCOPY) --strip-unneeded -R .eh_frame $(DLL_TARGET)_$(FILENAME_CODE).dll $(GENFW) -e UEFI_APPLICATION -o $(BUILDME)_$(FILENAME_CODE).efi \ - $(DLL_TARGET)_$(FILENAME_CODE).dll + $(DLL_TARGET)_$(FILENAME_CODE).dll clean: make clean diff --git a/refind/Makefile b/refind/Makefile index afda38a..88fbc40 100644 --- a/refind/Makefile +++ b/refind/Makefile @@ -30,18 +30,23 @@ ifeq ($(ARCH),aarch64) TARGET = refind_aa64.efi endif -LOCAL_GNUEFI_CFLAGS = -I$(SRCDIR) -I$(SRCDIR)/../include -I$(SRCDIR)/../libeg -I$(SRCDIR)/../mok -LOCAL_LDFLAGS = -L$(SRCDIR)/../libeg/ -L$(SRCDIR)/../mok/ -L$(SRCDIR)/../EfiLib/ +LOCAL_GNUEFI_CFLAGS = -I$(SRCDIR) -I$(SRCDIR)/../include \ + -I$(SRCDIR)/../libeg -I$(SRCDIR)/../mok +LOCAL_LDFLAGS = -L$(SRCDIR)/../libeg/ -L$(SRCDIR)/../mok/ \ + -L$(SRCDIR)/../EfiLib/ LOCAL_LIBS = -leg -lmok -lEfiLib -OBJS = main.o mystrings.o apple.o line_edit.o config.o menu.o screen.o icns.o gpt.o crc32.o lib.o driver_support.o legacy.o +OBJS = main.o mystrings.o apple.o line_edit.o config.o menu.o \ + screen.o icns.o gpt.o crc32.o lib.o driver_support.o \ + legacy.o include $(SRCDIR)/../Make.common all: $(TARGET) $(SHLIB_TARGET): $(OBJS) - $(LD) $(LOCAL_LDFLAGS) $(GNUEFI_LDFLAGS) $(SUBSYSTEM_LDFLAG) $(OBJS) -o $@ $(LOCAL_LIBS) $(GNUEFI_LIBS) + $(LD) $(LOCAL_LDFLAGS) $(GNUEFI_LDFLAGS) $(SUBSYSTEM_LDFLAG) $(OBJS) \ + -o $@ $(LOCAL_LIBS) $(GNUEFI_LIBS) $(TARGET): $(SHLIB_TARGET) $(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \ @@ -50,7 +55,6 @@ $(TARGET): $(SHLIB_TARGET) chmod a-x $(TARGET) clean: - rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt refind_*.dll *.lib + rm -f $(TARGET) *~ *.so $(OBJS) *.efi *.obj refind_*.txt \ + refind_*.dll *.lib -# EOF -# DO NOT DELETE -- 2.39.2