On 4/1/26 8:43 AM, Ilias Apalodimas wrote:
+++ b/include/fdtdec.h
@@ -965,6 +965,21 @@ int fdtdec_setup_mem_ram_top(void);
* invalid
*/
int fdtdec_setup_memory_banksize(void);
+/**
+ * fdtdec_setup_ram_size() - decode and setup setup gd->ram_size to the sum of
+ * all banks
+ *
+ * Decode the /memory 'reg' property to determine the memory available in all
+ * banks and populate the global data ram_size with it.
+ *
+ * This function should be called from a boards board_get_usable_ram_top().
Is the board_get_usable_ram_top() really the right place to call this ?
It feels like it is being conflated with ram_top here too.
I don't think so. You are effectively calculating the top address you
should relocate to. You should also calculate the difference in
ramsize. Those two should not be separated actions
The address where you relocate to is gd->relocaddr, which is ram_top
minus all the reserved areas, see common/board_f.c setup_dest_addr().
This setup_dest_addr() function does manipulate with gd->ram_size , but
only to handle CONFIG_SYS_MEM_TOP_HIDE , which may not be the right
place for it, I think it would be better to have a separate initcall for
the ram_size calculation, which precedes setup_dest_addr().
With that, the function description can claim that each function must be
called before that specific initcall, fdtdec_setup_mem_ram_top() before
setup_dest_addr() and fdtdec_setup_ram_size() before
setup_whatever_is_the_new_initcall_name().