Re: [PATCH 6/7] riscv: add CONFIG_API support

2020-04-23 Thread Bin Meng
On Tue, Apr 21, 2020 at 6:35 AM  wrote:
>
> From: Mitchell Horne 
>
> 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

Could you please include a URL for FreeBSD's loader(8)?

> RISC-V.
>
> Signed-off-by: Mitchell Horne 
> Cc: r...@andestech.com
> Cc: bmeng...@gmail.com
> Cc: atish.pa...@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 00..33a56535f3
> --- /dev/null
> +++ b/api/api_platform-riscv.c
> @@ -0,0 +1,33 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2007 Stanislav Galabov 
> + *
> + * This file contains routines that fetch data from bd_info sources
> + */
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +#include 
> +
> +#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 = 0x8020
>  endif
>  endif
> +ifeq ($(ARCH),riscv)
> +LOAD_ADDR = 0x8400
> +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 
> +   .text
> +   .globl _start
> +_start:
> +   lla t0, search_hint

Looks lla is only supported in newer assemblers?

> +   REG_S   sp, 0(t0)
> +   tailmain
> +
> +   .globl syscall
> +syscall:
> +   lla t0, syscall_ptr
> +   REG_L   t2, 0(t0)
> +   jr  t2
>  #else
>  #error No support for this arch!
>  #endif
> --

Regards,
Bin


[PATCH 6/7] riscv: add CONFIG_API support

2020-04-20 Thread mhorne
From: Mitchell Horne 

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 
Cc: r...@andestech.com
Cc: bmeng...@gmail.com
Cc: atish.pa...@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 00..33a56535f3
--- /dev/null
+++ b/api/api_platform-riscv.c
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2007 Stanislav Galabov 
+ *
+ * This file contains routines that fetch data from bd_info sources
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#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 = 0x8020
 endif
 endif
+ifeq ($(ARCH),riscv)
+LOAD_ADDR = 0x8400
+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 
+   .text
+   .globl _start
+_start:
+   lla t0, search_hint
+   REG_S   sp, 0(t0)
+   tailmain
+
+   .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