From: Michael Buesch Date: Fri, 24 Sep 2010 17:58:18 +0000 (+0200) Subject: Add brcm80211-ivaldump X-Git-Tag: b43-fwcutter-014~9 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=32c0354095b2d2ca8fa58ede4fd9b47d793cb249;p=b43-tools.git Add brcm80211-ivaldump Signed-off-by: Michael Buesch --- diff --git a/disassembler/Makefile b/disassembler/Makefile index fe59ece..b069205 100644 --- a/disassembler/Makefile +++ b/disassembler/Makefile @@ -52,7 +52,8 @@ $(BIN): $(call OBJS,$(SRCS)) install: all install -m 755 $(BIN) $(PREFIX)/bin/ install -m 755 b43-ivaldump $(PREFIX)/bin/ - install -m 755 brcm80211fwconv $(PREFIX)/bin/ + install -m 755 brcm80211-ivaldump $(PREFIX)/bin/ + install -m 755 brcm80211-fwconv $(PREFIX)/bin/ clean: -rm -Rf obj dep *~ *.orig *.rej diff --git a/disassembler/brcm80211-ivaldump b/disassembler/brcm80211-ivaldump new file mode 100755 index 0000000..9a1ad2d --- /dev/null +++ b/disassembler/brcm80211-ivaldump @@ -0,0 +1,70 @@ +#!/usr/bin/env python +""" +# A small script to dump the contents of a brcm80211 initvals section +# +# Copyright (C) 2010 Michael Buesch +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 +# as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +""" + +import sys + + +def usage(): + print "brcm80211 initvals section dumper" + print "Prints a .initvals assembly section to stdout." + print "" + print "Copyright (C) 2010 Michael Buesch " + print "Licensed under the GNU/GPL version 2" + print "" + print "Usage: brcm80211-ivaldump FILE" + print "" + print "FILE is the file that is going to be dumped" + return + +if len(sys.argv) != 2: + usage() + sys.exit(1) + +filename = sys.argv[1] + +try: + ivals = file(filename).read() +except IOError, e: + print "Could not read the initvals file: %s" % e.strerror + sys.exit(1) + +if len(ivals) == 0 or len(ivals) % 8 != 0: + print "The input file is malformed." + sys.exit(1) + +sectname = filename.split('/')[-1] +if sectname.endswith(".fw"): + sectname = sectname[:-3] +print ".initvals(%s)" % sectname +for idx in range(0, len(ivals), 8): + addr = ord(ivals[idx + 0]) + addr |= ord(ivals[idx + 1]) << 8 + size = ord(ivals[idx + 2]) + size |= ord(ivals[idx + 3]) << 8 + value = ord(ivals[idx + 4]) + value |= ord(ivals[idx + 5]) << 8 + value |= ord(ivals[idx + 6]) << 16 + value |= ord(ivals[idx + 7]) << 24 + + if addr == 0xFFFF: + break + if size == 4: + print "\tmmio32\t0x%08X, 0x%04X" % (value, addr) + elif size == 2: + print "\tmmio16\t0x%08X, 0x%04X" % (value, addr) + else: + print "The input file is malformed (invalid size field: 0x%04X)" % size + sys.exit(1)