#!/usr/bin/env python # Fill in checksum/size of an option rom, and pad it to proper length. # # Copyright (C) 2009 Kevin O'Connor # # This file may be distributed under the terms of the GNU GPLv3 license. import sys, struct from python23compat import as_bytes def alignpos(pos, alignbytes): mask = alignbytes - 1 return (pos + mask) & ~mask def checksum(data): if (sys.version_info > (3, 0)): cksum = sum(data) else: cksum = sum(map(ord, data)) return struct.pack('