debug("total_memory by %s = %llu\n", __func__, total_memory);
#if !defined(CONFIG_PHYS_64BIT)
- /* Check for more than max memory. Bad. */
- if ((first_ctrl == 0) && (total_memory > CONFIG_MAX_MEM_MAPPED)) {
+ /*
+ * Show warning about big DDR moodules. But avoid warning for 4 GB DDR
+ * modules when U-Boot supports RAM of maximal size 4 GB - 1 byte.
+ */
+ if ((first_ctrl == 0) && (total_memory - 1 > (phys_size_t)~0ULL)) {
puts("Detected ");
print_size(total_memory, " of memory\n");
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
puts("This U-Boot only supports <= ");
- print_size(CONFIG_MAX_MEM_MAPPED, " of DDR\n");
+ print_size((unsigned long long)((phys_size_t)~0ULL)+1, " of DDR\n");
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
#ifndef CONFIG_SPL_BUILD
puts(" "); /* re-align to match init_dram print */
#endif
- total_memory = CONFIG_MAX_MEM_MAPPED;
}
#endif
+ /* Ensure that total_memory does not overflow on return */
+ if (total_memory > (phys_size_t)~0ULL)
+ total_memory = (phys_size_t)~0ULL;
+
return total_memory;
}