Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 318904
b: refs/heads/master
c: bd48498
h: refs/heads/master
v: v3
  • Loading branch information
Sjur Brændeland authored and Ohad Ben-Cohen committed Jul 15, 2012
1 parent 59de528 commit 6703e16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 160e7c840fe85836040c43e0058d5afced470c85
refs/heads/master: bd48498487735a01abc68edb76e3d86393e096e1
24 changes: 12 additions & 12 deletions trunk/drivers/remoteproc/remoteproc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
/**
* rproc_load_segments() - load firmware segments to memory
* @rproc: remote processor which will be booted using these fw segments
* @elf_data: the content of the ELF firmware image
* @len: firmware size (in bytes)
* @fw: the ELF firmware image
*
* This function loads the firmware segments to memory, where the remote
* processor expects them.
Expand All @@ -199,12 +198,13 @@ static void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
* supported, though.
*/
static int
rproc_load_segments(struct rproc *rproc, const u8 *elf_data, size_t len)
rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
{
struct device *dev = &rproc->dev;
struct elf32_hdr *ehdr;
struct elf32_phdr *phdr;
int i, ret = 0;
const u8 *elf_data = fw->data;

ehdr = (struct elf32_hdr *)elf_data;
phdr = (struct elf32_phdr *)(elf_data + ehdr->e_phoff);
Expand All @@ -230,9 +230,9 @@ rproc_load_segments(struct rproc *rproc, const u8 *elf_data, size_t len)
break;
}

if (offset + filesz > len) {
if (offset + filesz > fw->size) {
dev_err(dev, "truncated fw: need 0x%x avail 0x%x\n",
offset + filesz, len);
offset + filesz, fw->size);
ret = -EINVAL;
break;
}
Expand Down Expand Up @@ -819,8 +819,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct resource_table *table, int l
/**
* rproc_find_rsc_table() - find the resource table
* @rproc: the rproc handle
* @elf_data: the content of the ELF firmware image
* @len: firmware size (in bytes)
* @fw: the ELF firmware image
* @tablesz: place holder for providing back the table size
*
* This function finds the resource table inside the remote processor's
Expand All @@ -833,7 +832,7 @@ rproc_handle_virtio_rsc(struct rproc *rproc, struct resource_table *table, int l
* (and @tablesz isn't set).
*/
static struct resource_table *
rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len,
rproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
int *tablesz)
{
struct elf32_hdr *ehdr;
Expand All @@ -842,6 +841,7 @@ rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len,
struct device *dev = &rproc->dev;
struct resource_table *table = NULL;
int i;
const u8 *elf_data = fw->data;

ehdr = (struct elf32_hdr *)elf_data;
shdr = (struct elf32_shdr *)(elf_data + ehdr->e_shoff);
Expand All @@ -858,7 +858,7 @@ rproc_find_rsc_table(struct rproc *rproc, const u8 *elf_data, size_t len,
table = (struct resource_table *)(elf_data + offset);

/* make sure we have the entire table */
if (offset + size > len) {
if (offset + size > fw->size) {
dev_err(dev, "resource table truncated\n");
return NULL;
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
rproc->bootaddr = ehdr->e_entry;

/* look for the resource table */
table = rproc_find_rsc_table(rproc, fw->data, fw->size, &tablesz);
table = rproc_find_rsc_table(rproc, fw, &tablesz);
if (!table)
goto clean_up;

Expand All @@ -1047,7 +1047,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
}

/* load the ELF segments to memory */
ret = rproc_load_segments(rproc, fw->data, fw->size);
ret = rproc_load_segments(rproc, fw);
if (ret) {
dev_err(dev, "Failed to load program segments: %d\n", ret);
goto clean_up;
Expand Down Expand Up @@ -1090,7 +1090,7 @@ static void rproc_fw_config_virtio(const struct firmware *fw, void *context)
goto out;

/* look for the resource table */
table = rproc_find_rsc_table(rproc, fw->data, fw->size, &tablesz);
table = rproc_find_rsc_table(rproc, fw, &tablesz);
if (!table)
goto out;

Expand Down

0 comments on commit 6703e16

Please sign in to comment.