summaryrefslogtreecommitdiffstats
path: root/src/util/zbin.c
diff options
context:
space:
mode:
authorMichael Brown2010-04-20 12:05:53 +0200
committerMichael Brown2010-04-20 13:56:28 +0200
commit9068249e24acc7342cd913b70745f5449b86b664 (patch)
tree58fd0e96e1b2300972ab018c79cb89a6132a5f97 /src/util/zbin.c
parent[prefix] Use flat real mode for access to high memory (diff)
downloadipxe-9068249e24acc7342cd913b70745f5449b86b664.tar.gz
ipxe-9068249e24acc7342cd913b70745f5449b86b664.tar.xz
ipxe-9068249e24acc7342cd913b70745f5449b86b664.zip
[prefix] Add .text16.early section
Add a section .text16.early which is always kept inline with the prefix. This will allow for some code sharing between the .prefix and .text16 sections. Note that the simple solution of just prepending the .prefix section to the .text16 section will not work, because a bug in Wyse Streaming Manager server (WLDRM13.BIN) requires us to place a dummy PXENV+ entry point at the start of .text16. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util/zbin.c')
-rw-r--r--src/util/zbin.c61
1 files changed, 56 insertions, 5 deletions
diff --git a/src/util/zbin.c b/src/util/zbin.c
index 707ae995..f0df5ea0 100644
--- a/src/util/zbin.c
+++ b/src/util/zbin.c
@@ -16,6 +16,7 @@ struct input_file {
struct output_file {
void *buf;
size_t len;
+ size_t hdr_len;
size_t max_len;
};
@@ -38,6 +39,13 @@ struct zinfo_pack {
uint32_t align;
};
+struct zinfo_payload {
+ char type[4];
+ uint32_t pad1;
+ uint32_t pad2;
+ uint32_t align;
+};
+
struct zinfo_add {
char type[4];
uint32_t offset;
@@ -49,6 +57,7 @@ union zinfo_record {
struct zinfo_common common;
struct zinfo_copy copy;
struct zinfo_pack pack;
+ struct zinfo_payload payload;
struct zinfo_add add;
};
@@ -209,8 +218,22 @@ static int process_zinfo_pack ( struct input_file *input,
return 0;
}
+static int process_zinfo_payl ( struct input_file *input,
+ struct output_file *output,
+ union zinfo_record *zinfo ) {
+ struct zinfo_payload *payload = &zinfo->payload;
+
+ output->len = align ( output->len, payload->align );
+ output->hdr_len = output->len;
+
+ if ( DEBUG ) {
+ fprintf ( stderr, "PAYL at %#zx\n", output->hdr_len );
+ }
+}
+
static int process_zinfo_add ( struct input_file *input,
struct output_file *output,
+ size_t len,
struct zinfo_add *add,
size_t datasize ) {
size_t offset = add->offset;
@@ -227,7 +250,7 @@ static int process_zinfo_add ( struct input_file *input,
}
target = ( output->buf + offset );
- size = ( align ( output->len, add->divisor ) / add->divisor );
+ size = ( align ( len, add->divisor ) / add->divisor );
switch ( datasize ) {
case 1:
@@ -283,7 +306,7 @@ static int process_zinfo_add ( struct input_file *input,
fprintf ( stderr, "ADDx [%#zx,%#zx) (%s%#x+(%#zx/%#x)) = "
"%#lx\n", offset, ( offset + datasize ),
( ( addend < 0 ) ? "-" : "" ), abs ( addend ),
- output->len, add->divisor, val );
+ len, add->divisor, val );
}
return 0;
@@ -292,19 +315,43 @@ static int process_zinfo_add ( struct input_file *input,
static int process_zinfo_addb ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
- return process_zinfo_add ( input, output, &zinfo->add, 1 );
+ return process_zinfo_add ( input, output, output->len,
+ &zinfo->add, 1 );
}
static int process_zinfo_addw ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
- return process_zinfo_add ( input, output, &zinfo->add, 2 );
+ return process_zinfo_add ( input, output, output->len,
+ &zinfo->add, 2 );
}
static int process_zinfo_addl ( struct input_file *input,
struct output_file *output,
union zinfo_record *zinfo ) {
- return process_zinfo_add ( input, output, &zinfo->add, 4 );
+ return process_zinfo_add ( input, output, output->len,
+ &zinfo->add, 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 );
+}
+
+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 );
+}
+
+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 );
}
struct zinfo_processor {
@@ -317,9 +364,13 @@ struct zinfo_processor {
static struct zinfo_processor zinfo_processors[] = {
{ "COPY", process_zinfo_copy },
{ "PACK", process_zinfo_pack },
+ { "PAYL", process_zinfo_payl },
{ "ADDB", process_zinfo_addb },
{ "ADDW", process_zinfo_addw },
{ "ADDL", process_zinfo_addl },
+ { "ADHB", process_zinfo_adhb },
+ { "ADHW", process_zinfo_adhw },
+ { "ADHL", process_zinfo_adhl },
};
static int process_zinfo ( struct input_file *input,