Bootdesc building working

This commit is contained in:
Bahadir Balban
2009-09-30 16:31:34 +03:00
parent 1aa31bc9d5
commit 73225a0119
7 changed files with 85 additions and 223 deletions

View File

@@ -58,71 +58,6 @@ def main():
print "Afterburn:"
for burn in burns:
print " ", burn
if options.lma_boundary:
paddr_first = 0
paddr_start = 0
paddr_end = 0
for pheader in elffile.pheaders:
x = pheader.ai
if str(x.p_type) != "LOAD":
continue
# First time assign the first p_paddr.
if paddr_first == 0:
paddr_first = 1
paddr_start = x.p_paddr.value
# Then if new paddr is lesser, reassign start.
if paddr_start > x.p_paddr.value:
paddr_start = x.p_paddr.value
# If end of segment is greater, reassign end.
if paddr_end < x.p_paddr + x.p_memsz:
paddr_end = x.p_paddr + x.p_memsz
rest, image_name = path.split(args[0])
if image_name[-4] == ".":
image_name = image_name[:-4]
print image_name
if hex(paddr_start)[-1] == "L":
print "image_start " + hex(paddr_start)[:-1]
else:
print "image_start " + hex(paddr_start)
if hex(paddr_end)[-1] == "L":
print "image_end " + hex(paddr_end)[:-1]
else:
print "image_end " + hex(paddr_end)
if options.ffpage:
paddr_max = 0
p_align = 0
for pheader in elffile.pheaders:
x = pheader.ai
if str(x.p_type) == "LOAD":
paddr = x.p_paddr + x.p_memsz
p_align = x.p_align
if paddr > paddr_max:
paddr_max = paddr
print "/*\n" + \
" * The next free p_align'ed LMA base address\n" + \
" *\n" + \
" * p_align = " + hex(p_align.value) + "\n" + \
" *\n" + \
" * Recap from ELF spec: p_align: Loadable process segments must have\n" + \
" * congruent values for p_vaddr and p_offset, modulo the page size. \n" + \
" * This member gives the value to which the segments are aligned in \n" + \
" * memory and in the file. Values 0 and 1 mean that no alignment is \n" + \
" * required. Otherwise, p_align should be a positive, integral power\n" + \
" * of 2, and p_addr should equal p_offset, modulo p_align. \n" + \
" * This essentially means next available address must be aligned at\n" + \
" * p_align, rather than the page_size, which one (well, I) would \n" + \
" * normally expect. \n" + \
" */\n"
paddr_aligned = paddr_max & ~(p_align.value - 1)
if paddr_max & (p_align.value - 1):
paddr_aligned += p_align.value
if hex(paddr_aligned)[-1] == "L":
print "physical_base = " + hex(paddr_aligned)[:-1] + ";"
else:
print "physical_base = " + hex(paddr_aligned) + ";"
if __name__ == "__main__":
main()