2 # Script to check a bios image and report info on it.
4 # Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
6 # This file may be distributed under the terms of the GNU GPLv3 license.
13 objinfo, rawfile, outfile = sys.argv[1:]
16 objinfofile = open(objinfo, 'rb')
17 symbols = layoutrom.parseObjDump(objinfofile)[1]
19 for name, (addr, section) in symbols.items():
23 f = open(rawfile, 'rb')
26 datasize = len(rawdata)
28 if datasize > 64*1024:
32 c16e = syms['code16_end'] + 0xf0000
33 f16e = syms['final_code16_end']
35 print "Error! 16bit code moved during linking (0x%x vs 0x%x)" % (
38 if datasize > finalsize:
39 print "Error! Code is too big (0x%x vs 0x%x)" % (
44 sizefree = syms['freespace_end'] - syms['freespace_start']
45 size16 = syms['code16_end'] - syms['code16_start']
46 size32 = syms['code32_end'] - syms['code32_start']
47 totalc = size16+size32
48 print "16bit size: %d" % size16
49 print "32bit size: %d" % size32
50 print "Total size: %d Free space: %d Percent used: %.1f%% (%dKiB rom)" % (
51 totalc, sizefree + finalsize - datasize
52 , (totalc / float(finalsize)) * 100.0
56 f = open(outfile, 'wb')
57 f.write(("\0" * (finalsize - datasize)) + rawdata)
60 if __name__ == '__main__':