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

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

Converting to JWasm -- phase 3 (not working) [2012-02-16]

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

Problems

o Problem with location of BSS
o Problem with segments

Info

o Adjusted DISCLAIM.TXT

File size: 14.3 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
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
292 ; This sets [CurIO_UseExtension] flag.
293 call PRECRAP_CheckFor13extensions
294
295
296
297 IFNDEF ReleaseCode
298 ret
299 ENDIF
300
301
302 call PRECRAP_CheckConfiguration
303
304
305 ; =======================================
306 ; Checks for MBR Virii :) I love that job
307 ; =======================================
308 test CFG_DetectStealth, 1
309 jz PCM_NoStealthDetection
310 call VIRUS_CheckForStealth
311 PCM_NoStealthDetection:
312 test CFG_DetectVirus, 1
313 jz PCM_NoVirusDetection
314 call VIRUS_CheckForVirus
315 PCM_NoVirusDetection:
316
317
318 ; ============================================
319 ; Delay for some time and get Strg/Alt State
320 ; ============================================
321 test CFG_CooperBars, 1
322 jnz PCM_ShortDelay
323 mov al, 27 ; About 1.5 seconds
324 test CFG_FloppyBootGetName, 1
325 jz PCM_LongDelay
326 PCM_ShortDelay:
327
328 mov al, 13 ; shorten delay,if floppy gets accessed
329 PCM_LongDelay:
330
331 call TIMER_WaitTicCount
332
333 ; First check, if any normal key got pressed...
334 mov ah, 1
335 int 16h
336 jz PCM_NoNormalKeyPressed
337 ; User doesn't know what to do...or he is crazy <g> so display message
338 mov si, offset TXT_HowEnterSetup
339 call MBR_Teletype
340 mov al, 54 ; about 3 seconds, delay again
341
342 call TIMER_WaitTicCount
343
344 PCM_NoNormalKeyPressed:
345 ; Now get keyboard Strg/Alt State
346 mov ah, 02h
347 int 16h
348 mov SETUP_KeysOnEntry, al
349
350 ; Copy device-name to the ContBIOSbootSeq-IPT entry
351 ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
352 ; this check will fail.
353 call PART_UpdateResumeBIOSName
354 ret
355PRECRAP_Main EndP
356
357
358
359AFTERCRAP_Main Proc Near
360 ; ===================================================
361 ; Now get volume label of FloppyDrive, if wanted...
362 ; ===================================================
363 test CFG_FloppyBootGetName, 1
364 jz ACM_NoFloppyGetName
365 call DriveIO_UpdateFloppyName
366 or ax, ax
367 jnz ACM_NoFloppyGetName
368 ; Try a second time, if it failed to detect the Floppy
369 call DriveIO_UpdateFloppyName
370 ACM_NoFloppyGetName:
371 ret
372AFTERCRAP_Main EndP
373
374PRECRAP_CheckFor13extensions Proc Near
375 mov ah, 41h
376 mov bx, 55AAh
377 mov dl, 80h
378 int 13h
379 cmp bx, 0AA55h
380 je PCCF13E_Found
381 PCCF13E_NotFound:
382 ret
383 PCCF13E_Found:
384 and cx, 1
385 jz PCCF13E_NotFound
386 mov CurIO_UseExtension, 1
387 ret
388PRECRAP_CheckFor13extensions EndP
389
390; Checks Configuration CheckSum...Displays message, if failed.
391PRECRAP_CheckConfiguration Proc Near Uses ds si es di
392 mov si, offset Configuration
393 xor bx, bx
394
395 ; Changed from 5 to calculated value (not here, see compat. issue below)
396 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
397 ; Size of the ab-configuration in 512 byte sectors
398 ;mov cx, (MBR_BackUpMBR - Configuration) / 200h
399
400 ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
401 ; AB v1.0.8 *should* stores a 7 sector configuration with a
402 ; 7 sector checksum.
403 ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8
404 ; config as corrupted, while this is not the case.
405 ; So, for compatibility reasons, in v1.0.8, the checksum stored is over
406 ; 5 sectors, to be compatible with v1.07.
407 ; This may change (be corrected) in future versions !
408 mov cx,5
409
410 mov dx, CFG_CheckConfig
411 mov CFG_CheckConfig, bx
412 PCCC_Loop:
413 call MBR_GetCheckOfSector
414 loop PCCC_Loop
415 cmp bx, dx
416 jne PCCC_Failed
417 mov CFG_CheckConfig, dx
418 ret
419 PCCC_Failed:
420 mov si, offset TXT_ERROR_CheckConfig
421 call MBR_Teletype
422 mov si, offset TXT_ERROR_CheckFailed
423 call MBR_Teletype
424 jmp MBR_HaltSystem
425PRECRAP_CheckConfiguration EndP
426
427
428; Rousseau: added
429; In: SI - Pointer to begin of string (EOS is 0)
430; Destroyed: SI
431; Fixme: Uses double writes to use attribute with teletype-function.
432MBR_TeletypeBold Proc Near Uses ax bx cx
433 MBRT_LoopBold:
434 lodsb
435 or al, al
436 jz MBRT_EndBold
437 push ax
438 mov ah,09h
439 mov bx,15
440 mov cx,1
441 int 10h
442 pop ax
443 mov ah,0eh
444 mov bx,7 ; Does not do anything in text-modus
445 mov cx,1
446 int 10h
447 jmp MBRT_LoopBold
448 MBRT_EndBold:
449 ret
450MBR_TeletypeBold EndP
451
452; In: SI - Pointer to begin of string (EOS is 0)
453; Destroyed: SI
454; Fixme: Uses double writes to use attribute with teletype-function.
455MBR_TeletypeVolName Proc Near Uses ax bx cx
456 mov cx, 11
457 MBRT_LoopVolName:
458 mov dx,cx ; Backup counter
459 lodsb
460 or al, al
461 jz MBRT_EndVolName
462 push ax
463 mov ah,09h
464 mov bx,15
465 mov cx,1
466 int 10h ; DX is preserved
467 pop ax
468 mov ah,0eh
469 mov bx,7 ; Does not do anything in text-modus
470 mov cx,1
471 int 10h ; DX is preserved
472 mov cx,dx ; Restore counter
473 loop MBRT_LoopVolName
474 MBRT_EndVolName:
475 ret
476MBR_TeletypeVolName EndP
477
478; Rousseau: added
479; Move cursor to next line
480; Just do a new-line if SI==0
481MBR_TeletypeNL Proc Near Uses ax bx cx
482 test si,si
483 jz MBR_TeletypeNL_NL
484 call MBR_Teletype
485 MBR_TeletypeNL_NL:
486 push si
487 mov si, offset NL
488 call MBR_Teletype
489 pop si
490 ret
491MBR_TeletypeNL EndP
492
493; Sync teletype position to VideoIO
494MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
495 pushf
496 mov bh, 0
497 mov ah, 02h
498 mov dh,[TextPosY]
499 mov dl,[TextPosX]
500 int 10h
501 popf
502 ret
503MBR_TeletypeSyncPos EndP
Note: See TracBrowser for help on using the repository browser.