
Indicate the address and size of RAM in the UPL handoff.
Signed-off-by: Simon Glass sjg@chromium.org ---
boot/upl_common.c | 22 +++++++++++++++++++++- include/upl.h | 12 ++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/boot/upl_common.c b/boot/upl_common.c index a5a1da9cb57..e60f22f47e0 100644 --- a/boot/upl_common.c +++ b/boot/upl_common.c @@ -136,6 +136,7 @@ int upl_add_graphics(struct upl_graphics *gra, ulong *basep, ulong *sizep)
int upl_create(struct upl *upl) { + struct upl_mem mem; ulong base, size; int ret;
@@ -148,7 +149,14 @@ int upl_create(struct upl *upl) if (IS_ENABLED(CONFIG_X86)) upl->addr_width = cpu_phys_address_size();
- /* no reserved memory */ + memset(&mem, '\0', sizeof(mem)); + alist_init_struct(&mem.region, struct memregion); + + ret = upl_add_region(&mem.region, gd->ram_base, gd->ram_size); + if (ret) + return log_msg_ret("uar", ret); + if (!alist_add(&upl->mem, mem)) + return log_msg_ret("arg", -ENOMEM);
ret = upl_add_serial(&upl->serial); if (ret && ret != -ENOENT) @@ -181,6 +189,18 @@ int upl_write_to_buf(struct upl *upl, ofnode root, struct abuf *buf) return 0; }
+int upl_add_region(struct alist *lst, u64 base, ulong size) +{ + struct memregion region; + + region.base = base; + region.size = size; + if (!alist_add(lst, region)) + return log_msg_ret("uar", -ENOMEM); + + return 0; +} + void upl_init(struct upl *upl) { memset(upl, '\0', sizeof(struct upl)); diff --git a/include/upl.h b/include/upl.h index aef23ad8e8e..5ddcd990de4 100644 --- a/include/upl.h +++ b/include/upl.h @@ -416,6 +416,18 @@ int upl_create(struct upl *upl); * Return: 0 if OK, -ve on error */ int upl_write_to_buf(struct upl *upl, ofnode root, struct abuf *buf); + +/** + * upl_add_region() - Add a region to a memory-region list + * + * Adds a new entry to the end of a list + * + * @lst: List to add to (struct memregion) + * @base: Base address of new region + * @size: Size of new region + * Return: 0 if OK, -ve on error + */ +int upl_add_region(struct alist *lst, u64 base, ulong size); #endif
/** upl_init() - Set up a UPL struct */