Ensure that the reserve map is doubleword aligned in blob and asm output.

main
David Gibson 2005-07-11 17:19:26 +10:00
parent a6c69572a3
commit 47f23dee09
1 changed files with 14 additions and 4 deletions

View File

@ -291,6 +291,7 @@ static void make_bph(struct boot_param_header *bph,
int reservenum, int reservenum,
int dtsize, int strsize) int dtsize, int strsize)
{ {
int reserve_off;
int reservesize = (reservenum+1) * sizeof(struct reserve_entry); int reservesize = (reservenum+1) * sizeof(struct reserve_entry);


memset(bph, 0xff, sizeof(*bph)); memset(bph, 0xff, sizeof(*bph));
@ -299,11 +300,14 @@ static void make_bph(struct boot_param_header *bph,
bph->version = vi->version; bph->version = vi->version;
bph->last_comp_version = vi->last_comp_version; bph->last_comp_version = vi->last_comp_version;


bph->off_mem_rsvmap = cpu_to_be32(vi->hdr_size); /* Reserve map should be doubleword aligned */
bph->off_dt_struct = cpu_to_be32(vi->hdr_size + reservesize); reserve_off = ALIGN(vi->hdr_size, 8);
bph->off_dt_strings = cpu_to_be32(vi->hdr_size + reservesize
bph->off_mem_rsvmap = cpu_to_be32(reserve_off);
bph->off_dt_struct = cpu_to_be32(reserve_off + reservesize);
bph->off_dt_strings = cpu_to_be32(reserve_off + reservesize
+ dtsize); + dtsize);
bph->totalsize = cpu_to_be32(vi->hdr_size + reservesize bph->totalsize = cpu_to_be32(reserve_off + reservesize
+ dtsize + strsize); + dtsize + strsize);
if (vi->flags & FTF_BOOTCPUID) if (vi->flags & FTF_BOOTCPUID)
@ -336,6 +340,10 @@ void write_dt_blob(FILE *f, struct node *tree, int version, int reservenum)


make_bph(&bph, vi, reservenum, dtbuf.len, strbuf.len); make_bph(&bph, vi, reservenum, dtbuf.len, strbuf.len);


/* Align the reserve map to an 8 byte boundary */
for (i = vi->hdr_size; i < be32_to_cpu(bph.off_mem_rsvmap); i++)
fputc(0, f);

fwrite(&bph, vi->hdr_size, 1, f); fwrite(&bph, vi->hdr_size, 1, f);
for (i = 0; i < reservenum+1; i++) for (i = 0; i < reservenum+1; i++)
fwrite(&re, sizeof(re), 1, f); fwrite(&re, sizeof(re), 1, f);
@ -408,6 +416,8 @@ void write_dt_asm(FILE *f, struct node *tree, int version, int reservenum)
fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n", fprintf(f, "\t.long\t_%s_strings_end - _%s_strings_start\t/* size_dt_strings */\n",
symprefix, symprefix); symprefix, symprefix);


/* align the reserve map to a doubleword boundary */
asm_emit_align(f, 8);
emit_label(f, symprefix, "reserve_map"); emit_label(f, symprefix, "reserve_map");
/* reserve map entry for the device tree itself */ /* reserve map entry for the device tree itself */
fprintf(f, "\t.long\t0, _%s_blob_start\n", symprefix); fprintf(f, "\t.long\t0, _%s_blob_start\n", symprefix);