source: trunk/TOOLS/INTERNAL/FIXCODE.C@ 54

Last change on this file since 54 was 54, checked in by Ben Rietbroek, 11 years ago

Preparing for v1.1.0 [2013-04-05]

During v1.0.8 it was decided that odd minor numbers will be
test-versions. Since v1.0.8 was actually a test-version with several
test-releases but with an even minor number, it was decided to bump the
final release to v1.1.0.

Thus, v1.1.1 will be the next test-version after the upcoming official
v1.1.0 release. When such test-versions are published, for instance to
get feedback, or solve a particular issue, the build-date and BLDLEVEL
information will identify such a test-release. This information can be
viewed by pressing the TAB-key while the Main Menu is displayed. Such
test-releases will also have a slightly different visual appearance to
distinguish them from official releases.

Because all test-versions between official releases identify themselves
with the same version number, upgrading from one test-release to another
requires the /forcecode option on the Installer.

Following this scheme, v1.1.2 will be the next official release after
the upcoming v1.1.0 release.

It is possible however, that major changes break compatibility with
previous releases, in which case the middle number will be incremented
to reflect this.

Note that this commit still identifies as v1.0.8.

Changes

o Bumped version information to v1.1.0
o Updated version dependent code in the Installers and SETABOOT.EXE

File size: 6.5 KB
Line 
1// AiR-BOOT (c) Copyright 1998-2008 M. Kiewitz
2//
3// This file is part of AiR-BOOT
4//
5// AiR-BOOT is free software: you can redistribute it and/or modify it under
6// the terms of the GNU General Public License as published by the Free
7// Software Foundation, either version 3 of the License, or (at your option)
8// any later version.
9//
10// AiR-BOOT is distributed in the hope that it will be useful, but WITHOUT ANY
11// WARRANTY: without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13// details.
14//
15// You should have received a copy of the GNU General Public License along with
16// AiR-BOOT. If not, see <http://www.gnu.org/licenses/>.
17//
18
19/*
20// FIXCODE.C -- Fix the AiR-BOOT image; include the code-size and MBR prot-img.
21// This reads AIR-BOOT.COM, merges MBR-PROT.BIN and writes AIRBOOT.BIN.
22// It is a quick-and-dirty translation of the original DOS-only ASM file.
23// Of course it's not as small but it's much easier to maintain across
24// multiple platforms. A small change with regard to the old ASM version is
25// that it directly writes AIRBOOT.BIN instead of writing AIR-BOOT.COM.
26// This way the pre and post situations are kept valid.
27*/
28
29
30#include "FIXCODE.H"
31
32
33#ifdef PLATFORM_DOS
34 char welcome[] = "FIXCODE: Hello from DOS !";
35#endif
36
37#ifdef PLATFORM_OS2
38 char welcome[] = "FIXCODE: Hello from OS/2 !";
39#endif
40
41#ifdef PLATFORM_WINNT
42 char welcome[] = "FIXCODE: Hello from Windows NT !";
43#endif
44
45#ifdef PLATFORM_LINUX
46 char welcome[] = "FIXCODE: Hello from Linux !";
47#endif
48
49
50/* File names */
51#define IN_FILE "AIR-BOOT.COM" // Target from assembly.
52#ifdef PLATFORM_LINUX
53#define MERGE_FILE "MBR-PROT/MBR-PROT.BIN" // MBR Protection Image.
54#else
55#define MERGE_FILE "MBR-PROT\\MBR-PROT.BIN" // MBR Protection Image.
56#endif
57#define OUT_FILE "AIRBOOT.BIN" // Generated loader image.
58
59
60/* Copyright message */
61char Copyright[] = "AiR-BOOT Bootcode Image Fix\n"
62 " - (c) Copyright 2009-2012 by M. Kiewitz\n";
63/* Progress messages */
64char LoadCode[] = " - Loading bootcode from file...";
65char LoadMBR[] = " - Loading MBR-protection from file...";
66char MergeMBR[] = " - Merging MBR-protection into bootcode...";
67char CountCode[] = " - Count code in bootcode-image...";
68char WriteCode[] = " - Saving bootcode to file...";
69char Okay[] = "ok\n";
70char Failed[] = "failed\n";
71
72/* Error messages */
73char FailedOpenCode[] = IN_FILE" not found\n";
74char FailedReadCode[] = "Read "IN_FILE" failed\n";
75char FailedInvalidCode[] = "Invalid "IN_FILE"\n";
76char FailedOpenMBR[] = MERGE_FILE" not found\n";
77char FailedReadMBR[] = "Read "MERGE_FILE" failed\n";
78char FailedInvalidMBR[] = "Invalid "MERGE_FILE"\n";
79char FailedWriteCode[] = "Write "OUT_FILE" failed\n";
80
81/* The signature we search for in the AIR-BOOT.COM image */
82char MBRProtectionSignature[] = "AiR-BOOT MBR-Protection Image";
83
84/* File buffers */
85char BootCode[IMAGE_SIZE]; // Buffer for boot-image
86char MBRProtection[MBRPROT_SIZE]; // Buffer for protection-image
87
88
89
90
91/*
92// Main Entrypoint.
93*/
94int main(int argc, char* argv[]) {
95 FILE* ifile = NULL;
96 FILE* mfile = NULL;
97 FILE* ofile = NULL;
98 size_t ibytes = 0;
99 size_t mbytes = 0;
100 size_t obytes = 0;
101 unsigned i = 0;
102 unsigned found = 0;
103
104
105#if DEBUG_LEVEL > 0
106 printf("\n%s\n", welcome);
107 printf("Debug level is: %d\n\n", DEBUG_LEVEL);
108#endif
109
110 /*
111 // Show copyright message.
112 */
113 printf("%s",Copyright);
114
115 /*
116 // Load AIR-BOOT.COM
117 */
118 printf("%s",LoadCode);
119 ifile = fopen(IN_FILE, "rb");
120 if (!ifile) {
121 printf("%s",FailedOpenCode);
122 exit(1);
123 }
124 ibytes = fread(BootCode, 1, IMAGE_SIZE, ifile);
125 if (ferror(ifile)) {
126 printf("%s",FailedReadCode);
127 exit(1);
128 }
129 //printf("ibytes: %d\n", ibytes);
130 fread(BootCode, 1, 1, ifile);
131 if (ibytes != IMAGE_SIZE || !feof(ifile)) {
132 printf("%s", FailedInvalidCode);
133 exit(1);
134 }
135 printf("%s", Okay);
136
137
138 /*
139 // Load MBR-PROT.BIN
140 */
141 printf("%s",LoadMBR);
142 mfile = fopen(MERGE_FILE, "rb");
143 if (!mfile) {
144 printf("%s",FailedOpenMBR);
145 exit(1);
146 }
147 mbytes = fread(MBRProtection, 1, MBRPROT_SIZE, mfile);
148 if (ferror(mfile)) {
149 printf("%s",FailedReadMBR);
150 exit(1);
151 }
152 fread(MBRProtection, 1, 1, mfile);
153 if (mbytes != MBRPROT_SIZE || !feof(mfile)) {
154 printf("%s", FailedInvalidMBR);
155 exit(1);
156 }
157 printf("%s", Okay);
158
159
160 /*
161 // Find Protection Image Signature.
162 // Note that this signature must reside on a sector boundary in the
163 // AIR-BOOT.COM image.
164 */
165 //~ for (i=0; i<55; i++) {
166 for (i=0; i<110; i++) {
167 if (!memcmp(MBRProtectionSignature, &BootCode[i*PAGESIZE], strlen(MBRProtectionSignature))) {
168 found = 1;
169 break;
170 }
171 }
172
173 /*
174 // Abort if not found.
175 */
176 printf("%s",MergeMBR);
177 if (!found) {
178 printf("%s",Failed);
179 exit(2);
180 }
181
182 /*
183 // Merge Protection Image.
184 */
185 //~ memcpy(&BootCode[i*SECSIZE], MBRProtection, MBRPROT_SIZE);
186 memcpy(&BootCode[i*PAGESIZE], MBRProtection, MBRPROT_SIZE);
187 printf("%s", Okay);
188
189
190 /*
191 // Count Code Sectors.
192 // Obsolete now because since v1.0.8+ the Protection Image has moved just
193 // below the Configuration and the code is always max. size.
194 // Overlap checking is done while assembling AIR-BOOT.ASM.
195 // So we just write the max. code sectors here.
196 */
197 printf("%s", CountCode);
198 BootCode[16] = 53;
199 printf("%s", Okay);
200
201 /*
202 // Write AIRBOOT.BIN
203 */
204 printf("%s", WriteCode);
205 ofile = fopen(OUT_FILE, "wb");
206 if (!ofile) {
207 printf("%s", FailedWriteCode);
208 exit(3);
209 }
210 obytes = fwrite(BootCode, 1, IMAGE_SIZE, ofile);
211 if (obytes != IMAGE_SIZE || ferror(ofile)) {
212 printf("%s", FailedWriteCode);
213 exit(3);
214 }
215 printf("%s", Okay);
216
217
218 /*
219 // Close files.
220 */
221 if (ifile)
222 fclose(ifile);
223 if (mfile)
224 fclose(mfile);
225 if (ofile)
226 fclose(ofile);
227
228
229 return 0L;
230}
231
Note: See TracBrowser for help on using the repository browser.