Return the allocated address of the memory block in the request structure
if a memory allocation was actually done. Leave the address untouched
otherwise. This enables a caller who wants to use the allocated memory
directly (rather than adding the memory to the heap) to see where memory
was allocated. None of the current callers needs this but the converted
ieee1275 loader will make use of it.

Signed-off-by: Stefan Berger <stef...@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.ki...@oracle.com>
Cc: Hari Bathini <hbath...@linux.ibm.com>
Cc: Pavithra Prakash <pavra...@in.ibm.com>
Cc: Michael Ellerman <m...@ellerman.id.au>
Cc: Carolyn Scherrer <cpsch...@us.ibm.com>
Cc: Mahesh Salgaonkar <mah...@linux.ibm.com>
Cc: Sourabh Jain <sourabhj...@linux.ibm.com>
---
 grub-core/kern/ieee1275/init.c        | 2 ++
 include/grub/powerpc/ieee1275/alloc.h | 1 +
 2 files changed, 3 insertions(+)

diff --git a/grub-core/kern/ieee1275/init.c b/grub-core/kern/ieee1275/init.c
index 217f25fae..6d5fb573a 100644
--- a/grub-core/kern/ieee1275/init.c
+++ b/grub-core/kern/ieee1275/init.c
@@ -518,6 +518,8 @@ regions_claim (grub_uint64_t addr, grub_uint64_t len, 
grub_memory_type_t type,
       if (rcr->init_region)
           grub_mm_init_region ((void *) (grub_addr_t) addr, len);
       rcr->total -= len;
+
+      rcr->addr = addr;
     }
 
   *(grub_uint32_t *) data = rcr->total;
diff --git a/include/grub/powerpc/ieee1275/alloc.h 
b/include/grub/powerpc/ieee1275/alloc.h
index dd7a847a5..9aaea4d46 100644
--- a/include/grub/powerpc/ieee1275/alloc.h
+++ b/include/grub/powerpc/ieee1275/alloc.h
@@ -28,6 +28,7 @@ struct regions_claim_request {
   unsigned int flags;     /* GRUB_MM_ADD_REGION_(NONE|CONSECUTIVE) */
   grub_uint32_t total;    /* number of requested bytes */
   bool init_region;       /* whether to add memory to the heap using 
grub_mm_init_region() */
+  grub_uint64_t addr;     /* result address */
 };
 
 #endif /* GRUB_POWERPC_IEEE1275_ALLOC_HEADER */
-- 
2.25.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to