From 00345258e9355de2bef8ed1164c28f505c868e0a Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 15 Jan 2022 15:09:45 +0500 Subject: [PATCH] Add arch "riscv64" --- Makefile.am | 4 ++++ configure.ac | 2 ++ include/Makefile.am | 2 ++ include/kernaux.h | 1 + include/kernaux/arch/riscv64.h | 14 ++++++++++++++ include/kernaux/asm/riscv64.h | 14 ++++++++++++++ src/asm/riscv64.S | 3 +++ 7 files changed, 40 insertions(+) create mode 100644 include/kernaux/arch/riscv64.h create mode 100644 include/kernaux/asm/riscv64.h create mode 100644 src/asm/riscv64.S diff --git a/Makefile.am b/Makefile.am index 36648a5..49df61f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,10 @@ if ASM_I386 libkernaux_a_SOURCES += src/asm/i386.S endif +if ASM_RISCV64 +libkernaux_a_SOURCES += src/asm/riscv64.S +endif + if ASM_X86_64 libkernaux_a_SOURCES += src/asm/x86_64.S endif diff --git a/configure.ac b/configure.ac index 001341c..5755d6b 100644 --- a/configure.ac +++ b/configure.ac @@ -54,6 +54,7 @@ AS_IF([test "$with_libc" = yes], do_with_libc) dnl Architecture AM_CONDITIONAL([ASM_I386], [test "$host_cpu" = i386]) +AM_CONDITIONAL([ASM_RISCV64], [test "$host_cpu" = riscv64]) AM_CONDITIONAL([ASM_X86_64], [test "$host_cpu" = x86_64]) dnl Features (disabled by default) @@ -79,6 +80,7 @@ AM_CONDITIONAL([WITH_LIBC_STRLEN], [test "$with_libc_strlen" = yes]) dnl Architecture AS_IF([test "$host_cpu" = i386], [AC_DEFINE([ASM_I386], [1], [architecture is i386])]) +AS_IF([test "$host_cpu" = riscv64], [AC_DEFINE([ASM_RISCV64], [1], [architecture is RISC-V 64-bit])]) AS_IF([test "$host_cpu" = x86_64], [AC_DEFINE([ASM_X86_64], [1], [architecture is x86_64])]) dnl Features (disabled by default) diff --git a/include/Makefile.am b/include/Makefile.am index 18c976b..ebabbbc 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,8 +1,10 @@ nobase_include_HEADERS = \ kernaux.h \ kernaux/arch/i386.h \ + kernaux/arch/riscv64.h \ kernaux/arch/x86_64.h \ kernaux/asm/i386.h \ + kernaux/asm/riscv64.h \ kernaux/asm/x86_64.h \ kernaux/assert.h \ kernaux/cmdline.h \ diff --git a/include/kernaux.h b/include/kernaux.h index 86d490f..3d1572a 100644 --- a/include/kernaux.h +++ b/include/kernaux.h @@ -18,4 +18,5 @@ #include #include +#include #include diff --git a/include/kernaux/arch/riscv64.h b/include/kernaux/arch/riscv64.h new file mode 100644 index 0000000..2af64f4 --- /dev/null +++ b/include/kernaux/arch/riscv64.h @@ -0,0 +1,14 @@ +#ifndef KERNAUX_INCLUDED_ARCH_RISCV64 +#define KERNAUX_INCLUDED_ARCH_RISCV64 + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/kernaux/asm/riscv64.h b/include/kernaux/asm/riscv64.h new file mode 100644 index 0000000..4ddaf89 --- /dev/null +++ b/include/kernaux/asm/riscv64.h @@ -0,0 +1,14 @@ +#ifndef KERNAUX_INCLUDED_ASM_RISCV64 +#define KERNAUX_INCLUDED_ASM_RISCV64 + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/asm/riscv64.S b/src/asm/riscv64.S new file mode 100644 index 0000000..c7cde56 --- /dev/null +++ b/src/asm/riscv64.S @@ -0,0 +1,3 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif