source: trunk/bootcode/regular/other.asm@ 95

Last change on this file since 95 was 95, checked in by Ben Rietbroek, 8 years ago

Moved 'CheckFor13extensions' to module 'driveio' [v1.1.1-testing]

CAUTION:
This is a testbuild !
AirBoot uses the BIOS to access disks and a small coding error can trash
partition tables or other vital disk structures. You are advised to make
backups of TRACK0 and EBRs before using this testbuild. More info at:
https://rousseaux.github.io/netlabs.air-boot/pdf/AirBoot-v1.1.0-manual.pdf

File size: 16.0 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 MODULE_NAMES
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 ret
82GetLenOfStrings EndP
83
84
85
86
87;
88; DO PREPARING STUFF.
89;
90PRECRAP_Main Proc Near
91 ; First initialize Variable-Area (everything with NUL)
92 ; We use the start instead of the variables because they could be 'orged'
93 ; to an offset. We want everything after the code to be nullified.
94 mov di, offset sobss
95 mov cx, offset EndOfVariables - offset sobss
96 xor ax, ax
97 shr cx, 1
98 inc cx
99 rep stosw
100
101
102 ;
103 ; Tasm needs .386 to handle 32-bit constants so we push the current
104 ; operating state and switch temporarily to handle
105 ; InitialFreeDriveletterMap.
106 ;
107 IFDEF TASM
108 pushstate
109 .386
110 ENDIF
111 ; Initialize the FreeDriveletterMap.
112 ; This is used by driveletter reassignment functions.
113 mov di, offset [FreeDriveletterMap]
114 mov ax, InitialFreeDriveletterMap AND 0ffffh
115 cld
116 stosw
117 mov ax, InitialFreeDriveletterMap SHR 16
118 stosw
119 ;
120 ; Restore Tasm operating state.
121 ;
122 IFDEF TASM
123 popstate
124 ENDIF
125
126
127 ; Use video page 0 for screen output
128 mov word ptr [VideoIO_Segment], VideoIO_Page0
129
130 ; Don't use blinking attribute
131 call VideoIO_NoBlinking
132
133 ; Get HardDriveCount
134 call DriveIO_GetHardDriveCount
135
136
137 ; Rousseau: added
138 call VideoIO_ClearScreen
139
140 ; Cursor to upper-left
141 mov byte ptr [TextPosX], 0
142 mov byte ptr [TextPosY], 0
143 call VideoIO_CursorSet
144
145 ;~ mov ax, VideoIO_Page1
146 ;~ call VideoIO_BackUpTo ; Copy BIOS POST to Second Page
147
148 ; Copyright
149 mov si, offset Copyright
150 call MBR_Teletype
151 xor si,si
152 call MBR_TeletypeNL
153
154
155 ;call SOUND_Beep
156
157 ; Show build info
158 call VideoIO_PrintBuildInfo
159
160 IFDEF AUX_DEBUG
161 ; Initialize the com-port for debugging
162 call AuxIO_Init
163 ENDIF
164
165 xor si,si
166 call MBR_TeletypeNL
167
168 ;
169 ; Write MBR back to disk to sync MBR variables.
170 ; Otherwise subsequent MBR loads will differ from the RAM stored one,
171 ; which is used by MBR protection to validate parts of the MBR.
172 ;
173 xor bx, bx
174 mov cx, 1
175 xor dh, dh
176 mov dl, [BIOS_BootDisk]
177 mov al, 1
178 mov ah, 03h
179 int 13h
180
181
182 ; Start with disk at index 0
183 xor cx,cx
184
185 PRECRAP_Main_next_disk:
186
187 ; Get next disk and convert to BIOS disk-number
188 mov dl,cl
189 or dl,80h
190
191 ;
192 ; This also setup the size of the i13xbuf.
193 ;
194 call DriveIO_GatherDiskInfo ; Also used to fill the geo, should be separate function
195
196 mov bx,offset [HugeDisk]
197 add bx,cx
198 mov [bx], al
199
200
201 ; CHECKSUM CALCULATION DOES NOT WORK YET HERE
202 ; CRC TABLE NOT INITED YET
203 ; Returns NC if no valid LVM record found
204 call DriveIO_LoadMasterLVMSector
205
206 pushf
207
208 ;~ mov al,'#'
209 ;~ pushf
210 ;~ call VideoIO_PrintSingleChar
211 ;~ popf
212 ;~ mov al,0
213 ;~ rcl al,1
214 ;~ call VideoIO_PrintHexByte
215 ;~ mov al,'#'
216 ;~ call VideoIO_PrintSingleChar
217
218 mov bx, offset [TrueSecs]
219 add bx,cx
220 add bx,cx
221 add bx,cx
222 add bx,cx
223 popf
224
225 ; bx now contains pointer to truesecs for this drive
226
227 jnc NoValidMasterLVM
228
229 ; ?? 3f bij disk 80h maar 0 bij disk 81h
230 mov si,offset [LVMSector]
231 mov ax,[si+LocLVM_Secs]
232
233 ;~ pusha
234 ;~ mov dx,ax
235 ;~ mov al,'%'
236 ;~ call VideoIO_PrintSingleChar
237 ;~ mov ax,dx
238 ;~ call VideoIO_PrintHexWord
239 ;~ mov al,'%'
240 ;~ call VideoIO_PrintSingleChar
241 ;~ popa
242
243 mov word ptr [bx],ax
244 jmp SkipUseBiosSecs
245
246
247 NoValidMasterLVM:
248 push bx ; push truesecs pointer
249 mov bx, offset [BIOS_Secs]
250 add bx,cx
251 add bx,cx
252 add bx,cx
253 add bx,cx
254
255 mov ax,[bx] ; get biossecs
256 pop bx
257 mov word ptr [bx],ax ; store bios secs in truesecs
258
259
260 SkipUseBiosSecs:
261 inc cx
262 cmp cl,[TotalHarddiscs]
263 jb PRECRAP_Main_next_disk
264
265
266
267 IFDEF AUX_DEBUG
268 ; Write some debug-info to the com-port
269 call DEBUG_Dump1
270 ENDIF
271
272 ;~ jz NoValidMasterLVM
273;~
274 ;~ ; A valid Master LVM has been found.
275 ;~ ; We use the values in here to determine the number of sectors per track,
276 ;~ ; since this could be OS/2 extended geometry.
277;~
278 ;~ jmp Continue1
279 ;~
280 ;~ mov word ptr [LOG_Secs],63
281
282; mov al,[HugeDisk] ;; fout, moet nog index bij
283; call AuxIO_TeletypeHexByte
284; call AuxIO_TeletypeNL
285
286; mov ax,word ptr [TrueSecs] ;; fout, moet nog index bij
287; call AuxIO_TeletypeHexWord
288; call AuxIO_TeletypeNL
289
290
291
292 ; Huge Disk indicator
293 mov si, offset [HugeBootDisk]
294 call MBR_Teletype
295 mov al,[HugeDisk]
296 mov si, offset [No]
297 test al,al
298 jz MBR_HugeDriveIndicator
299 mov si, offset [Yes]
300
301 MBR_HugeDriveIndicator:
302 call MBR_Teletype
303 xor si,si
304 call MBR_TeletypeNL
305
306
307 ;
308 ; Phase 1 Indicator
309 ;
310 mov si, offset [Phase1]
311 call MBR_Teletype
312
313 mov si, offset OS2_InstallVolume
314 mov al, [si]
315 test al,al ; See if phase 1 is active
316 jnz MBR_Main_BootThrough
317 mov si, offset NotActive
318
319 MBR_Main_BootThrough:
320 call MBR_Teletype
321 xor si,si
322 call MBR_TeletypeNL
323
324
325 ; Calculate Cooper-Bar Tables
326 IFDEF FX_ENABLED
327 call FX_CalculateTables
328 ENDIF
329
330 ; Calculate LVM-CRC-Table
331 call LVM_InitCRCTable
332
333 ; Get HardDriveCount
334 call DriveIO_GetHardDriveCount
335
336 ; Calculate CHS/LBA Switch Table
337 call DriveIO_InitLBASwitchTable
338
339 ; Setup PartitionPointers-Table
340 call PART_CalculateStraightPartPointers
341
342 ; Setup Cyrillic Charset, if needed
343 IFDEF TXT_IncludeCyrillic
344 call CHARSET_IncludeCyrillic
345 ENDIF
346
347
348 ; This sets [CurIO_UseExtension] flag.
349 call DriveIO_CheckFor13extensions
350 mov al,[CurIO_UseExtension]
351 test al,al
352 jnz INT13X_Supported
353
354 ;
355 ; Show Message that BIOS INT13X is not supported
356 ; and Halt the System.
357 ;
358 mov cx, 0C04h
359 mov si, offset TXT_NoINT13XSupport
360 call SETUP_ShowErrorBox
361
362 ; Halt the system.
363 jmp HaltSystem
364
365
366 ;
367 ; INT13X Supported so continue.
368 ;
369 INT13X_Supported:
370
371
372 ;
373 ; Check valididy of the AiR-BOOT Configuration.
374 ;
375 call PRECRAP_CheckConfiguration
376
377
378 ; =======================================
379 ; Checks for MBR Virii :) I love that job
380 ; =======================================
381 test byte ptr [CFG_DetectStealth], 1
382 jz PCM_NoStealthDetection
383 call VIRUS_CheckForStealth
384 PCM_NoStealthDetection:
385 test byte ptr [CFG_DetectVirus], 1
386 jz PCM_NoVirusDetection
387 call VIRUS_CheckForVirus
388 PCM_NoVirusDetection:
389
390
391 ; ============================================
392 ; Delay for some time and get Strg/Alt State
393 ; ============================================
394 test byte ptr [CFG_CooperBars], 1
395 jnz PCM_ShortDelay
396 mov al, 27 ; About 1.5 seconds
397 test byte ptr [CFG_FloppyBootGetName], 1
398 jz PCM_LongDelay
399 PCM_ShortDelay:
400
401 mov al, 13 ; shorten delay,if floppy gets accessed
402 PCM_LongDelay:
403
404 call TIMER_WaitTicCount
405
406 ; First check, if any normal key got pressed...
407 mov ah, 1
408 int 16h
409 jz PCM_NoNormalKeyPressed
410 ; User doesn't know what to do...or he is crazy <g> so display message
411 mov si, offset TXT_HowEnterSetup
412 call MBR_Teletype
413 mov al, 54 ; about 3 seconds, delay again
414
415 call TIMER_WaitTicCount
416
417 PCM_NoNormalKeyPressed:
418 ; Now get keyboard Strg/Alt State
419 mov ah, 02h
420 int 16h
421 mov [SETUP_KeysOnEntry], al
422
423 ; Copy device-name to the ContBIOSbootSeq-IPT entry
424 ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
425 ; this check will fail.
426 call PART_UpdateResumeBIOSName
427 ret
428PRECRAP_Main EndP
429
430
431
432
433AFTERCRAP_Main Proc Near
434 ; ===================================================
435 ; Now get volume label of FloppyDrive, if wanted...
436 ; ===================================================
437 test byte ptr [CFG_FloppyBootGetName], 1
438 jz ACM_NoFloppyGetName
439 call DriveIO_UpdateFloppyName
440 or ax, ax
441 jnz ACM_NoFloppyGetName
442 ; Try a second time, if it failed to detect the Floppy
443 call DriveIO_UpdateFloppyName
444 ACM_NoFloppyGetName:
445 ret
446AFTERCRAP_Main EndP
447
448
449; Checks Configuration CheckSum...Displays message, if failed.
450PRECRAP_CheckConfiguration Proc Near Uses ds si es di
451 mov si, offset Configuration
452 xor bx, bx
453
454 ; Changed from 5 to calculated value (not here, see compat. issue below)
455 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
456 ; Size of the ab-configuration in 512 byte sectors
457 ; mov cx, (MBR_BackUpMBR - Configuration) / 200h
458
459 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
460 ; AB v1.0.8+ *should* stores a 7 sector configuration with a
461 ; 7 sector checksum.
462 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8+
463 ; config as corrupted, while this is not the case.
464 ; So, for compatibility reasons, in v1.0.8+, the checksum stored is over
465 ; 5 sectors, to be compatible with v1.07.
466 ; This may change (be corrected) in future versions !
467 mov cx,5
468
469 mov dx, [CFG_CheckConfig]
470 mov [CFG_CheckConfig], bx
471 PCCC_Loop:
472 call MBR_GetCheckOfSector
473 loop PCCC_Loop
474 cmp bx, dx
475 jne PCCC_Failed
476 mov CFG_CheckConfig, dx
477 ret
478 PCCC_Failed:
479 mov si, offset TXT_ERROR_CheckConfig
480 call MBR_Teletype
481 mov si, offset TXT_ERROR_CheckFailed
482 call MBR_Teletype
483 jmp MBR_HaltSystem
484PRECRAP_CheckConfiguration EndP
485
486
487; Rousseau: added
488; In: SI - Pointer to begin of string (EOS is 0)
489; Destroyed: SI
490; Fixme: Uses double writes to use attribute with teletype-function.
491MBR_TeletypeBold Proc Near Uses ax bx cx
492 MBRT_LoopBold:
493 lodsb
494 or al, al
495 jz MBRT_EndBold
496 push ax
497 mov ah,09h
498 mov bx,15
499 mov cx,1
500 int 10h
501 pop ax
502 mov ah,0eh
503 mov bx,7 ; Does not do anything in text-modus
504 mov cx,1
505 int 10h
506 jmp MBRT_LoopBold
507 MBRT_EndBold:
508 ret
509MBR_TeletypeBold EndP
510
511
512; In: SI - Pointer to begin of string (EOS is 0)
513; Destroyed: SI
514; Fixme: Uses double writes to use attribute with teletype-function.
515MBR_TeletypeVolName Proc Near Uses ax bx cx
516 mov cx, 11
517 MBRT_LoopVolName:
518 mov dx,cx ; Backup counter
519 lodsb
520 or al, al
521 jz MBRT_EndVolName
522 push ax
523 mov ah,09h
524 mov bx,15
525 mov cx,1
526 int 10h ; DX is preserved
527 pop ax
528 mov ah,0eh
529 mov bx,7 ; Does not do anything in text-modus
530 mov cx,1
531 int 10h ; DX is preserved
532 mov cx,dx ; Restore counter
533 loop MBRT_LoopVolName
534 MBRT_EndVolName:
535 ret
536MBR_TeletypeVolName EndP
537
538; Rousseau: added
539; Move cursor to next line
540; Just do a new-line if SI==0
541MBR_TeletypeNL Proc Near Uses ax bx cx
542 test si,si
543 jz MBR_TeletypeNL_NL
544 call MBR_Teletype
545 MBR_TeletypeNL_NL:
546 push si
547 mov si, offset NL
548 call MBR_Teletype
549 pop si
550 ret
551MBR_TeletypeNL EndP
552
553; Sync teletype position to VideoIO
554MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
555 pushf
556 mov bh, 0
557 mov ah, 02h
558 mov dh,byte ptr [TextPosY]
559 mov dl,byte ptr [TextPosX]
560 int 10h
561 popf
562 ret
563MBR_TeletypeSyncPos EndP
Note: See TracBrowser for help on using the repository browser.