Skip to content

Commit b3c1679

Browse files
ktrzcinxlgirdwood
authored andcommitted
rimage: Remove ldc generation ability
SMEX is new tool designed to create ldc file content, so this ability in rimage should be removed to avoid duplication. Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
1 parent f87c6e8 commit b3c1679

5 files changed

Lines changed: 28 additions & 254 deletions

File tree

rimage/elf.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,11 @@ static int elf_read_sections(struct image *image, struct module *module,
7474

7575
module->bss_start = 0;
7676
module->bss_end = 0;
77-
78-
fprintf(stdout, "info: ignore .static_log_entries"
79-
" section for bootloader module\n");
80-
81-
module->logs_index = -EINVAL;
82-
83-
fprintf(stdout, "info: ignore .static_uuids section for bootloader module\n");
84-
module->uids_index = -EINVAL;
85-
86-
fprintf(stdout, "info: ignore .fw_ready"
87-
" section for bootloader module\n");
88-
89-
module->fw_ready_index = -EINVAL;
9077
} else {
9178
/* find manifest module data */
9279
module->bss_index = elf_find_section(image, module, ".bss");
9380
if (module->bss_index < 0)
9481
return module->bss_index;
95-
96-
/* find log entries and fw ready sections */
97-
module->logs_index = elf_find_section(image, module,
98-
".static_log_entries");
99-
100-
module->uids_index = elf_find_section(image, module,
101-
".static_uuid_entries");
102-
103-
module->fw_ready_index = elf_find_section(image, module,
104-
".fw_ready");
105-
if (module->fw_ready_index < 0)
106-
return module->fw_ready_index;
10782
}
10883

10984
/* parse each section */
@@ -369,8 +344,7 @@ static void elf_module_limits(struct image *image, struct module *module)
369344
section = &module->section[i];
370345

371346
/* module bss can sometimes be missed */
372-
if (i != module->bss_index && i != module->logs_index &&
373-
i != module->fw_ready_index) {
347+
if (i != module->bss_index) {
374348
/* only check valid sections */
375349
if (!(section->flags & valid))
376350
continue;

rimage/file_simple.c

Lines changed: 0 additions & 196 deletions
Original file line numberDiff line numberDiff line change
@@ -73,73 +73,6 @@ static int get_mem_zone_type(struct image *image, Elf32_Shdr *section)
7373
return SOF_FW_BLK_TYPE_INVALID;
7474
}
7575

76-
static int fw_version_copy(struct snd_sof_logs_header *header,
77-
const struct module *module)
78-
{
79-
Elf32_Shdr *section = NULL;
80-
struct sof_ipc_ext_data_hdr *ext_hdr = NULL;
81-
void *buffer = NULL;
82-
83-
if (module->fw_ready_index <= 0)
84-
return 0;
85-
86-
section = &module->section[module->fw_ready_index];
87-
88-
buffer = calloc(1, section->size);
89-
if (!buffer)
90-
return -ENOMEM;
91-
92-
fseek(module->fd, section->off, SEEK_SET);
93-
size_t count = fread(buffer, 1,
94-
section->size, module->fd);
95-
96-
if (count != section->size) {
97-
fprintf(stderr, "error: can't read ready section %d\n", -errno);
98-
free(buffer);
99-
return -errno;
100-
}
101-
102-
memcpy(&header->version,
103-
&((struct sof_ipc_fw_ready *)buffer)->version,
104-
sizeof(header->version));
105-
106-
/* fw_ready structure contains main (primarily kernel)
107-
* ABI version.
108-
*/
109-
110-
fprintf(stdout, "fw abi main version: %d:%d:%d\n",
111-
SOF_ABI_VERSION_MAJOR(header->version.abi_version),
112-
SOF_ABI_VERSION_MINOR(header->version.abi_version),
113-
SOF_ABI_VERSION_PATCH(header->version.abi_version));
114-
115-
/* let's find dbg abi version, which the log client
116-
* is interested in and override the kernel's one.
117-
*
118-
* skip the base fw-ready record and begin from the first extension.
119-
*/
120-
ext_hdr = buffer + ((struct sof_ipc_fw_ready *)buffer)->hdr.size;
121-
while ((uintptr_t)ext_hdr < (uintptr_t)buffer + section->size) {
122-
if (ext_hdr->type == SOF_IPC_EXT_USER_ABI_INFO) {
123-
header->version.abi_version =
124-
((struct sof_ipc_user_abi_version *)
125-
ext_hdr)->abi_dbg_version;
126-
break;
127-
}
128-
//move to the next entry
129-
ext_hdr = (struct sof_ipc_ext_data_hdr *)
130-
((uint8_t *)ext_hdr + ext_hdr->hdr.size);
131-
}
132-
133-
fprintf(stdout, "fw abi dbg version: %d:%d:%d\n",
134-
SOF_ABI_VERSION_MAJOR(header->version.abi_version),
135-
SOF_ABI_VERSION_MINOR(header->version.abi_version),
136-
SOF_ABI_VERSION_PATCH(header->version.abi_version));
137-
138-
free(buffer);
139-
140-
return 0;
141-
}
142-
14376
static int block_idx;
14477

14578
static int write_block(struct image *image, struct module *module,
@@ -442,135 +375,6 @@ static int simple_write_firmware(struct image *image)
442375
return 0;
443376
}
444377

445-
static int write_logs_dictionary(struct image *image)
446-
{
447-
struct snd_sof_logs_header header;
448-
int i, ret = 0;
449-
void *buffer = NULL;
450-
451-
memcpy(header.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE);
452-
header.data_offset = sizeof(struct snd_sof_logs_header);
453-
454-
for (i = 0; i < image->num_modules; i++) {
455-
struct module *module = &image->module[i];
456-
457-
/* extract fw_version from fw_ready message located
458-
* in .fw_ready section
459-
*/
460-
ret = fw_version_copy(&header, module);
461-
if (ret < 0)
462-
goto out;
463-
464-
if (module->logs_index > 0) {
465-
Elf32_Shdr *section =
466-
&module->section[module->logs_index];
467-
468-
header.base_address = section->vaddr;
469-
header.data_length = section->size;
470-
471-
fwrite(&header, sizeof(struct snd_sof_logs_header), 1,
472-
image->ldc_out_fd);
473-
474-
buffer = calloc(1, section->size);
475-
if (!buffer)
476-
return -ENOMEM;
477-
478-
fseek(module->fd, section->off, SEEK_SET);
479-
size_t count = fread(buffer, 1, section->size,
480-
module->fd);
481-
if (count != section->size) {
482-
fprintf(stderr,
483-
"error: can't read logs section %d\n",
484-
-errno);
485-
ret = -errno;
486-
goto out;
487-
}
488-
count = fwrite(buffer, 1, section->size,
489-
image->ldc_out_fd);
490-
if (count != section->size) {
491-
fprintf(stderr,
492-
"error: can't write section %d\n",
493-
-errno);
494-
ret = -errno;
495-
goto out;
496-
}
497-
498-
fprintf(stdout, "logs dictionary: size %u\n",
499-
header.data_length + header.data_offset);
500-
fprintf(stdout, "including fw version of size: %lu\n",
501-
(unsigned long)sizeof(header.version));
502-
}
503-
}
504-
out:
505-
if (buffer)
506-
free(buffer);
507-
508-
return ret;
509-
}
510-
511-
static int write_uids_dictionary(struct image *image)
512-
{
513-
struct snd_sof_uids_header header;
514-
Elf32_Shdr *section;
515-
int i, ret = 0;
516-
void *buffer = NULL;
517-
518-
memcpy(header.sig, SND_SOF_UIDS_SIG, SND_SOF_UIDS_SIG_SIZE);
519-
header.data_offset = sizeof(struct snd_sof_uids_header);
520-
521-
for (i = 0; i < image->num_modules; i++) {
522-
struct module *module = &image->module[i];
523-
524-
if (module->uids_index <= 0)
525-
continue;
526-
section = &module->section[module->uids_index];
527-
528-
header.base_address = section->vaddr;
529-
header.data_length = section->size;
530-
531-
fwrite(&header, sizeof(struct snd_sof_uids_header), 1,
532-
image->ldc_out_fd);
533-
534-
buffer = calloc(1, section->size);
535-
if (!buffer)
536-
return -ENOMEM;
537-
fseek(module->fd, section->off, SEEK_SET);
538-
if (fread(buffer, 1, section->size, module->fd) !=
539-
section->size) {
540-
fprintf(stderr, "error: can't read uids section %d\n",
541-
-errno);
542-
ret = -errno;
543-
goto out;
544-
}
545-
if (fwrite(buffer, 1, section->size, image->ldc_out_fd) !=
546-
section->size) {
547-
fprintf(stderr, "error: cant't write section %d\n",
548-
-errno);
549-
ret = -errno;
550-
goto out;
551-
}
552-
fprintf(stdout, "uids dictionary: size %u\n",
553-
header.data_length + header.data_offset);
554-
}
555-
out:
556-
free(buffer);
557-
return ret;
558-
}
559-
560-
int write_dictionaries(struct image *image)
561-
{
562-
int ret = 0;
563-
564-
ret = write_logs_dictionary(image);
565-
if (ret)
566-
goto out;
567-
568-
ret = write_uids_dictionary(image);
569-
570-
out:
571-
return ret;
572-
}
573-
574378
const struct adsp machine_byt = {
575379
.name = "byt",
576380
.mem_zones = {

rimage/rimage.c

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ static void usage(char *name)
3838
fprintf(stdout, "\t -v enable verbose output\n");
3939
fprintf(stdout, "\t -r enable relocatable ELF files\n");
4040
fprintf(stdout, "\t -s MEU signing offset\n");
41-
fprintf(stdout, "\t -p log dictionary outfile\n");
4241
fprintf(stdout, "\t -i set IMR type\n");
4342
fprintf(stdout, "\t -x set xcc module offset\n");
4443
exit(0);
@@ -55,14 +54,11 @@ int main(int argc, char *argv[])
5554

5655
image.xcc_mod_offset = DEFAULT_XCC_MOD_OFFSET;
5756

58-
while ((opt = getopt(argc, argv, "ho:p:m:vba:s:k:l:ri:x:")) != -1) {
57+
while ((opt = getopt(argc, argv, "ho:m:vba:s:k:l:ri:x:")) != -1) {
5958
switch (opt) {
6059
case 'o':
6160
image.out_file = optarg;
6261
break;
63-
case 'p':
64-
image.ldc_out_file = optarg;
65-
break;
6662
case 'm':
6763
mach = optarg;
6864
break;
@@ -101,9 +97,6 @@ int main(int argc, char *argv[])
10197
if (!image.out_file || !mach)
10298
usage(argv[0]);
10399

104-
if (!image.ldc_out_file)
105-
image.ldc_out_file = "out.ldc";
106-
107100
/* find machine */
108101
for (i = 0; i < ARRAY_SIZE(machine); i++) {
109102
if (!strcmp(mach, machine[i]->name)) {
@@ -158,22 +151,10 @@ int main(int argc, char *argv[])
158151
else
159152
ret = image.adsp->write_firmware(&image);
160153

161-
unlink(image.ldc_out_file);
162-
image.ldc_out_fd = fopen(image.ldc_out_file, "wb");
163-
if (!image.ldc_out_fd) {
164-
fprintf(stderr, "error: unable to open %s for writing %d\n",
165-
image.ldc_out_file, errno);
166-
ret = -EINVAL;
167-
goto out;
168-
}
169-
ret = write_dictionaries(&image);
170154
out:
171155
/* close files */
172156
if (image.out_fd)
173157
fclose(image.out_fd);
174158

175-
if (image.ldc_out_fd)
176-
fclose(image.ldc_out_fd);
177-
178159
return ret;
179160
}

rimage/rimage.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,6 @@ struct module {
6767
int num_bss;
6868
int fw_size;
6969
int bss_index;
70-
int logs_index;
71-
int uids_index;
72-
int fw_ready_index;
7370

7471
/* sizes do not include any gaps */
7572
int bss_size;
@@ -95,9 +92,7 @@ struct module {
9592
struct image {
9693

9794
const char *out_file;
98-
const char *ldc_out_file;
9995
FILE *out_fd;
100-
FILE *ldc_out_fd;
10196
void *pos;
10297

10398
const struct adsp *adsp;

0 commit comments

Comments
 (0)