remoteproc: parse STE-firmware and find resource table address
Parse the STE firmware and scan the TOC-table to find the address of the loaded resource table. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> [rebase patch; update terminology] Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
This commit is contained in:
parent
95f9578163
commit
e4b5141481
@ -64,26 +64,18 @@ static int sproc_load_segments(struct rproc *rproc, const struct firmware *fw)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Find the entry for resource table in the Table of Content */
|
/* Find the entry for resource table in the Table of Content */
|
||||||
static struct ste_toc_entry *sproc_find_rsc_entry(const struct firmware *fw)
|
static const struct ste_toc_entry *sproc_find_rsc_entry(const void *data)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct ste_toc *toc;
|
const struct ste_toc *toc;
|
||||||
|
toc = data;
|
||||||
if (!fw)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
toc = (void *)fw->data;
|
|
||||||
|
|
||||||
/* Search the table for the resource table */
|
/* Search the table for the resource table */
|
||||||
for (i = 0; i < SPROC_MAX_TOC_ENTRIES &&
|
for (i = 0; i < SPROC_MAX_TOC_ENTRIES &&
|
||||||
toc->table[i].start != 0xffffffff; i++) {
|
toc->table[i].start != 0xffffffff; i++) {
|
||||||
|
|
||||||
if (!strncmp(toc->table[i].name, SPROC_RESOURCE_NAME,
|
if (!strncmp(toc->table[i].name, SPROC_RESOURCE_NAME,
|
||||||
sizeof(toc->table[i].name))) {
|
sizeof(toc->table[i].name)))
|
||||||
if (toc->table[i].start > fw->size)
|
|
||||||
return NULL;
|
|
||||||
return &toc->table[i];
|
return &toc->table[i];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -96,9 +88,12 @@ sproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
|
|||||||
{
|
{
|
||||||
struct sproc *sproc = rproc->priv;
|
struct sproc *sproc = rproc->priv;
|
||||||
struct resource_table *table;
|
struct resource_table *table;
|
||||||
struct ste_toc_entry *entry;
|
const struct ste_toc_entry *entry;
|
||||||
|
|
||||||
entry = sproc_find_rsc_entry(fw);
|
if (!fw)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
entry = sproc_find_rsc_entry(fw->data);
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
sproc_err(sproc, "resource table not found in fw\n");
|
sproc_err(sproc, "resource table not found in fw\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -149,10 +144,30 @@ sproc_find_rsc_table(struct rproc *rproc, const struct firmware *fw,
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the resource table inside the remote processor's firmware. */
|
||||||
|
static struct resource_table *
|
||||||
|
sproc_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw)
|
||||||
|
{
|
||||||
|
struct sproc *sproc = rproc->priv;
|
||||||
|
const struct ste_toc_entry *entry;
|
||||||
|
|
||||||
|
if (!fw || !sproc->fw_addr)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
entry = sproc_find_rsc_entry(sproc->fw_addr);
|
||||||
|
if (!entry) {
|
||||||
|
sproc_err(sproc, "resource table not found in fw\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sproc->fw_addr + entry->start;
|
||||||
|
}
|
||||||
|
|
||||||
/* STE modem firmware handler operations */
|
/* STE modem firmware handler operations */
|
||||||
const struct rproc_fw_ops sproc_fw_ops = {
|
const struct rproc_fw_ops sproc_fw_ops = {
|
||||||
.load = sproc_load_segments,
|
.load = sproc_load_segments,
|
||||||
.find_rsc_table = sproc_find_rsc_table,
|
.find_rsc_table = sproc_find_rsc_table,
|
||||||
|
.find_loaded_rsc_table = sproc_find_loaded_rsc_table,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Kick the modem with specified notification id */
|
/* Kick the modem with specified notification id */
|
||||||
|
Loading…
Reference in New Issue
Block a user