blob: bce3719bbb45f15a7ae1418fa195933ea394f992 [file] [log] [blame]
Michael S. Tsirkin4a027682013-10-03 16:30:37 +03001#ifndef __ROMFILE_LOADER_H
2#define __ROMFILE_LOADER_H
3
4#include "types.h" // u8
5#include "util.h" // romfile_s
6
7#define ROMFILE_LOADER_FILESZ 56
8
9/* ROM file linker/loader interface. Linker uses little endian format */
10struct romfile_loader_entry_s {
11 u32 command;
12 union {
13 /*
Ben Warrenaa7219d2017-02-20 19:56:16 -080014 * COMMAND_ALLOCATE - allocate a table from @alloc.file
15 * subject to @alloc.align alignment (must be power of 2)
16 * and @alloc.zone (can be HIGH or FSEG) requirements.
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030017 *
18 * Must appear exactly once for each file, and before
19 * this file is referenced by any other command.
20 */
21 struct {
Ben Warrenaa7219d2017-02-20 19:56:16 -080022 char file[ROMFILE_LOADER_FILESZ];
23 u32 align;
24 u8 zone;
25 } alloc;
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030026
27 /*
28 * COMMAND_ADD_POINTER - patch the table (originating from
Ben Warrenaa7219d2017-02-20 19:56:16 -080029 * @dest_file) at @pointer.offset, by adding a pointer to the table
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030030 * originating from @src_file. 1,2,4 or 8 byte unsigned
Ben Warrenaa7219d2017-02-20 19:56:16 -080031 * addition is used depending on @pointer.size.
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030032 */
33 struct {
Ben Warrenaa7219d2017-02-20 19:56:16 -080034 char dest_file[ROMFILE_LOADER_FILESZ];
35 char src_file[ROMFILE_LOADER_FILESZ];
36 u32 offset;
37 u8 size;
38 } pointer;
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030039
40 /*
41 * COMMAND_ADD_CHECKSUM - calculate checksum of the range specified by
Ben Warrenaa7219d2017-02-20 19:56:16 -080042 * @cksum.start and @cksum.length fields,
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030043 * and then add the value at @cksum_offset.
44 * Checksum simply sums -X for each byte X in the range
45 * using 8-bit math.
46 */
47 struct {
Ben Warrenaa7219d2017-02-20 19:56:16 -080048 char file[ROMFILE_LOADER_FILESZ];
49 u32 offset;
50 u32 start;
51 u32 length;
52 } cksum;
Michael S. Tsirkin4a027682013-10-03 16:30:37 +030053
54 /* padding */
55 char pad[124];
56 };
57};
58
59enum {
60 ROMFILE_LOADER_COMMAND_ALLOCATE = 0x1,
61 ROMFILE_LOADER_COMMAND_ADD_POINTER = 0x2,
62 ROMFILE_LOADER_COMMAND_ADD_CHECKSUM = 0x3,
63};
64
65enum {
66 ROMFILE_LOADER_ALLOC_ZONE_HIGH = 0x1,
67 ROMFILE_LOADER_ALLOC_ZONE_FSEG = 0x2,
68};
69
70int romfile_loader_execute(const char *name);
71
72#endif