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

Last change on this file since 31 was 31, checked in by Ben Rietbroek, 13 years ago

Bumped code-version to v1.0.8 [2011-11-11]

Fixes

o Fixed the drive-letter feature that was broken in v1.07
o Corrected release date in signature which was not updated with v1.07

Changes

o Bumped code-version in signature to v1.0.8

The extra dot is cosmetic only, the version in the signature
is BCD-coded and did not change format.

o Reworked MBR code to contain two I13X signatures

These signatures are actually MOV EAX,'X31I' in the original eCS
LVM MBR-code. However, they are at different offsets in the v1.x
and v2.x versions of the LVM MBR-code. (v1.x->0d5h -- v2.x->0d0h)
Other code might depend on their existence so we put both in
the AiR-BOOT MBR. (See eCS bugtracker issue #3002)

Note

This commit and all following commits upto and including the RC3
commit [2012-09-09] are delayed commits from a local repository.
Also, the RC (Release Candidate) naming of the corresponding commits
is a bit misleading. One would label a revision with RC when near to
a final release. Since many things have changed between RC1,RC2 & RC3,
these RC's should be interpreted as mile-stones.

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

File size: 13.4 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 Uses
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 ZF=1 if no valid LVM record found
146
147 pushf
148 mov bx, offset TrueSecs
149 add bx,cx
150 add bx,cx
151 add bx,cx
152 add bx,cx
153 popf
154
155 ; bx now contains pointer to truesecs for this drive
156
157 jz NoValidMasterLVM
158
159 mov si,offset LVMSector
160 mov ax,[si+LocLVM_Secs]
161 mov word ptr [bx],ax
162 jmp SkipUseBiosSecs
163
164
165 NoValidMasterLVM:
166 push bx ; push truesecs pointer
167 mov bx, offset BIOS_Secs
168 add bx,cx
169 add bx,cx
170 add bx,cx
171 add bx,cx
172
173 mov ax,[bx] ; get biossecs
174 pop bx
175 mov word ptr [bx],ax ; store bios secs in truesecs
176
177
178 SkipUseBiosSecs:
179 inc cx
180 cmp cl,[TotalHarddiscs]
181 jb PRECRAP_Main_next_disk
182
183
184
185IFDEF AuxDebug
186 ; Write some debug-info to the com-port
187 call DEBUG_Dump1
188ENDIF
189
190 ; jz NoValidMasterLVM
191
192
193 ; A valid Master LVM has been found.
194 ; We use the values in here to determine the number of sectors per track,
195 ; since this could be OS/2 extended geometry.
196
197 ; jmp Continue1
198
199
200 ;mov word ptr [LOG_Secs],63
201
202 mov al,[HugeDisk] ;; fout, moet nog index bij
203 call AuxIO_TeletypeHexByte
204 call AuxIO_TeletypeNL
205
206 mov ax,word ptr [TrueSecs] ;; fout, moet nog index bij
207 call AuxIO_TeletypeHexWord
208 call AuxIO_TeletypeNL
209
210
211
212 ; Huge Disk indicator
213 mov si, offset HugeBootDisk
214 call MBR_Teletype
215 mov al,[HugeDisk]
216 mov si, offset No
217 test al,al
218 jz MBR_HugeDriveIndicator
219 mov si, offset Yes
220
221 MBR_HugeDriveIndicator:
222 call MBR_Teletype
223 xor si,si
224 call MBR_TeletypeNL
225
226
227
228
229
230 ;
231 ; Phase 1 Indicator
232 ;
233 mov si, offset Phase1
234 call MBR_Teletype
235
236 mov si, offset eCS_InstallVolume
237 mov al, [si]
238 test al,al ; See if phase 1 is active
239 jnz MBR_Main_BootThrough
240 mov si, offset NotActive
241
242 MBR_Main_BootThrough:
243 call MBR_TeleType
244 xor si,si
245 call MBR_TeletypeNL ; ALP barks undefined symbol; must use prototypes ?
246
247
248 ; Calculate Cooper-Bar Tables
249 call FX_CalculateTables
250
251 ; Calculate LVM-CRC-Table
252 call LVM_InitCRCTable
253
254 ; Get HardDriveCount
255 call DriveIO_GetHardDriveCount
256
257 ; Calculate CHS/LBA Switch Table
258 call DriveIO_InitLBASwitchTable
259
260 ; Setup PartitionPointers-Table
261 call PART_CalculateStraightPartPointers
262
263 ; Setup Cyrillic Charset, if needed
264 ifdef TXT_IncludeCyrillic
265 call CHARSET_IncludeCyrillic
266 endif
267
268 call PRECRAP_CheckFor13extensions
269
270 IFNDEF ReleaseCode
271 ret
272 ENDIF
273
274 call PRECRAP_CheckConfiguration
275
276 ; =======================================
277 ; Checks for MBR Virii :) I love that job
278 ; =======================================
279 test CFG_DetectStealth, 1
280 jz PCM_NoStealthDetection
281 call VIRUS_CheckForStealth
282 PCM_NoStealthDetection:
283 test CFG_DetectVirus, 1
284 jz PCM_NoVirusDetection
285 call VIRUS_CheckForVirus
286 PCM_NoVirusDetection:
287
288
289 ; ============================================
290 ; Delay for some time and get Strg/Alt State
291 ; ============================================
292 test CFG_CooperBars, 1
293 jnz PCM_ShortDelay
294 mov al, 27 ; About 1.5 seconds
295 test CFG_FloppyBootGetName, 1
296 jz PCM_LongDelay
297 PCM_ShortDelay:
298
299 mov al, 13 ; shorten delay,if floppy gets accessed
300 PCM_LongDelay:
301
302 call TIMER_WaitTicCount
303
304 ; First check, if any normal key got pressed...
305 mov ah, 1
306 int 16h
307 jz PCM_NoNormalKeyPressed
308 ; User doesn't know what to do...or he is crazy <g> so display message
309 mov si, offset TXT_HowEnterSetup
310 call MBR_Teletype
311 mov al, 54 ; about 3 seconds, delay again
312
313 call TIMER_WaitTicCount
314
315 PCM_NoNormalKeyPressed:
316 ; Now get keyboard Strg/Alt State
317 mov ah, 02h
318 int 16h
319 mov SETUP_KeysOnEntry, al
320
321 ; Copy device-name to the ContBIOSbootSeq-IPT entry
322 ; We may not do this before PRECRAP_CheckConfiguration, because otherwise
323 ; this check will fail.
324 call PART_UpdateResumeBIOSName
325 ret
326PRECRAP_Main EndP
327
328
329
330AFTERCRAP_Main Proc Near Uses
331 ; ===================================================
332 ; Now get volume label of FloppyDrive, if wanted...
333 ; ===================================================
334 test CFG_FloppyBootGetName, 1
335 jz ACM_NoFloppyGetName
336 call DriveIO_UpdateFloppyName
337 or ax, ax
338 jnz ACM_NoFloppyGetName
339 ; Try a second time, if it failed to detect the Floppy
340 call DriveIO_UpdateFloppyName
341 ACM_NoFloppyGetName:
342 ret
343AFTERCRAP_Main EndP
344
345PRECRAP_CheckFor13extensions Proc Near
346 mov ah, 41h
347 mov bx, 55AAh
348 mov dl, 80h
349 int 13h
350 cmp bx, 0AA55h
351 je PCCF13E_Found
352 PCCF13E_NotFound:
353 ret
354 PCCF13E_Found:
355 and cx, 1
356 jz PCCF13E_NotFound
357 mov CurIO_UseExtension, 1
358 ret
359PRECRAP_CheckFor13extensions EndP
360
361; Checks Configuration CheckSum...Displays message, if failed.
362PRECRAP_CheckConfiguration Proc Near Uses ds si es di
363 mov si, offset Configuration
364 xor bx, bx
365
366 ; Changed from 5 to calculated
367 ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
368 mov cx, (MBR_BackUpMBR - Configuration) / 2 ; Size of the ab-configuration
369 ; TASM does not evaluate expression above corrrectly.
370 ; Listing shows correct opcode but generated opcode has imm. word byteswapped.
371 ; Casting to byte also does not work (overflow).
372 ; So we swap back here -- must be removed in JWasm version !!
373 xchg ch,cl
374
375 mov dx, CFG_CheckConfig
376 mov CFG_CheckConfig, bx
377 PCCC_Loop:
378 call MBR_GetCheckOfSector
379 loop PCCC_Loop
380 cmp bx, dx
381 jne PCCC_Failed
382 mov CFG_CheckConfig, dx
383 ret
384 PCCC_Failed:
385 mov si, offset TXT_ERROR_CheckConfig
386 call MBR_Teletype
387 mov si, offset TXT_ERROR_CheckFailed
388 call MBR_Teletype
389 jmp MBR_HaltSystem
390PRECRAP_CheckConfiguration EndP
391
392
393; Rousseau: added
394; In: SI - Pointer to begin of string (EOS is 0)
395; Destroyed: SI
396; Fixme: Uses double writes to use attribute with teletype-function.
397MBR_TeletypeBold Proc Near Uses ax bx cx
398 MBRT_LoopBold:
399 lodsb
400 or al, al
401 jz MBRT_EndBold
402 push ax
403 mov ah,09h
404 mov bx,15
405 mov cx,1
406 int 10h
407 pop ax
408 mov ah,0eh
409 mov bx,7 ; Does not do anything in text-modus
410 mov cx,1
411 int 10h
412 jmp MBRT_LoopBold
413 MBRT_EndBold:
414 ret
415MBR_TeletypeBold EndP
416
417; In: SI - Pointer to begin of string (EOS is 0)
418; Destroyed: SI
419; Fixme: Uses double writes to use attribute with teletype-function.
420MBR_TeletypeVolName Proc Near Uses ax bx cx
421 mov cx, 11
422 MBRT_LoopVolName:
423 mov dx,cx ; Backup counter
424 lodsb
425 or al, al
426 jz MBRT_EndVolName
427 push ax
428 mov ah,09h
429 mov bx,15
430 mov cx,1
431 int 10h ; DX is preserved
432 pop ax
433 mov ah,0eh
434 mov bx,7 ; Does not do anything in text-modus
435 mov cx,1
436 int 10h ; DX is preserved
437 mov cx,dx ; Restore counter
438 loop MBRT_LoopVolName
439 MBRT_EndVolName:
440 ret
441MBR_TeletypeVolName EndP
442
443; Rousseau: added
444; Move cursor to next line
445; Just do a new-line if SI==0
446MBR_TeletypeNL Proc Near Uses ax bx cx
447 test si,si
448 jz MBR_TeletypeNL_NL
449 call MBR_Teletype
450 MBR_TeletypeNL_NL:
451 push si
452 mov si, offset NL
453 call MBR_Teletype
454 pop si
455 ret
456MBR_TeletypeNL EndP
457
458; Sync teletype position to VideoIO
459MBR_TeletypeSyncPos Proc Near Uses ax bx cx dx
460 pushf
461 mov bh, 0
462 mov ah, 02h
463 mov dh,[TextPosY]
464 mov dl,[TextPosX]
465 int 10h
466 popf
467 ret
468MBR_TeletypeSyncPos EndP
Note: See TracBrowser for help on using the repository browser.