Kevin O'Connor | 2fda7cb | 2008-07-05 20:41:53 -0400 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Script to check a bios image and report info on it. |
| 3 | # |
| 4 | # Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net> |
| 5 | # |
| 6 | # This file may be distributed under the terms of the GNU GPLv3 license. |
| 7 | |
| 8 | import sys |
| 9 | |
| 10 | def main(): |
| 11 | # Read in symbols (that are valid) |
| 12 | syms = {} |
| 13 | for line in sys.stdin.readlines(): |
| 14 | try: |
| 15 | addr, type, sym = line.split() |
| 16 | syms[sym] = int(addr, 16) |
| 17 | except: |
| 18 | pass |
| 19 | |
Kevin O'Connor | 711ddc6 | 2009-01-17 15:17:34 -0500 | [diff] [blame^] | 20 | c16e = syms['code16_end'] + 0xf0000 |
| 21 | f16e = syms['final_code16_end'] |
| 22 | if c16e != f16e: |
Kevin O'Connor | 202024a | 2009-01-17 10:41:28 -0500 | [diff] [blame] | 23 | print "Error! 16bit code moved during linking (0x%x vs 0x%x)" % ( |
Kevin O'Connor | 711ddc6 | 2009-01-17 15:17:34 -0500 | [diff] [blame^] | 24 | c16e, f16e) |
Kevin O'Connor | 2fda7cb | 2008-07-05 20:41:53 -0400 | [diff] [blame] | 25 | sys.exit(1) |
| 26 | |
Kevin O'Connor | 202024a | 2009-01-17 10:41:28 -0500 | [diff] [blame] | 27 | sizefree = syms['freespace1_end'] - syms['freespace1_start'] |
| 28 | size16 = syms['code16_end'] - syms['code16_start'] - sizefree |
Kevin O'Connor | 2fda7cb | 2008-07-05 20:41:53 -0400 | [diff] [blame] | 29 | size32 = syms['code32_end'] - syms['code32_start'] |
Kevin O'Connor | 4556a2c | 2008-07-12 14:30:11 -0400 | [diff] [blame] | 30 | totalc = size16+size32 |
Kevin O'Connor | 202024a | 2009-01-17 10:41:28 -0500 | [diff] [blame] | 31 | print "16bit size: %d" % size16 |
| 32 | print "32bit size: %d" % size32 |
| 33 | print "Total size: %d Free space: %d Percent used: %.1f%%" % ( |
Kevin O'Connor | 4556a2c | 2008-07-12 14:30:11 -0400 | [diff] [blame] | 34 | totalc, sizefree |
| 35 | , (totalc / float(size16+size32+sizefree)) * 100.0) |
Kevin O'Connor | 2fda7cb | 2008-07-05 20:41:53 -0400 | [diff] [blame] | 36 | |
| 37 | if __name__ == '__main__': |
| 38 | main() |