This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new b8b541fbf5 mpfs: Remove the ddrstorage section from the OpenSBI package
b8b541fbf5 is described below

commit b8b541fbf5c75f13387560bb0639a4a5b27ec881
Author: Ville Juven <ville.ju...@unikie.com>
AuthorDate: Tue Aug 9 14:29:24 2022 +0300

    mpfs: Remove the ddrstorage section from the OpenSBI package
    
    It is not really needed; g_hart_stacks is only used during SBI init as
    a temporary stack area. We can use the scratch area buffers for this, as
    the scratch areas define almost 4K of extra space, which is used for
    exception stacks anyway.
---
 arch/risc-v/src/mpfs/mpfs_opensbi.c                      | 16 +---------------
 arch/risc-v/src/mpfs/mpfs_opensbi_utils.S                | 11 ++++-------
 boards/risc-v/mpfs/icicle/scripts/ld-envm-opensbi.script |  5 -----
 tools/mpfs/Config.mk                                     |  4 ++--
 4 files changed, 7 insertions(+), 29 deletions(-)

diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi.c 
b/arch/risc-v/src/mpfs/mpfs_opensbi.c
index 8ac3e6645d..6beb8ee05b 100644
--- a/arch/risc-v/src/mpfs/mpfs_opensbi.c
+++ b/arch/risc-v/src/mpfs/mpfs_opensbi.c
@@ -59,14 +59,6 @@
 #define MPFS_PMP_DEFAULT_ADDR      0xfffffffff
 #define MPFS_PMP_DEFAULT_PERM      0x000000009f
 
-/* The following define is not accessible with assember.  Make sure it's in
- * sync with the assembler usage in mpfs_opensbi_utils.S.
- */
-
-#if SBI_PLATFORM_DEFAULT_HART_STACK_SIZE != 8192
-#  error "Fix define in file mpfs_opensbi_utils.S"
-#endif
-
 #define MPFS_SYSREG_SOFT_RESET_CR     (MPFS_SYSREG_BASE + \
                                        MPFS_SYSREG_SOFT_RESET_CR_OFFSET)
 #define MPFS_SYSREG_SUBBLK_CLOCK_CR   (MPFS_SYSREG_BASE + \
@@ -232,15 +224,9 @@ static const struct sbi_platform platform =
 
 /* This must go into l2_scratchpad region, starting at 0x0a000000. */
 
-static sbi_scratch_holder_t g_scratches[MPFS_MAX_NUM_HARTS] \
+sbi_scratch_holder_t g_scratches[MPFS_MAX_NUM_HARTS] \
                __attribute__((section(".l2_scratchpad")));
 
-/* These stacks are used in the mpfs_opensbi_utils.S */
-
-uint8_t g_hart_stacks[SBI_PLATFORM_DEFAULT_HART_STACK_SIZE * \
-                      MPFS_HART_COUNT] \
-                      __attribute__((section(".ddrstorage"), aligned(16)));
-
 static const uint64_t sbi_entrypoints[] =
 {
   CONFIG_MPFS_HART0_ENTRYPOINT,
diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S 
b/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
index b8abcaed09..92627feb25 100644
--- a/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
+++ b/arch/risc-v/src/mpfs/mpfs_opensbi_utils.S
@@ -46,10 +46,6 @@
  * Pre-processor Definitions
  ****************************************************************************/
 
-#ifndef SBI_PLATFORM_DEFAULT_HART_STACK_SIZE
-#define SBI_PLATFORM_DEFAULT_HART_STACK_SIZE 8192
-#endif
-
 /****************************************************************************
  * Public Symbols
  ****************************************************************************/
@@ -100,13 +96,14 @@ mpfs_opensbi_prepare_hart:
   la   t0, mpfs_global_pointer
   ld   gp, 0(t0)
 
-  /* Setup stacks per hart */
+  /* Setup stacks per hart, the stack top is the end of the hart's scratch */
 
   csrr a0, mhartid
-  li   t1, SBI_PLATFORM_DEFAULT_HART_STACK_SIZE
+  li   t1, SBI_SCRATCH_SIZE
   mul  t0, a0, t1
-  la   sp, g_hart_stacks
+  la   sp, g_scratches
   add  sp, sp, t0
+  add  sp, sp, t1
   jal  mpfs_opensbi_setup
 
 /****************************************************************************
diff --git a/boards/risc-v/mpfs/icicle/scripts/ld-envm-opensbi.script 
b/boards/risc-v/mpfs/icicle/scripts/ld-envm-opensbi.script
index 678279fb7a..912f472f53 100644
--- a/boards/risc-v/mpfs/icicle/scripts/ld-envm-opensbi.script
+++ b/boards/risc-v/mpfs/icicle/scripts/ld-envm-opensbi.script
@@ -20,7 +20,6 @@
 
 MEMORY
 {
-    ddr  (rx)     : ORIGIN = 0x80000000, LENGTH = 4M          /* w/ cache */
     envm (rx)     : ORIGIN = 0x20220100, LENGTH = 128K - 256  /* 256 reserved 
for hss headers */
     l2lim  (rwx)  : ORIGIN = 0x08000000, LENGTH = 1024k
     l2zerodevice (rwx) : ORIGIN = 0x0A000000, LENGTH = 512k
@@ -39,10 +38,6 @@ SECTIONS
       riscv_asm*
     } > ddr
 
-    .ddrstorage : {
-      *(.ddrstorage)
-    } > ddr
-
     .l2_scratchpad : ALIGN(0x10)
     {
         __l2_scratchpad_load = LOADADDR(.l2_scratchpad);
diff --git a/tools/mpfs/Config.mk b/tools/mpfs/Config.mk
index d5a6d02533..639169f2d0 100644
--- a/tools/mpfs/Config.mk
+++ b/tools/mpfs/Config.mk
@@ -27,11 +27,11 @@
 ifeq ($(CONFIG_MPFS_OPENSBI),y)
 define POSTBUILD
        $(Q) echo "SBI: Creating nuttx.sbi file"
-       $(Q) $(OBJCOPY) -O binary -j .text.sbi -j .ddrstorage $(BIN) nuttx.sbi
+       $(Q) $(OBJCOPY) -O binary -j .text.sbi $(BIN) nuttx.sbi
        $(Q) ([ $$? -eq 0 ] && echo "Done.")
        $(Q) echo nuttx.sbi >> nuttx.manifest
        $(Q) echo "SBI: Removing unnecessary sections from nuttx binary"
-       $(Q) $(OBJCOPY) -O binary -R .text.sbi -R .l2_scratchpad -R .ddrstorage 
$(BIN) nuttx.bin
+       $(Q) $(OBJCOPY) -O binary -R .text.sbi -R .l2_scratchpad $(BIN) 
nuttx.bin
        $(Q) ([ $$? -eq 0 ] && echo "Done.")
 endef
 endif

Reply via email to