mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
common: sf_command: Add ram region validation
Signed-off-by: Vandhiadevan Karunamoorthy <vkarunam@codeaurora.org> Change-Id: I36a48bae392388cfd565c6a351f01247959bb613
This commit is contained in:
parent
64af2446f8
commit
73966739fb
1 changed files with 13 additions and 0 deletions
|
|
@ -19,6 +19,8 @@
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
#include <dm/device-internal.h>
|
#include <dm/device-internal.h>
|
||||||
|
|
||||||
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
static struct spi_flash *flash;
|
static struct spi_flash *flash;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -265,6 +267,7 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
int dev = 0;
|
int dev = 0;
|
||||||
loff_t offset, len, maxsize;
|
loff_t offset, len, maxsize;
|
||||||
|
unsigned long sram_end = CONFIG_SYS_SDRAM_BASE + gd->ram_size;
|
||||||
|
|
||||||
if (argc < 3)
|
if (argc < 3)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
@ -283,6 +286,16 @@ static int do_spi_flash_read_write(int argc, char * const argv[])
|
||||||
argv[0], flash->size);
|
argv[0], flash->size);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
/* Validate DDR region address */
|
||||||
|
if ((addr < CONFIG_SYS_SDRAM_BASE) || (addr > (sram_end - 1))) {
|
||||||
|
puts("Invalid RAM address \n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((addr + len) > sram_end) {
|
||||||
|
puts("No space available\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
buf = map_physmem(addr, len, MAP_WRBACK);
|
buf = map_physmem(addr, len, MAP_WRBACK);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue