diff options
| author | Sughosh Ganu <sughosh.ganu@linaro.org> | 2024-08-26 17:29:18 +0530 | 
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2024-09-03 14:08:50 -0600 | 
| commit | ed17a33fed296a87219b0ff702045ce488bc3771 (patch) | |
| tree | e1ac01002f7dcd0e1c1adbf5139234038ea58f8f /cmd/load.c | |
| parent | a368850ae2551a4fcc5f9a2e9e8e90c056d4fe73 (diff) | |
lmb: make LMB memory map persistent and global
The current LMB API's for allocating and reserving memory use a
per-caller based memory view. Memory allocated by a caller can then be
overwritten by another caller. Make these allocations and reservations
persistent using the alloced list data structure.
Two alloced lists are declared -- one for the available(free) memory,
and one for the used memory. Once full, the list can then be extended
at runtime.
[sjg: Use a stack to store pointer of lmb struct when running lmb tests]
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
[sjg: Optimise the logic to add a region in lmb_add_region_flags()]
Diffstat (limited to 'cmd/load.c')
| -rw-r--r-- | cmd/load.c | 7 | 
1 files changed, 3 insertions, 4 deletions
| diff --git a/cmd/load.c b/cmd/load.c index d773a25d70c..56da3a4c5de 100644 --- a/cmd/load.c +++ b/cmd/load.c @@ -141,7 +141,6 @@ static int do_load_serial(struct cmd_tbl *cmdtp, int flag, int argc,  static ulong load_serial(long offset)  { -	struct lmb lmb;  	char	record[SREC_MAXRECLEN + 1];	/* buffer for one S-Record	*/  	char	binbuf[SREC_MAXBINLEN];		/* buffer for binary data	*/  	int	binlen;				/* no. of data bytes in S-Rec.	*/ @@ -154,7 +153,7 @@ static ulong load_serial(long offset)  	int	line_count =  0;  	long ret; -	lmb_init_and_reserve(&lmb, gd->bd, (void *)gd->fdt_blob); +	lmb_init_and_reserve(gd->bd, (void *)gd->fdt_blob);  	while (read_record(record, SREC_MAXRECLEN + 1) >= 0) {  		type = srec_decode(record, &binlen, &addr, binbuf); @@ -182,7 +181,7 @@ static ulong load_serial(long offset)  		    {  			void *dst; -			ret = lmb_reserve(&lmb, store_addr, binlen); +			ret = lmb_reserve(store_addr, binlen);  			if (ret) {  				printf("\nCannot overwrite reserved area (%08lx..%08lx)\n",  					store_addr, store_addr + binlen); @@ -191,7 +190,7 @@ static ulong load_serial(long offset)  			dst = map_sysmem(store_addr, binlen);  			memcpy(dst, binbuf, binlen);  			unmap_sysmem(dst); -			lmb_free(&lmb, store_addr, binlen); +			lmb_free(store_addr, binlen);  		    }  		    if ((store_addr) < start_addr)  			start_addr = store_addr; | 
