[PATCH 6/7] riscv: add CONFIG_API support
mhorne at FreeBSD.org
mhorne at FreeBSD.org
Tue Apr 21 00:34:17 CEST 2020
From: Mitchell Horne <mhorne at FreeBSD.org>
Add the necessary changes to allow building the CONFIG_API option on the
RISC-V architecture. The downstream consumer of this API is the u-boot
version of FreeBSD's loader(8). This enables the loader to be ported to
RISC-V.
Signed-off-by: Mitchell Horne <mhorne at FreeBSD.org>
Cc: rick at andestech.com
Cc: bmeng.cn at gmail.com
Cc: atish.patra at wdc.com
---
api/Makefile | 1 +
api/api_platform-riscv.c | 33 +++++++++++++++++++++++++++++++++
examples/api/Makefile | 3 +++
examples/api/crt0.S | 15 +++++++++++++++
4 files changed, 52 insertions(+)
create mode 100644 api/api_platform-riscv.c
diff --git a/api/Makefile b/api/Makefile
index bd2d035fcd..737854e2c6 100644
--- a/api/Makefile
+++ b/api/Makefile
@@ -6,3 +6,4 @@ obj-y += api.o api_display.o api_net.o api_storage.o
obj-$(CONFIG_ARM) += api_platform-arm.o
obj-$(CONFIG_PPC) += api_platform-powerpc.o
obj-$(CONFIG_MIPS) += api_platform-mips.o
+obj-$(CONFIG_RISCV) += api_platform-riscv.o
diff --git a/api/api_platform-riscv.c b/api/api_platform-riscv.c
new file mode 100644
index 0000000000..33a56535f3
--- /dev/null
+++ b/api/api_platform-riscv.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2007 Stanislav Galabov <sgalabov at gmail.com>
+ *
+ * This file contains routines that fetch data from bd_info sources
+ */
+
+#include <config.h>
+#include <linux/types.h>
+#include <api_public.h>
+
+#include <asm/u-boot.h>
+#include <asm/global_data.h>
+
+#include "api_private.h"
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/*
+ * Important notice: handling of individual fields MUST be kept in sync with
+ * include/asm-generic/u-boot.h, so any changes
+ * need to reflect their current state and layout of structures involved!
+ */
+int platform_sys_info(struct sys_info *si)
+{
+ int i;
+
+ for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++)
+ platform_set_mr(si, gd->bd->bi_dram[i].start,
+ gd->bd->bi_dram[i].size, MR_ATTR_DRAM);
+
+ return 1;
+}
diff --git a/examples/api/Makefile b/examples/api/Makefile
index 8fa9c04118..0f9d0e013f 100644
--- a/examples/api/Makefile
+++ b/examples/api/Makefile
@@ -18,6 +18,9 @@ else
LOAD_ADDR = 0x80200000
endif
endif
+ifeq ($(ARCH),riscv)
+LOAD_ADDR = 0x84000000
+endif
# Resulting ELF and binary exectuables will be named demo and demo.bin
extra-y = demo demo.bin
diff --git a/examples/api/crt0.S b/examples/api/crt0.S
index 658bc59a82..2ba23331df 100644
--- a/examples/api/crt0.S
+++ b/examples/api/crt0.S
@@ -65,6 +65,21 @@ return_addr:
.data
.align 8
.long 0
+
+#elif defined(CONFIG_RISCV)
+#include <asm/asm.h>
+ .text
+ .globl _start
+_start:
+ lla t0, search_hint
+ REG_S sp, 0(t0)
+ tail main
+
+ .globl syscall
+syscall:
+ lla t0, syscall_ptr
+ REG_L t2, 0(t0)
+ jr t2
#else
#error No support for this arch!
#endif
--
2.26.1
More information about the U-Boot
mailing list