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

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

Changes to XTIDE Universal BIOS:

  • INT 13h optimizations to save almost 100 bytes.
File size: 5.2 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 INTPACK
16; Returns with INTPACK in SS:BP:
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; ResetHardDisksHandledByOurBIOS
92; Parameters:
93; BL: Requested drive (DL when entering AH=00h)
94; DS: RAMVARS segment
95; Returns:
96; BH: Error code from requested drive (if available)
97; Corrupts registers:
98; AX, CX, DX, DI
99;--------------------------------------------------------------------
100ALIGN JUMP_ALIGN
101AH0h_ResetHardDisksHandledByOurBIOS:
102 mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH
103 test dh, dh
104 jz SHORT .AllDrivesReset ; Return if no drives
105 mov dl, [RAMVARS.bFirstDrv] ; Load number of first our drive
106 add dh, dl ; DH = one past last drive to reset
107ALIGN JUMP_ALIGN
108.DriveResetLoop:
109 call AHDh_ResetDrive
110 call .BackupErrorCodeFromMasterOrSlaveToBH
111 inc dx
112 cmp dl, dh ; All done?
113 jb SHORT .DriveResetLoop ; If not, reset next drive
114.AllDrivesReset:
115 ret
116
117;--------------------------------------------------------------------
118; .BackupErrorCodeFromMasterOrSlaveToBH
119; Parameters:
120; AH: Error code for drive DL reset
121; BL: Requested drive (DL when entering AH=00h)
122; DL: Drive just resetted
123; DS: RAMVARS segment
124; Returns:
125; BH: Backuped error code
126; DL: Incremented if next drive is slave drive
127; (=already resetted)
128; Corrupts registers:
129; CX, DI
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132.BackupErrorCodeFromMasterOrSlaveToBH:
133 call BackupErrorCodeFromTheRequestedDriveToBH
134 mov cx, [RAMVARS.wIdeBase] ; Load base port for resetted drive
135
136 inc dx ; DL to next drive
137 call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS
138 jnc SHORT .NoMoreDrivesOrNoSlaveDrive
139 cmp cx, [RAMVARS.wIdeBase] ; Next drive is from same controller?
140 je SHORT BackupErrorCodeFromTheRequestedDriveToBH
141.NoMoreDrivesOrNoSlaveDrive:
142 dec dx
143 ret
144
145
146;--------------------------------------------------------------------
147; BackupErrorCodeFromTheRequestedDriveToBH
148; Parameters:
149; AH: Error code from the last resetted drive
150; DL: Drive last resetted
151; BL: Requested drive (DL when entering AH=00h)
152; Returns:
153; BH: Backuped error code
154; Corrupts registers:
155; Nothing
156;--------------------------------------------------------------------
157ALIGN JUMP_ALIGN
158BackupErrorCodeFromTheRequestedDriveToBH:
159 cmp dl, bl ; Requested drive?
160 eCMOVE bh, ah
161 ret
Note: See TracBrowser for help on using the repository browser.