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

Last change on this file since 65 was 57, checked in by Ben Rietbroek, 10 years ago

All source-files lowercased [v1.1.1-testing]

Some standard files like 'COPYING', 'LICENSE', etc. have not been
converted to lower case because they are usually distributed uppercased.

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