1

So basically, I'm trying to do input with gnu-efi and I've struggled but I finally got something compiling. Here it is:

#include <efi.h>
#include <efilib.h>

EFI_STATUS EFIAPI efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {

        EFI_STATUS status;
        EFI_INPUT_KEY Key;
        InitializeLib(ImageHandle, SystemTable);

        //status = SystemTable->ConIn->Reset(SystemTable->ConIn, FALSE);
        if (EFI_ERROR(status))
        return status;

        SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Hello pussy\n");
        while((status = SystemTable->ConIn->ReadKeyStroke(SystemTable->ConIn, &Key)) == EFI_NOT_READY && Key.ScanCode != 0x17);
times
        return EFI_SUCCESS;
}

My problem is that this causes the process to be stuck on the starting and makes my fans go crazy. There are no errors or anything. It just doesn't work. It stops the process and it makes my fans go overdrive. Any ConIn function does that.

** Extra info: **

The make file I compile my code with:


OBJS            = main3.o
TARGET          = hello3.efi

EFIINC          = /usr/include/efi
EFIINCS         = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB             = /usr/lib64
EFILIB          = /usr/lib64/
EFI_CRT_OBJS    = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS         = $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS          = -ffreestanding $(EFIINCS) -fno-stack-protector -fpic \
                -fshort-wchar -mno-red-zone -Wall -c
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: $(TARGET)

main3.o: hello.c
        gcc $(CFLAGS) hello3.c -o main3.o

hello3.so: $(OBJS)
        ld $(LDFLAGS) $(OBJS) -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) $^ $@

the command I run qemu with:

qemu-system-x86_64 -bios OVMF.fd -drive media=disk,id=boot,format=raw,file=fat:rw:DirContainingEFI/BOOT/bootx64.efi,index=0

0 Answers0