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

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

Removed the ancient 'ReleaseCode' conditional [v1.1.1-testing]

This was used in pre v1.07 versions to create a DOS .COM executable
for debugging. It has never been used in v1.07+ versions and debugging
is now done using the serial port from native AirBoot. Time to get rid
of this unused stuff.

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: 15.8 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 OS2_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
351 ;
352 ; Check valididy of the AiR-BOOT Configuration.
353 ;
354 call PRECRAP_CheckConfiguration
355
356
357 ; =======================================
358 ; Checks for MBR Virii :) I love that job
359 ; =======================================
360 test byte ptr [CFG_DetectStealth], 1
361 jz PCM_NoStealthDetection
362 call VIRUS_CheckForStealth
363 PCM_NoStealthDetection:
364 test byte ptr [CFG_DetectVirus], 1
365 jz PCM_NoVirusDetection
366 call VIRUS_CheckForVirus
367 PCM_NoVirusDetection:
368
369
370 ; ============================================
371 ; Delay for some time and get Strg/Alt State
372 ; ============================================
373 test byte ptr [CFG_CooperBars], 1
374 jnz PCM_ShortDelay
375 mov al, 27 ; About 1.5 seconds
376 test byte ptr [CFG_FloppyBootGetName], 1
377 jz PCM_LongDelay
378 PCM_ShortDelay:
379
380 mov al, 13 ; shorten delay,if floppy gets accessed
381 PCM_LongDelay:
382
383 call TIMER_WaitTicCount
384
385 ; First check, if any normal key got pressed...
386 mov ah, 1
387 int 16h
388 jz PCM_NoNormalKeyPressed
389 ; User doesn't know what to do...or he is crazy <g> so display message
390 mov si, offset TXT_HowEnterSetup
391 call MBR_Teletype
392 mov al, 54 ; about 3 seconds, delay again
393
394 call TIMER_WaitTicCount
395
396 PCM_NoNormalKeyPressed:
397 ; Now get keyboard Strg/Alt State
398 mov ah, 02h
399 int 16h
400 mov [SETUP_KeysOnEntry], al
401
402 ; Copy device-name to the ContBIOSbootSeq-IPT entry
403 ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
404 ; this check will fail.
405 call PART_UpdateResumeBIOSName
406 ret
407PRECRAP_Main EndP
408
409
410
411
412AFTERCRAP_Main Proc Near
413 ; ===================================================
414 ; Now get volume label of FloppyDrive, if wanted...
415 ; ===================================================
416 test byte ptr [CFG_FloppyBootGetName], 1
417 jz ACM_NoFloppyGetName
418 call DriveIO_UpdateFloppyName
419 or ax, ax
420 jnz ACM_NoFloppyGetName
421 ; Try a second time, if it failed to detect the Floppy
422 call DriveIO_UpdateFloppyName
423 ACM_NoFloppyGetName:
424 ret
425AFTERCRAP_Main EndP
426
427
428
429
430PRECRAP_CheckFor13extensions Proc Near
431 mov ah, 41h
432 mov bx, 55AAh
433 mov dl, 80h
434 int 13h
435 cmp bx, 0AA55h
436 je PCCF13E_Found
437 PCCF13E_NotFound:
438 ret
439 PCCF13E_Found:
440 and cx, 1
441 jz PCCF13E_NotFound
442 mov byte ptr [CurIO_UseExtension], 1
443 ret
444PRECRAP_CheckFor13extensions EndP
445
446
447; Checks Configuration CheckSum...Displays message, if failed.
448PRECRAP_CheckConfiguration Proc Near Uses ds si es di
449 mov si, offset Configuration
450 xor bx, bx
451
452 ; Changed from 5 to calculated value (not here, see compat. issue below)
453 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
454 ; Size of the ab-configuration in 512 byte sectors
455 ; mov cx, (MBR_BackUpMBR - Configuration) / 200h
456
457 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
458 ; AB v1.0.8+ *should* stores a 7 sector configuration with a
459 ; 7 sector checksum.
460 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8+
461 ; config as corrupted, while this is not the case.
462 ; So, for compatibility reasons, in v1.0.8+, the checksum stored is over
463 ; 5 sectors, to be compatible with v1.07.
464 ; This may change (be corrected) in future versions !
465 mov cx,5
466
467 mov dx, [CFG_CheckConfig]
468 mov [CFG_CheckConfig], bx
469 PCCC_Loop:
470 call MBR_GetCheckOfSector
471 loop PCCC_Loop
472 cmp bx, dx
473 jne PCCC_Failed
474 mov CFG_CheckConfig, dx
475 ret
476 PCCC_Failed:
477 mov si, offset TXT_ERROR_CheckConfig
478 call MBR_Teletype
479 mov si, offset TXT_ERROR_CheckFailed
480 call MBR_Teletype
481 jmp MBR_HaltSystem
482PRECRAP_CheckConfiguration EndP
483
484
485; Rousseau: added
486; In: SI - Pointer to begin of string (EOS is 0)
487; Destroyed: SI
488; Fixme: Uses double writes to use attribute with teletype-function.
489MBR_TeletypeBold Proc Near Uses ax bx cx
490 MBRT_LoopBold:
491 lodsb
492 or al, al
493 jz MBRT_EndBold
494 push ax
495 mov ah,09h
496 mov bx,15
497 mov cx,1
498 int 10h
499 pop ax
500 mov ah,0eh
501 mov bx,7 ; Does not do anything in text-modus
502 mov cx,1
503 int 10h
504 jmp MBRT_LoopBold
505 MBRT_EndBold:
506 ret
507MBR_TeletypeBold EndP
508
509
510; In: SI - Pointer to begin of string (EOS is 0)
511; Destroyed: SI
512; Fixme: Uses double writes to use attribute with teletype-function.
513MBR_TeletypeVolName Proc Near Uses ax bx cx
514 mov cx, 11
515 MBRT_LoopVolName:
516 mov dx,cx ; Backup counter
517 lodsb
518 or al, al
519 jz MBRT_EndVolName
520 push ax
521 mov ah,09h
522 mov bx,15
523 mov cx,1
524 int 10h ; DX is preserved
525 pop ax
526 mov ah,0eh
527 mov bx,7 ; Does not do anything in text-modus
528 mov cx,1
529 int 10h ; DX is preserved
530 mov cx,dx ; Restore counter
531 loop MBRT_LoopVolName
532 MBRT_EndVolName:
533 ret
534MBR_TeletypeVolName EndP
535
536; Rousseau: added
537; Move cursor to next line
538; Just do a new-line if SI==0
539MBR_TeletypeNL Proc Near Uses ax bx cx
540 test si,si
541 jz MBR_TeletypeNL_NL
542 call MBR_Teletype
543 MBR_TeletypeNL_NL:
544 push si
545 mov si, offset NL
546 call MBR_Teletype
547 pop si
548 ret
549MBR_TeletypeNL EndP
550
551; Sync teletype position to VideoIO
552MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
553 pushf
554 mov bh, 0
555 mov ah, 02h
556 mov dh,byte ptr [TextPosY]
557 mov dl,byte ptr [TextPosX]
558 int 10h
559 popf
560 ret
561MBR_TeletypeSyncPos EndP
Note: See TracBrowser for help on using the repository browser.