Changeset 46 for trunk/TOOLS/INTERNAL
- Timestamp:
- Apr 12, 2014, 8:23:32 AM (11 years ago)
- Location:
- trunk/TOOLS/INTERNAL
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/TOOLS/INTERNAL/FIXCODE
r43 r46 4 4 # $airboot@ecomstation.com$ 5 5 # 6 # This is a hack until the Linux version of FIXCODE.C is finished.6 # This is a quick-hack until the Linux version of FIXCODE.C is finished. 7 7 # Note that it does not search for the AiR-BOOT Protection Signature, 8 8 # but embeds it at the 'well known' location. 9 # I t the protection image is moved, this script will corrupt AIR-BOOT.COM10 # of which the final AIRBOOT.BIN is derived.9 # If the protection image is moved, this script will produce a corrupted 10 # AIRBOOT.BIN. 11 11 # Also, a code-size of 35h (max size) is always inserted. 12 # Furthermore, it does no sanity checks whatsoever.12 # Furthermore, it does not do any sanity checks whatsoever. 13 13 # 14 14 15 PROT_IMG="MBR-PROT/MBR_PROT.COM" 15 # 16 # This script is now obsolete. 17 # 18 exit 1; 19 20 21 PROT_IMG="MBR-PROT/MBR-PROT.BIN" 16 22 AB_INTERIM_IMG="AIR-BOOT.COM" 23 AB_IMG="AIRBOOT.BIN" 17 24 CODE_SIZE_OFFSET=16 18 25 PROT_IMG_OFFSET=26624 19 26 20 27 28 function echox() { 29 echo -e $@; 30 } 31 32 21 33 function Header() { 22 echo "Header";34 echox "\t## FIXCODE script for Linux ##"; 23 35 } 24 36 25 37 function CheckIfFileExists() { 26 echo "CheckIfFileExists";38 echox "\tCheckIfFileExists"; 27 39 if [ ! -f "${1}" ]; then 28 echo "ERROR: File ${1} could not be found !";29 echo "Aborting...";40 echox "\tERROR: File ${1} could not be found !"; 41 echox "\t Aborting..."; 30 42 exit 1; 31 43 else 32 echo "File ${1} found, OK.";44 echox "\tFile ${1} found, OK."; 33 45 fi; 34 46 } 35 47 48 function CreateImage() { 49 echox "\tCreateImage"; 50 cp -a "${1}" "${2}"; 51 } 52 36 53 function EmbedCodeSize() { 37 echo "EmbedCodeSize"; 38 echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc; 54 echox "\tEmbedCodeSize"; 55 echo "${1}" 56 echo -n "5" | dd of="${1}" bs=1 seek=${CODE_SIZE_OFFSET} conv=notrunc 2> /dev/null; 39 57 } 40 58 41 59 function EmbedProtectionImage() { 42 echo "EmbedProtectionImage";43 dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc ;60 echox "\tEmbedProtectionImage"; 61 dd if="${1}" of="${2}" bs=1 seek=${PROT_IMG_OFFSET} conv=notrunc 2> /dev/null; 44 62 } 45 63 46 64 function VerifyImage() { 47 echo "VerfyImage";65 echox "\tVerfyImage"; 48 66 } 49 67 50 68 function Footer() { 51 echo "Footer"; 69 echox "\t## AiR-BOOT code fixed ##"; 70 echo ""; 52 71 } 53 72 … … 58 77 # 59 78 function Main() { 60 echo "## Main ##";79 echo ""; 61 80 Header; 62 CheckIfFileExists "${PROT_IMG}" 63 CheckIfFileExists "${AB_INTERIM_IMG}" 64 EmbedCodeSize "${AB_INTERIM_IMG}"; 65 EmbedProtectionImage "${PROT_IMG}" "${AB_INTERIM_IMG}"; 81 CheckIfFileExists "${PROT_IMG}"; 82 CheckIfFileExists "${AB_INTERIM_IMG}"; 83 CreateImage "${AB_INTERIM_IMG}" "${AB_IMG}"; 84 EmbedProtectionImage "${PROT_IMG}" "${AB_IMG}"; 85 EmbedCodeSize "${AB_IMG}"; 66 86 Footer; 67 87 } -
trunk/TOOLS/INTERNAL/FIXCODE.ASM
r43 r46 41 41 COM_CodeName db 'AIR-BOOT.COM', 0 42 42 COM_LoadMBR db ' - Loading MBR-protection from file...$' 43 COM_MBRName db 'MBR-PROT\MBR _PROT.COM', 043 COM_MBRName db 'MBR-PROT\MBR-PROT.BIN', 0 44 44 COM_MergeMBR db ' - Merging MBR-protection into bootcode...$' 45 45 COM_CountCode db ' - Count code in bootcode-image...$' … … 51 51 COM_FailedReadCode db 'Read air-boot.com failed', 13, 10, '$' 52 52 COM_FailedInvalidCode db 'Invalid air-boot.com', 13, 10, '$' 53 COM_FailedOpenMBR db 'mbr-prot\mbr _prot.comnot found', 13, 10, '$'54 COM_FailedReadMBR db 'Read mbr-prot\mbr _prot.comfailed', 13, 10, '$'55 COM_FailedInvalidMBR db 'Invalid mbr-prot\mbr _prot.com', 13, 10, '$'53 COM_FailedOpenMBR db 'mbr-prot\mbr-prot.bin not found', 13, 10, '$' 54 COM_FailedReadMBR db 'Read mbr-prot\mbr-prot.bin failed', 13, 10, '$' 55 COM_FailedInvalidMBR db 'Invalid mbr-prot\mbr-prot.bin', 13, 10, '$' 56 56 COM_FailedWriteCode db 'Write air-boot.com failed', 13, 10, '$' 57 57 … … 65 65 ShowMessage EndP 66 66 67 ShowError Proc Near 68 mov ah, 09h 69 int 21h ; DOS: WRITE STRING DS:DX TO CONSOLE 70 jmp EndProgram 71 ret 72 ShowError EndP 67 ShowError Proc Near 68 mov ah, 09h 69 int 21h ; DOS: WRITE STRING DS:DX TO CONSOLE 70 mov al,1 ; Error code 71 jmp EndProgram 72 ret 73 ShowError EndP 73 74 74 75 COM_Init: … … 128 129 call ShowMessage 129 130 130 ; Open MBR_PROT. COM131 ; Open MBR_PROT.BIN 131 132 mov dx, offset COM_LoadMBR 132 133 call ShowMessage … … 141 142 DoneOpenMBR: mov bx, ax ; BX = Filehandle 142 143 143 ; Load MBR _PROT.COM144 ; Load MBR-PROT.BIN 144 145 mov ah, 3Fh 145 146 mov cx, 1024 ; Image size … … 204 205 mov dx, offset COM_Failed 205 206 call ShowMessage 207 mov al,2 ; Error code 206 208 jmp EndProgram 207 209 … … 220 222 221 223 mov si, offset BootCode 222 add si, 512*53 223 mov cx, 256 224 mov dx, 53 224 add si, 512*53 ; 6A00 225 mov cx, 256 ; 512 bytes 226 mov dx, 53 ; initial count 225 227 COM_CodeEndLoop:push cx 226 228 push si … … 277 279 mov dx, offset COM_Okay 278 280 call ShowMessage 281 xor al,al ; No Error 279 282 jmp EndProgram 280 283 … … 282 285 EndProgram: 283 286 ; DOS: TERMINATE PROGRAM 284 mov a x, 4C00h287 mov ah, 04Ch 285 288 int 21h 286 289 -
trunk/TOOLS/INTERNAL/FIXCODE.C
r37 r46 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. 25 */ 26 27 1 28 #include "FIXCODE.H" 2 29 … … 19 46 20 47 21 #define IN_FILE "AIR-BOOT.COM" // Target from assembly. 22 #define MERGE_FILE "MBR_PROT.BIN" // MBR protection TSR. 23 #define OUT_FILE "AIRBOOT.BIN" // Generated loader image. 24 25 26 48 /* File names */ 49 #define IN_FILE "AIR-BOOT.COM" // Target from assembly. 50 #ifdef PLATFORM_LINUX 51 #define MERGE_FILE "MBR-PROT/MBR-PROT.BIN" // MBR protection TSR. 52 #else 53 #define MERGE_FILE "MBR-PROT\\MBR-PROT.BIN" // MBR protection TSR. 54 #endif 55 #define OUT_FILE "AIRBOOT.BIN" // Generated loader image. 56 57 58 /* Copyright message */ 59 char Copyright[] = "AiR-BOOT Bootcode Image Fix\n" 60 " - (c) Copyright 2009-2012 by M. Kiewitz\n"; 61 /* Progress messages */ 62 char LoadCode[] = " - Loading bootcode from file..."; 63 char LoadMBR[] = " - Loading MBR-protection from file..."; 64 char MergeMBR[] = " - Merging MBR-protection into bootcode..."; 65 char CountCode[] = " - Count code in bootcode-image..."; 66 char WriteCode[] = " - Saving bootcode to file..."; 67 char Okay[] = "ok\n"; 68 char Failed[] = "failed\n"; 69 70 /* Error messages */ 71 char FailedOpenCode[] = IN_FILE" not found\n"; 72 char FailedReadCode[] = "Read "IN_FILE" failed\n"; 73 char FailedInvalidCode[] = "Invalid "IN_FILE"\n"; 74 char FailedOpenMBR[] = MERGE_FILE" not found\n"; 75 char FailedReadMBR[] = "Read "MERGE_FILE" failed\n"; 76 char FailedInvalidMBR[] = "Invalid "MERGE_FILE"\n"; 77 char FailedWriteCode[] = "Write "OUT_FILE" failed\n"; 78 79 /* The signature we search for in the AIR-BOOT.COM image */ 80 char MBRProtectionSignature[] = "AiR-BOOT MBR-Protection Image"; 81 82 /* File buffers */ 83 char BootCode[IMAGE_SIZE]; // Buffer for boot-image 84 char MBRProtection[1024]; // Buffer for protection-image 85 86 87 88 89 /* 90 // Main Entrypoint. 91 */ 27 92 int main(int argc, char* argv[]) { 28 FILE* ifile = NULL; 29 FILE* mfile = NULL; 30 FILE* ofile = NULL; 31 93 FILE* ifile = NULL; 94 FILE* mfile = NULL; 95 FILE* ofile = NULL; 96 size_t ibytes = 0; 97 size_t mbytes = 0; 98 size_t obytes = 0; 99 unsigned i = 0; 100 unsigned found = 0; 101 102 103 #if DEBUG_LEVEL > 0 104 printf("\n%s\n", welcome); 105 printf("Debug level is: %d\n\n", DEBUG_LEVEL); 106 #endif 107 108 /* 109 // Show copyright message. 110 */ 111 printf("%s",Copyright); 112 113 /* 114 // Load AIR-BOOT.COM 115 */ 116 printf("%s",LoadCode); 32 117 ifile = fopen(IN_FILE, "rb"); 118 if (!ifile) { 119 printf("%s",FailedOpenCode); 120 exit(1); 121 } 122 ibytes = fread(BootCode, 1, IMAGE_SIZE, ifile); 123 if (ferror(ifile)) { 124 printf("%s",FailedReadCode); 125 exit(1); 126 } 127 //printf("ibytes: %d\n", ibytes); 128 fread(BootCode, 1, 1, ifile); 129 if (ibytes != IMAGE_SIZE || !feof(ifile)) { 130 printf("%s", FailedInvalidCode); 131 exit(1); 132 } 133 printf("%s", Okay); 134 135 136 /* 137 // Load MBR-PROT.BIN 138 */ 139 printf("%s",LoadMBR); 33 140 mfile = fopen(MERGE_FILE, "rb"); 141 if (!mfile) { 142 printf("%s",FailedOpenMBR); 143 exit(1); 144 } 145 mbytes = fread(MBRProtection, 1, MBRPROT_SIZE, mfile); 146 if (ferror(mfile)) { 147 printf("%s",FailedReadMBR); 148 exit(1); 149 } 150 fread(MBRProtection, 1, 1, mfile); 151 if (mbytes != MBRPROT_SIZE || !feof(mfile)) { 152 printf("%s", FailedInvalidMBR); 153 exit(1); 154 } 155 printf("%s", Okay); 156 157 158 /* 159 // Find Protection Image Signature. 160 // Note that this signature must reside on a sector boundary. 161 */ 162 for (i=0; i<55; i++) { 163 if (!memcmp(MBRProtectionSignature, &BootCode[i*SECSIZE], strlen(MBRProtectionSignature))) { 164 found = 1; 165 break; 166 } 167 } 168 169 /* 170 // Merge Protection Image. 171 */ 172 printf("%s",MergeMBR); 173 if (!found) { 174 printf("%s",Failed); 175 exit(2); 176 } 177 memcpy(&BootCode[i*SECSIZE], MBRProtection, MBRPROT_SIZE); 178 printf("%s", Okay); 179 180 181 /* 182 // Count Code Sectors. 183 // Obsolete now since the Protection Image has moved just below the 184 // Configuration and the code is always max. size. 185 // Overlap checking is done while assembling AIR-BOOT.ASM. 186 */ 187 printf("%s", CountCode); 188 BootCode[16] = 53; 189 printf("%s", Okay); 190 191 /* 192 // Write AIRBOOT.BIN 193 */ 194 printf("%s", WriteCode); 34 195 ofile = fopen(OUT_FILE, "wb"); 35 36 37 printf("\n%s\n", welcome); 38 39 #if DEBUG_LEVEL > 0 40 printf("Debug level is: %d", DEBUG_LEVEL); 41 #endif 42 43 196 if (!ofile) { 197 printf("%s", FailedWriteCode); 198 exit(3); 199 } 200 obytes = fwrite(BootCode, 1, IMAGE_SIZE, ofile); 201 if (obytes != IMAGE_SIZE || ferror(ofile)) { 202 printf("%s", FailedWriteCode); 203 exit(3); 204 } 205 printf("%s", Okay); 206 207 208 /* 209 // Close files. 210 */ 211 if (ifile) 212 fclose(ifile); 213 if (mfile) 214 fclose(mfile); 215 if (ofile) 216 fclose(ofile); 44 217 45 218 -
trunk/TOOLS/INTERNAL/FIXCODE.H
r37 r46 6 6 #define PLATFORM_DOS 7 7 #elif defined(__OS2__) && !defined(OS2) 8 #define INCL_NOPMAPI9 #define INCL_BASE10 #define INCL_DOS11 #define INCL_DOSDEVIOCTL12 #include <os2.h>13 8 #define PLATFORM_OS2 14 9 #elif defined(__NT__) 15 #include <windows.h>16 10 #define PLATFORM_WINNT 17 11 #elif defined(__LINUX__) … … 21 15 #endif 22 16 17 23 18 #include <stdlib.h> 24 19 #include <stdio.h> … … 26 21 27 22 28 29 30 31 32 33 34 35 23 #define IMAGE_SIZE 31744 24 #define MBRPROT_SIZE 1024 25 #define SECSIZE 512 36 26 37 27 #endif 38 39 40 41 42 43 -
trunk/TOOLS/INTERNAL/Makefile
r37 r46 102 102 # 103 103 CC16=wcc 104 CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -fo=$^. 105 CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^. 106 CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -fo=$^. 104 MM16=-ml 105 CC16_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -w4 -e25 -zq -otexan -fo=$^. -fr=$^&.ERR 106 CC16_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d2 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR 107 CC16_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM16) -d2 -w4 -e25 -zq -od -fo=$^. -fr=$^&.ERR 107 108 CC16_FLAGS=$(CC16_FLAGS_D$(DEBUG_LEVEL)) 108 109 … … 110 111 # 32-bits C Compiler 111 112 # 113 MM32=-mf 112 114 CC32=wcc386 113 CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -w4 -e25 -zq -od -6r -mf -fo=$^.114 CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.115 CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) -d2 -w4 -e25 -zq -od -6r -mf -fo=$^.115 CC32_FLAGS_D0=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -w4 -e25 -zq -otexan -6r -fo=$^. -fr=$^&.ERR 116 CC32_FLAGS_D1=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR 117 CC32_FLAGS_D2=-dDEBUG_LEVEL=$(DEBUG_LEVEL) $(MM32) -d2 -w4 -e25 -zq -od -6r -fo=$^. -fr=$^&.ERR 116 118 CC32_FLAGS_R=-w4 -e25 -zq -od -6r -mf -fo=$^. 117 119 CC32_FLAGS=$(CC32_FLAGS_D$(DEBUG_LEVEL)) … … 210 212 # 211 213 212 #213 # While the DOS build-environment has been kept alive in this version,214 # it has several drawbacks:215 # - No support for long filenames216 # - Very limited memory217 # - JWasmR does not work because of memory limitations218 # - JWasmD does not work at all219 # - Batch scripting is very rudimentairy220 #221 # Therefore, the DOS build-environment will most probably disappear222 # in future versions.223 # This does not influence the building of DOS targets, which can be done224 # on OS/2, Windows or Linux.225 #226 227 228 214 229 215 … … 244 230 @echo TARGET: $^&.COM [DOS 16-bits COM-file] 245 231 $(ASM) $(ASM_FLAGS) $(BASENAME).ASM 246 @wdis $^. > $^&.WDA232 @wdis -fi $^. > $^&.WDA 247 233 248 234 … … 259 245 @echo TARGET: $^&.EXE [DOS 16-bits Executable] 260 246 $(CC16) $(CC16_FLAGS) -bt=dos $(BASENAME).C 261 @wdis $^. > $^&.WDA247 @wdis -fi $^. > $^&.WDA 262 248 263 249 … … 274 260 @echo TARGET: $^&.EXE [NT 32-bits Executable] 275 261 $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)nt -bt=nt $(BASENAME).C 276 @wdis $^. > $^&.WDA262 @wdis -fi $^. > $^&.WDA 277 263 278 264 … … 289 275 @echo TARGET: $^&.EXE [OS/2 32-bits Executable] 290 276 $(CC32) $(CC32_FLAGS) -I$(%WATCOM)$(DS)h$(DS)os2 -bt=os2 $(BASENAME).C 291 @wdis $^. > $^&.WDA277 @wdis -fi $^. > $^&.WDA 292 278 293 279 … … 305 291 @echo TARGET: $^&.ELF [Linux 32-bits Executable] 306 292 $(CC32) $(CC32_FLAGS) -bt=linux $(BASENAME).C 307 @wdis $^. > $^&.WDA293 @wdis -fi $^. > $^&.WDA 308 294 309 295 … … 330 316 @if exist *.OBJ $(RM) *.OBJ 331 317 @if exist *.WDA $(RM) *.WDA 318 @if exist *.NDA $(RM) *.NDA 332 319 @if exist *.MAP $(RM) *.MAP 333 320 @if exist *.LST $(RM) *.LST
Note:
See TracChangeset
for help on using the changeset viewer.