mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-29 08:01:08 +00:00
[new uImage] Provide ability to restrict region used for boot images
Allow the user to set 'bootm_low' and 'bootm_size' env vars as a way to restrict what memory range is used for bootm. Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Acked-by: Marian Balakowicz <m8@semihalf.com>
This commit is contained in:
parent
e822d7fc4d
commit
d3f2fa0d27
5 changed files with 60 additions and 8 deletions
|
@ -124,6 +124,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||
ulong os_data, os_len;
|
||||
ulong image_start, image_end;
|
||||
ulong load_start, load_end;
|
||||
ulong mem_start, mem_size;
|
||||
|
||||
struct lmb lmb;
|
||||
|
||||
|
@ -134,11 +135,10 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
|
|||
|
||||
lmb_init(&lmb);
|
||||
|
||||
#ifdef CFG_SDRAM_BASE
|
||||
lmb_add(&lmb, CFG_SDRAM_BASE, gd->bd->bi_memsize);
|
||||
#else
|
||||
lmb_add(&lmb, 0, gd->bd->bi_memsize);
|
||||
#endif
|
||||
mem_start = getenv_bootm_low();
|
||||
mem_size = getenv_bootm_size();
|
||||
|
||||
lmb_add(&lmb, mem_start, mem_size);
|
||||
|
||||
board_lmb_reserve(&lmb);
|
||||
|
||||
|
|
|
@ -132,6 +132,32 @@ int getenv_autostart (void)
|
|||
return (s && (*s == 'n')) ? 0 : 1;
|
||||
}
|
||||
|
||||
ulong getenv_bootm_low(void)
|
||||
{
|
||||
char *s = getenv ("bootm_low");
|
||||
if (s) {
|
||||
ulong tmp = simple_strtoul (s, NULL, 16);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#ifdef CFG_SDRAM_BASE
|
||||
return CFG_SDRAM_BASE;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
ulong getenv_bootm_size(void)
|
||||
{
|
||||
char *s = getenv ("bootm_size");
|
||||
if (s) {
|
||||
ulong tmp = simple_strtoul (s, NULL, 16);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
return gd->bd->bi_memsize;
|
||||
}
|
||||
|
||||
void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
|
||||
{
|
||||
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
|
||||
|
|
|
@ -316,6 +316,8 @@ int image_check_dcrc (image_header_t *hdr);
|
|||
int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize);
|
||||
int getenv_verify (void);
|
||||
int getenv_autostart (void);
|
||||
ulong getenv_bootm_low(void);
|
||||
ulong getenv_bootm_size(void);
|
||||
void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -57,12 +57,14 @@ void do_bootm_linux(cmd_tbl_t * cmdtp, int flag,
|
|||
int ret;
|
||||
|
||||
ulong cmd_start, cmd_end;
|
||||
ulong bootmap_base = 0;
|
||||
ulong bootmap_base;
|
||||
bd_t *kbd;
|
||||
ulong ep = 0;
|
||||
void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
|
||||
struct lmb *lmb = images->lmb;
|
||||
|
||||
bootmap_base = getenv_bootm_low();
|
||||
|
||||
/*
|
||||
* Booting a (Linux) kernel image
|
||||
*
|
||||
|
|
|
@ -59,6 +59,10 @@ extern ulong get_effective_memsize(void);
|
|||
static ulong get_sp (void);
|
||||
static void set_clocks_in_mhz (bd_t *kbd);
|
||||
|
||||
#ifndef CFG_LINUX_LOWMEM_MAX_SIZE
|
||||
#define CFG_LINUX_LOWMEM_MAX_SIZE (768*1024*1024)
|
||||
#endif
|
||||
|
||||
void __attribute__((noinline))
|
||||
do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
||||
bootm_headers_t *images)
|
||||
|
@ -67,6 +71,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
|||
|
||||
ulong initrd_start, initrd_end;
|
||||
ulong rd_data_start, rd_data_end, rd_len;
|
||||
ulong size;
|
||||
|
||||
ulong cmd_start, cmd_end, bootmap_base;
|
||||
bd_t *kbd;
|
||||
|
@ -80,7 +85,24 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
|||
char *of_flat_tree = NULL;
|
||||
#endif
|
||||
|
||||
bootmap_base = 0;
|
||||
bootmap_base = getenv_bootm_low();
|
||||
size = getenv_bootm_size();
|
||||
|
||||
#ifdef DEBUG
|
||||
if (((u64)bootmap_base + size) > (CFG_SDRAM_BASE + (u64)gd->ram_size))
|
||||
puts("WARNING: bootm_low + bootm_size exceed total memory\n");
|
||||
if ((bootmap_base + size) > get_effective_memsize())
|
||||
puts("WARNING: bootm_low + bootm_size exceed eff. memory\n");
|
||||
#endif
|
||||
|
||||
size = min(size, get_effective_memsize());
|
||||
size = min(size, CFG_LINUX_LOWMEM_MAX_SIZE);
|
||||
|
||||
if (size < getenv_bootm_size()) {
|
||||
ulong base = bootmap_base + size;
|
||||
printf("WARNING: adjusting available memory to %x\n", size);
|
||||
lmb_reserve(lmb, base, getenv_bootm_size() - size);
|
||||
}
|
||||
|
||||
/*
|
||||
* Booting a (Linux) kernel image
|
||||
|
@ -92,7 +114,7 @@ do_bootm_linux(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[],
|
|||
* pointer.
|
||||
*/
|
||||
sp = get_sp();
|
||||
debug ("## Current stack ends at 0x%08lx ", sp);
|
||||
debug ("## Current stack ends at 0x%08lx\n", sp);
|
||||
|
||||
/* adjust sp by 1K to be safe */
|
||||
sp -= 1024;
|
||||
|
|
Loading…
Reference in a new issue