[romprefix] Add a dummy ROM header to cover the .mrom payload

The header of a .mrom image declares its length to be only a few
kilobytes; the remainder is accessed via a sideband mechanism.  This
makes it difficult to append an additional ROM image, such as an EFI
ROM.

Add a second, dummy ROM header covering the payload portion of the
.mrom image, allowing consumers to locate any appended ROM images in
the usual way.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2012-06-10 18:25:26 +01:00
parent 12be8bc544
commit 9e8d431a0d
5 changed files with 198 additions and 74 deletions

View File

@@ -237,15 +237,15 @@ static int process_zinfo_add ( struct input_file *input
__attribute__ (( unused )),
struct output_file *output,
size_t len,
struct zinfo_add *add,
struct zinfo_add *add, size_t offset,
size_t datasize ) {
size_t offset = add->offset;
void *target;
signed long addend;
unsigned long size;
signed long val;
unsigned long mask;
offset += add->offset;
if ( ( offset + datasize ) > output->len ) {
fprintf ( stderr, "Add at %#zx outside output buffer\n",
offset );
@@ -319,42 +319,90 @@ static int process_zinfo_addb ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->len,
&zinfo->add, 1 );
&zinfo->add, 0, 1 );
}
static int process_zinfo_addw ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->len,
&zinfo->add, 2 );
&zinfo->add, 0, 2 );
}
static int process_zinfo_addl ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->len,
&zinfo->add, 4 );
&zinfo->add, 0, 4 );
}
static int process_zinfo_adhb ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->hdr_len,
&zinfo->add, 1 );
&zinfo->add, 0, 1 );
}
static int process_zinfo_adhw ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->hdr_len,
&zinfo->add, 2 );
&zinfo->add, 0, 2 );
}
static int process_zinfo_adhl ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output, output->hdr_len,
&zinfo->add, 4 );
&zinfo->add, 0, 4 );
}
static int process_zinfo_adpb ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, 0, 1 );
}
static int process_zinfo_adpw ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, 0, 2 );
}
static int process_zinfo_adpl ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, 0, 4 );
}
static int process_zinfo_appb ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, output->hdr_len, 1 );
}
static int process_zinfo_appw ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, output->hdr_len, 2 );
}
static int process_zinfo_appl ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
return process_zinfo_add ( input, output,
( output->len - output->hdr_len ),
&zinfo->add, output->hdr_len, 4 );
}
struct zinfo_processor {
@@ -374,6 +422,12 @@ static struct zinfo_processor zinfo_processors[] = {
{ "ADHB", process_zinfo_adhb },
{ "ADHW", process_zinfo_adhw },
{ "ADHL", process_zinfo_adhl },
{ "ADPB", process_zinfo_adpb },
{ "ADPW", process_zinfo_adpw },
{ "ADPL", process_zinfo_adpl },
{ "APPB", process_zinfo_appb },
{ "APPW", process_zinfo_appw },
{ "APPL", process_zinfo_appl },
};
static int process_zinfo ( struct input_file *input,