Merge patch series "boot: fdt: Change type of env_get_bootm_low() to phys_addr_t"

This commit is contained in:
Tom Rini 2024-04-11 09:39:04 -06:00
commit 01437e3145
4 changed files with 28 additions and 34 deletions

View file

@ -242,13 +242,13 @@ static int boot_get_kernel(const char *addr_fit, struct bootm_headers *images,
#ifdef CONFIG_LMB #ifdef CONFIG_LMB
static void boot_start_lmb(struct bootm_headers *images) static void boot_start_lmb(struct bootm_headers *images)
{ {
ulong mem_start; phys_addr_t mem_start;
phys_size_t mem_size; phys_size_t mem_size;
mem_start = env_get_bootm_low(); mem_start = env_get_bootm_low();
mem_size = env_get_bootm_size(); mem_size = env_get_bootm_size();
lmb_init_and_reserve_range(&images->lmb, (phys_addr_t)mem_start, lmb_init_and_reserve_range(&images->lmb, mem_start,
mem_size, NULL); mem_size, NULL);
} }
#else #else

View file

@ -107,14 +107,12 @@ static int on_loadaddr(const char *name, const char *value, enum env_op op,
} }
U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr); U_BOOT_ENV_CALLBACK(loadaddr, on_loadaddr);
ulong env_get_bootm_low(void) phys_addr_t env_get_bootm_low(void)
{ {
char *s = env_get("bootm_low"); char *s = env_get("bootm_low");
if (s) { if (s)
ulong tmp = hextoul(s, NULL); return simple_strtoull(s, NULL, 16);
return tmp;
}
#if defined(CFG_SYS_SDRAM_BASE) #if defined(CFG_SYS_SDRAM_BASE)
return CFG_SYS_SDRAM_BASE; return CFG_SYS_SDRAM_BASE;
@ -127,14 +125,12 @@ ulong env_get_bootm_low(void)
phys_size_t env_get_bootm_size(void) phys_size_t env_get_bootm_size(void)
{ {
phys_size_t tmp, size; phys_addr_t start, low;
phys_addr_t start; phys_size_t size;
char *s = env_get("bootm_size"); char *s = env_get("bootm_size");
if (s) { if (s)
tmp = (phys_size_t)simple_strtoull(s, NULL, 16); return simple_strtoull(s, NULL, 16);
return tmp;
}
start = gd->ram_base; start = gd->ram_base;
size = gd->ram_size; size = gd->ram_size;
@ -144,22 +140,19 @@ phys_size_t env_get_bootm_size(void)
s = env_get("bootm_low"); s = env_get("bootm_low");
if (s) if (s)
tmp = (phys_size_t)simple_strtoull(s, NULL, 16); low = simple_strtoull(s, NULL, 16);
else else
tmp = start; low = start;
return size - (tmp - start); return size - (low - start);
} }
phys_size_t env_get_bootm_mapsize(void) phys_size_t env_get_bootm_mapsize(void)
{ {
phys_size_t tmp;
char *s = env_get("bootm_mapsize"); char *s = env_get("bootm_mapsize");
if (s) { if (s)
tmp = (phys_size_t)simple_strtoull(s, NULL, 16); return simple_strtoull(s, NULL, 16);
return tmp;
}
#if defined(CFG_SYS_BOOTMAPSZ) #if defined(CFG_SYS_BOOTMAPSZ)
return CFG_SYS_BOOTMAPSZ; return CFG_SYS_BOOTMAPSZ;
@ -538,7 +531,7 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
ulong *initrd_start, ulong *initrd_end) ulong *initrd_start, ulong *initrd_end)
{ {
char *s; char *s;
ulong initrd_high; phys_addr_t initrd_high;
int initrd_copy_to_ram = 1; int initrd_copy_to_ram = 1;
s = env_get("initrd_high"); s = env_get("initrd_high");
@ -553,8 +546,8 @@ int boot_ramdisk_high(struct lmb *lmb, ulong rd_data, ulong rd_len,
initrd_high = env_get_bootm_mapsize() + env_get_bootm_low(); initrd_high = env_get_bootm_mapsize() + env_get_bootm_low();
} }
debug("## initrd_high = 0x%08lx, copy_to_ram = %d\n", debug("## initrd_high = 0x%llx, copy_to_ram = %d\n",
initrd_high, initrd_copy_to_ram); (u64)initrd_high, initrd_copy_to_ram);
if (rd_data) { if (rd_data) {
if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */ if (!initrd_copy_to_ram) { /* zero-copy ramdisk support */

View file

@ -160,9 +160,11 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
{ {
void *fdt_blob = *of_flat_tree; void *fdt_blob = *of_flat_tree;
void *of_start = NULL; void *of_start = NULL;
u64 start, size, usable; phys_addr_t start, size, usable;
char *fdt_high; char *fdt_high;
ulong mapsize, low; phys_addr_t addr;
phys_addr_t low;
phys_size_t mapsize;
ulong of_len = 0; ulong of_len = 0;
int bank; int bank;
int err; int err;
@ -185,7 +187,6 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
fdt_high = env_get("fdt_high"); fdt_high = env_get("fdt_high");
if (fdt_high) { if (fdt_high) {
ulong desired_addr = hextoul(fdt_high, NULL); ulong desired_addr = hextoul(fdt_high, NULL);
ulong addr;
if (desired_addr == ~0UL) { if (desired_addr == ~0UL) {
/* All ones means use fdt in place */ /* All ones means use fdt in place */
@ -217,14 +218,14 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
if (start + size < low) if (start + size < low)
continue; continue;
usable = min(start + size, (u64)(low + mapsize));
/* /*
* At least part of this DRAM bank is usable, try * At least part of this DRAM bank is usable, try
* using it for LMB allocation. * using the DRAM bank up to 'usable' address limit
* for LMB allocation.
*/ */
of_start = map_sysmem((ulong)lmb_alloc_base(lmb, usable = min(start + size, low + mapsize);
of_len, 0x1000, usable), of_len); addr = lmb_alloc_base(lmb, of_len, 0x1000, usable);
of_start = map_sysmem(addr, of_len);
/* Allocation succeeded, use this block. */ /* Allocation succeeded, use this block. */
if (of_start != NULL) if (of_start != NULL)
break; break;
@ -233,7 +234,7 @@ int boot_relocate_fdt(struct lmb *lmb, char **of_flat_tree, ulong *of_size)
* Reduce the mapping size in the next bank * Reduce the mapping size in the next bank
* by the size of attempt in current bank. * by the size of attempt in current bank.
*/ */
mapsize -= usable - max(start, (u64)low); mapsize -= usable - max(start, low);
if (!mapsize) if (!mapsize)
break; break;
} }

View file

@ -946,7 +946,7 @@ static inline void image_set_name(struct legacy_img_hdr *hdr, const char *name)
int image_check_hcrc(const struct legacy_img_hdr *hdr); int image_check_hcrc(const struct legacy_img_hdr *hdr);
int image_check_dcrc(const struct legacy_img_hdr *hdr); int image_check_dcrc(const struct legacy_img_hdr *hdr);
#ifndef USE_HOSTCC #ifndef USE_HOSTCC
ulong env_get_bootm_low(void); phys_addr_t env_get_bootm_low(void);
phys_size_t env_get_bootm_size(void); phys_size_t env_get_bootm_size(void);
phys_size_t env_get_bootm_mapsize(void); phys_size_t env_get_bootm_mapsize(void);
#endif #endif