RISC-V: Add to build system

This patch adds support for RISC-V to the grub build system. With this
patch, I can successfully build grub on RISC-V as a UEFI application.

Signed-off-by: Alexander Graf <agraf@suse.de>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Alexander Graf 2019-02-12 11:31:07 +01:00 committed by Vincent Batts
parent 1edef90cf9
commit 09d8eedbba
22 changed files with 201 additions and 21 deletions

View file

@ -53,13 +53,15 @@ EXPORT_FUNC (__umoddi3) (grub_uint64_t a, grub_uint64_t b);
#endif
#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || defined (__arm__)
#if defined (__sparc__) || defined (__powerpc__) || defined (__mips__) || \
defined (__arm__) || defined(__riscv)
unsigned
EXPORT_FUNC (__ctzdi2) (grub_uint64_t x);
#define NEED_CTZDI2 1
#endif
#if defined (__mips__) || defined (__arm__)
#if defined (__mips__) || defined (__arm__) || \
(defined(__riscv) && (__riscv_xlen == 32))
unsigned
EXPORT_FUNC (__ctzsi2) (grub_uint32_t x);
#define NEED_CTZSI2 1
@ -157,7 +159,8 @@ void EXPORT_FUNC (_savegpr_31) (void);
#endif
#if defined (__powerpc__) || defined(__mips__) || defined (__arm__)
#if defined (__powerpc__) || defined(__mips__) || defined (__arm__) || \
(defined(__riscv) && (__riscv_xlen == 32))
int
EXPORT_FUNC(__ucmpdi2) (grub_uint64_t a, grub_uint64_t b);
@ -172,7 +175,8 @@ grub_uint64_t
EXPORT_FUNC (__lshrdi3) (grub_uint64_t u, int b);
#endif
#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || defined (__arm__)
#if defined (__powerpc__) || defined(__mips__) || defined(__sparc__) || \
defined (__arm__) || defined(__riscv)
grub_uint32_t
EXPORT_FUNC(__bswapsi2) (grub_uint32_t u);

View file

@ -1691,7 +1691,8 @@ struct grub_efi_block_io
typedef struct grub_efi_block_io grub_efi_block_io_t;
#if (GRUB_TARGET_SIZEOF_VOID_P == 4) || defined (__ia64__) \
|| defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__)
|| defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \
|| defined(__riscv)
#define efi_call_0(func) func()
#define efi_call_1(func, a) func(a)

View file

@ -92,7 +92,7 @@ extern void (*EXPORT_VAR(grub_efi_net_config)) (grub_efi_handle_t hnd,
char **device,
char **path);
#if defined(__arm__) || defined(__aarch64__)
#if defined(__arm__) || defined(__aarch64__) || defined(__riscv)
void *EXPORT_FUNC(grub_efi_get_firmware_fdt)(void);
grub_err_t EXPORT_FUNC(grub_efi_get_ram_base)(grub_addr_t *);
#include <grub/cpu/linux.h>

View file

@ -340,7 +340,8 @@ grub_uint64_t EXPORT_FUNC(grub_divmod64) (grub_uint64_t n,
grub_uint64_t *r);
/* Must match softdiv group in gentpl.py. */
#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__))
#if !defined(GRUB_MACHINE_EMU) && (defined(__arm__) || defined(__ia64__) || \
(defined(__riscv) && (__riscv_xlen == 32)))
#define GRUB_DIVISION_IN_SOFTWARE 1
#else
#define GRUB_DIVISION_IN_SOFTWARE 0

View file

@ -103,6 +103,8 @@ enum grub_install_plat
GRUB_INSTALL_PLATFORM_I386_XEN_PVH,
GRUB_INSTALL_PLATFORM_ARM64_EFI,
GRUB_INSTALL_PLATFORM_ARM_COREBOOT,
GRUB_INSTALL_PLATFORM_RISCV32_EFI,
GRUB_INSTALL_PLATFORM_RISCV64_EFI,
GRUB_INSTALL_PLATFORM_MAX
};