Lines Matching +full:image +full:- +full:processor
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Remote Processor Framework ELF loader
8 * Ohad Ben-Cohen <ohad@wizery.com>
12 * Suman Anna <s-anna@ti.com>
29 * rproc_elf_sanity_check() - Sanity Check for ELF32/ELF64 firmware image
30 * @rproc: the remote processor handle
31 * @fw: the ELF firmware image
33 * Make sure this fw image is sane (ie a correct ELF32/ELF64 file).
35 * Return: 0 on success and -EINVAL upon any failure
39 const char *name = rproc->firmware;
40 struct device *dev = &rproc->dev;
54 return -EINVAL;
57 if (fw->size < sizeof(struct elf32_hdr)) {
58 dev_err(dev, "Image is too small\n");
59 return -EINVAL;
62 ehdr = (struct elf32_hdr *)fw->data;
64 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG)) {
65 dev_err(dev, "Image is corrupted (bad magic)\n");
66 return -EINVAL;
69 class = ehdr->e_ident[EI_CLASS];
72 return -EINVAL;
75 if (class == ELFCLASS64 && fw->size < sizeof(struct elf64_hdr)) {
77 return -EINVAL;
82 if (ehdr->e_ident[EI_DATA] != ELFDATA2LSB) {
84 if (ehdr->e_ident[EI_DATA] != ELFDATA2MSB) {
87 return -EINVAL;
90 phoff = elf_hdr_get_e_phoff(class, fw->data);
91 shoff = elf_hdr_get_e_shoff(class, fw->data);
92 phnum = elf_hdr_get_e_phnum(class, fw->data);
95 if (fw->size < shoff + elf_shdr_get_size) {
96 dev_err(dev, "Image is too small\n");
97 return -EINVAL;
102 return -EINVAL;
105 if (phoff > fw->size) {
107 return -EINVAL;
118 * rproc_elf_get_boot_addr() - Get rproc's boot address.
119 * @rproc: the remote processor handle
120 * @fw: the ELF firmware image
123 * processors. Some will always boot at a specific hard-coded address.
125 * Return: entry point address of the ELF image
130 return elf_hdr_get_e_entry(fw_elf_get_class(fw), fw->data);
135 * rproc_elf_load_segments() - load firmware segments to memory
136 * @rproc: remote processor which will be booted using these fw segments
137 * @fw: the ELF firmware image
140 * processor expects them.
148 * allocated (and mapped) earlier on behalf of the remote processor,
162 struct device *dev = &rproc->dev;
166 const u8 *elf_data = fw->data;
193 ret = -EINVAL;
197 if (offset + filesz > fw->size) {
199 offset + filesz, fw->size);
200 ret = -EINVAL;
207 ret = -EOVERFLOW;
216 ret = -EINVAL;
220 /* put the segment where the remote processor expects it */
237 memset_io((void __iomem *)(ptr + filesz), 0, memsz - filesz);
239 memset(ptr + filesz, 0, memsz - filesz);
254 const u8 *elf_data = (void *)fw->data;
256 size_t fw_size = fw->size;
288 dev_err(dev, "header-less resource table\n");
293 if (table->ver != 1) {
294 dev_err(dev, "unsupported fw ver: %d\n", table->ver);
299 if (table->reserved[0] || table->reserved[1]) {
305 if (struct_size(table, offset, table->num) > size) {
317 * rproc_elf_load_rsc_table() - load the resource table
319 * @fw: the ELF firmware image
321 * This function finds the resource table inside the remote processor's
329 struct device *dev = &rproc->dev;
331 const u8 *elf_data = fw->data;
338 return -EINVAL;
350 rproc->cached_table = kmemdup(table, tablesz, GFP_KERNEL);
351 if (!rproc->cached_table)
352 return -ENOMEM;
354 rproc->table_ptr = rproc->cached_table;
355 rproc->table_sz = tablesz;
362 * rproc_elf_find_loaded_rsc_table() - find the loaded resource table
364 * @fw: the ELF firmware image
367 * call this function if the table wasn't loaded yet - it's a bug if you do.
378 struct device *dev = &rproc->dev;
380 shdr = find_table(&rproc->dev, fw);