source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm@ 259

Last change on this file since 259 was 259, checked in by gregli@…, 13 years ago

For function int13/0h, restored the code to only reset the floppy drives if a floppy drive was passed in for reset. Other minor optimizations. Better create new floppy support in Serial Server.

File size: 6.7 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Int 13h function AH=0h, Disk Controller Reset.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=0h, Disk Controller Reset.
9;
10; AH0h_HandlerForDiskControllerReset
11; Parameters:
12; DL: Translated Drive number (ignored so all drives are reset)
13; If bit 7 is set all hard disks and floppy disks reset.
14; DS:DI: Ptr to DPT (in RAMVARS segment)
15; SS:BP: Ptr to IDEPACK
16; Returns with INTPACK:
17; AH: Int 13h return status (from drive requested in DL)
18; CF: 0 if succesfull, 1 if error
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21AH0h_HandlerForDiskControllerReset:
22 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors
23 call ResetFloppyDrivesWithInt40h
24
25%ifdef MODULE_SERIAL_FLOPPY
26;
27; "Reset" emulatd serial floppy drives, if any. There is nothing to actually do for this reset,
28; but record the proper error return code if one of these floppy drives is the drive requested.
29;
30 call RamVars_UnpackFlopCntAndFirstToAL
31 cbw ; Clears AH (there are flop drives) or ffh (there are not)
32 ; Either AH has success code (flop drives are present)
33 ; or it doesn't matter because we won't match drive ffh
34
35 cwd ; clears DX (there are flop drives) or ffffh (there are not)
36
37 adc dl, al ; second drive (CF set) if present
38 ; If no drive is present, this will result in ffh which
39 ; won't match a drive
40 call BackupErrorCodeFromTheRequestedDriveToBH
41 mov dl, al ; We may end up doing the first drive twice (if there is
42 call BackupErrorCodeFromTheRequestedDriveToBH ; only one drive), but doing it again is not harmful.
43%endif
44
45 test bl, bl ; If we were called with a floppy disk, then we are done,
46 jns SHORT .SkipHardDiskReset ; don't do hard disks.
47
48 call ResetForeignHardDisks
49 call AH0h_ResetHardDisksHandledByOurBIOS
50.SkipHardDiskReset:
51 mov ah, bh
52 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
53
54
55;--------------------------------------------------------------------
56; ResetFloppyDrivesWithInt40h
57; Parameters:
58; BL: Requested drive (DL when entering AH=00h)
59; Returns:
60; BH: Error code from requested drive (if available)
61; Corrupts registers:
62; AX, DL, DI
63;--------------------------------------------------------------------
64ALIGN JUMP_ALIGN
65ResetFloppyDrivesWithInt40h:
66 call GetDriveNumberForForeignBiosesToDL
67 and dl, 7Fh ; Clear hard disk bit
68 xor ah, ah ; Disk Controller Reset
69 int BIOS_DISKETTE_INTERRUPT_40h
70 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
71
72
73;--------------------------------------------------------------------
74; ResetForeignHardDisks
75; Parameters:
76; BL: Requested drive (DL when entering AH=00h)
77; DS: RAMVARS segment
78; Returns:
79; BH: Error code from requested drive (if available)
80; Corrupts registers:
81; AX, DL, DI
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84ResetForeignHardDisks:
85 call GetDriveNumberForForeignBiosesToDL
86 xor ah, ah ; Disk Controller Reset
87 call Int13h_CallPreviousInt13hHandler
88;;; fall-through to BackupErrorCodeFromTheRequestedDriveToBH
89
90
91;--------------------------------------------------------------------
92; BackupErrorCodeFromTheRequestedDriveToBH
93; Parameters:
94; AH: Error code from the last resetted drive
95; DL: Drive last resetted
96; BL: Requested drive (DL when entering AH=00h)
97; Returns:
98; BH: Backuped error code
99; Corrupts registers:
100; Nothing
101;--------------------------------------------------------------------
102ALIGN JUMP_ALIGN
103BackupErrorCodeFromTheRequestedDriveToBH:
104 cmp dl, bl ; Requested drive?
105 eCMOVE bh, ah
106 ret
107
108
109;--------------------------------------------------------------------
110; GetDriveNumberForForeignBiosesToDL
111; Parameters:
112; BL: Requested drive (DL when entering AH=00h)
113; DS: RAMVARS segment
114; Returns:
115; DL: BL if foreign drive
116; 80h if our drive
117; Corrupts registers:
118; DI
119;--------------------------------------------------------------------
120ALIGN JUMP_ALIGN
121GetDriveNumberForForeignBiosesToDL:
122 mov dl, bl
123 call RamVars_IsDriveHandledByThisBIOS
124 jc SHORT .Return ; Return what was in BL unmodified
125 mov dl, 80h
126.Return:
127 ret
128
129
130;--------------------------------------------------------------------
131; AH0h_ResetHardDisksHandledByOurBIOS
132; Parameters:
133; BL: Requested drive (DL when entering AH=00h)
134; DS: RAMVARS segment
135; SS:BP: Ptr to IDEPACK
136; Returns:
137; BH: Error code from requested drive (if available)
138; Corrupts registers:
139; AX, CX, DX, SI, DI
140;--------------------------------------------------------------------
141ALIGN JUMP_ALIGN
142AH0h_ResetHardDisksHandledByOurBIOS:
143 mov dx, [RAMVARS.wDrvCntAndFirst] ; DL = drive number, DH = drive count
144 test dh, dh
145 jz SHORT .AllDrivesReset ; Return if no drives
146 add dh, dl ; DH = one past last drive to reset
147ALIGN JUMP_ALIGN
148.DriveResetLoop:
149 call AHDh_ResetDrive
150 call .BackupErrorCodeFromMasterOrSlaveToBH
151 inc dx
152 cmp dl, dh ; All done?
153 jb SHORT .DriveResetLoop ; If not, reset next drive
154.AllDrivesReset:
155 ret
156
157
158;--------------------------------------------------------------------
159; .BackupErrorCodeFromMasterOrSlaveToBH
160; Parameters:
161; AH: Error code for drive DL reset
162; BL: Requested drive (DL when entering AH=00h)
163; DL: Drive just resetted
164; DS: RAMVARS segment
165; Returns:
166; BH: Backuped error code
167; DL: Incremented if next drive is slave drive
168; (=already resetted)
169; Corrupts registers:
170; CX, DI
171;--------------------------------------------------------------------
172ALIGN JUMP_ALIGN
173.BackupErrorCodeFromMasterOrSlaveToBH:
174 call BackupErrorCodeFromTheRequestedDriveToBH
175 call GetBasePortToCX ; Load base port for resetted drive
176 push cx
177 inc dx ; DL to next drive
178 call GetBasePortToCX
179 pop di
180 cmp cx, di ; Next drive is from same controller?
181 je SHORT BackupErrorCodeFromTheRequestedDriveToBH
182.NoMoreDrivesOrNoSlaveDrive:
183 dec dx
184 ret
185
186
187;--------------------------------------------------------------------
188; GetBasePortToCX
189; Parameters:
190; DL: Drive number
191; DS: RAMVARS segment
192; Returns:
193; CX: Base port address
194; CF: Set if valid drive number
195; Cleared if invalid drive number
196; Corrupts registers:
197; DI
198;--------------------------------------------------------------------
199ALIGN JUMP_ALIGN
200GetBasePortToCX:
201 xchg cx, bx
202 xor bx, bx
203 call FindDPT_ForDriveNumber
204 mov bl, [di+DPT.bIdevarsOffset]
205 mov bx, [cs:bx+IDEVARS.wPort]
206 xchg bx, cx
207 ret
208
209
Note: See TracBrowser for help on using the repository browser.