Skip to content

Commit

Permalink
add RISCV64 and upgrade to VS2022
Browse files Browse the repository at this point in the history
* Also use our own fork of gnu-efi.
  • Loading branch information
pbatard committed Nov 7, 2023
1 parent ced5a02 commit d403e4c
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "gnu-efi"]
path = gnu-efi
url = git://git.code.sf.net/p/gnu-efi/code
url = https://github.com/pbatard/gnu-efi.git
ignore = dirty
16 changes: 8 additions & 8 deletions .vs/msvc/gnu-efi.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,55 +46,55 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
Expand Down
16 changes: 8 additions & 8 deletions .vs/msvc/uefi-simple.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,52 +46,52 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<WindowsSDKDesktopARM64Support>true</WindowsSDKDesktopARM64Support>
</PropertyGroup>
Expand Down
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ else
else ifeq ($(shell uname -m),aarch64)
ARCH = aa64
CROSS_COMPILE =
else ifeq ($(shell uname -m),riscv64)
ARCH = riscv64
CROSS_COMPILE =
else
ARCH = ia32
endif
Expand Down Expand Up @@ -76,6 +79,17 @@ else ifeq ($(ARCH),aa64)
LDFLAGS = -Wl,--no-wchar-size-warning -Wl,--defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
CRT0_LIBS = -lgnuefi
QEMU_OPTS = -M virt -cpu cortex-a57
else ifeq ($(ARCH),riscv64)
GNUEFI_ARCH = riscv64
GCC_ARCH = riscv64
QEMU_ARCH = riscv64
FW_BASE = QEMU_EFI
CROSS_COMPILE = $(GCC_ARCH)-linux-gnu-
EP_PREFIX =
CFLAGS = -fpic -fshort-wchar
LDFLAGS = -Wl,--defsym=EFI_SUBSYSTEM=$(SUBSYSTEM)
CRT0_LIBS = -lgnuefi
QEMU_OPTS = -M virt -cpu sifive_u
endif
FW_ARCH = $(shell echo $(ARCH) | tr a-z A-Z)
FW_ZIP = $(FW_BASE)-$(FW_ARCH).zip
Expand Down Expand Up @@ -112,8 +126,8 @@ 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.)
GCCVERSION := $(shell $(CC) -dumpversion | cut -f1 -d. | cut -f1 -d-)
GCCMINOR := $(shell $(CC) -dumpversion | cut -f2 -d. | cut -f1 -d-)
GCCMACHINE := $(shell $(CC) -dumpmachine)
GCCNEWENOUGH := $(shell ( [ $(GCCVERSION) -gt "4" ] \
|| ( [ $(GCCVERSION) -eq "4" ] \
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ UEFI:SIMPLE - EFI development made easy
=======================================

A simple UEFI "Hello World!" style application that can:
* be compiled on Windows or Linux, using Visual Studio 2019, MinGW or gcc.
* be compiled for x86_32, x86_64, ARM or ARM64/AARCH64 targets
* be compiled on Windows or Linux, using Visual Studio 2022, MinGW or gcc.
* be compiled for x86_32, x86_64, ARM, ARM64 or RISCV64 targets
* be tested on the fly, through a [QEMU](https://www.qemu.org/) +
[OVMF](https://github.com/tianocore/tianocore.github.io/wiki/OVMF) or
[QEMU_EFI](http://snapshots.linaro.org/components/kernel/leg-virt-tianocore-edk2-upstream/latest/)
virtual machine.

## Prerequisites

* [Visual Studio 2019](https://www.visualstudio.com/vs/community/) or gcc/make
* [Visual Studio 2022](https://www.visualstudio.com/vs/community/) or gcc/make
* [QEMU](http://www.qemu.org) __v2.7 or later__
(NB: You can find QEMU Windows binaries [here](https://qemu.weilnetz.de/w64/))
* git
Expand Down Expand Up @@ -40,17 +40,18 @@ If needed you can also add `ARCH=<arch>` and `CROSS_COMPILE=<tuple>`, e.g.:

* `make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-`
* `make ARCH=aa64 CROSS_COMPILE=aarch64-linux-gnu-`
* `make ARCH=riscv64 CROSS_COMPILE=riscv64-linux-gnu-`

where `<arch>` can be `x64`, `ia32`, `arm` or `aa64`.
where `<arch>` can be `x64`, `ia32`, `arm`, `aa64` or `riscv64`.

You can also add `qemu` as your `make` target to run the application under QEMU,
in which case a relevant UEFI firmware (OVMF for x86 or QEMU_EFI for Arm) will
be automatically downloaded to run your application against it.

## Visual Studio 2019 and ARM/ARM64 support
## Visual Studio 2022 and ARM/ARM64 support

Please be mindful that, to enable ARM or ARM64 compilation support in Visual Studio
2019, you __MUST__ go to the _Individual components_ screen in the setup application
2022, you __MUST__ go to the _Individual components_ screen in the setup application
and select the ARM/ARM64 build tools there, as they do __NOT__ appear in the default
_Workloads_ screen:

Expand Down
2 changes: 1 addition & 1 deletion gnu-efi
18 changes: 8 additions & 10 deletions main.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
/*
* UEFI:SIMPLE - UEFI development made easy
* Copyright ©️ 2014-2021 Pete Batard <[email protected]> - Public Domain
* Copyright ©️ 2014-2023 Pete Batard <[email protected]> - Public Domain
* See COPYING for the full licensing terms.
*/
#include <efi.h>
#include <efilib.h>
#include <libsmbios.h>

#if defined(_M_X64) || defined(__x86_64__)
static CHAR16* Arch = L"x64";
static CHAR16* ArchName = L"64-bit x86";
static CHAR16* ArchName = L"x86 64-bit";
#elif defined(_M_IX86) || defined(__i386__)
static CHAR16* Arch = L"ia32";
static CHAR16* ArchName = L"32-bit x86";
static CHAR16* ArchName = L"x86 32-bit";
#elif defined (_M_ARM64) || defined(__aarch64__)
static CHAR16* Arch = L"aa64";
static CHAR16* ArchName = L"64-bit ARM";
static CHAR16* ArchName = L"ARM 64-bit";
#elif defined (_M_ARM) || defined(__arm__)
static CHAR16* Arch = L"arm";
static CHAR16* ArchName = L"32-bit ARM";
static CHAR16* ArchName = L"ARM 32-bit";
#elif defined (_M_RISCV64) || (defined(__riscv) && (__riscv_xlen == 64))
static CHAR16* ArchName = L"RISC-V 64-bit";
#else
# error Unsupported architecture
#endif
Expand Down Expand Up @@ -112,7 +110,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
* %E Set output attribute to error
* %r Human readable version of a status code
*/
Print(L"\n%H*** UEFI Simple ***%N\n\n");
Print(L"\n%H*** UEFI Simple (%s) ***%N\n\n", ArchName);

PrintSystemInfo();

Expand Down

0 comments on commit d403e4c

Please sign in to comment.