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

Last change on this file since 47 was 46, checked in by Ben Rietbroek, 12 years ago

Various Changes [2012-04-14]

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 THESE COMMITS!!

Changes

o Added BLDLEVEL support
o Enhanced Master Make
o Sanitized sources
o Support for Wasm and Masm6 (experimental)
o Renamed MBR_PROT.ASM to MBR-PROT.ASM
o Merged bitfield code Into Installer
o First steps for cross platform Installer
o More...

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