Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / seabios / src / fw / romfile_loader.h
1 #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 */
10 struct romfile_loader_entry_s {
11     u32 command;
12     union {
13         /*
14          * 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.
17          *
18          * Must appear exactly once for each file, and before
19          * this file is referenced by any other command.
20          */
21         struct {
22             char alloc_file[ROMFILE_LOADER_FILESZ];
23             u32 alloc_align;
24             u8 alloc_zone;
25         };
26
27         /*
28          * COMMAND_ADD_POINTER - patch the table (originating from
29          * @dest_file) at @pointer_offset, by adding a pointer to the table
30          * originating from @src_file. 1,2,4 or 8 byte unsigned
31          * addition is used depending on @pointer_size.
32          */
33         struct {
34             char pointer_dest_file[ROMFILE_LOADER_FILESZ];
35             char pointer_src_file[ROMFILE_LOADER_FILESZ];
36             u32 pointer_offset;
37             u8 pointer_size;
38         };
39
40         /*
41          * COMMAND_ADD_CHECKSUM - calculate checksum of the range specified by
42          * @cksum_start and @cksum_length fields,
43          * 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 {
48             char cksum_file[ROMFILE_LOADER_FILESZ];
49             u32 cksum_offset;
50             u32 cksum_start;
51             u32 cksum_length;
52         };
53
54         /* padding */
55         char pad[124];
56     };
57 };
58
59 enum {
60     ROMFILE_LOADER_COMMAND_ALLOCATE     = 0x1,
61     ROMFILE_LOADER_COMMAND_ADD_POINTER  = 0x2,
62     ROMFILE_LOADER_COMMAND_ADD_CHECKSUM = 0x3,
63 };
64
65 enum {
66     ROMFILE_LOADER_ALLOC_ZONE_HIGH = 0x1,
67     ROMFILE_LOADER_ALLOC_ZONE_FSEG = 0x2,
68 };
69
70 int romfile_loader_execute(const char *name);
71
72 #endif