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

Last change on this file since 91 was 84, checked in by krille_n_@…, 14 years ago

Minor size optimizations in various files.

File size: 5.5 KB
Line 
1; File name : AH0h_HReset.asm
2; Project name : IDE BIOS
3; Created date : 27.9.2007
4; Last update : 13.1.2011
5; Author : Tomi Tilli,
6; : Krister Nordvall (optimizations)
7; Description : Int 13h function AH=0h, Disk Controller Reset.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Int 13h function AH=0h, Disk Controller Reset.
14;
15; AH0h_HandlerForDiskControllerReset
16; Parameters:
17; AH: Bios function 0h
18; DL: Drive number (ignored so all drives are reset)
19; If bit 7 is set all hard disks and floppy disks reset.
20; Parameters loaded by Int13h_Jump:
21; DS: RAMVARS segment
22; Returns:
23; AH: Int 13h return status (from drive requested in DL)
24; CF: 0 if succesfull, 1 if error
25; IF: 1
26; Corrupts registers:
27; Flags
28;--------------------------------------------------------------------
29ALIGN JUMP_ALIGN
30AH0h_HandlerForDiskControllerReset:
31 push dx
32 push cx
33 push bx
34 push ax
35
36 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors
37 call ResetFloppyDrivesWithInt40h
38 test bl, 80h
39 jz SHORT .SkipHardDiskReset
40 call ResetForeignHardDisks
41 call AH0h_ResetHardDisksHandledByOurBIOS
42ALIGN JUMP_ALIGN
43.SkipHardDiskReset:
44 mov ah, bh ; Copy error code to AH
45 xor al, al ; Zero AL...
46 cmp al, bh ; ...and set CF if error
47 jmp Int13h_PopXRegsAndReturn
48
49
50;--------------------------------------------------------------------
51; ResetFloppyDrivesWithInt40h
52; Parameters:
53; BL: Requested drive (DL when entering AH=00h)
54; Returns:
55; BH: Error code from requested drive (if available)
56; Corrupts registers:
57; AX, DL, DI
58;--------------------------------------------------------------------
59ALIGN JUMP_ALIGN
60ResetFloppyDrivesWithInt40h:
61 call GetDriveNumberForForeignBiosesToDL
62 and dl, 7Fh ; Clear hard disk bit
63 xor ah, ah ; Disk Controller Reset
64 int INTV_FLOPPY_FUNC
65 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
66
67
68;--------------------------------------------------------------------
69; ResetForeignHardDisks
70; Parameters:
71; BL: Requested drive (DL when entering AH=00h)
72; DS: RAMVARS segment
73; Returns:
74; BH: Error code from requested drive (if available)
75; Corrupts registers:
76; AX, DL, DI
77;--------------------------------------------------------------------
78ALIGN JUMP_ALIGN
79ResetForeignHardDisks:
80 call GetDriveNumberForForeignBiosesToDL
81 xor ah, ah ; Disk Controller Reset
82 call Int13h_CallPreviousInt13hHandler
83 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH
84
85
86;--------------------------------------------------------------------
87; GetDriveNumberForForeignBiosesToDL
88; Parameters:
89; BL: Requested drive (DL when entering AH=00h)
90; DS: RAMVARS segment
91; Returns:
92; DL: BL if foreign drive
93; 80h if our drive
94; Corrupts registers:
95; DI
96;--------------------------------------------------------------------
97ALIGN JUMP_ALIGN
98GetDriveNumberForForeignBiosesToDL:
99 mov dl, bl
100 call RamVars_IsDriveHandledByThisBIOS
101 jnc SHORT .Return ; Return what was in BL unmodified
102 mov dl, 80h
103ALIGN JUMP_ALIGN
104.Return:
105 ret
106
107
108;--------------------------------------------------------------------
109; ResetHardDisksHandledByOurBIOS
110; Parameters:
111; BL: Requested drive (DL when entering AH=00h)
112; DS: RAMVARS segment
113; Returns:
114; BH: Error code from requested drive (if available)
115; Corrupts registers:
116; AX, CX, DX, DI
117;--------------------------------------------------------------------
118ALIGN JUMP_ALIGN
119AH0h_ResetHardDisksHandledByOurBIOS:
120 mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH
121 test dh, dh
122 jz SHORT .AllDrivesReset ; Return if no drives
123 mov dl, [RAMVARS.bFirstDrv] ; Load number of first our drive
124 add dh, dl ; DH = one past last drive to reset
125ALIGN JUMP_ALIGN
126.DriveResetLoop:
127 call AHDh_ResetDrive
128 call .BackupErrorCodeFromMasterOrSlaveToBH
129 inc dx
130 cmp dl, dh ; All done?
131 jb SHORT .DriveResetLoop ; If not, reset next drive
132.AllDrivesReset:
133 ret
134
135;--------------------------------------------------------------------
136; .BackupErrorCodeFromMasterOrSlaveToBH
137; Parameters:
138; AH: Error code for drive DL reset
139; BL: Requested drive (DL when entering AH=00h)
140; DL: Drive just resetted
141; DS: RAMVARS segment
142; Returns:
143; BH: Backuped error code
144; DL: Incremented if next drive is slave drive
145; (=already resetted)
146; Corrupts registers:
147; CX, DI
148;--------------------------------------------------------------------
149ALIGN JUMP_ALIGN
150.BackupErrorCodeFromMasterOrSlaveToBH:
151 call BackupErrorCodeFromTheRequestedDriveToBH
152 mov cx, [RAMVARS.wIdeBase] ; Load base port for resetted drive
153
154 inc dx ; DL to next drive
155 call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS
156 jnc SHORT .NoMoreDrivesOrNoSlaveDrive
157 cmp cx, [RAMVARS.wIdeBase] ; Next drive is from same controller?
158 je SHORT BackupErrorCodeFromTheRequestedDriveToBH
159.NoMoreDrivesOrNoSlaveDrive:
160 dec dx
161 ret
162
163
164;--------------------------------------------------------------------
165; BackupErrorCodeFromTheRequestedDriveToBH
166; Parameters:
167; AH: Error code from the last resetted drive
168; DL: Drive last resetted
169; BL: Requested drive (DL when entering AH=00h)
170; Returns:
171; BH: Backuped error code
172; Corrupts registers:
173; Nothing
174;--------------------------------------------------------------------
175ALIGN JUMP_ALIGN
176BackupErrorCodeFromTheRequestedDriveToBH:
177 cmp dl, bl ; Requested drive?
178 jne SHORT .Return
179 mov bh, ah
180ALIGN JUMP_ALIGN
181.Return:
182 ret
Note: See TracBrowser for help on using the repository browser.