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

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

AiR-BOOT v1.0.8-rc3 build-20120909 [2012-09-10]

With Git one can easily hop-skip-and-jump between branches.
So I use Git for my local repos and make use of this easy branching.
Because SVN can only handle lineair history, these branches had to be
rebased before committing them to Netlabs. So, this commit contains a
multitude of changes which makes it a bit hairy.

New

o Display LVM drive-letters in the main menu

A populair request was to show drive-letter information in the menu.
Drive-letters however, are OS specific and AiR-BOOT cannot
accurately predict what drive-letter other operating systems would
assign to what partition. eCS LVM drive-letters however are stored
in the LVM-record and can thus be displayed.

o Added 'Show LVM Drive Letters' option in SETUP/BASIC

This will toggle the display of LVM drive-letters in the main menu.
By default this option is enabled.

o Show popup message when BIOS INT13X extensions are not available

The system is halted.

o Show 'DEL to Power Off' in the bottom left corner

This tries to power-off the system, but it may not work for you.

o Simple interactive debugger

Outputs to the serial port with a few one-letter commands to dump
internal tables and state. (Only available in debug builds)

o Enhanced drive-letter feature

Enable multiple eCS installations using the same drive-letter.
This makes it possible to clone a system with the command
'XCOPY /h /o /t /s /e /r /v /e' to another drive and have that boot
from the same drive-letter.
(Or installing to the same drive by hiding the other system)

Changes

o Reduced MBR protection-image from 1024 to 768 bytes

Luckily the MBR Protection Image code does not exceed 768 bytes,
so that gives us another 256 bytes of precious code-space.
Now the non-EN versions are happy again.
Note that the alignment for the image changed from 512 to 256 bytes.
MBR-PROT.ASM, FIXCODE.C, PARTMAIN.ASM and AIR-BOOT.ASM have been
adjusted for this change.
The fight for code-space continues...

o Updating from v1.06 now also copies over drive-letters

When the user has forced drive-letters in v1.06 these will be copied
over to the v1.0.8 configuration when upgrading.
Because the drive-letter feature is broken in v1.07,
the drive-letter table does not get copied over when upgrading
from v1.07.

o Made FX-code optional to compile in

The FX-code supplies the shifting screen-effects when 'Cooper Bars'
is enabled in the setup. With the current enhancements made however,
there is a continuous lack of code-space, especially when debug-code
is included during development. The FX-code occupies some
1200 bytes, a space that can be put to better use. Therefore the
inclusion of the FX-code has been made conditional to make room for
either debugging or future new features.

o Also rewrite PBR on HPFS

Earlier, a fix was made to write a modified PBR back in case JFS was
used. This was done to enable the drive-letter feature on JFS, since
the PBR JFS-bootcode does not use the supplied PBR in memory.
With the enhancements in the drive-letter feature, the HPFS PBR
needs to be updated on disk also, to cope with zero drive-letters in
the HPFS PBR. This potentially fixes a missing drive-letter in the
PBR when the system is restored from an archive. You might need the
drive-letter feature to force the correct drive-letter on the first
boot, after which the feature can be disabled.

o Added extra MBR protection

When AiR-BOOT is active, it is only AiR-BOOT that writes to the MBR.
To protect the MBR from programming errors, like the one below,
any write to the MBR is now checked for validity.
In essence this is protecting your MBR from bad programming done
by me...

Fixes

o Fixed a minor bug with displaying LVM drive-letters

When more partitions that can be displayed were present, scrolling
the menu would not scroll the drive-letter. Fixed.

o Fixed a bug with regard to the drive-letter feature

When partitions were deleted, and some partitions above the deleted
partition(s) had a drive-letter forced, these partitions would lose
this assignment. This bug is also present in v1.06.

Note

The AIRBOOT.HIS file mentions a DOCU directory with the AiR-BOOT
documentation etc. However, this is not present in this commit and
will be provided at a later time.

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.