blob: 7ba4d0de391d12c4fe30b91c7969ae3dd0310467 [file] [log] [blame]
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -04001#!/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
8import sys
9
10def 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'Connord2899772008-07-06 09:56:14 -040020 c16s = syms['code16_start'] + 0xf0000
21 c32s = syms['final_code16_start']
22 f16s = syms['code16_fixed_start'] + 0xf0000
23 f32s = syms['final_code16_fixed_start']
24 if c16s != c32s or f16s != f32s:
25 print ("Error! 16bit code moved during linking"
26 " (0x%x vs 0x%x, 0x%x vs 0x%x)" % (
27 c32s, c16s, f16s, f32s))
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040028 sys.exit(1)
29
30 size16 = syms['code16_end'] - syms['code16_start']
31 size32 = syms['code32_end'] - syms['code32_start']
Kevin O'Connor4556a2c2008-07-12 14:30:11 -040032 totalc = size16+size32
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040033 sizefree = syms['freespace1_end'] - syms['freespace1_start']
Kevin O'Connord2899772008-07-06 09:56:14 -040034 tablefree = syms['freespace2_end'] - syms['freespace2_start']
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040035 print "16bit C-code size: %d" % size16
36 print "32bit C-code size: %d" % size32
Kevin O'Connor4556a2c2008-07-12 14:30:11 -040037 print "Total C-code size: %d Free space: %d Percent used: %.1f%%" % (
38 totalc, sizefree
39 , (totalc / float(size16+size32+sizefree)) * 100.0)
Kevin O'Connord2899772008-07-06 09:56:14 -040040 print "BIOS table space: %d" % tablefree
Kevin O'Connor2fda7cb2008-07-05 20:41:53 -040041
42if __name__ == '__main__':
43 main()