source: trunk/BOOTCODE/REGULAR/OTHER.ASM@ 34

Last change on this file since 34 was 32, checked in by Ben Rietbroek, 13 years ago

Fixed Win7 boot from FAT32 and HPFS zero-drive ussue [2011-11-20]

Fixes

o Fixed booting Windows 7 from FAT32

Booting Windows (NT/2K/XP/Vista/7) from FAT32 when the actual system
resides on an NTFS partition actually chainload the Windows
boot-loader in the FAT32 partition.
A bug in the handling of such a FAT32 partition with the Windows
boot-loader caused it not to find NTLDR is some cases.

o Fixed HPFS zero-drive issue

The BPB contains a field that indicates the boot-drive to the
OS2BOOT and OS2LDR programs. When creating an HPFS partition and
then restoring a system from archive (i.e. a zip-file) of course
does not set this field, since only files are restored.
This causes the boot process to halt with "...cannot operate..."
or even boot another HPFS partition. This field is now derived from
the LVM drive-letter if it contains an incorrect value.

o Corrected CRC calculations on AiR-BOOT configuration

V1.07 expanded the number of partitions from 30 to 45.
However, this was not done correctly and the configuration CRC was
still caclulated over 5 sectors. Initial v1.0.8 code corrected this
but this results in the v1.07 installer and setaboot programs
breaking on v1.0.8 code. So, for the time being the CRC caclucation
is reverted back to 5 sectors for the sake of v1.07 compatibility.
Save and restore of the configuration use 7 sectors of course.

o Corrected contact information

V1.07 shipped with the wrong contact information, causing issues
to be reported on sourceforge instead of netlabs.

Changes

o Renamed original README.TXT to README.MKW
o Added 1README.TXT
o Added COPYING (GNU License)

Note

This commit and all following commits upto and including the RC3
commit [2012-09-09] are delayed commits from a local repository.
Also, the RC (Release Candidate) naming of the corresponding commits
is a bit misleading. One would label a revision with RC when near to
a final release. Since many things have changed between RC1,RC2 & RC3,
these RC's should be interpreted as mile-stones.

WARNING!!

All commits upto and including the commit of [2012-05-13] contain
a severe bug!! Building from these sources and then disabling
the 'force LBA' feature while also using the drive-letter feature or
editing the label can destroy the MBR on all attached disks!!
DO NOT DISABLE 'FORCE LBA USAGE' WHEN BUILT FROM THE ABOVE COMMITS!!

File size: 14.2 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; AiR-BOOT / OTHER ROUTINES
20;---------------------------------------------------------------------------
21
22IFDEF ModuleNames
23DB 'OTHER',0
24ENDIF
25
26; In: DS:SI - Pointer to begin of string
27; CX - Len of string
28; Out: CX - Supposed real len of string
29; Zero Flag set if nul string
30; Destroyed: None
31GetLenOfName Proc Near Uses ax si
32 add si, cx
33 dec si
34 GLON_NameLoop:
35 mov al, ds:[si]
36 dec si
37 cmp al, 32
38 ja GLON_EndLoop
39 dec cx
40 jnz GLON_NameLoop
41 GLON_EndLoop:
42 or cx, cx
43 ret ; return supposed len
44GetLenOfName EndP
45
46; In: DS:SI - Pointer to NUL-terminated string
47; Out: CX - Length of string
48; Zero Flag set if nul string
49; Destroyed: None
50GetLenOfString Proc Near Uses ax si
51 xor cx, cx
52 GLOS_StringLoop:
53 lodsb
54 or al, al
55 jz GLOS_EndOfString
56 inc cx
57 jmp GLOS_StringLoop
58
59 GLOS_EndOfString:
60 or cx, cx
61 ret
62GetLenOfString EndP
63
64; In: DS:SI - Pointer to NUL-terminated strings
65; CL - Counter, how many strings to count
66; Out: CX - Length of strings
67; Destroyed: None
68GetLenOfStrings Proc Near Uses bx dx si
69 mov dh, cl
70 xor dl, dl
71 GLOSS_StringsLoop:
72 call GetLenOfString
73 add dl, cl
74 add si, cx
75 inc si
76 dec dh
77 jnz GLOSS_StringsLoop
78 ;movzx cx, dl
79 mov cl,dl
80 mov ch,0
81
82 ret
83GetLenOfStrings EndP
84
85PRECRAP_Main Proc Near Uses
86 ; First initialize Variable-Area (everything with NUL)
87 mov di, offset BeginOfVariables
88 mov cx, offset EndOfVariables-offset BeginOfVariables
89 xor ax, ax
90 shr cx, 1
91 inc cx
92 rep stosw
93
94 mov VideoIO_Segment, VideoIO_Page0
95
96 ; Don't use blinking attribute
97 call VideoIO_NoBlinking
98
99 ; Get HardDriveCount
100 call DriveIO_GetHardDriveCount
101
102
103 ; Rousseau: added
104 call VideoIO_ClearScreen
105
106 ; Cursor to upper-left
107 mov TextPosX, 0
108 mov TextPosY, 0
109 call VideoIO_CursorSet
110
111 ;mov ax, VideoIO_Page1
112 ;call VideoIO_BackUpTo ; Copy BIOS POST to Second Page
113
114 ; Copyright
115 mov si, offset Copyright
116 call MBR_Teletype
117 xor si,si
118 call MBR_TeletypeNL
119
120
121 ;call SOUND_Beep
122
123 ; Build Date
124 mov si, offset BUILD_DATE
125 call MBR_TeletypeNL
126
127 ; Initialize the com-port for debugging
128; call AuxIO_Init
129
130 xor si,si
131 call MBR_TeletypeNL
132
133 xor cx,cx
134 PRECRAP_Main_next_disk:
135
136 mov dl,cl
137 or dl,80h
138
139 call DriveIO_GatherDiskInfo ; Also used to fill the geo, should be separate function
140
141 mov bx,offset HugeDisk
142 add bx,cx
143 mov [bx], al
144
145 call DriveIO_LoadMasterLVMSector ; returns NC if no valid LVM record found
146
147 pushf
148
149; mov al,'#'
150; pushf
151; call VideoIO_PrintSingleChar
152; popf
153; mov al,0
154; rcl al,1
155; call VideoIO_PrintHexByte
156; mov al,'#'
157; call VideoIO_PrintSingleChar
158
159 mov bx, offset TrueSecs
160 add bx,cx
161 add bx,cx
162 add bx,cx
163 add bx,cx
164 popf
165
166 ; bx now contains pointer to truesecs for this drive
167
168 jnc NoValidMasterLVM
169
170 ; ?? 3f bij disk 80h maar 0 bij disk 81h
171 mov si,offset LVMSector
172 mov ax,[si+LocLVM_Secs]
173
174; pusha
175; mov dx,ax
176; mov al,'%'
177; call VideoIO_PrintSingleChar
178; mov ax,dx
179; call VideoIO_PrintHexWord
180; mov al,'%'
181; call VideoIO_PrintSingleChar
182; popa
183
184 mov word ptr [bx],ax
185 jmp SkipUseBiosSecs
186
187
188 NoValidMasterLVM:
189 push bx ; push truesecs pointer
190 mov bx, offset BIOS_Secs
191 add bx,cx
192 add bx,cx
193 add bx,cx
194 add bx,cx
195
196 mov ax,[bx] ; get biossecs
197 pop bx
198 mov word ptr [bx],ax ; store bios secs in truesecs
199
200
201 SkipUseBiosSecs:
202 inc cx
203 cmp cl,[TotalHarddiscs]
204 jb PRECRAP_Main_next_disk
205
206
207
208IFDEF AuxDebug
209 ; Write some debug-info to the com-port
210 call DEBUG_Dump1
211ENDIF
212
213 ; jz NoValidMasterLVM
214
215
216 ; A valid Master LVM has been found.
217 ; We use the values in here to determine the number of sectors per track,
218 ; since this could be OS/2 extended geometry.
219
220 ; jmp Continue1
221
222
223 ;mov word ptr [LOG_Secs],63
224
225; mov al,[HugeDisk] ;; fout, moet nog index bij
226; call AuxIO_TeletypeHexByte
227; call AuxIO_TeletypeNL
228
229; mov ax,word ptr [TrueSecs] ;; fout, moet nog index bij
230; call AuxIO_TeletypeHexWord
231; call AuxIO_TeletypeNL
232
233
234
235 ; Huge Disk indicator
236 mov si, offset HugeBootDisk
237 call MBR_Teletype
238 mov al,[HugeDisk]
239 mov si, offset No
240 test al,al
241 jz MBR_HugeDriveIndicator
242 mov si, offset Yes
243
244 MBR_HugeDriveIndicator:
245 call MBR_Teletype
246 xor si,si
247 call MBR_TeletypeNL
248
249
250
251
252
253 ;
254 ; Phase 1 Indicator
255 ;
256 mov si, offset Phase1
257 call MBR_Teletype
258
259 mov si, offset eCS_InstallVolume
260 mov al, [si]
261 test al,al ; See if phase 1 is active
262 jnz MBR_Main_BootThrough
263 mov si, offset NotActive
264
265 MBR_Main_BootThrough:
266 call MBR_TeleType
267 xor si,si
268 call MBR_TeletypeNL
269
270
271 ; Calculate Cooper-Bar Tables
272 call FX_CalculateTables
273
274 ; Calculate LVM-CRC-Table
275 call LVM_InitCRCTable
276
277 ; Get HardDriveCount
278 call DriveIO_GetHardDriveCount
279
280 ; Calculate CHS/LBA Switch Table
281 call DriveIO_InitLBASwitchTable
282
283 ; Setup PartitionPointers-Table
284 call PART_CalculateStraightPartPointers
285
286 ; Setup Cyrillic Charset, if needed
287 ifdef TXT_IncludeCyrillic
288 call CHARSET_IncludeCyrillic
289 endif
290
291 call PRECRAP_CheckFor13extensions
292
293 IFNDEF ReleaseCode
294 ret
295 ENDIF
296
297 call PRECRAP_CheckConfiguration
298
299 ; =======================================
300 ; Checks for MBR Virii :) I love that job
301 ; =======================================
302 test CFG_DetectStealth, 1
303 jz PCM_NoStealthDetection
304 call VIRUS_CheckForStealth
305 PCM_NoStealthDetection:
306 test CFG_DetectVirus, 1
307 jz PCM_NoVirusDetection
308 call VIRUS_CheckForVirus
309 PCM_NoVirusDetection:
310
311
312 ; ============================================
313 ; Delay for some time and get Strg/Alt State
314 ; ============================================
315 test CFG_CooperBars, 1
316 jnz PCM_ShortDelay
317 mov al, 27 ; About 1.5 seconds
318 test CFG_FloppyBootGetName, 1
319 jz PCM_LongDelay
320 PCM_ShortDelay:
321
322 mov al, 13 ; shorten delay,if floppy gets accessed
323 PCM_LongDelay:
324
325 call TIMER_WaitTicCount
326
327 ; First check, if any normal key got pressed...
328 mov ah, 1
329 int 16h
330 jz PCM_NoNormalKeyPressed
331 ; User doesn't know what to do...or he is crazy <g> so display message
332 mov si, offset TXT_HowEnterSetup
333 call MBR_Teletype
334 mov al, 54 ; about 3 seconds, delay again
335
336 call TIMER_WaitTicCount
337
338 PCM_NoNormalKeyPressed:
339 ; Now get keyboard Strg/Alt State
340 mov ah, 02h
341 int 16h
342 mov SETUP_KeysOnEntry, al
343
344 ; Copy device-name to the ContBIOSbootSeq-IPT entry
345 ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
346 ; this check will fail.
347 call PART_UpdateResumeBIOSName
348 ret
349PRECRAP_Main EndP
350
351
352
353AFTERCRAP_Main Proc Near Uses
354 ; ===================================================
355 ; Now get volume label of FloppyDrive, if wanted...
356 ; ===================================================
357 test CFG_FloppyBootGetName, 1
358 jz ACM_NoFloppyGetName
359 call DriveIO_UpdateFloppyName
360 or ax, ax
361 jnz ACM_NoFloppyGetName
362 ; Try a second time, if it failed to detect the Floppy
363 call DriveIO_UpdateFloppyName
364 ACM_NoFloppyGetName:
365 ret
366AFTERCRAP_Main EndP
367
368PRECRAP_CheckFor13extensions Proc Near
369 mov ah, 41h
370 mov bx, 55AAh
371 mov dl, 80h
372 int 13h
373 cmp bx, 0AA55h
374 je PCCF13E_Found
375 PCCF13E_NotFound:
376 ret
377 PCCF13E_Found:
378 and cx, 1
379 jz PCCF13E_NotFound
380 mov CurIO_UseExtension, 1
381 ret
382PRECRAP_CheckFor13extensions EndP
383
384; Checks Configuration CheckSum...Displays message, if failed.
385PRECRAP_CheckConfiguration Proc Near Uses ds si es di
386 mov si, offset Configuration
387 xor bx, bx
388
389 ; Changed from 5 to calculated value (not here, see compat. issue below)
390 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
391 ; Size of the ab-configuration in 512 byte sectors
392 ;mov cx, (MBR_BackUpMBR - Configuration) / 200h
393
394 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
395 ; AB v1.0.8 *should* stores a 7 sector configuration with a
396 ; 7 sector checksum.
397 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
398 ; config as corrupted, while this is not the case.
399 ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
400 ; 5 sectors, to be compatible with v1.07.
401 ; This may change (be corrected) in future versions !
402 mov cx,5
403
404 mov dx, CFG_CheckConfig
405 mov CFG_CheckConfig, bx
406 PCCC_Loop:
407 call MBR_GetCheckOfSector
408 loop PCCC_Loop
409 cmp bx, dx
410 jne PCCC_Failed
411 mov CFG_CheckConfig, dx
412 ret
413 PCCC_Failed:
414 mov si, offset TXT_ERROR_CheckConfig
415 call MBR_Teletype
416 mov si, offset TXT_ERROR_CheckFailed
417 call MBR_Teletype
418 jmp MBR_HaltSystem
419PRECRAP_CheckConfiguration EndP
420
421
422; Rousseau: added
423; In: SI - Pointer to begin of string (EOS is 0)
424; Destroyed: SI
425; Fixme: Uses double writes to use attribute with teletype-function.
426MBR_TeletypeBold Proc Near Uses ax bx cx
427 MBRT_LoopBold:
428 lodsb
429 or al, al
430 jz MBRT_EndBold
431 push ax
432 mov ah,09h
433 mov bx,15
434 mov cx,1
435 int 10h
436 pop ax
437 mov ah,0eh
438 mov bx,7 ; Does not do anything in text-modus
439 mov cx,1
440 int 10h
441 jmp MBRT_LoopBold
442 MBRT_EndBold:
443 ret
444MBR_TeletypeBold EndP
445
446; In: SI - Pointer to begin of string (EOS is 0)
447; Destroyed: SI
448; Fixme: Uses double writes to use attribute with teletype-function.
449MBR_TeletypeVolName Proc Near Uses ax bx cx
450 mov cx, 11
451 MBRT_LoopVolName:
452 mov dx,cx ; Backup counter
453 lodsb
454 or al, al
455 jz MBRT_EndVolName
456 push ax
457 mov ah,09h
458 mov bx,15
459 mov cx,1
460 int 10h ; DX is preserved
461 pop ax
462 mov ah,0eh
463 mov bx,7 ; Does not do anything in text-modus
464 mov cx,1
465 int 10h ; DX is preserved
466 mov cx,dx ; Restore counter
467 loop MBRT_LoopVolName
468 MBRT_EndVolName:
469 ret
470MBR_TeletypeVolName EndP
471
472; Rousseau: added
473; Move cursor to next line
474; Just do a new-line if SI==0
475MBR_TeletypeNL Proc Near Uses ax bx cx
476 test si,si
477 jz MBR_TeletypeNL_NL
478 call MBR_Teletype
479 MBR_TeletypeNL_NL:
480 push si
481 mov si, offset NL
482 call MBR_Teletype
483 pop si
484 ret
485MBR_TeletypeNL EndP
486
487; Sync teletype position to VideoIO
488MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
489 pushf
490 mov bh, 0
491 mov ah, 02h
492 mov dh,[TextPosY]
493 mov dl,[TextPosX]
494 int 10h
495 popf
496 ret
497MBR_TeletypeSyncPos EndP
Note: See TracBrowser for help on using the repository browser.