source: xtideuniversalbios/trunk/Tools/checksum.pl @ 568

Last change on this file since 568 was 568, checked in by krille_n_@…, 9 years ago

Changes:

  • SerDrive: Using named pipe mode (serdrive -p) now works under Windows XP/2000/Server 2003.
  • checksum.pl: Added a compatibility fix for 3Com 3C503 cards.
  • XTIDECFG will now scan every possible segment address to find and load the BIOS and/or its settings from EEPROM. This should simplify things for people using combined option ROMs.
  • Fixed a bug from r521 in BootSector.asm where the BIOS would not display a timeout error if it failed to load the boot sector from harddrive.
  • Fixed a bug from r541 in CompatibleDPT.asm where CompatibleDPT_CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI would generate an invalid checksum in the DPTE.
  • Optimizations and other fixes.
File size: 2.5 KB
Line 
1@rem = '--*-Perl-*--
2@echo off
3perl -x -S %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
4goto endofperl
5@rem ';
6#!perl
7#
8# Add checksum byte to ROM image
9#
10# Use a size of 0 to skip this script entirely (file is not modified)
11#
12# On Windows, this file can be renamed to a batch file and invoked directly (for example, "c:\>checksum file size")
13#
14
15#
16# XTIDE Universal BIOS and Associated Tools
17# Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
18#
19# This program is free software; you can redistribute it and/or modify
20# it under the terms of the GNU General Public License as published by
21# the Free Software Foundation; either version 2 of the License, or
22# (at your option) any later version.
23#
24# This program is distributed in the hope that it will be useful,
25# but WITHOUT ANY WARRANTY; without even the implied warranty of
26# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
27# GNU General Public License for more details.
28# Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
29#
30
31($ARGV[0] ne "" && $ARGV[1] ne "") || die "usage: checksum filename size\n";
32
33$desiredSize = int($ARGV[1]);
34
35if( $desiredSize == 0 )
36{
37    exit( 0 );
38}
39
40open FILE, "+<".$ARGV[0] || die "file not found\n";
41binmode FILE;
42$cs = 0;
43$last = 0;
44$bytes = 0;
45while( ($n = read( FILE, $d, 1 )) != 0 )
46{
47    $cs = $cs + ord($d);
48    $cs = $cs % 256;
49    $bytes = $bytes + 1;
50}
51$oldBytes = $bytes;
52
53if( $bytes > $desiredSize - 1 )
54{
55    die "ERROR: image is bigger than ".($desiredSize-1).": $bytes\n";
56}
57
58$fixzero = chr(0);
59
60#
61# Compatibility fix for 3Com 3C503 cards. They use 8 KB ROMs and return 8080h as the last word of the ROM.
62#
63if( $desiredSize == 8192 ) {
64    if( $bytes < $desiredSize - 3 ) {
65        while( $bytes < $desiredSize - 3 ) {
66            print FILE $fixzero;
67            $bytes++;
68        }
69        $fixl = ($cs == 0 ? 0 : 256 - $cs);
70        $fix = chr($fixl).chr($cs);
71        print FILE $fix;
72        $bytes += 2;
73    } else {
74        print "Warning! ".$ARGV[0]." cannot be used on a 3Com 3C503 card!\n";
75    }
76}
77
78while( $bytes < $desiredSize - 1 )
79{
80    print FILE $fixzero;
81    $bytes++;
82}
83
84$fixl = ($cs == 0 ? 0 : 256 - $cs);
85$fix = chr($fixl);
86print FILE $fix;
87
88close FILE;
89
90open FILE, "<".$ARGV[0];
91binmode FILE;
92$cs = 0;
93$newBytes = 0;
94while( ($n = read( FILE, $d, 1 )) != 0 )
95{
96    $cs = $cs + ord($d);
97    $cs = $cs % 256;
98    $newBytes++;
99}
100$cs == 0 || die "Checksum verification failed\n";
101
102print "checksum: ".$ARGV[0].": $oldBytes bytes before, $newBytes bytes after\n";
103
104__DATA__
105:endofperl
Note: See TracBrowser for help on using the repository browser.