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

Last change on this file since 177 was 152, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • XTIDE mod should now be supported (untested).
  • Interrupt Service Routine no longer requires variable from RAMVARS.
  • Some small improvements.
File size: 5.6 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 test bl, bl
25 jns SHORT .SkipHardDiskReset
26 call ResetForeignHardDisks
27 call AH0h_ResetHardDisksHandledByOurBIOS
28.SkipHardDiskReset:
29 mov ah, bh
30 jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
31
32
33;--------------------------------------------------------------------
34; ResetFloppyDrivesWithInt40h
35; Parameters:
36; BL: Requested drive (DL when entering AH=00h)
37; Returns:
38; BH: Error code from requested drive (if available)
39; Corrupts registers:
40; AX, DL, DI
41;--------------------------------------------------------------------
42ALIGN JUMP_ALIGN
43ResetFloppyDrivesWithInt40h:
44 call GetDriveNumberForForeignBiosesToDL
45 and dl, 7Fh ; Clear hard disk bit
46 xor ah, ah ; Disk Controller Reset
47 int BIOS_DISKETTE_INTERRUPT_40h
48 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
49
50
51;--------------------------------------------------------------------
52; ResetForeignHardDisks
53; Parameters:
54; BL: Requested drive (DL when entering AH=00h)
55; DS: RAMVARS segment
56; Returns:
57; BH: Error code from requested drive (if available)
58; Corrupts registers:
59; AX, DL, DI
60;--------------------------------------------------------------------
61ALIGN JUMP_ALIGN
62ResetForeignHardDisks:
63 call GetDriveNumberForForeignBiosesToDL
64 xor ah, ah ; Disk Controller Reset
65 call Int13h_CallPreviousInt13hHandler
66 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
67
68
69;--------------------------------------------------------------------
70; GetDriveNumberForForeignBiosesToDL
71; Parameters:
72; BL: Requested drive (DL when entering AH=00h)
73; DS: RAMVARS segment
74; Returns:
75; DL: BL if foreign drive
76; 80h if our drive
77; Corrupts registers:
78; DI
79;--------------------------------------------------------------------
80ALIGN JUMP_ALIGN
81GetDriveNumberForForeignBiosesToDL:
82 mov dl, bl
83 call RamVars_IsDriveHandledByThisBIOS
84 jnc SHORT .Return ; Return what was in BL unmodified
85 mov dl, 80h
86.Return:
87 ret
88
89
90;--------------------------------------------------------------------
91; AH0h_ResetHardDisksHandledByOurBIOS
92; Parameters:
93; BL: Requested drive (DL when entering AH=00h)
94; DS: RAMVARS segment
95; SS:BP: Ptr to IDEPACK
96; Returns:
97; BH: Error code from requested drive (if available)
98; Corrupts registers:
99; AX, CX, DX, SI, DI
100;--------------------------------------------------------------------
101ALIGN JUMP_ALIGN
102AH0h_ResetHardDisksHandledByOurBIOS:
103 mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH
104 test dh, dh
105 jz SHORT .AllDrivesReset ; Return if no drives
106 mov dl, [RAMVARS.bFirstDrv] ; Load number of our first drive
107 add dh, dl ; DH = one past last drive to reset
108ALIGN JUMP_ALIGN
109.DriveResetLoop:
110 call AHDh_ResetDrive
111 call .BackupErrorCodeFromMasterOrSlaveToBH
112 inc dx
113 cmp dl, dh ; All done?
114 jb SHORT .DriveResetLoop ; If not, reset next drive
115.AllDrivesReset:
116 ret
117
118;--------------------------------------------------------------------
119; .BackupErrorCodeFromMasterOrSlaveToBH
120; Parameters:
121; AH: Error code for drive DL reset
122; BL: Requested drive (DL when entering AH=00h)
123; DL: Drive just resetted
124; DS: RAMVARS segment
125; Returns:
126; BH: Backuped error code
127; DL: Incremented if next drive is slave drive
128; (=already resetted)
129; Corrupts registers:
130; CX, DI
131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
133.BackupErrorCodeFromMasterOrSlaveToBH:
134 call BackupErrorCodeFromTheRequestedDriveToBH
135 call GetBasePortToCX ; Load base port for resetted drive
136 push cx
137 inc dx ; DL to next drive
138 call GetBasePortToCX
139 pop di
140 cmp cx, di ; Next drive is from same controller?
141 je SHORT BackupErrorCodeFromTheRequestedDriveToBH
142.NoMoreDrivesOrNoSlaveDrive:
143 dec dx
144 ret
145
146;--------------------------------------------------------------------
147; GetBasePortToCX
148; Parameters:
149; DL: Drive number
150; DS: RAMVARS segment
151; Returns:
152; CX: Base port address
153; CF: Set if valid drive number
154; Cleared if invalid drive number
155; Corrupts registers:
156; DI
157;--------------------------------------------------------------------
158ALIGN JUMP_ALIGN
159GetBasePortToCX:
160 xchg cx, bx
161 xor bx, bx
162 call FindDPT_ForDriveNumber
163 mov bl, [di+DPT.bIdevarsOffset]
164 mov bx, [cs:bx+IDEVARS.wPort]
165 xchg bx, cx
166 ret
167
168
169;--------------------------------------------------------------------
170; BackupErrorCodeFromTheRequestedDriveToBH
171; Parameters:
172; AH: Error code from the last resetted drive
173; DL: Drive last resetted
174; BL: Requested drive (DL when entering AH=00h)
175; Returns:
176; BH: Backuped error code
177; Corrupts registers:
178; Nothing
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
181BackupErrorCodeFromTheRequestedDriveToBH:
182 cmp dl, bl ; Requested drive?
183 eCMOVE bh, ah
184 ret
Note: See TracBrowser for help on using the repository browser.