Skip to content

Commit

Permalink
use uefi_main as entry point and use UEFI arch designations
Browse files Browse the repository at this point in the history
* Also finx additional ARM compilation issues with gcc and
  enable ARM debugging with Visual Studio
  • Loading branch information
pbatard committed Apr 22, 2016
1 parent 8a7d8af commit eeb7eef
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 77 deletions.
15 changes: 11 additions & 4 deletions .msvc/debug.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

' Modify these variables as needed
QEMU_PATH = "C:\Program Files\qemu\"
' You can add something like "-S -gdb tcp:127.0.0.1:1234" if you plan to use gdb to debug
QEMU_OPTS = "-net none -monitor none -parallel none"
OVMF_DIR = "http://efi.akeo.ie/OVMF/"
OVMF_REV = "r15214"
' Set to True if you need to download a file that might be cached locally
NO_CACHE = False

Expand All @@ -24,21 +25,27 @@ If (TARGET = "x86") Then
ElseIf (TARGET = "x64") Then
UEFI_EXT = "x64"
QEMU_ARCH = "x86_64"
ElseIf (TARGET = "ARM") Then
UEFI_EXT = "arm"
QEMU_ARCH = "arm"
' You can also add '-device VGA' to the options below, to get graphics output.
' But if you do, be mindful that the keyboard input may not work... :(
QEMU_OPTS = "-M virt -cpu cortex-a15 " & QEMU_OPTS
Else
MsgBox("Unsupported debug target: " & TARGET)
Call WScript.Quit(1)
End If
BOOT_NAME = "boot" & UEFI_EXT & ".efi"
OVMF_ARCH = UCase(UEFI_EXT)
OVMF_ZIP = "OVMF-" & OVMF_ARCH & "-" & OVMF_REV & ".zip"
OVMF_ZIP = "OVMF-" & OVMF_ARCH & ".zip"
OVMF_BIOS = "OVMF_" & OVMF_ARCH & ".fd"
OVMF_URL = OVMF_DIR & OVMF_ZIP
QEMU_EXE = "qemu-system-" & QEMU_ARCH & "w.exe"
VHD_ZIP = "ntfs.zip"
VHD_IMG = "ntfs.vhd"
VHD_URL = "http://efi.akeo.ie/test/" & VHD_ZIP
DRV = "ntfs_" & UEFI_EXT & ".efi"
DRV_URL = "http://efi.akeo.ie/downloads/efifs-0.8/" & UEFI_EXT & "/" & DRV
DRV_URL = "http://efi.akeo.ie/downloads/efifs-0.9/" & UEFI_EXT & "/" & DRV

' Globals
Set fso = CreateObject("Scripting.FileSystemObject")
Expand Down Expand Up @@ -147,4 +154,4 @@ Call shell.Run("%COMSPEC% /c mkdir ""image\efi\boot""", 0, True)
Call fso.CopyFile(BIN, "image\efi\boot\" & BOOT_NAME, True)
Call shell.Run("%COMSPEC% /c mkdir ""image\efi\rufus""", 0, True)
Call fso.CopyFile(DRV, "image\efi\rufus\" & DRV, True)
Call shell.Run("""" & QEMU_PATH & QEMU_EXE & """ -L . -bios " & OVMF_BIOS & " -net none -hda fat:image -hdb ntfs.vhd", 1, True)
Call shell.Run("""" & QEMU_PATH & QEMU_EXE & """ " & QEMU_OPTS & " -L . -bios " & OVMF_BIOS & " -hda fat:image -hdb ntfs.vhd", 1, True)
8 changes: 4 additions & 4 deletions .msvc/gnu-efi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<OutDir>$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)x64\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)ia32\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<OutDir>$(SolutionDir)arm\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<OutDir>$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)x64\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)ia32\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
Expand Down
20 changes: 10 additions & 10 deletions .msvc/uefi-ntfs.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@
<TargetExt>.efi</TargetExt>
<GenerateManifest>false</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)x64\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<TargetName>bootx64</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetExt>.efi</TargetExt>
<GenerateManifest>false</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)ia32\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<TargetName>bootia32</TargetName>
</PropertyGroup>
Expand All @@ -117,15 +117,15 @@
<TargetExt>.efi</TargetExt>
<GenerateManifest>false</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)x86_64\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)x64\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<TargetName>bootx64</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetExt>.efi</TargetExt>
<GenerateManifest>false</GenerateManifest>
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)x86_32\$(Configuration)\</OutDir>
<OutDir>$(SolutionDir)ia32\$(Configuration)\</OutDir>
<IntDir>$(OutDir)$(ProjectName)\</IntDir>
<TargetName>bootia32</TargetName>
</PropertyGroup>
Expand Down Expand Up @@ -159,7 +159,7 @@
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4210</AdditionalOptions>
Expand Down Expand Up @@ -188,7 +188,7 @@
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4210</AdditionalOptions>
Expand Down Expand Up @@ -218,7 +218,7 @@
</RandomizedBaseAddress>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/IGNORE:4210</AdditionalOptions>
Expand Down Expand Up @@ -246,7 +246,7 @@
<Link>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalDependencies>gnu-efi.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -275,7 +275,7 @@
<Link>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalDependencies>gnu-efi.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down Expand Up @@ -305,7 +305,7 @@
<Link>
<DataExecutionPrevention>false</DataExecutionPrevention>
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>EfiMain</EntryPointSymbol>
<EntryPointSymbol>efi_main</EntryPointSymbol>
<SubSystem>EFI Application</SubSystem>
<AdditionalDependencies>gnu-efi.lib;libcmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
Expand Down
12 changes: 6 additions & 6 deletions .msvc/uefi-ntfs.vcxproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">
<LocalDebuggerCommand>$(SystemRoot)\System32\wscript</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs $(Configuration) $(TargetPath) $(PlatformShortName)</LocalDebuggerCommandArguments>
<LocalDebuggerCommandArguments>//d .msvc\debug.vbs "$(Configuration)" "$(TargetPath)" "$(PlatformShortName)"</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>$(SolutionDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
Expand Down
74 changes: 45 additions & 29 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ SUBSYSTEM = 10 # 10 = EFI application

# Try to auto-detect the target ARCH
ifeq ($(shell uname -o),Msys)
IS_MINGW32 = $(findstring MINGW32,$(shell uname -s))
IS_MINGW64 = $(findstring MINGW64,$(shell uname -s))
IS_MINGW32 = $(findstring MINGW32,$(shell uname -s))
IS_MINGW64 = $(findstring MINGW64,$(shell uname -s))
ifeq ($(IS_MINGW32),MINGW32)
ARCH = ia32
endif
Expand Down Expand Up @@ -36,25 +36,37 @@ ifeq ($(ARCH),x64)
CROSS_COMPILE = $(GCC_ARCH)-$(MINGW_HOST)-mingw32-
EP_PREFIX =
CFLAGS = -m64 -mno-red-zone
LDFLAGS = -Wl,-dll
LDFLAGS = -Wl,-dll -Wl,--subsystem,$(SUBSYSTEM)
else ifeq ($(ARCH),ia32)
GNUEFI_ARCH = ia32
GCC_ARCH = i686
QEMU_ARCH = i386
CROSS_COMPILE = $(GCC_ARCH)-$(MINGW_HOST)-mingw32-
EP_PREFIX = _
CFLAGS = -m32 -mno-red-zone
LDFLAGS = -Wl,-dll
LDFLAGS = -Wl,-dll -Wl,--subsystem,$(SUBSYSTEM)
else ifeq ($(ARCH),arm)
GNUEFI_ARCH = arm
GCC_ARCH = arm
QEMU_ARCH = arm
CROSS_COMPILE = $(GCC_ARCH)-linux-gnueabi-
QEMU_OPTS = -M virt -cpu cortex-a15
CROSS_COMPILE = $(GCC_ARCH)-linux-gnueabihf-
EP_PREFIX =
CFLAGS = -marm -fpic -fshort-wchar
LDFLAGS = -Wl,--no-wchar-size-warning
LDFLAGS = -Wl,--no-wchar-size-warning -Wl,--defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
CRT0_LIBS = -lgnuefi
endif
OVMF_ARCH = $(shell echo $(ARCH) | tr a-z A-Z)
OVMF_ZIP = OVMF-$(OVMF_ARCH).zip
GNUEFI_DIR = $(CURDIR)/gnu-efi
GNUEFI_LIBS = lib

# If the compiler produces an elf binary, we need to fiddle with a PE crt0
ifneq ($(CRT0_LIBS),)
CRT0_DIR = $(GNUEFI_DIR)/$(GNUEFI_ARCH)/gnuefi
LDFLAGS += -L$(CRT0_DIR) -T $(GNUEFI_DIR)/gnuefi/elf_$(ARCH)_efi.lds $(CRT0_DIR)/crt0-efi-$(ARCH).o
GNUEFI_LIBS += gnuefi
endif

# SYSTEMROOT is only defined on Windows systems
ifneq ($(SYSTEMROOT),)
Expand All @@ -65,26 +77,26 @@ ifneq ($(SYSTEMROOT),)
else
QEMU = qemu-system-$(QEMU_ARCH) -nographic
endif
GNUEFI_DIR = $(CURDIR)/gnu-efi

CC := $(CROSS_COMPILE)gcc
CFLAGS += -fno-stack-protector -Wshadow -Wall -Wunused -Werror-implicit-function-declaration
CFLAGS += -I$(GNUEFI_DIR)/inc -I$(GNUEFI_DIR)/inc/$(GNUEFI_ARCH) -I$(GNUEFI_DIR)/inc/protocol
LDFLAGS+= -Wl,--subsystem,$(SUBSYSTEM) -nostdlib -shared -e $(EP_PREFIX)EfiMain
LIBS := -L$(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib -lefi

OVMF_ZIP = OVMF-$(OVMF_ARCH)-r15214.zip
CC := $(CROSS_COMPILE)gcc
OBJCOPY := $(CROSS_COMPILE)objcopy
CFLAGS += -fno-stack-protector -Wshadow -Wall -Wunused -Werror-implicit-function-declaration
CFLAGS += -I$(GNUEFI_DIR)/inc -I$(GNUEFI_DIR)/inc/$(GNUEFI_ARCH) -I$(GNUEFI_DIR)/inc/protocol
CFLAGS += -DCONFIG_$(GNUEFI_ARCH) -D__MAKEWITH_GNUEFI -DGNU_EFI_USE_MS_ABI
LDFLAGS += -L$(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib -e $(EP_PREFIX)efi_main
LDFLAGS += -s -Wl,-Bsymbolic -nostdlib -shared
LIBS = -lefi $(CRT0_LIBS)

ifeq (, $(shell which $(CC)))
$(error The selected compiler ($(CC)) was not found)
endif

GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.)
GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.)
GCCMACHINE := $(shell $(CC) -dumpmachine)
GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
|| ( [ $(GCCVERSION) -eq "4" ] \
&& [ $(GCCMINOR) -ge "7" ] ) ) \
GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d.)
GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d.)
GCCMACHINE := $(shell $(CC) -dumpmachine)
GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
|| ( [ $(GCCVERSION) -eq "4" ] \
&& [ $(GCCMINOR) -ge "7" ] ) ) \
&& echo 1)
ifneq ($(GCCNEWENOUGH),1)
$(error You need GCC 4.7 or later)
Expand All @@ -94,32 +106,38 @@ ifneq ($(GCC_ARCH),$(findstring $(GCC_ARCH), $(GCCMACHINE)))
$(error The selected compiler ($(CC)) is not set for $(TARGET))
endif


.PHONY: all clean superclean
all: boot.efi
all: $(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib/libefi.a boot.efi

$(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib/libefi.a:
$(MAKE) -C$(GNUEFI_DIR) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(GNUEFI_ARCH) lib
$(MAKE) -C$(GNUEFI_DIR) CROSS_COMPILE=$(CROSS_COMPILE) ARCH=$(GNUEFI_ARCH) $(GNUEFI_LIBS)

%.efi: %.o $(GNUEFI_DIR)/$(GNUEFI_ARCH)/lib/libefi.a
%.efi: %.o
@echo [LD] $(notdir $@)
ifeq ($(CRT0_LIBS),)
@$(CC) $(LDFLAGS) $< -o $@ $(LIBS)
else
@$(CC) $(LDFLAGS) $< -o $*.elf $(LIBS)
@$(OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel* \
-j .rela* -j .reloc -j .eh_frame -O binary $*.elf $@
@rm -f $*.elf
endif

%.o: %.c
@echo [CC] $(notdir $@)
@$(CC) $(CFLAGS) -ffreestanding -c $<

qemu: CFLAGS += -D_DEBUG
qemu: boot.efi OVMF_$(OVMF_ARCH).fd ntfs.vhd image/efi/boot/boot$(ARCH).efi image/efi/rufus/ntfs_$(ARCH).efi
$(QEMU) -bios ./OVMF_$(OVMF_ARCH).fd -net none -hda fat:image -hdb ntfs.vhd
qemu: all OVMF_$(OVMF_ARCH).fd ntfs.vhd image/efi/boot/boot$(ARCH).efi image/efi/rufus/ntfs_$(ARCH).efi
$(QEMU) $(QEMU_OPTS) -bios ./OVMF_$(OVMF_ARCH).fd -net none -hda fat:image -hdb ntfs.vhd

image/efi/boot/boot$(ARCH).efi: boot.efi
mkdir -p image/efi/boot
cp -f $< $@

# NTFS driver
ntfs_$(ARCH).efi:
wget http://efi.akeo.ie/downloads/efifs-0.8/$(ARCH)/ntfs_$(ARCH).efi
wget http://efi.akeo.ie/downloads/efifs-0.9/$(ARCH)/ntfs_$(ARCH).efi

image/efi/rufus/ntfs_$(ARCH).efi: ntfs_$(ARCH).efi
mkdir -p image/efi/rufus
Expand All @@ -132,14 +150,12 @@ ntfs.vhd:
rm ntfs.zip

OVMF_$(OVMF_ARCH).fd:
# Use our own mirror, since SourceForge are being such ASSES about direct downloads...
wget http://efi.akeo.ie/OVMF/$(OVMF_ZIP)
unzip $(OVMF_ZIP) OVMF.fd
mv OVMF.fd OVMF_$(OVMF_ARCH).fd
rm $(OVMF_ZIP)

clean:
$(MAKE) -C$(GNUEFI_DIR) clean
rm -f boot.efi *.o
rm -rf image

Expand Down
9 changes: 5 additions & 4 deletions boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ EFI_HANDLE EfiImageHandle = NULL;
#endif
// Always good to know the arch we're running
#if defined(_M_X64) || defined(__x86_64__)
static CHAR16* Arch = L"x86_64";
static CHAR16* Arch = L"x64";
#elif defined(_M_IX86) || defined(__i386__)
static CHAR16* Arch = L"x86_32";
static CHAR16* Arch = L"ia32";
#elif defined (_M_ARM) || defined(__arm__)
static CHAR16* Arch = L"ARM";
static CHAR16* Arch = L"arm";
#endif

/*
Expand Down Expand Up @@ -320,8 +320,9 @@ static VOID DisconnectBlockingDrivers(VOID) {

/*
* Application entry-point
* NB: This must be set to 'efi_main' for gnu-efi crt0 compatibility
*/
EFI_STATUS EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
EFI_LOADED_IMAGE *LoadedImage;
EFI_STATUS Status;
Expand Down

0 comments on commit eeb7eef

Please sign in to comment.