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 / DRIVE I/O
|
---|
20 | ;---------------------------------------------------------------------------
|
---|
21 |
|
---|
22 |
|
---|
23 |
|
---|
24 | IFDEF MODULE_NAMES
|
---|
25 | DB 'DRIVEIO',0
|
---|
26 | ENDIF
|
---|
27 |
|
---|
28 | ;
|
---|
29 | ; Check if INT13X extensions are supported.
|
---|
30 | ; AirBoot requires these extensions, and will halt if they are not available.
|
---|
31 | ; Modified: [CurIO_UseExtension]
|
---|
32 | DriveIO_CheckFor13extensions Proc Near Uses ax bx cx dx
|
---|
33 | mov ah, 41h
|
---|
34 | mov bx, 55AAh
|
---|
35 | mov dl, [BIOS_BootDisk] ; We check using the boot-disk
|
---|
36 | int 13h
|
---|
37 |
|
---|
38 | IFDEF AUX_DEBUG
|
---|
39 | IF 0
|
---|
40 | DBG_TEXT_OUT_AUX 'DriveIO_CheckFor13extensions:'
|
---|
41 | PUSHRF
|
---|
42 | call DEBUG_DumpRegisters
|
---|
43 | ;~ call AuxIO_DumpParagraph
|
---|
44 | ;~ call AuxIO_TeletypeNL
|
---|
45 | mov si, offset [Scratch]
|
---|
46 | mov word ptr [si], 50h
|
---|
47 | mov ah, 48h
|
---|
48 | int 13h
|
---|
49 | call DEBUG_DumpRegisters
|
---|
50 | ;~ call AuxIO_DumpSector
|
---|
51 | POPRF
|
---|
52 | ENDIF
|
---|
53 | ENDIF
|
---|
54 |
|
---|
55 | jc PCCF13E_NotFound ; Error occured
|
---|
56 | cmp bx, 0AA55h
|
---|
57 | je PCCF13E_Found
|
---|
58 | PCCF13E_NotFound:
|
---|
59 | ret
|
---|
60 | PCCF13E_Found:
|
---|
61 | and cx, 1 ; Check 42h-44h,47h,48h supported
|
---|
62 | jz PCCF13E_NotFound ; Sig OK but no support, strange beast
|
---|
63 | mov byte ptr [CurIO_UseExtension], 1
|
---|
64 | ret
|
---|
65 | DriveIO_CheckFor13extensions EndP
|
---|
66 |
|
---|
67 |
|
---|
68 | ; Note: Some routines set DS/ES to CS or even address via CS, even if its not
|
---|
69 | ; needed. This was done for SECURITY. So DO NOT remove it.
|
---|
70 | ; Its there to make sure the correct data is loaded/written to/from
|
---|
71 | ; harddrive.
|
---|
72 | ;
|
---|
73 | ; IF YOU MODIFY ANYTHING IN HERE, YOU MAY EASILY BREAK YOUR HARDDRIVE!
|
---|
74 |
|
---|
75 | ; Will only load base-configuration, will NOT load IPT nor Hide-Config
|
---|
76 | ; Those are originally loaded on startup and will NOT get reloaded.
|
---|
77 | DriveIO_LoadConfiguration Proc Near Uses ax bx cx dx es
|
---|
78 |
|
---|
79 | IFDEF AUX_DEBUG
|
---|
80 | IF 0
|
---|
81 | DBG_TEXT_OUT_AUX 'DriveIO_LoadConfiguration:'
|
---|
82 | PUSHRF
|
---|
83 | ;~ call DEBUG_DumpRegisters
|
---|
84 | ;~ call AuxIO_DumpParagraph
|
---|
85 | ;~ call AuxIO_TeletypeNL
|
---|
86 | POPRF
|
---|
87 | ENDIF
|
---|
88 | ENDIF
|
---|
89 |
|
---|
90 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
91 | mov ax, cs
|
---|
92 | mov es, ax
|
---|
93 | mov bx, offset Configuration
|
---|
94 | xor dh, dh
|
---|
95 | mov dl, [BIOS_BootDisk] ; Disk we booted from
|
---|
96 | mov cx, 0037h ; Sector 55 (CHS)
|
---|
97 | mov ax, 0201h ; Function 02, read 1 sector...
|
---|
98 | int 13h
|
---|
99 | jnc DIOLC_NoError
|
---|
100 | call MBR_LoadError ; Will Abort BootUp
|
---|
101 |
|
---|
102 |
|
---|
103 | DIOLC_NoError:
|
---|
104 | ret
|
---|
105 | DriveIO_LoadConfiguration EndP
|
---|
106 |
|
---|
107 | DriveIO_SaveConfiguration Proc Near Uses ax bx cx dx ds es si
|
---|
108 |
|
---|
109 | IFDEF AUX_DEBUG
|
---|
110 | IF 0
|
---|
111 | DBG_TEXT_OUT_AUX 'DriveIO_SaveConfiguration:'
|
---|
112 | PUSHRF
|
---|
113 | ;~ call DEBUG_DumpRegisters
|
---|
114 | ;~ call AuxIO_DumpParagraph
|
---|
115 | ;~ call AuxIO_TeletypeNL
|
---|
116 | POPRF
|
---|
117 | ENDIF
|
---|
118 | ENDIF
|
---|
119 |
|
---|
120 | mov ax, cs
|
---|
121 | mov ds, ax
|
---|
122 | mov es, ax ; Safety first (CS==DS==ES)
|
---|
123 | ; --- Overwrite Floppy-Name with "FloppyDrive"
|
---|
124 | mov si, offset TXT_Floppy_Drive
|
---|
125 | mov di, offset PartitionTable
|
---|
126 | sub di, 30 ; Adjust to Floppy-Name
|
---|
127 | mov cx, 11
|
---|
128 | rep movsb
|
---|
129 | mov si, offset Configuration ; Calculate new checksum
|
---|
130 | xor bx, bx
|
---|
131 |
|
---|
132 | ; Changed from 5 to calculated value (not here, see compat. issue below)
|
---|
133 | ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
|
---|
134 | ; Size of the ab-configuration in 512 byte sectors
|
---|
135 | ;mov cx, (MBR_BackUpMBR - Configuration) / 200h
|
---|
136 |
|
---|
137 | ; AB v1.07 stores a 5 sector configuration with a 5 sector checksum.
|
---|
138 | ; AB v1.0.8+ *should* stores a 7 sector configuration with a
|
---|
139 | ; 7 sector checksum.
|
---|
140 | ; Because 5 was hardcoded here, SET(A)BOOT v1.07 will see see an AB v1.0.8+
|
---|
141 | ; config as corrupted, while this is not the case.
|
---|
142 | ; So, for compatibility reasons, in v1.0.8+, the checksum stored is over
|
---|
143 | ; 5 sectors, to be compatible with v1.07.
|
---|
144 | ; This may change (be corrected) in future versions !
|
---|
145 | mov cx,5
|
---|
146 |
|
---|
147 | mov dx, [CFG_CheckConfig]
|
---|
148 | mov [CFG_CheckConfig], bx
|
---|
149 | DIOSC_Loop:
|
---|
150 | call MBR_GetCheckOfSector
|
---|
151 | loop DIOSC_Loop
|
---|
152 | mov [CFG_CheckConfig], bx
|
---|
153 | ; --------------------------------------------------------------------
|
---|
154 | ; ES == CS
|
---|
155 | mov bx, offset Configuration
|
---|
156 | xor dh, dh
|
---|
157 | mov dl, [BIOS_BootDisk] ; Disk we booted from
|
---|
158 | mov cx, 0037h ; Sector 55 (CHS)
|
---|
159 |
|
---|
160 | ; Changed from 5 to calculated value
|
---|
161 | ; Fixes issue: #2987 -- "air-boot doesn't remember drive letter"
|
---|
162 | ; Size of the ab-configuration in 512 byte sectors
|
---|
163 | mov al, (MBR_BackUpMBR - Configuration) / 200h
|
---|
164 | mov ah,03h
|
---|
165 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
166 | int 13h
|
---|
167 | jnc DIOSC_NoError
|
---|
168 | call MBR_SaveError ; Will Abort BootUp
|
---|
169 | DIOSC_NoError:
|
---|
170 | ret
|
---|
171 | DriveIO_SaveConfiguration EndP
|
---|
172 |
|
---|
173 | DriveIO_UpdateFloppyName Proc Near Uses bx cx dx ds si es di
|
---|
174 | mov ax, cs
|
---|
175 | mov ds, ax
|
---|
176 | mov es, ax
|
---|
177 |
|
---|
178 | mov ah, 00h ; Function 0 - Reset Drive
|
---|
179 | xor dl, dl
|
---|
180 | int 13h
|
---|
181 | xor dx, dx ; Cylinder=0, Head=0
|
---|
182 | mov cx, 1 ; Sector=1, Drive=0
|
---|
183 | mov bx, offset TmpSector ; ES:BX - TmpSector
|
---|
184 | mov ax, 0201h ; Function 2 - Load Sector
|
---|
185 | int 13h
|
---|
186 | jnc DIOUFN_AllFine
|
---|
187 |
|
---|
188 | ; --- Overwrite Floppy-Name with "No Disc"
|
---|
189 | mov si, offset TXT_Floppy_NoDisc
|
---|
190 | xor ax, ax
|
---|
191 | DIOUFN_WriteFloppyName:
|
---|
192 | mov di, offset PartitionTable
|
---|
193 | sub di, 30 ; Adjust to Floppy-Name
|
---|
194 | mov cl, 11
|
---|
195 | rep movsb
|
---|
196 | ret ; AX=-1 -> GotDisc, =0 -> NoDisc
|
---|
197 |
|
---|
198 | ; --- Floppy found and read, data in TempSector
|
---|
199 | DIOUFN_AllFine:
|
---|
200 | mov ax, -1
|
---|
201 | mov si, offset TXT_Floppy_NoName
|
---|
202 | cmp wptr es:[bx+54], 'AF'
|
---|
203 | jne DIOUFN_WriteFloppyName
|
---|
204 | cmp wptr es:[bx+56], '1T'
|
---|
205 | jne DIOUFN_WriteFloppyName
|
---|
206 | cmp bptr es:[bx+58], '2'
|
---|
207 | jne DIOUFN_WriteFloppyName
|
---|
208 | mov si, bx
|
---|
209 | add si, 43 ; FAT12 - Volume Label Location
|
---|
210 | jmp DIOUFN_WriteFloppyName
|
---|
211 | DriveIO_UpdateFloppyName EndP
|
---|
212 |
|
---|
213 | ; =============================================================================
|
---|
214 | ; HARDDRIVE / GENERAL ACCESS
|
---|
215 | ; =============================================================================
|
---|
216 | ; The following routines are used for harddisc/floppy access.
|
---|
217 | ; The access is done via INT 13h/CHS or INT 13h/LBA.
|
---|
218 | ; Access will be done prefered by INT 13h/CHS, because it's (I wonder!) much
|
---|
219 | ; faster, than the LBA-method. I don't know, why LBA is so slow. Perhaps BIOS.
|
---|
220 | ;
|
---|
221 | ; Internal access (to AiR-BOOT) is always done via INT 13h/CHS.
|
---|
222 |
|
---|
223 | DriveIO_GetHardDriveCount Proc Near Uses ds si
|
---|
224 | push ds
|
---|
225 | push si
|
---|
226 | push 0040h
|
---|
227 | pop ds
|
---|
228 | mov si, 0075h
|
---|
229 | mov dh, ds:[si] ; 40:75 -> POST: Total Harddiscs == DL
|
---|
230 | pop si
|
---|
231 | pop ds
|
---|
232 | mov [TotalHarddiscs], dh
|
---|
233 | ret
|
---|
234 | DriveIO_GetHardDriveCount EndP
|
---|
235 |
|
---|
236 |
|
---|
237 | ; Fills our LBA-Usage table. It holds the LBA-address, where BIOS/CHS access is
|
---|
238 | ; stopped and BIOS/LBA access is started.
|
---|
239 | ; This is calculated by Sector*Heads. Comparing will get done with Bit 25-10
|
---|
240 | ; on LBA sectors, so we actually divide sector number by 1024.
|
---|
241 | DriveIO_InitLBASwitchTable Proc Near Uses es di
|
---|
242 | mov di, offset LBASwitchTable
|
---|
243 | mov dh, [TotalHarddiscs]
|
---|
244 | mov dl, 80h ; First disk to process
|
---|
245 | DIOILUT_DriveLoop:
|
---|
246 | push dx
|
---|
247 | push di
|
---|
248 | mov ah, 08h
|
---|
249 | int 13h ; DISK - GET DRIVE PARAMETERS
|
---|
250 | mov ah, 0FBh ; Assume 255 heads/63 sectors, if error
|
---|
251 | jc DIOILUT_Error
|
---|
252 | and cl, 111111b ; Isolate lower 6 bits of CL -> sector count
|
---|
253 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
254 | ;movzx ax, cl
|
---|
255 | mov al,cl
|
---|
256 | mov ah,0
|
---|
257 |
|
---|
258 | mov bl, dh ; DH -> max head number
|
---|
259 | mul bl ; AX = Sectors*Heads
|
---|
260 | shl ah, 1
|
---|
261 | shl ah, 1 ; Shift 2 bits, so we are able to compare to
|
---|
262 | ; bit 16-23 of the LBA address
|
---|
263 | DIOILUT_Error:
|
---|
264 | pop di
|
---|
265 | pop dx
|
---|
266 | mov bptr ds:[di], ah ; Save that value
|
---|
267 | inc di ; Go to next BYTE
|
---|
268 | inc dl ; Next disk
|
---|
269 | dec dh ; Decrease disks to process
|
---|
270 | jnz DIOILUT_DriveLoop ; Next disk if DH != 0
|
---|
271 | ret
|
---|
272 | DriveIO_InitLBASwitchTable EndP
|
---|
273 |
|
---|
274 | ; #########################################################################
|
---|
275 | ; Routine: Loads partition to ExecBase and checks for validity
|
---|
276 | ; #########################################################################
|
---|
277 | ; Calling : bx:ax - Absolute sector
|
---|
278 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
279 | ; Returns : Carry Set if invalid partition encountered
|
---|
280 | ; Preserve: all registers
|
---|
281 | ; #########################################################################
|
---|
282 | DriveIO_LoadPartition Proc Near Uses si
|
---|
283 |
|
---|
284 | IFDEF AUX_DEBUG
|
---|
285 | IF 0
|
---|
286 | DBG_TEXT_OUT_AUX 'DriveIO_LoadPartition:'
|
---|
287 | PUSHRF
|
---|
288 | call DEBUG_DumpRegisters
|
---|
289 | ;~ call AuxIO_DumpParagraph
|
---|
290 | ;~ call AuxIO_TeletypeNL
|
---|
291 | POPRF
|
---|
292 | ENDIF
|
---|
293 | ENDIF
|
---|
294 |
|
---|
295 | mov wptr cs:[CurPartition_Location+0], ax
|
---|
296 | mov wptr cs:[CurPartition_Location+2], bx
|
---|
297 | mov wptr cs:[CurPartition_Location+4], dx
|
---|
298 | mov wptr cs:[CurPartition_Location+6], cx ; Saves the location
|
---|
299 | mov si, offset PartitionSector ; DS:SI - ExecBase
|
---|
300 |
|
---|
301 |
|
---|
302 | ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
---|
303 | call DriveIO_LoadSector
|
---|
304 |
|
---|
305 | clc
|
---|
306 | cmp wptr [si+LocBR_Magic], 0AA55h
|
---|
307 | je DIOLP_Success
|
---|
308 | ; We check, if we are scanning partitions. In that case, if CHS is not 0/0/1
|
---|
309 | ; we will display a "bad partition table" message and halt the system.
|
---|
310 | cmp cx, 0001h
|
---|
311 | jne DIOLP_Failed
|
---|
312 | or dh, dh
|
---|
313 | jnz DIOLP_Failed
|
---|
314 | stc ; Set carry, so no partition table
|
---|
315 | DIOLP_Success:
|
---|
316 |
|
---|
317 |
|
---|
318 |
|
---|
319 | ret
|
---|
320 | DIOLP_Failed:
|
---|
321 | jmp DriveIO_GotLoadError
|
---|
322 | DriveIO_LoadPartition EndP
|
---|
323 |
|
---|
324 | ; #########################################################################
|
---|
325 | ; Routine: Writes a partition from ExecBase to its original sector
|
---|
326 | ; #########################################################################
|
---|
327 | ; Calling : none
|
---|
328 | ; Returns : none
|
---|
329 | ; Preserve: all registers
|
---|
330 | ; #########################################################################
|
---|
331 | DriveIO_SavePartition Proc Near Uses ax bx cx dx si
|
---|
332 |
|
---|
333 | IFDEF AUX_DEBUG
|
---|
334 | IF 0
|
---|
335 | DBG_TEXT_OUT_AUX 'DriveIO_SavePartition:'
|
---|
336 | PUSHRF
|
---|
337 | ;~ call DEBUG_DumpRegisters
|
---|
338 | ;~ call AuxIO_DumpParagraph
|
---|
339 | ;~ call AuxIO_TeletypeNL
|
---|
340 | POPRF
|
---|
341 | ENDIF
|
---|
342 | ENDIF
|
---|
343 |
|
---|
344 | mov ax, wptr cs:[CurPartition_Location+0]
|
---|
345 | mov bx, wptr cs:[CurPartition_Location+2]
|
---|
346 | mov dx, wptr cs:[CurPartition_Location+4]
|
---|
347 | mov cx, wptr cs:[CurPartition_Location+6] ; Gets prev. saved location
|
---|
348 | mov si, offset PartitionSector ; DS:SI - ExecBase
|
---|
349 | cmp wptr [si+LocBR_Magic], 0AA55h ; Checks for signature, if not found
|
---|
350 | jne DIOSP_SevereError ; we assume a really bad error
|
---|
351 | call DriveIO_SaveSector
|
---|
352 | DIOSP_SevereError:
|
---|
353 | ret
|
---|
354 | DriveIO_SavePartition EndP
|
---|
355 |
|
---|
356 |
|
---|
357 |
|
---|
358 | ;##############################################################################
|
---|
359 | ;# The location of LVM sectors depends on the OS/2 geometry used when the disk
|
---|
360 | ;# was prepared. This geometry is present in the Master LVM sector, which has
|
---|
361 | ;# already been located if it exists. All partitions, whether primary or
|
---|
362 | ;# logical, have an entry in a partition table. For primary partitions this
|
---|
363 | ;# table is located in the MBR, while for logical partitions this table is
|
---|
364 | ;# located in the EBR for that logical partition. An LVM record is located
|
---|
365 | ;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
|
---|
366 | ;# information for all primary partitions. For logical partitions, the LVM
|
---|
367 | ;# sector only has one entry, because EBRs are chained. The global LVM info,
|
---|
368 | ;# like disk-name, sectors per track, etc. is replicated between the Master
|
---|
369 | ;# LVM sector and LVM sectors corresponding to logical partitions. This info
|
---|
370 | ;# is kept in sync by the OS/2 LVM Engine.
|
---|
371 | ;##############################################################################
|
---|
372 | ;# ACTION : Attempts to load the corresponding LVM sector for a partition
|
---|
373 | ;# ----------------------------------------------------------------------------
|
---|
374 | ;# EFFECTS : Modifies DAP structure and fills or clears sector buffer
|
---|
375 | ;# ----------------------------------------------------------------------------
|
---|
376 | ;# IN : MEM - Location info is in [CurPartition_Location]
|
---|
377 | ;# ----------------------------------------------------------------------------
|
---|
378 | ;# OUT : CF=1 - failure, no valid LVM sector was loaded
|
---|
379 | ;# : SI - Points to the sector buffer ([LVMSector])
|
---|
380 | ;##############################################################################
|
---|
381 | DriveIO_LoadLVMSector Proc Near Uses ax bx cx dx di
|
---|
382 |
|
---|
383 | IFDEF AUX_DEBUG
|
---|
384 | IF 1
|
---|
385 | DBG_TEXT_OUT_AUX 'DriveIO_LoadLVMSector:'
|
---|
386 | PUSHRF
|
---|
387 | call DEBUG_DumpRegisters
|
---|
388 | ;~ call AuxIO_DumpSector
|
---|
389 | ;~ call AuxIO_DumpParagraph
|
---|
390 | ;~ call AuxIO_TeletypeNL
|
---|
391 | POPRF
|
---|
392 | ENDIF
|
---|
393 | ENDIF
|
---|
394 |
|
---|
395 | ; Clear the sector buffer
|
---|
396 | mov si, offset [LVMSector]
|
---|
397 | call ClearSectorBuffer
|
---|
398 |
|
---|
399 | ; Quit with CY if LVM is ignored in SETUP
|
---|
400 | test byte ptr [CFG_IgnoreLVM], 1 ; ZF=0 means ignore LVM
|
---|
401 | jnz DIOLLVMS_NoLVMSector ; Quit if so
|
---|
402 |
|
---|
403 | ; Load the location of the current partition being acted upon.
|
---|
404 | ; Note that this is not the actual LBA of the partition, but the
|
---|
405 | ; sector that has the partition table that contains the entry
|
---|
406 | ; for the partition. In other words, for primary partitions the LBA
|
---|
407 | ; address points to the MBR while for extended partitions it points
|
---|
408 | ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
|
---|
409 | ; Also note that the BIOS CHS values (DH and CX) below are not used,
|
---|
410 | ; because we explicitly use LBA sector loading.
|
---|
411 | mov ax, wptr cs:[CurPartition_Location+0] ; LBA lo of MBR/EBR
|
---|
412 | mov bx, wptr cs:[CurPartition_Location+2] ; LBA hi of MBR/EBR
|
---|
413 | mov dx, wptr cs:[CurPartition_Location+4] ; BIOS disk num & head
|
---|
414 | mov cx, wptr cs:[CurPartition_Location+6] ; BIOS cyl & sec
|
---|
415 |
|
---|
416 | ; Calculate the entry in the DISKINFO array for this disk,
|
---|
417 | ; and put the LVM_SPT in DI
|
---|
418 | push bx
|
---|
419 | call DriveIO_CalcDiskInfoPointer
|
---|
420 | mov di, [bx+LocDISKINFO_LVM_Secs]
|
---|
421 | pop bx
|
---|
422 |
|
---|
423 | ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
|
---|
424 | test di, di ; See if it is 0
|
---|
425 | jz DIOLLVMS_NoLVMSector ; Quit if so
|
---|
426 |
|
---|
427 | ; Adjust the location to point to the LVM sector
|
---|
428 | add ax, di ; Add the LVM sectors-per-track
|
---|
429 | adc bx, 0 ; Propagate LBA lo overflow to LBA hi
|
---|
430 | sub ax, 1 ; LVM sector is located one sector below
|
---|
431 | sbb bx, 0 ; Propagate borrow to LBA hi
|
---|
432 |
|
---|
433 | ; Load the LVM sector into [LVMSector]
|
---|
434 | mov si, offset [LVMSector] ; Points to sector buffer
|
---|
435 | mov di, ds ; Segment of that buffer
|
---|
436 | call DriveIO_ReadSectorLBA ; Read the LVM sector
|
---|
437 |
|
---|
438 | IFDEF AUX_DEBUG
|
---|
439 | IF 1
|
---|
440 | DBG_TEXT_OUT_AUX 'LVMSecLoaded'
|
---|
441 | PUSHRF
|
---|
442 | call DEBUG_DumpRegisters
|
---|
443 | call AuxIO_DumpSector
|
---|
444 | ;~ call AuxIO_DumpParagraph
|
---|
445 | ;~ call AuxIO_TeletypeNL
|
---|
446 | POPRF
|
---|
447 | ENDIF
|
---|
448 | ENDIF
|
---|
449 |
|
---|
450 | jc DIOLLVMS_NoLVMSector ; Quit on error
|
---|
451 |
|
---|
452 | ; Check the validity of the LVM sector, quit with CY if invalid
|
---|
453 | call LVM_ValidateSector ; Check signature and CRC
|
---|
454 | jnc DIOLLVMS_NoLVMSector ; Quit if not valid
|
---|
455 |
|
---|
456 | ; We're done, indicate success and return
|
---|
457 | clc
|
---|
458 | jmp DIOLLVMS_Done
|
---|
459 |
|
---|
460 | DIOLLVMS_NoLVMSector:
|
---|
461 |
|
---|
462 | ; Clear the sector buffer
|
---|
463 | mov si, offset [LVMSector]
|
---|
464 | call ClearSectorBuffer
|
---|
465 | mov bptr [si+LocLVM_SignatureStart], 0
|
---|
466 |
|
---|
467 | ; Indicate no valid LVM sector was loaded
|
---|
468 | stc
|
---|
469 |
|
---|
470 | DIOLLVMS_Done:
|
---|
471 |
|
---|
472 | ret
|
---|
473 | DriveIO_LoadLVMSector EndP
|
---|
474 |
|
---|
475 |
|
---|
476 |
|
---|
477 | ;##############################################################################
|
---|
478 | ;# The location of LVM sectors depends on the OS/2 geometry used when the disk
|
---|
479 | ;# was prepared. This geometry is present in the Master LVM sector, which has
|
---|
480 | ;# already been located if it exists. All partitions, whether primary or
|
---|
481 | ;# logical, have an entry in a partition table. For primary partitions this
|
---|
482 | ;# table is located in the MBR, while for logical partitions this table is
|
---|
483 | ;# located in the EBR for that logical partition. An LVM record is located
|
---|
484 | ;# LVM_SPT-1 sectors above an MBR or EBR. The Master LVM record contains the
|
---|
485 | ;# information for all primary partitions. For logical partitions, the LVM
|
---|
486 | ;# sector only has one entry, because EBRs are chained. The global LVM info,
|
---|
487 | ;# like disk-name, sectors per track, etc. is replicated between the Master
|
---|
488 | ;# LVM sector and LVM sectors corresponding to logical partitions. This info
|
---|
489 | ;# is kept in sync by the OS/2 LVM Engine.
|
---|
490 | ;##############################################################################
|
---|
491 | ;# ACTION : Attempts to save the corresponding LVM sector for a partition
|
---|
492 | ;# ----------------------------------------------------------------------------
|
---|
493 | ;# EFFECTS : Modifies DAP structure and writes LVM sector to disk
|
---|
494 | ;# ----------------------------------------------------------------------------
|
---|
495 | ;# IN : MEM - Location info is in [CurPartition_Location]
|
---|
496 | ;# : SI - Pointer to sector buffer
|
---|
497 | ;# ----------------------------------------------------------------------------
|
---|
498 | ;# OUT : CF=1 - failure, no valid LVM sector was saved
|
---|
499 | ;##############################################################################
|
---|
500 | DriveIO_SaveLVMSector Proc Near Uses ax bx cx dx di
|
---|
501 |
|
---|
502 | IFDEF AUX_DEBUG
|
---|
503 | IF 1
|
---|
504 | DBG_TEXT_OUT_AUX 'DriveIO_SaveLVMSector:'
|
---|
505 | PUSHRF
|
---|
506 | call DEBUG_DumpRegisters
|
---|
507 | ;~ call AuxIO_DumpParagraph
|
---|
508 | ;~ call AuxIO_TeletypeNL
|
---|
509 | POPRF
|
---|
510 | ENDIF
|
---|
511 | ENDIF
|
---|
512 |
|
---|
513 | ; Quit with CY if LVM is ignored in SETUP
|
---|
514 | test byte ptr [CFG_IgnoreLVM], 1 ; ZF=0 means ignore LVM
|
---|
515 | jnz DIOSLVMS_SevereError ; Quit if so
|
---|
516 |
|
---|
517 | ; Check the validity of the LVM sector, quit with CY if invalid
|
---|
518 | call LVM_ValidateSector ; Check signature and CRC
|
---|
519 | jnc DIOSLVMS_SevereError ; Quit if not valid
|
---|
520 |
|
---|
521 | ; Load the location of the current partition being acted upon.
|
---|
522 | ; Note that this is not the actual LBA of the partition, but the
|
---|
523 | ; sector that has the partition table that contains the entry
|
---|
524 | ; for the partition. In other words, for primary partitions the LBA
|
---|
525 | ; address points to the MBR while for extended partitions it points
|
---|
526 | ; to an EBR. In both cases the LVM sector is located LVM_SPT-1 above.
|
---|
527 | ; Also note that the BIOS CHS values (DH and CX) below are not used,
|
---|
528 | ; because we explicitly use LBA sector loading.
|
---|
529 | mov ax, wptr cs:[CurPartition_Location+0] ; LBA lo of MBR/EBR
|
---|
530 | mov bx, wptr cs:[CurPartition_Location+2] ; LBA hi of MBR/EBR
|
---|
531 | mov dx, wptr cs:[CurPartition_Location+4] ; BIOS disk num & head
|
---|
532 | mov cx, wptr cs:[CurPartition_Location+6] ; BIOS cyl & sec
|
---|
533 |
|
---|
534 | ; Calculate the entry in the DISKINFO array for this disk,
|
---|
535 | ; and put the LVM_SPT in DI
|
---|
536 | push bx
|
---|
537 | call DriveIO_CalcDiskInfoPointer
|
---|
538 | mov di, [bx+LocDISKINFO_LVM_Secs]
|
---|
539 | pop bx
|
---|
540 |
|
---|
541 | ; If the LVM_SPT is ZERO, no LVM info is present and we quit with CY
|
---|
542 | test di, di ; See if it is 0
|
---|
543 | jz DIOSLVMS_SevereError ; Quit if so
|
---|
544 |
|
---|
545 | ; Adjust the location to point to the LVM sector
|
---|
546 | add ax, di ; Add the LVM sectors-per-track
|
---|
547 | adc bx, 0 ; Propagate LBA lo overflow to LBA hi
|
---|
548 | sub ax, 1 ; LVM sector is located one sector below
|
---|
549 | sbb bx, 0 ; Propagate borrow to LBA hi
|
---|
550 |
|
---|
551 | IFDEF AUX_DEBUG
|
---|
552 | IF 1
|
---|
553 | DBG_TEXT_OUT_AUX 'LVMSecSaved'
|
---|
554 | PUSHRF
|
---|
555 | call DEBUG_DumpRegisters
|
---|
556 | call AuxIO_DumpSector
|
---|
557 | ;~ call AuxIO_DumpParagraph
|
---|
558 | ;~ call AuxIO_TeletypeNL
|
---|
559 | POPRF
|
---|
560 | ENDIF
|
---|
561 | ENDIF
|
---|
562 |
|
---|
563 | ; Save the LVM sector pointed to by SI
|
---|
564 | mov di, ds ; Segment of that buffer
|
---|
565 | call DriveIO_WriteSectorLBA ; Read the LVM sector
|
---|
566 | clc
|
---|
567 | jc DIOSLVMS_SevereError ; Quit on error
|
---|
568 |
|
---|
569 | ; We're done, indicate success and return
|
---|
570 | clc
|
---|
571 | jmp DIOSLVMS_Done
|
---|
572 |
|
---|
573 | DIOSLVMS_SevereError:
|
---|
574 | ; Indicate no valid LVM sector was saved
|
---|
575 | stc
|
---|
576 |
|
---|
577 | DIOSLVMS_Done:
|
---|
578 | ret
|
---|
579 | DriveIO_SaveLVMSector EndP
|
---|
580 |
|
---|
581 |
|
---|
582 |
|
---|
583 | ; Special error message instead of "LOAD ERROR" during partition scanning,
|
---|
584 | ; so users will notice that something is bad with their partition table(s)
|
---|
585 | DriveIO_GotLoadError Proc Near
|
---|
586 | test byte ptr cs:[CurIO_Scanning], 1 ; Must be CS:, cause DS!=CS maybe here
|
---|
587 | jnz InScanMode
|
---|
588 | jmp MBR_LoadError
|
---|
589 | InScanMode:
|
---|
590 | mov si, offset TXT_BrokenPartitionTable
|
---|
591 | push cs
|
---|
592 | pop ds
|
---|
593 | call MBR_Teletype
|
---|
594 | mov si, offset BrokenHDD
|
---|
595 | sub dl, 50h ; 80h -> '0'
|
---|
596 | cmp dl, 39h
|
---|
597 | jbe DIOGLE_BelowA
|
---|
598 | add dl, 7 ; 3Ah -> 'A'
|
---|
599 | DIOGLE_BelowA:
|
---|
600 | mov bptr [si+5], dl
|
---|
601 | call MBR_Teletype
|
---|
602 |
|
---|
603 | ; JWasm: cannot jump to local label in other procedure.
|
---|
604 | ; Changed to halt here.
|
---|
605 | ;jmp MBRLE_Halt
|
---|
606 | DriveIO_GotLoadError_halt:
|
---|
607 | jmp DriveIO_GotLoadError_halt
|
---|
608 | DriveIO_GotLoadError EndP
|
---|
609 |
|
---|
610 | ; #########################################################################
|
---|
611 | ; Routine: Loads a specified sector to DS:DI
|
---|
612 | ; #########################################################################
|
---|
613 | ; Calling : bx:ax - Absolute sector
|
---|
614 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
615 | ; ds:si - Destination-Adress
|
---|
616 | ; Returns : none
|
---|
617 | ; Preserve: all registers
|
---|
618 | ; #########################################################################
|
---|
619 | DriveIO_LoadSector Proc Near Uses ax bx cx dx ds si es di
|
---|
620 |
|
---|
621 | IFDEF AUX_DEBUG
|
---|
622 | IF 0
|
---|
623 | DBG_TEXT_OUT_AUX 'DriveIO_LoadSector:'
|
---|
624 | PUSHRF
|
---|
625 | call DEBUG_DumpRegisters
|
---|
626 | ;~ call AuxIO_DumpParagraph
|
---|
627 | ;~ call AuxIO_TeletypeNL
|
---|
628 | POPRF
|
---|
629 | ENDIF
|
---|
630 | ENDIF
|
---|
631 |
|
---|
632 | ; Is the drive not a harddrive?
|
---|
633 | cmp dl, 80h
|
---|
634 | jb DIOLS_UseNormal
|
---|
635 |
|
---|
636 | test byte ptr cs:[CurIO_UseExtension], 1
|
---|
637 | jz DIOLS_UseNormal
|
---|
638 | ; Are we forced do use LBA via Setting?
|
---|
639 | jnz DIOLS_UseExtension
|
---|
640 |
|
---|
641 | ; Upper 8 bits of LBA-address set?
|
---|
642 | ; Then use LBA (maximum boundary is 16320x16x63 = FB0400h)
|
---|
643 | or bh, bh
|
---|
644 | jnz DIOLS_UseExtension
|
---|
645 | ; Compare Switch-Table value to bit 16-23 of LBA-address
|
---|
646 | mov di, dx
|
---|
647 | and di, 007Fh
|
---|
648 | cmp bptr cs:[LBASwitchTable+di], bl
|
---|
649 | jbe DIOLS_UseExtension
|
---|
650 |
|
---|
651 | DIOLS_UseNormal:
|
---|
652 |
|
---|
653 | IFDEF AUX_DEBUG
|
---|
654 | IF 0
|
---|
655 | DBG_TEXT_OUT_AUX 'DriveIO_ReadSectorCHS:'
|
---|
656 | PUSHRF
|
---|
657 | call DEBUG_DumpRegisters
|
---|
658 | call AuxIO_DumpParagraph
|
---|
659 | call AuxIO_TeletypeNL
|
---|
660 | POPRF
|
---|
661 | ENDIF
|
---|
662 | ENDIF
|
---|
663 |
|
---|
664 | mov di, 3 ; retry count
|
---|
665 | DIOLS_ErrorLoop:
|
---|
666 | push ds
|
---|
667 | pop es
|
---|
668 | mov bx, si ; ES:BX - Destination
|
---|
669 | mov ax, 0201h ; Function 2 - Load Sector
|
---|
670 | int 13h
|
---|
671 | jnc DIOLS_Success
|
---|
672 | dec di ; decrement retry count
|
---|
673 | jnz DIOLS_ErrorLoop
|
---|
674 |
|
---|
675 | ; Sector load failed...
|
---|
676 | jmp DriveIO_GotLoadError
|
---|
677 |
|
---|
678 | DIOLS_UseExtension:
|
---|
679 |
|
---|
680 | mov di, ds ; segment for transfer address
|
---|
681 | call DriveIO_ReadSectorLBA ; extended read
|
---|
682 | jc DriveIO_GotLoadError ; halt on error
|
---|
683 |
|
---|
684 | ;~ push cx
|
---|
685 | ;~ mov cs:[INT13X_DAP_NumBlocks], 1 ; Copy ONE sector
|
---|
686 | ;~ mov wptr cs:[INT13X_DAP_Transfer+0], si
|
---|
687 | ;~ mov cx, ds
|
---|
688 | ;~ mov wptr cs:[INT13X_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
---|
689 | ;~ mov wptr cs:[INT13X_DAP_Absolute+0], ax
|
---|
690 | ;~ mov wptr cs:[INT13X_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
---|
691 | ;~ push cs
|
---|
692 | ;~ pop ds
|
---|
693 | ;~ mov si, offset [INT13X_DAP]
|
---|
694 | ;~ mov ah, 42h ; Extended Read
|
---|
695 | ;~ int 13h
|
---|
696 | ;~ pop cx
|
---|
697 | ;~ jnc DIOLS_Success
|
---|
698 |
|
---|
699 | ; Sector load failed...
|
---|
700 | ;~ jmp DriveIO_GotLoadError
|
---|
701 |
|
---|
702 | DIOLS_Success:
|
---|
703 |
|
---|
704 | IFDEF AUX_DEBUG
|
---|
705 | IF 0
|
---|
706 | DBG_TEXT_OUT_AUX 'sector loaded'
|
---|
707 | PUSHRF
|
---|
708 | ;~ call DEBUG_DumpRegisters
|
---|
709 | ;~ call AuxIO_DumpSector
|
---|
710 | mov cx, 32
|
---|
711 | @@:
|
---|
712 | call AuxIO_DumpParagraph
|
---|
713 | call AuxIO_TeletypeNL
|
---|
714 | add si, 16
|
---|
715 | loop @B
|
---|
716 | POPRF
|
---|
717 | ENDIF
|
---|
718 | ENDIF
|
---|
719 | ret
|
---|
720 | DriveIO_LoadSector EndP
|
---|
721 |
|
---|
722 |
|
---|
723 | ;##############################################################################
|
---|
724 | ;# ACTION : Loads the Master Boot Record from the specified drive into buffer
|
---|
725 | ;# ----------------------------------------------------------------------------
|
---|
726 | ;# EFFECTS : Modifies DAP structure and fills or clears transfer buffer
|
---|
727 | ;# ----------------------------------------------------------------------------
|
---|
728 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
729 | ;# : SI - Pointer to transfer buffer
|
---|
730 | ;# ----------------------------------------------------------------------------
|
---|
731 | ;# OUT : CF=1 - failure
|
---|
732 | ;# : AL.0 - MBR signature present
|
---|
733 | ;# : AL.1 - Primary partitions present
|
---|
734 | ;# : AL.2 - Extended partitions present
|
---|
735 | ;# : AL.3 - AiR-BOOT signature present
|
---|
736 | ;# : AL.4:7 - Reserved, returned as 0
|
---|
737 | ;# : AH.0:7 - Reserved, returned as 0
|
---|
738 | ;##############################################################################
|
---|
739 | DriveIO_LoadMBR Proc Near uses bx cx dx si di
|
---|
740 |
|
---|
741 | ; Always clear the transfer buffer first
|
---|
742 | call ClearSectorBuffer
|
---|
743 |
|
---|
744 | ; Assume an invalid MBR
|
---|
745 | xor ax, ax
|
---|
746 |
|
---|
747 | ; Accept only valid harddisks
|
---|
748 | call DriveIO_IsValidHarddisk
|
---|
749 | jc DriveIO_LoadMBR_exit
|
---|
750 |
|
---|
751 | ; Save the address of the transfer buffer
|
---|
752 | mov di, si
|
---|
753 |
|
---|
754 | ; Read the MBR from disk
|
---|
755 | xor ax, ax ; LBA low
|
---|
756 | xor bx, bx ; LBA high
|
---|
757 | xor dh, dh ; Head 0
|
---|
758 | mov cx, 1 ; Sector 1
|
---|
759 | call DriveIO_LoadSector ; Read the sector from disk
|
---|
760 |
|
---|
761 | ; Check the loaded MBR for a signature
|
---|
762 | xor ax, ax ; Assume an invalid MBR
|
---|
763 | mov dx, [si+LocBR_Magic] ; Get word from MBR signature location
|
---|
764 | cmp dx, 0aa55h ; Is it the magic value ?
|
---|
765 | jne DriveIO_LoadMBR_exit ; Nope, no need to test anything else
|
---|
766 |
|
---|
767 | ; Indicate we have a MBR signature
|
---|
768 | or al, 01h
|
---|
769 |
|
---|
770 | ; Advance to the partition table
|
---|
771 | add si, 01beh
|
---|
772 |
|
---|
773 | ; Total of 4 entries to check
|
---|
774 | mov cx, 4
|
---|
775 |
|
---|
776 | DriveIO_LoadMBR_next_entry:
|
---|
777 | mov dl, [si+LocBRPT_SystemID] ; Get partition-type / system-id
|
---|
778 | add si, 10h ; Point to next entry
|
---|
779 | test dl, dl ; Nothing in this one ?
|
---|
780 | loopz DriveIO_LoadMBR_next_entry ; Then check next entry
|
---|
781 |
|
---|
782 | ; All entries checked and last one was also empty, we're done
|
---|
783 | jz DriveIO_LoadMBR_check_ab
|
---|
784 |
|
---|
785 | ; Found a non-empty entry, set bits according to its type
|
---|
786 | cmp dl, 05h ; Old style extended container ?
|
---|
787 | jne @F ; Nope...
|
---|
788 | or al, 04h ; Yep, mark ext. container present
|
---|
789 | @@: cmp dl, 0fh ; New style extended container ?
|
---|
790 | jne @F ; Nope...
|
---|
791 | or al, 04h ; Yep, mark ext. container present
|
---|
792 | @@: or al, 02h ; Then is must be a primary
|
---|
793 | jcxz DriveIO_LoadMBR_check_ab ; CX=0? Then all entries processed,
|
---|
794 | jmp DriveIO_LoadMBR_next_entry ; otherwise check next entry
|
---|
795 |
|
---|
796 | ; Check if an AiR-BOOT signature is present
|
---|
797 | DriveIO_LoadMBR_check_ab:
|
---|
798 | mov si, offset [MBR_ABSig] ; Offset of AiR-BOOT signature
|
---|
799 | inc di ; Advance buffer pointer
|
---|
800 | inc di ; to AiR-BOOT signature location
|
---|
801 | mov cx, 7 ; Length of AiR-BOOT signature
|
---|
802 | cld ; Direction upwards
|
---|
803 | repe cmpsb ; Compare 7 bytes
|
---|
804 | jne DriveIO_LoadMBR_exit ; Nope, no AiR-BOOT on this disk
|
---|
805 | or al, 08h ; Yep, AiR-BOOT is on this disk
|
---|
806 | ;~ jmp DriveIO_LoadMBR_exit
|
---|
807 |
|
---|
808 | DriveIO_LoadMBR_exit:
|
---|
809 | ret
|
---|
810 | DriveIO_LoadMBR EndP
|
---|
811 |
|
---|
812 |
|
---|
813 | ;##############################################################################
|
---|
814 | ;# ACTION : Reads a sector from disk using INT13 extensions
|
---|
815 | ;# ----------------------------------------------------------------------------
|
---|
816 | ;# EFFECTS : Modifies DAP structure and fills transfer buffer
|
---|
817 | ;# ----------------------------------------------------------------------------
|
---|
818 | ;# IN : BX:AX - LBA address of sector
|
---|
819 | ;# : DI:SI - SEG:OFF of transfer buffer
|
---|
820 | ;# ----------------------------------------------------------------------------
|
---|
821 | ;# OUT : CF=1 - failure
|
---|
822 | ;##############################################################################
|
---|
823 | DriveIO_ReadSectorLBA Proc Near
|
---|
824 |
|
---|
825 | IFDEF AUX_DEBUG
|
---|
826 | IF 0
|
---|
827 | DBG_TEXT_OUT_AUX 'DriveIO_ReadSectorLBA:'
|
---|
828 | PUSHRF
|
---|
829 | call DEBUG_DumpRegisters
|
---|
830 | call AuxIO_DumpParagraph
|
---|
831 | call AuxIO_TeletypeNL
|
---|
832 | POPRF
|
---|
833 | ENDIF
|
---|
834 | ENDIF
|
---|
835 |
|
---|
836 | ; Push all registers
|
---|
837 | pusha
|
---|
838 | push ds
|
---|
839 | push es
|
---|
840 |
|
---|
841 | ; One sector to read
|
---|
842 | mov cs:[INT13X_DAP_NumBlocks], 1
|
---|
843 |
|
---|
844 | ; Setup transfer address
|
---|
845 | mov wptr cs:[INT13X_DAP_Transfer+0], si ; offset
|
---|
846 | mov wptr cs:[INT13X_DAP_Transfer+2], di ; segment
|
---|
847 |
|
---|
848 | ; Setup LBA64 address of requested sector
|
---|
849 | mov wptr cs:[INT13X_DAP_Absolute+0], ax ; low word lower part
|
---|
850 | mov wptr cs:[INT13X_DAP_Absolute+2], bx ; high word lower part
|
---|
851 | mov wptr cs:[INT13X_DAP_Absolute+4], 0 ; low word upper part
|
---|
852 | mov wptr cs:[INT13X_DAP_Absolute+6], 0 ; high word upper part
|
---|
853 |
|
---|
854 | ; Address of packet
|
---|
855 | mov si, offset [INT13X_DAP] ; disk address packet
|
---|
856 |
|
---|
857 | ; Do the extended read
|
---|
858 | mov ah, 42h ; read function
|
---|
859 | int 13h ; transfer to bios
|
---|
860 |
|
---|
861 | ; Error occured
|
---|
862 | jc DriveIO_ReadSectorLBA_exit
|
---|
863 |
|
---|
864 | ; AH should also be zero
|
---|
865 | test ah, ah
|
---|
866 | stc
|
---|
867 | jnz DriveIO_ReadSectorLBA_exit
|
---|
868 |
|
---|
869 | ; Disk read succeeded, clear CF
|
---|
870 | clc
|
---|
871 |
|
---|
872 | DriveIO_ReadSectorLBA_exit:
|
---|
873 |
|
---|
874 | ; Pop all registers
|
---|
875 | pop es
|
---|
876 | pop ds
|
---|
877 | popa
|
---|
878 |
|
---|
879 | ret
|
---|
880 | DriveIO_ReadSectorLBA EndP
|
---|
881 |
|
---|
882 |
|
---|
883 |
|
---|
884 | ;##############################################################################
|
---|
885 | ;# ACTION : Writes a sector to disk using INT13 extensions
|
---|
886 | ;# ----------------------------------------------------------------------------
|
---|
887 | ;# EFFECTS : Modifies DAP structure and mofifies the disk
|
---|
888 | ;# ----------------------------------------------------------------------------
|
---|
889 | ;# IN : BX:AX - LBA address of sector
|
---|
890 | ;# : DI:SI - SEG:OFF of transfer buffer
|
---|
891 | ;# ----------------------------------------------------------------------------
|
---|
892 | ;# OUT : CF=1 - failure
|
---|
893 | ;##############################################################################
|
---|
894 | DriveIO_WriteSectorLBA Proc Near
|
---|
895 |
|
---|
896 | IFDEF AUX_DEBUG
|
---|
897 | IF 0
|
---|
898 | DBG_TEXT_OUT_AUX 'DriveIO_WriteSectorLBA:'
|
---|
899 | PUSHRF
|
---|
900 | call DEBUG_DumpRegisters
|
---|
901 | call AuxIO_DumpParagraph
|
---|
902 | call AuxIO_TeletypeNL
|
---|
903 | POPRF
|
---|
904 | ENDIF
|
---|
905 | ENDIF
|
---|
906 |
|
---|
907 | ; Push all registers
|
---|
908 | pusha
|
---|
909 | push ds
|
---|
910 | push es
|
---|
911 |
|
---|
912 | ; One sector to read
|
---|
913 | mov cs:[INT13X_DAP_NumBlocks], 1
|
---|
914 |
|
---|
915 | ; Setup transfer address
|
---|
916 | mov wptr cs:[INT13X_DAP_Transfer+0], si ; offset
|
---|
917 | mov wptr cs:[INT13X_DAP_Transfer+2], di ; segment
|
---|
918 |
|
---|
919 | ; Setup LBA64 address of requested sector
|
---|
920 | mov wptr cs:[INT13X_DAP_Absolute+0], ax ; low word lower part
|
---|
921 | mov wptr cs:[INT13X_DAP_Absolute+2], bx ; high word lower part
|
---|
922 | mov wptr cs:[INT13X_DAP_Absolute+4], 0 ; low word upper part
|
---|
923 | mov wptr cs:[INT13X_DAP_Absolute+6], 0 ; high word upper part
|
---|
924 |
|
---|
925 | ; Address of packet
|
---|
926 | mov si, offset [INT13X_DAP] ; disk address packet
|
---|
927 |
|
---|
928 | ; Do the extended write
|
---|
929 | xor al, al ; no write verify
|
---|
930 | mov ah, 43h ; write function
|
---|
931 | int 13h ; transfer to bios
|
---|
932 |
|
---|
933 | ; Error occured
|
---|
934 | jc DriveIO_WriteSectorLBA_exit
|
---|
935 |
|
---|
936 | ; AH should also be zero
|
---|
937 | test ah, ah
|
---|
938 | stc
|
---|
939 | jnz DriveIO_WriteSectorLBA_exit
|
---|
940 |
|
---|
941 | ; Disk write succeeded, clear CF
|
---|
942 | clc
|
---|
943 |
|
---|
944 | DriveIO_WriteSectorLBA_exit:
|
---|
945 |
|
---|
946 | ; Pop all registers
|
---|
947 | pop es
|
---|
948 | pop ds
|
---|
949 | popa
|
---|
950 |
|
---|
951 | ret
|
---|
952 | DriveIO_WriteSectorLBA EndP
|
---|
953 |
|
---|
954 |
|
---|
955 |
|
---|
956 |
|
---|
957 | ;##############################################################################
|
---|
958 | ;# The Master LVM sector is *not* necessarily located at the end of the BIOS
|
---|
959 | ;# view of TRACK0. Its location depends on the *OS/2 geometry* active when the
|
---|
960 | ;# disk was partitioned. For disks < 502MiB this will most likely be LBA sector
|
---|
961 | ;# 62, but for disks >502MiB, *extended* OS/2 geometry was used and DANIS506
|
---|
962 | ;# uses SPT=127 for disks < 1TiB while IBMS506 uses SPT=255.
|
---|
963 | ;# When a huge disk < 1TiB was partitioned with IBMS506, thus using SPT=255,
|
---|
964 | ;# and the driver was later changed to DANIS506, DANI uses SPT=255, eventhough
|
---|
965 | ;# the disk < 1TiB. Whether it is DANI that is LVM aware or something else
|
---|
966 | ;# (maybe LVM itself) that makes DANI use the correct geometry has yet to be
|
---|
967 | ;# investigated.
|
---|
968 | ;#
|
---|
969 | ;# Related geometry issues are also present with USB sticks, which can get
|
---|
970 | ;# assigned a geometry by OS/2, which can depend if the stick was partitioned
|
---|
971 | ;# on foreign systems or not, or even OS/2 manufacturing a geometry that is not
|
---|
972 | ;# the same as the BIOS reports to us here. In both cases, fixed disks and
|
---|
973 | ;# removable disks, the geometry recorded in the BPB of a partition can also
|
---|
974 | ;# influence the geometry that OS/2 assigns. This is the case when 'preparing'
|
---|
975 | ;# disks for LVM use, in which case BPB values could be incorporated.
|
---|
976 | ;#
|
---|
977 | ;# What this all boils down to, is that the geometry reported by the BIOS is
|
---|
978 | ;# of no practical use, especially not when taking BIOS USB MSD emulation into
|
---|
979 | ;# account. These are among the reasons why AirBoot needs to use LBA addressing
|
---|
980 | ;# when handling LVM stuff and why LBA use cannot be disabled in the SETUP
|
---|
981 | ;# anymore.
|
---|
982 | ;#
|
---|
983 | ;# So, a Master LVM sector can be present on any sector from LBA 254 downwards
|
---|
984 | ;# and the only way to locate the correct one is to scan all the way down and,
|
---|
985 | ;# if one is found, do proper validation on its values, because it may also be
|
---|
986 | ;# a 'phantom' LVM sector left over from previous partition layouts.
|
---|
987 | ;# Most of such 'phantoms' can be filtered out by verifying the location of
|
---|
988 | ;# the found sector against the OS/2 geometry it specifies itself, which means
|
---|
989 | ;# it must be located at the LBA of the SPT-1 it specifies.
|
---|
990 | ;##############################################################################
|
---|
991 | ;# ACTION : Locates the Master LVM sector on the specified disk
|
---|
992 | ;# ----------------------------------------------------------------------------
|
---|
993 | ;# EFFECTS : Leaves [Scratch] with last sector read or cleared
|
---|
994 | ;# ----------------------------------------------------------------------------
|
---|
995 | ;# IN : DL - BIOS disk number of drive to search
|
---|
996 | ;# ----------------------------------------------------------------------------
|
---|
997 | ;# OUT : CF=1 - found
|
---|
998 | ;# : BX:AX - LBA address of LVM sector if found, 0 otherwise
|
---|
999 | ;##############################################################################
|
---|
1000 | DriveIO_LocateMasterLVMSector Proc Near uses cx dx si di ds es
|
---|
1001 |
|
---|
1002 | IFDEF AUX_DEBUG
|
---|
1003 | IF 1
|
---|
1004 | DBG_TEXT_OUT_AUX 'DriveIO_LocateMasterLVMSector:'
|
---|
1005 | PUSHRF
|
---|
1006 | call DEBUG_DumpRegisters
|
---|
1007 | ;~ call AuxIO_DumpSector
|
---|
1008 | ;~ call AuxIO_DumpParagraph
|
---|
1009 | ;~ call AuxIO_TeletypeNL
|
---|
1010 | POPRF
|
---|
1011 | ENDIF
|
---|
1012 | ENDIF
|
---|
1013 |
|
---|
1014 | ; LBA address to start scanning down from
|
---|
1015 | mov cx, 255
|
---|
1016 |
|
---|
1017 | ; Make sure ES==DS
|
---|
1018 | push ds
|
---|
1019 | pop es
|
---|
1020 |
|
---|
1021 | ; Because JCXZ is used, LBA sector 0 is never loaded and checked.
|
---|
1022 | ; This is of course no problem since it is the MBR.
|
---|
1023 | DriveIO_LocateMasterLVMSector_next:
|
---|
1024 | mov si, offset [Scratch] ; Use scratch area to load sectors
|
---|
1025 | call ClearSectorBuffer ; Clear the scratch area
|
---|
1026 | clc ; Indicate Master LVM sector not found
|
---|
1027 | jcxz DriveIO_LocateMasterLVMSector_done
|
---|
1028 |
|
---|
1029 | ; Read the LBA sector specified in CX
|
---|
1030 | mov ax, cx ; LBA low
|
---|
1031 | xor bx, bx ; LBA high
|
---|
1032 | mov di, ds ; Segment of scratch buffer
|
---|
1033 | mov si, offset [Scratch] ; Offset of scratch buffer
|
---|
1034 | call DriveIO_ReadSectorLBA ; Read the sector
|
---|
1035 | lahf ; Save CF
|
---|
1036 | dec cx ; Prepare LBA of next sector to read
|
---|
1037 | sahf ; Restore CF
|
---|
1038 | ; No need to do any LVM sector validation when read error, read next
|
---|
1039 | jc DriveIO_LocateMasterLVMSector_next
|
---|
1040 |
|
---|
1041 | ; See if the read sector has a valid signature and checksum
|
---|
1042 | call LVM_ValidateSector
|
---|
1043 |
|
---|
1044 | ; NC indicates invalid or none-LVM sector, read next
|
---|
1045 | jnc DriveIO_LocateMasterLVMSector_next
|
---|
1046 |
|
---|
1047 | ; We have found a valid LVM sector !
|
---|
1048 | ; So it contains the OS/2 geometry for the disk.
|
---|
1049 | ; That means this LVM sector itself must be located on the last sector
|
---|
1050 | ; of the SPT value its OS/2 geometery specifies, which, in LBA terms
|
---|
1051 | ; is LVM SPT-1 -- let's check that...
|
---|
1052 | mov bx, offset [Scratch] ; Offset of the loaded LVM sector
|
---|
1053 | mov al, [bx+LocLVM_Secs] ; Get the LVM SPT value (<=255)
|
---|
1054 | dec al ; Adjust to LVM LBA
|
---|
1055 | mov ah, cl ; Get next LVM LBA to search
|
---|
1056 | inc ah ; This one was found here
|
---|
1057 | cmp al, ah ; If same, LVM LBA location OK
|
---|
1058 | jne DriveIO_LocateMasterLVMSector_next
|
---|
1059 |
|
---|
1060 | ; The LVM sector we found is at the location it should be on disk,
|
---|
1061 | ; so it's almost 99% sure this is the correct one.
|
---|
1062 | ; Now we should compare the start and sizes of the partitions in the
|
---|
1063 | ; MBR with the partitions specified in this LVM record.
|
---|
1064 | ; We'll implement that later after some more research.
|
---|
1065 | ; For now we assume this is the correct Master LVM sector for the disk.
|
---|
1066 | inc cx ; CX was prepared to read next, correct that
|
---|
1067 | stc ; Indicate we have found the Master LVM sector
|
---|
1068 |
|
---|
1069 | DriveIO_LocateMasterLVMSector_done:
|
---|
1070 | mov bx, 0 ; A Master LVM sector always has high LBA=0
|
---|
1071 | mov ax, cx ; Low LBA of Master LVM sector
|
---|
1072 |
|
---|
1073 | ; We leave it up to the caller to store the value in a proper place
|
---|
1074 | ret
|
---|
1075 | DriveIO_LocateMasterLVMSector EndP
|
---|
1076 |
|
---|
1077 |
|
---|
1078 |
|
---|
1079 | ;
|
---|
1080 | ; ############################################################
|
---|
1081 | ; # Check for a valid MBR-sector to be written to disk #
|
---|
1082 | ; ############################################################
|
---|
1083 | ;
|
---|
1084 | ; In
|
---|
1085 | ; --
|
---|
1086 | ; DL = Physical Disk
|
---|
1087 | ; BX:CX = LBA sector
|
---|
1088 | ; DI:SI = Source buffer
|
---|
1089 | ;
|
---|
1090 | ; Out
|
---|
1091 | ; ---
|
---|
1092 | ; CY = 1 if invalid MBR in source buffer, 0 if valid
|
---|
1093 | ;
|
---|
1094 | ; This routine is called when DriveIO_SaveSector attempts to write to the MBR.
|
---|
1095 | ; It checks if the sector to be written has some sensible values in certain
|
---|
1096 | ; places. In fact, if the sector is written to the boot-disk, the AiR-BOOT
|
---|
1097 | ; signature should be present and the partition table should be the same
|
---|
1098 | ; as the one at the start of the AiR-BOOT code in memory, except maybe for the
|
---|
1099 | ; active flags.
|
---|
1100 | ; For other disks, only the active flags are checked to be 00h or 80h and
|
---|
1101 | ; the AA55h MBR signature.
|
---|
1102 | ;
|
---|
1103 | DriveIO_ProtectMBR Proc Near
|
---|
1104 | pusha ; Push all registers
|
---|
1105 | push es ; Push ES because we need it for string instructions
|
---|
1106 | push cs ; Make ES point...
|
---|
1107 | pop es ; to CS
|
---|
1108 |
|
---|
1109 | ; Save the pointer to the sector to write in BX
|
---|
1110 | mov bx,si
|
---|
1111 |
|
---|
1112 | ;
|
---|
1113 | ; If the sector to be written is not the boot-disk, then skip
|
---|
1114 | ; checking the AiR-BOOT MBR.
|
---|
1115 | ;
|
---|
1116 | cmp dl, [BIOS_BootDisk]
|
---|
1117 | jne DriveIO_ProtectMBR_is_not_bootdisk
|
---|
1118 |
|
---|
1119 | ;
|
---|
1120 | ; The boot-disk is accessed so the sector to be written must be
|
---|
1121 | ; the AiR-BOOT MBR. This is the same as the first 512 bytes
|
---|
1122 | ; relocated to 8000:0000 and this the start of the AB-code.
|
---|
1123 | ;
|
---|
1124 | mov si,bx ; Get pointer to sector to write
|
---|
1125 | xor di,di ; Point DI to start of AB-code (MBR)
|
---|
1126 | mov cx, offset [MBR_PartTable] ; Bytes upto P-table must be same
|
---|
1127 | cld ; Compare upwards
|
---|
1128 | repe cmpsb ; Compare upto P-table
|
---|
1129 |
|
---|
1130 | ; If not the same this is not the an AiR-BOOT boot-disk MBR !
|
---|
1131 | jne DriveIO_ProtectMBR_not_valid_MBR ; SEVERE ERROR !
|
---|
1132 |
|
---|
1133 | ; Continue with signature check
|
---|
1134 | jmp DriveIO_ProtectMBR_check_signature
|
---|
1135 |
|
---|
1136 |
|
---|
1137 | ;
|
---|
1138 | ; The disk is not the boot-disk so we don't know what kind of MBR is on it.
|
---|
1139 | ; Some sanity checks should be here.
|
---|
1140 | ;
|
---|
1141 | DriveIO_ProtectMBR_is_not_bootdisk:
|
---|
1142 |
|
---|
1143 | ;
|
---|
1144 | ; sanity checks...
|
---|
1145 | ;
|
---|
1146 |
|
---|
1147 | ; Continue with signature check
|
---|
1148 | jmp DriveIO_ProtectMBR_check_signature
|
---|
1149 |
|
---|
1150 |
|
---|
1151 | DriveIO_ProtectMBR_check_signature:
|
---|
1152 | ; See if the sector to write contains a valid signature
|
---|
1153 | mov si,bx ; Get pointer to sector to write
|
---|
1154 | mov di, offset [MBR_Sig] ; Offset to MBR signature
|
---|
1155 | add si,di ; Make SI point to it in sec to write
|
---|
1156 | lodsw ; Load it
|
---|
1157 | cmp ax,0aa55h ; See if it is valid
|
---|
1158 |
|
---|
1159 | ; If no signature this cannot be a valid MBR !
|
---|
1160 | jne DriveIO_ProtectMBR_not_valid_MBR ; SEVERE ERROR !
|
---|
1161 |
|
---|
1162 |
|
---|
1163 | ;
|
---|
1164 | ; The sector to be written seems to be valid.
|
---|
1165 | ; Set CY=0 to indicate a valid MBR.
|
---|
1166 | ;
|
---|
1167 | DriveIO_ProtectMBR_is_valid_MBR:
|
---|
1168 | clc
|
---|
1169 | jmp DriveIO_ProtectMBR_end
|
---|
1170 |
|
---|
1171 | ;
|
---|
1172 | ; Something is terribly wrong; a non-MBR sector seems about to be written.
|
---|
1173 | ; Set CY=1 and let the calling code handle this situation.
|
---|
1174 | ;
|
---|
1175 | DriveIO_ProtectMBR_not_valid_MBR:
|
---|
1176 | stc
|
---|
1177 | jmp DriveIO_ProtectMBR_end
|
---|
1178 |
|
---|
1179 | ;
|
---|
1180 | ; Return to the caller with no registers modyfied except FLAGS.
|
---|
1181 | ;
|
---|
1182 | DriveIO_ProtectMBR_end:
|
---|
1183 | pop es
|
---|
1184 | popa
|
---|
1185 | ret
|
---|
1186 | DriveIO_ProtectMBR Endp
|
---|
1187 |
|
---|
1188 |
|
---|
1189 |
|
---|
1190 | ; #########################################################################
|
---|
1191 | ; Routine: Checks if the MBR is addressed by either CHS or LBA
|
---|
1192 | ; #########################################################################
|
---|
1193 | ; Calling : bx:ax - Absolute sector
|
---|
1194 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
1195 | ; Returns : ZF=1 if MBR is addressed, else ZF=0
|
---|
1196 | ; Preserve: all registers
|
---|
1197 | ; #########################################################################
|
---|
1198 | DriveIO_MBR_Addressed Proc
|
---|
1199 | push ax
|
---|
1200 | push bx
|
---|
1201 |
|
---|
1202 | or bx,ax ; Results in 0 in BX if MBR is addressed by LBA
|
---|
1203 | jz DriveIO_MBR_Addressed_done
|
---|
1204 |
|
---|
1205 | mov ax,cx ; Results in 1 in AX if CYL 0, SEC 1 is addressed
|
---|
1206 | add al,dh ; Results in 1 in AX if HEAD 0 is addressed
|
---|
1207 | dec ax ; Results in 0 in AX if MBR is addressed by CHS
|
---|
1208 |
|
---|
1209 | DriveIO_MBR_Addressed_done:
|
---|
1210 | pop bx
|
---|
1211 | pop ax
|
---|
1212 | ret
|
---|
1213 | DriveIO_MBR_Addressed EndP
|
---|
1214 |
|
---|
1215 |
|
---|
1216 |
|
---|
1217 |
|
---|
1218 | ; #########################################################################
|
---|
1219 | ; Routine: Writes DS:SI to a specified sector
|
---|
1220 | ; #########################################################################
|
---|
1221 | ; Calling : bx:ax - Absolute sector
|
---|
1222 | ; cx:dx - Cylinder/Sector, Side/Drive (hi/lo-byte)
|
---|
1223 | ; ds:si - Source-Adress
|
---|
1224 | ; Returns : none
|
---|
1225 | ; Preserve: all registers
|
---|
1226 | ; #########################################################################
|
---|
1227 | DriveIO_SaveSector Proc Near Uses ax bx cx dx ds si es di
|
---|
1228 |
|
---|
1229 | IFDEF AUX_DEBUG
|
---|
1230 | IF 0
|
---|
1231 | DBG_TEXT_OUT_AUX 'DriveIO_SaveSector:'
|
---|
1232 | PUSHRF
|
---|
1233 | ;~ call DEBUG_DumpRegisters
|
---|
1234 | ;~ call AuxIO_DumpParagraph
|
---|
1235 | ;~ call AuxIO_TeletypeNL
|
---|
1236 | POPRF
|
---|
1237 | ENDIF
|
---|
1238 | ENDIF
|
---|
1239 |
|
---|
1240 |
|
---|
1241 | ;!
|
---|
1242 | ;! DEBUG_BLOCK
|
---|
1243 | ;! Force write to LBA0 to test interception routine.
|
---|
1244 | ;! Do *NOT* enable unless you are debugging, will overwrite MBR !
|
---|
1245 | ;!
|
---|
1246 | IFDEF AUX_DEBUG
|
---|
1247 | IF 0
|
---|
1248 | pushf
|
---|
1249 | pusha
|
---|
1250 | xor ax,ax
|
---|
1251 | xor bx,bx
|
---|
1252 | xor cx,cx
|
---|
1253 | inc cx
|
---|
1254 | xor dh,dh
|
---|
1255 | popa
|
---|
1256 | popf
|
---|
1257 | ENDIF
|
---|
1258 | ENDIF
|
---|
1259 |
|
---|
1260 | ;
|
---|
1261 | ; Check if the MBR is the destination for the write.
|
---|
1262 | ; ZF=1 if so.
|
---|
1263 | ;
|
---|
1264 | call DriveIO_MBR_Addressed
|
---|
1265 | jnz DriveIO_SaveSector_continue_write
|
---|
1266 |
|
---|
1267 |
|
---|
1268 | ; MBR is addressed, check the sector that is requested to be written.
|
---|
1269 | ; For the bootdisk it should contain the AiR-BOOT signature, valid
|
---|
1270 | ; partition-table entries and the AA55h signature.
|
---|
1271 | ; If not, something is terribly wrong in some piece of the AB code.
|
---|
1272 | ; For any other disk (80h+) at least a valid partition table should
|
---|
1273 | ; be present together with the AA55h signature.
|
---|
1274 | call DriveIO_ProtectMBR
|
---|
1275 | jnc DriveIO_SaveSector_continue_write
|
---|
1276 |
|
---|
1277 |
|
---|
1278 | ;
|
---|
1279 | ; WE HAVE A SEVERE ERROR CONDITION !
|
---|
1280 | ; SOME AB CODE TRIES TO WRITE A NON-MBR TO THE DISK !
|
---|
1281 | ; ASK THE USER TO REPORT THIS !
|
---|
1282 | ; HALT THE SYSTEM !
|
---|
1283 | ;
|
---|
1284 |
|
---|
1285 | ; Show error-box
|
---|
1286 | mov cx, 0C04h
|
---|
1287 | mov si, offset NonMBRwrite
|
---|
1288 | call SETUP_ShowErrorBox
|
---|
1289 | mov cx, 0C04h
|
---|
1290 | mov si, offset NonMBRwrite_rep
|
---|
1291 | call SETUP_ShowErrorBox
|
---|
1292 |
|
---|
1293 |
|
---|
1294 | IFDEF AUX_DEBUG
|
---|
1295 | IF 0
|
---|
1296 | pushf
|
---|
1297 | pusha
|
---|
1298 | mov si, offset [NonMBRwrite]
|
---|
1299 | call AuxIO_TeletypeNL
|
---|
1300 | call AuxIO_Print
|
---|
1301 | call AuxIO_TeletypeNL
|
---|
1302 | popa
|
---|
1303 | popf
|
---|
1304 | ENDIF
|
---|
1305 | ENDIF
|
---|
1306 |
|
---|
1307 | ; Show popup and halt the system.
|
---|
1308 | jmp HaltSystem
|
---|
1309 |
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | ;
|
---|
1313 | ; Continue the write if not MBR sector or MBR to write is validated.
|
---|
1314 | ;
|
---|
1315 | DriveIO_SaveSector_continue_write:
|
---|
1316 | test byte ptr cs:[CurIO_UseExtension], 1
|
---|
1317 | jz DIOSS_UseNormal
|
---|
1318 | ; Are we forced do use LBA via Setting?
|
---|
1319 | ; Always use INT13X on v1.0.8+.
|
---|
1320 | ;~ test byte ptr cs:[CFG_ForceLBAUsage], 1
|
---|
1321 | ;~ jnz DIOSS_UseExtension
|
---|
1322 | jmp DIOSS_UseExtension
|
---|
1323 | ; Is the drive not a harddrive?
|
---|
1324 | cmp dl, 80h
|
---|
1325 | jb DIOSS_UseNormal
|
---|
1326 | ; Upper 8 bits of LBA-address set? -> Use LBA (maximum boundary is FB0400h)
|
---|
1327 | or bh, bh
|
---|
1328 | jnz DIOSS_UseExtension
|
---|
1329 | ; Compare Switch-Table value to bit 16-23 of LBA-address
|
---|
1330 | mov di, dx
|
---|
1331 | and di, 007Fh
|
---|
1332 | cmp bptr cs:[LBASwitchTable+di], bl
|
---|
1333 | jbe DIOSS_UseExtension
|
---|
1334 |
|
---|
1335 | DIOSS_UseNormal:
|
---|
1336 |
|
---|
1337 | IFDEF AUX_DEBUG
|
---|
1338 | IF 0
|
---|
1339 | DBG_TEXT_OUT_AUX 'DriveIO_WriteSectorCHS:'
|
---|
1340 | PUSHRF
|
---|
1341 | call DEBUG_DumpRegisters
|
---|
1342 | call AuxIO_DumpParagraph
|
---|
1343 | call AuxIO_TeletypeNL
|
---|
1344 | POPRF
|
---|
1345 | ENDIF
|
---|
1346 | ENDIF
|
---|
1347 |
|
---|
1348 | mov di, 3 ; retry count
|
---|
1349 | DIOSS_ErrorLoop:
|
---|
1350 | push ds
|
---|
1351 | pop es
|
---|
1352 | mov bx, si ; ES:BX - Destination
|
---|
1353 | mov ax, 0301h ; Function 3 - Write Sector
|
---|
1354 | int 13h
|
---|
1355 | jnc DIOSS_Success
|
---|
1356 | dec di ; decrement retry count
|
---|
1357 | jnz DIOSS_ErrorLoop
|
---|
1358 | call MBR_SaveError
|
---|
1359 |
|
---|
1360 | DIOSS_UseExtension:
|
---|
1361 |
|
---|
1362 | mov di, ds ; segment for transfer address
|
---|
1363 | call DriveIO_WriteSectorLBA ; extended write
|
---|
1364 | jc MBR_SaveError ; halt on error
|
---|
1365 |
|
---|
1366 | ;~ push cx
|
---|
1367 | ;~ mov cs:[INT13X_DAP_NumBlocks], 1 ; Copy ONE sector
|
---|
1368 | ;~ mov wptr cs:[INT13X_DAP_Transfer+0], si
|
---|
1369 | ;~ mov cx, ds
|
---|
1370 | ;~ mov wptr cs:[INT13X_DAP_Transfer+2], cx ; Fill out Transfer Adress
|
---|
1371 | ;~ mov wptr cs:[INT13X_DAP_Absolute+0], ax
|
---|
1372 | ;~ mov wptr cs:[INT13X_DAP_Absolute+2], bx ; Fill out Absolute Sector
|
---|
1373 | ;~ push cs
|
---|
1374 | ;~ pop ds
|
---|
1375 | ;~ mov si, offset [INT13X_DAP]
|
---|
1376 | ;~ mov ax, 4300h ; Extended Write (No Verify)
|
---|
1377 | ;~ int 13h
|
---|
1378 | ;~ pop cx
|
---|
1379 | ;~ jnc DIOSS_Success
|
---|
1380 | ;~ call MBR_SaveError
|
---|
1381 |
|
---|
1382 | DIOSS_Success:
|
---|
1383 | ret
|
---|
1384 | DriveIO_SaveSector EndP
|
---|
1385 |
|
---|
1386 |
|
---|
1387 |
|
---|
1388 |
|
---|
1389 | ;##############################################################################
|
---|
1390 | ;# When a disk has a Master LVM sector, it means it has been prepared for use
|
---|
1391 | ;# by OS/2 and contains important information about how OS/2 views its geometry
|
---|
1392 | ;# and other disk related properties. This function assumes the LBA address
|
---|
1393 | ;# of the Master LVM sector has already been located and simply loads the
|
---|
1394 | ;# sector into [LVMSector].
|
---|
1395 | ;#
|
---|
1396 | ;# Note that because this is an operation similar to the regular loading of
|
---|
1397 | ;# sectors, the disk I/O semantics are used here. This means CF=0 when an LVM
|
---|
1398 | ;# sector is successfully loaded and CF=1 otherwise.
|
---|
1399 | ;##############################################################################
|
---|
1400 | ;# ACTION : Loads the Master LVM sector if one exists
|
---|
1401 | ;# ----------------------------------------------------------------------------
|
---|
1402 | ;# EFFECTS : Modifies DAP structure and [LVMSector]
|
---|
1403 | ;# ----------------------------------------------------------------------------
|
---|
1404 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
1405 | ;# ----------------------------------------------------------------------------
|
---|
1406 | ;# OUT : CF=0 - Valid Master LVM sector found and loaded
|
---|
1407 | ;##############################################################################
|
---|
1408 | DriveIO_LoadMasterLVMSector Proc Near
|
---|
1409 |
|
---|
1410 | IFDEF AUX_DEBUG
|
---|
1411 | IF 0
|
---|
1412 | DBG_TEXT_OUT_AUX 'DriveIO_LoadMasterLVMSector:'
|
---|
1413 | PUSHRF
|
---|
1414 | ;~ call DEBUG_DumpRegisters
|
---|
1415 | ;~ call AuxIO_DumpParagraph
|
---|
1416 | ;~ call AuxIO_TeletypeNL
|
---|
1417 | POPRF
|
---|
1418 | ENDIF
|
---|
1419 | ENDIF
|
---|
1420 |
|
---|
1421 | ; Save all registers
|
---|
1422 | pusha
|
---|
1423 |
|
---|
1424 | ; Check if BIOS disk number is valid
|
---|
1425 | call DriveIO_IsValidHarddisk
|
---|
1426 | jc DriveIO_LoadMasterLVMSector_error
|
---|
1427 |
|
---|
1428 | ; Calculate the entry in the DISKINFO array for this disk
|
---|
1429 | call DriveIO_CalcDiskInfoPointer
|
---|
1430 |
|
---|
1431 | ; Save the entry for later recalls
|
---|
1432 | mov bp, bx
|
---|
1433 |
|
---|
1434 | ; Get the LBA address of the Master LVM sector
|
---|
1435 | mov ax, [bx+LocDISKINFO_LVM_MasterLBA+00h]
|
---|
1436 | mov bx, [bx+LocDISKINFO_LVM_MasterLBA+02h]
|
---|
1437 |
|
---|
1438 | ; LBA of Master LVM sector cannot be 0, so none was found during
|
---|
1439 | ; the gathering of disk information.
|
---|
1440 | mov cx, ax
|
---|
1441 | or cx, bx
|
---|
1442 | jz DriveIO_LoadMasterLVMSector_error
|
---|
1443 |
|
---|
1444 | ; Load it into [LVMSector]
|
---|
1445 | mov di, ds
|
---|
1446 | mov si, offset [LVMSector]
|
---|
1447 | call DriveIO_ReadSectorLBA
|
---|
1448 | jc DriveIO_LoadMasterLVMSector_error
|
---|
1449 |
|
---|
1450 | ; Validate the Master LVM sector
|
---|
1451 | call LVM_ValidateSector
|
---|
1452 |
|
---|
1453 | ; Complement success indicator to conform to semantics of this function
|
---|
1454 | cmc
|
---|
1455 |
|
---|
1456 | ; Master LVM sector was valid and is now loaded in [LVMSector]
|
---|
1457 | jnc DriveIO_LoadMasterLVMSector_ret
|
---|
1458 |
|
---|
1459 | DriveIO_LoadMasterLVMSector_error:
|
---|
1460 |
|
---|
1461 | ; Clear the sector buffer for safety reasons
|
---|
1462 | mov si, offset [LVMSector]
|
---|
1463 | call ClearSectorBuffer
|
---|
1464 |
|
---|
1465 | ; Indicate no Master LVM sector loaded
|
---|
1466 | stc
|
---|
1467 |
|
---|
1468 | DriveIO_LoadMasterLVMSector_ret:
|
---|
1469 |
|
---|
1470 | ; Restore all registers
|
---|
1471 | popa
|
---|
1472 |
|
---|
1473 | ret
|
---|
1474 | DriveIO_LoadMasterLVMSector Endp
|
---|
1475 |
|
---|
1476 |
|
---|
1477 |
|
---|
1478 |
|
---|
1479 | ;##############################################################################
|
---|
1480 | ;# There is much information to know about the connected disks.
|
---|
1481 | ;# We also want this information clustered per disk and available before
|
---|
1482 | ;# further disk and partition scanning takes place.
|
---|
1483 | ;# This function gathers such information like INT13, INT13X, MBR, LVM, more.
|
---|
1484 | ;# Especially important is the LVM information, because that contains the
|
---|
1485 | ;# geometry OS/2 uses to access the disk. Other important information is the
|
---|
1486 | ;# presence of valid MBRs, logical partitions and whatnot.
|
---|
1487 | ;# This function gathers such information and stores it in a DISKINFO structure
|
---|
1488 | ;# for which an instance exists for every disk found.
|
---|
1489 | ;##############################################################################
|
---|
1490 | ;# ACTION : Gather disk information and store this in the BSS
|
---|
1491 | ;# ----------------------------------------------------------------------------
|
---|
1492 | ;# EFFECTS : Modifies DAP structure and the buffers it uses, fills DISKINFO[n]
|
---|
1493 | ;# ----------------------------------------------------------------------------
|
---|
1494 | ;# IN : DL - BIOS disk number (80h,81h,etc)
|
---|
1495 | ;# ----------------------------------------------------------------------------
|
---|
1496 | ;# OUT : CF=1 - failure
|
---|
1497 | ;##############################################################################
|
---|
1498 | DriveIO_GatherDiskInfo Proc Near
|
---|
1499 |
|
---|
1500 | IFDEF AUX_DEBUG
|
---|
1501 | IF 1
|
---|
1502 | DBG_TEXT_OUT_AUX 'DriveIO_GatherDiskInfo:'
|
---|
1503 | PUSHRF
|
---|
1504 | call DEBUG_DumpRegisters
|
---|
1505 | ;~ call AuxIO_DumpParagraph
|
---|
1506 | ;~ call AuxIO_TeletypeNL
|
---|
1507 | POPRF
|
---|
1508 | ENDIF
|
---|
1509 | ENDIF
|
---|
1510 |
|
---|
1511 | ; Push all registers we use
|
---|
1512 | pusha
|
---|
1513 | push ds
|
---|
1514 | push es
|
---|
1515 |
|
---|
1516 | ; Make sure ES=DS
|
---|
1517 | push ds
|
---|
1518 | pop es
|
---|
1519 |
|
---|
1520 | ; Check if BIOS disk number is valid
|
---|
1521 | call DriveIO_IsValidHarddisk
|
---|
1522 | jc DriveIO_GatherDiskInfo_error
|
---|
1523 |
|
---|
1524 | ; Calculate the entry in the DISKINFO array for this disk
|
---|
1525 | call DriveIO_CalcDiskInfoPointer
|
---|
1526 |
|
---|
1527 | ; Save the entry for later recalls
|
---|
1528 | mov bp, bx
|
---|
1529 |
|
---|
1530 | ; Store the BIOS disk number in the structure
|
---|
1531 | mov [bx+LocDISKINFO_DiskNum], dl
|
---|
1532 |
|
---|
1533 | ; ------------------------------------------------------------------- [ INT13 ]
|
---|
1534 |
|
---|
1535 | ; Get BIOS Disk Parameters (legacy method)
|
---|
1536 | mov ah, 08h ; Get Disk Parameters
|
---|
1537 | int 13h ; Call BIOS
|
---|
1538 |
|
---|
1539 | ; CF=1 or AH!=0 indicates error
|
---|
1540 | jc DriveIO_GatherDiskInfo_error
|
---|
1541 | test ah, ah
|
---|
1542 | jnz DriveIO_GatherDiskInfo_error
|
---|
1543 |
|
---|
1544 | ; Recall DISKINFO entry
|
---|
1545 | mov bx, bp
|
---|
1546 |
|
---|
1547 | ; Store SPT (WORD)
|
---|
1548 | xor ah, ah ; Zero extend SPT to 16 bits
|
---|
1549 | mov al, cl ; Hi 2 bits max cyl and max sec
|
---|
1550 | and al, 3fh ; Mask max sec (1-based)
|
---|
1551 | mov [bx+LocDISKINFO_I13_Secs], ax ; Store SPT
|
---|
1552 |
|
---|
1553 | ; Store HEADS (WORD)
|
---|
1554 | xor dl, dl ; Zero extend HEADS to 16 bits
|
---|
1555 | xchg dl, dh ; Get max head (0-based)
|
---|
1556 | inc dx ; Head count
|
---|
1557 | mov [bx+LocDISKINFO_I13_Heads], dx ; Store HEADS
|
---|
1558 |
|
---|
1559 | ; Store CYLS (WORD)
|
---|
1560 | shr cl, 6 ; Hi 2 bits of max cyl to 1:0
|
---|
1561 | xchg cl, ch ; Max cyl (0-based)
|
---|
1562 | inc cx ; Cyl count
|
---|
1563 | mov [bx+LocDISKINFO_I13_Cyls], cx ; Store CYLS
|
---|
1564 |
|
---|
1565 | ; Recall BIOS disk number
|
---|
1566 | mov dl, [bx+LocDISKINFO_DiskNum]
|
---|
1567 |
|
---|
1568 | ; ------------------------------------------------------------------ [ INT13X ]
|
---|
1569 |
|
---|
1570 | ; Get BIOS Disk Parameters (extended method)
|
---|
1571 | mov si, offset [Scratch] ; Buffer to return disk info
|
---|
1572 | mov ax, 80h ; Size of buffer
|
---|
1573 | mov [si], ax ; Store it in first word
|
---|
1574 | mov ah, 48h ; Get Extended Disk Parameters
|
---|
1575 | int 13h ; Call BIOS
|
---|
1576 |
|
---|
1577 | ; CF=1 or AH!=0 indicates error
|
---|
1578 | jc DriveIO_GatherDiskInfo_error
|
---|
1579 | test ah, ah
|
---|
1580 | jnz DriveIO_GatherDiskInfo_error
|
---|
1581 |
|
---|
1582 | ; Store flags (WORD)
|
---|
1583 | cld ; Direction up
|
---|
1584 | lodsw ; Buffersize, discard
|
---|
1585 | lodsw ; Flags (CHS valid etc)
|
---|
1586 | mov [bx+LocDISKINFO_I13X_Flags], ax ; Store them
|
---|
1587 |
|
---|
1588 | ; Store CYLS (DWORD)
|
---|
1589 | lodsw ; Cyl count low
|
---|
1590 | mov [bx+LocDISKINFO_I13X_Cyls+00h], ax ; Store CYLS low
|
---|
1591 | lodsw ; Cyl count high
|
---|
1592 | mov [bx+LocDISKINFO_I13X_Cyls+02h], ax ; Store CYLS high
|
---|
1593 |
|
---|
1594 | ; Store HEADS (DWORD)
|
---|
1595 | lodsw ; Head count low
|
---|
1596 | mov [bx+LocDISKINFO_I13X_Heads+00h], ax ; Store HEADS low
|
---|
1597 | lodsw ; Head count high
|
---|
1598 | mov [bx+LocDISKINFO_I13X_Heads+02h], ax ; Store HEADS high
|
---|
1599 |
|
---|
1600 | ; Store SPT (DWORD)
|
---|
1601 | lodsw ; Secs per track low
|
---|
1602 | mov [bx+LocDISKINFO_I13X_Secs+00h], ax ; Store SPT low
|
---|
1603 | lodsw ; Secs per track high
|
---|
1604 | mov [bx+LocDISKINFO_I13X_Secs+02h], ax ; Store SPT high
|
---|
1605 |
|
---|
1606 | ; Store total LBA sectors (QWORD)
|
---|
1607 | lea di, [bx+LocDISKINFO_I13X_SecsLBA]
|
---|
1608 | mov cx, 4
|
---|
1609 | rep movsw
|
---|
1610 |
|
---|
1611 | ; Store sector size (WORD)
|
---|
1612 | lodsw
|
---|
1613 | mov [bx+LocDISKINFO_I13X_SecSize], ax
|
---|
1614 |
|
---|
1615 | ; Store bus name (4 bytes, space padded, v3.0+)
|
---|
1616 | lea si, [Scratch+24h]
|
---|
1617 | lea di, [bx+LocDISKINFO_I13X_HostBus]
|
---|
1618 | movsw
|
---|
1619 | movsw
|
---|
1620 |
|
---|
1621 | ; Store interface name (8 bytes, space padded, v3.0+)
|
---|
1622 | lea di, [bx+LocDISKINFO_I13X_Interface]
|
---|
1623 | mov cx, 4
|
---|
1624 | rep movsw
|
---|
1625 |
|
---|
1626 | ; Should gather some more INT13X info here,
|
---|
1627 | ; like maybe Advanced Format stuff or so.
|
---|
1628 | ; We'll investigate that at a later time.
|
---|
1629 |
|
---|
1630 | ; --------------------------------------------------------------------- [ MBR ]
|
---|
1631 |
|
---|
1632 | ; Load the MBR
|
---|
1633 | mov si, offset [TmpSector]
|
---|
1634 | call DriveIO_LoadMBR
|
---|
1635 |
|
---|
1636 | ; Store MBR flags (valid sig, partitions present, airboot installed)
|
---|
1637 | mov [bx+LocDISKINFO_MbrFlags], al
|
---|
1638 |
|
---|
1639 | ; Recall BIOS disk number
|
---|
1640 | mov dl, [bx+LocDISKINFO_DiskNum]
|
---|
1641 |
|
---|
1642 | ; --------------------------------------------------------------------- [ LVM ]
|
---|
1643 |
|
---|
1644 | ; Locate the Master LVM sector, if any
|
---|
1645 | call DriveIO_LocateMasterLVMSector
|
---|
1646 |
|
---|
1647 | ; Save Master LVM sector LBA high
|
---|
1648 | mov cx, bx
|
---|
1649 |
|
---|
1650 | ; Recall DISKINFO entry
|
---|
1651 | mov bx, bp
|
---|
1652 |
|
---|
1653 | ; Store Master LVM sector LBA
|
---|
1654 | mov [bx+LocDISKINFO_LVM_MasterLBA+00h], ax
|
---|
1655 | mov [bx+LocDISKINFO_LVM_MasterLBA+02h], cx
|
---|
1656 |
|
---|
1657 | ; No Master LVM sector found, so skip storing LVM info for this disk
|
---|
1658 | jnc DriveIO_GatherDiskInfo_no_master_lvm
|
---|
1659 |
|
---|
1660 | ; Load the Master LVM sector into [LVMSector]
|
---|
1661 | call DriveIO_LoadMasterLVMSector
|
---|
1662 |
|
---|
1663 | ; No valid Master LVM sector, so skip storing LVM info for this disk
|
---|
1664 | jc DriveIO_GatherDiskInfo_no_master_lvm
|
---|
1665 |
|
---|
1666 | ; A valid Master LVM sector has been loaded into [LVMSector]
|
---|
1667 | mov si, offset [LVMSector]
|
---|
1668 |
|
---|
1669 | ; Get the number of sectors per track (OS/2 geometry)
|
---|
1670 | mov ax, [si+LocLVM_Secs+00h]
|
---|
1671 | mov cx, [si+LocLVM_Secs+02h]
|
---|
1672 |
|
---|
1673 | ; Store it
|
---|
1674 | mov [bx+LocDISKINFO_LVM_Secs+00h], ax
|
---|
1675 | mov [bx+LocDISKINFO_LVM_Secs+02h], cx
|
---|
1676 |
|
---|
1677 | ; Get the number of heads (OS/2 geometry)
|
---|
1678 | mov ax, [si+LocLVM_Heads+00h]
|
---|
1679 | mov cx, [si+LocLVM_Heads+02h]
|
---|
1680 |
|
---|
1681 | ; Store it
|
---|
1682 | mov [bx+LocDISKINFO_LVM_Heads+00h], ax
|
---|
1683 | mov [bx+LocDISKINFO_LVM_Heads+02h], cx
|
---|
1684 |
|
---|
1685 | ; Should gather some more LVM info here,
|
---|
1686 | ; like OS/2 extended geometry and other flags.
|
---|
1687 | ; We'll implement that at a later time.
|
---|
1688 |
|
---|
1689 | DriveIO_GatherDiskInfo_no_master_lvm:
|
---|
1690 |
|
---|
1691 | ; When no Master LVM sector was found,
|
---|
1692 | ; the LVM info in the DISKINFO structure for the disk
|
---|
1693 | ; will be ZERO because the area was cleared in PRECRAP.
|
---|
1694 |
|
---|
1695 | ; Indicate success
|
---|
1696 | clc
|
---|
1697 |
|
---|
1698 | jmp DriveIO_GatherDiskInfo_ret
|
---|
1699 |
|
---|
1700 | DriveIO_GatherDiskInfo_error:
|
---|
1701 | stc
|
---|
1702 | DriveIO_GatherDiskInfo_ret:
|
---|
1703 |
|
---|
1704 |
|
---|
1705 | IFDEF AUX_DEBUG
|
---|
1706 | IF 1
|
---|
1707 | DBG_TEXT_OUT_AUX '[DISKINFO]'
|
---|
1708 | PUSHRF
|
---|
1709 | call DEBUG_DumpRegisters
|
---|
1710 | ;~ call AuxIO_DumpParagraph
|
---|
1711 | ;~ call AuxIO_TeletypeNL
|
---|
1712 | mov si, bp
|
---|
1713 | mov cx, 4
|
---|
1714 | @@:
|
---|
1715 | call AuxIO_DumpParagraph
|
---|
1716 | call AuxIO_TeletypeNL
|
---|
1717 | add si, 16
|
---|
1718 | loop @B
|
---|
1719 | mov si, offset [Scratch]
|
---|
1720 | mov cx, 4
|
---|
1721 | @@:
|
---|
1722 | call AuxIO_DumpParagraph
|
---|
1723 | call AuxIO_TeletypeNL
|
---|
1724 | add si, 16
|
---|
1725 | loop @B
|
---|
1726 | mov si, offset [LVMSector]
|
---|
1727 | mov cx, 7
|
---|
1728 | @@:
|
---|
1729 | call AuxIO_DumpParagraph
|
---|
1730 | call AuxIO_TeletypeNL
|
---|
1731 | add si, 16
|
---|
1732 | loop @B
|
---|
1733 | POPRF
|
---|
1734 | ENDIF
|
---|
1735 | ENDIF
|
---|
1736 |
|
---|
1737 | ; Restore registers
|
---|
1738 | pop es
|
---|
1739 | pop ds
|
---|
1740 | popa
|
---|
1741 |
|
---|
1742 | ret
|
---|
1743 | DriveIO_GatherDiskInfo EndP
|
---|
1744 |
|
---|
1745 | ;------------------------------------------------------------------------------
|
---|
1746 | ; Scan all disks to gather information
|
---|
1747 | ;------------------------------------------------------------------------------
|
---|
1748 | ; IN : None
|
---|
1749 | ; OUT : CF=1 - some failure occured
|
---|
1750 | ; : ZF=1 - no harddisks
|
---|
1751 | ; NOTE : This does the preliminary gathering of disk information
|
---|
1752 | ;------------------------------------------------------------------------------
|
---|
1753 | DriveIO_ScanDisks Proc Near
|
---|
1754 |
|
---|
1755 | IFDEF AUX_DEBUG
|
---|
1756 | IF 1
|
---|
1757 | DBG_TEXT_OUT_AUX 'DriveIO_ScanDisks:'
|
---|
1758 | PUSHRF
|
---|
1759 | call DEBUG_DumpRegisters
|
---|
1760 | ;~ call AuxIO_DumpParagraph
|
---|
1761 | ;~ call AuxIO_TeletypeNL
|
---|
1762 | POPRF
|
---|
1763 | ENDIF
|
---|
1764 | ENDIF
|
---|
1765 |
|
---|
1766 | ; Save all registers
|
---|
1767 | pusha
|
---|
1768 |
|
---|
1769 | ; Get number of disks in DH
|
---|
1770 | call DriveIO_GetHardDriveCount
|
---|
1771 |
|
---|
1772 | ; Check if there are any disks to scan
|
---|
1773 | xor cx, cx ; Prepare 16-bit counter
|
---|
1774 | mov cl, dh ; Number of disks now in CX
|
---|
1775 | jcxz DriveIO_ScanDisks_end ; Quit if no disks
|
---|
1776 |
|
---|
1777 | ; Scan disks from 80h upward
|
---|
1778 | mov dl, 80h ; BIOS number of first disk
|
---|
1779 | DriveIO_ScanDisks_next:
|
---|
1780 | call DriveIO_GatherDiskInfo ; Gather info for this disk
|
---|
1781 | jc DriveIO_ScanDisks_end ; Quit if some error occured
|
---|
1782 | inc dl ; Advance to next disk
|
---|
1783 | loop DriveIO_ScanDisks_next ; Scan next disk if there is one
|
---|
1784 | test dl, dl ; Set ZF=0
|
---|
1785 | clc ; Indicate success
|
---|
1786 |
|
---|
1787 | DriveIO_ScanDisks_end:
|
---|
1788 | ; Restore all registers
|
---|
1789 | popa
|
---|
1790 |
|
---|
1791 | ret
|
---|
1792 | DriveIO_ScanDisks EndP
|
---|
1793 |
|
---|
1794 | ;------------------------------------------------------------------------------
|
---|
1795 | ; Calculate pointer to entry in DISKINFO structure
|
---|
1796 | ;------------------------------------------------------------------------------
|
---|
1797 | ; IN : DL BIOS disk number (80h etc)
|
---|
1798 | ; OUT : BX Pointer to entry
|
---|
1799 | ; NOTE : BIOS disk number must be valid
|
---|
1800 | ;------------------------------------------------------------------------------
|
---|
1801 | DriveIO_CalcDiskInfoPointer Proc Near
|
---|
1802 | xchg bx, ax ; AX is used for calculation
|
---|
1803 | mov al, DISKINFO_Size ; Size of DISKINFO structure
|
---|
1804 | mov ah, dl ; BIOS disk number
|
---|
1805 | sub ah, 80h ; Now 0-based index
|
---|
1806 | mul ah ; Now offset into DISKINFO array
|
---|
1807 | add ax, offset [DiskInformation] ; Base of DISKINFO array
|
---|
1808 | xchg bx, ax ; BX now points to entry for disk
|
---|
1809 | ret
|
---|
1810 | DriveIO_CalcDiskInfoPointer EndP
|
---|
1811 |
|
---|
1812 | ;------------------------------------------------------------------------------
|
---|
1813 | ; Check if the BIOS disk number in DL is a harddisk and in range
|
---|
1814 | ;------------------------------------------------------------------------------
|
---|
1815 | ; IN : DL BIOS disk number (80h etc)
|
---|
1816 | ; OUT : CF=1 if invalid disk number or out of range
|
---|
1817 | ; NOTE : Only modifies flags
|
---|
1818 | ;------------------------------------------------------------------------------
|
---|
1819 | DriveIO_IsValidHarddisk Proc Near Uses dx
|
---|
1820 | cmp dl, 80h ; BIOS disk number must be at least 80h
|
---|
1821 | jb @F ; Not a harddisk, exit with CY
|
---|
1822 | mov dh, dl ; Save to do compare
|
---|
1823 | sub dh, 80h ; Now 0 based disk number
|
---|
1824 | inc dh ; Now 1 based disk number
|
---|
1825 | cmp [TotalHarddiscs], dh ; Out of range, exit with CY
|
---|
1826 | @@: ret
|
---|
1827 | DriveIO_IsValidHarddisk EndP
|
---|
1828 |
|
---|
1829 |
|
---|
1830 | ; Values for sectors per track table corresponding to DriveIO_IsHugeDrive return value.
|
---|
1831 | ;~ secs_per_track_table db 63,127,255,255,255,255
|
---|
1832 |
|
---|
1833 | ;~ db_lmlvm db 'Load Master LVM -- disk: ',0
|
---|