UEFI application for Intel Galileo (i586)

208 Views Asked by At

I'm working on a simple application that will be running on a Intel Galileo's board as UEFI app. I've started with a "Hello, World" app and tested it under qemu-system-i386 and it works well. Then, I've run it under Galileo EFI Shell and it stuck (nothing happend and never returned anything - like a never-ending loop). I know that Intel Galileo's Quark processor is a i586 architecture. It shouldn't be a problem to run application compiled for i386 under i586, due to the backward compatibility, am I right? Or am I missing something?

I'm using Ubuntu 14.04 (32-bit) for development with GCC 5.4.0 (default). Also, I'm using gnu-efi in version 3.0.4.

Should I build a cross-compiler? Will it resolve all of my problems? Is it necessary?

Here is a sample code:

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

EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) {
    InitializeLib(ImageHandle, SystemTable);
    Print(L"Hello, World!\n");

    return EFI_SUCCESS;
}

Here is my Makefile:

ARCH            = ia32

OBJS            = src/main.o
HEADERS         = 
TARGET          = build/main.efi

EFIINC          = lib/gnu-efi/inc
EFIINCS         = -I$(EFIINC) -I$(EFIINC)/$(ARCH) -I$(EFIINC)/protocol
LIB             = lib/gnu-efi/$(ARCH)/lib
EFILIB          = lib/gnu-efi/gnuefi
EFI_CRT_OBJS    = $(EFILIB)/crt0-efi-$(ARCH).o
EFI_LDS         = $(EFILIB)/elf_$(ARCH)_efi.lds

CFLAGS          = $(EFIINCS) -ffreestanding -fno-stack-protector -fpic -fshort-wchar -mno-red-zone -Wall -masm=intel

LDFLAGS         = -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L $(EFILIB) -L $(LIB) $(EFI_CRT_OBJS)

all: $(TARGET)

build: $(TARGET)

src/%.so: $(OBJS) $(HEADERS)
    ld $(LDFLAGS) $(OBJS) -o $@ -l:libefi.a -l:libgnuefi.a

build/%.efi: src/%.so
    objcopy -j .text -j .sdata -j .data -j .dynamic \
        -j .dynsym  -j .rel -j .rela -j .reloc \
        --target=efi-app-$(ARCH) $^ $@

run:
    qemu-system-i386 bin/OVMF.fd -hda fat:build

.PHONY: all build run
0

There are 0 best solutions below