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

Last change on this file since 19 was 3, checked in by Tomi Tilli, 14 years ago
File size: 4.3 KB
Line 
1; File name : AH0h_HReset.asm
2; Project name : IDE BIOS
3; Created date : 27.9.2007
4; Last update : 2.5.2010
5; Author : Tomi Tilli
6; Description : Int 13h function AH=0h, Disk Controller Reset.
7
8RETRIES_IF_RESET_FAILS EQU 3
9TIMEOUT_BEFORE_RESET_RETRY EQU 5 ; System timer ticks
10
11; Section containing code
12SECTION .text
13
14;--------------------------------------------------------------------
15; Int 13h function AH=0h, Disk Controller Reset.
16;
17; AH0h_HandlerForDiskControllerReset
18; Parameters:
19; AH: Bios function 0h
20; DL: Drive number (ignored so all drives are reset)
21; If bit 7 is set all hard disks and floppy disks reset.
22; Parameters loaded by Int13h_Jump:
23; DS: RAMVARS segment
24; Returns:
25; AH: Int 13h return status
26; CF: 0 if succesfull, 1 if error
27; IF: 1
28; Corrupts registers:
29; Flags
30;--------------------------------------------------------------------
31ALIGN JUMP_ALIGN
32AH0h_HandlerForDiskControllerReset:
33 push dx
34 push cx
35 push bx
36 push ax
37
38 test dl, 80h ; Reset floppy drives only?
39 jz SHORT .ResetForeignControllers
40 call AH0h_ResetOurControllers
41.ResetForeignControllers:
42 call AH0h_ResetFloppyAndForeignHardDiskControllers
43 jmp Int13h_PopXRegsAndReturn ; Return since error
44
45
46;--------------------------------------------------------------------
47; Resets all IDE controllers handled by this BIOS.
48;
49; AH0h_ResetOurControllers
50; Parameters:
51; DS: RAMVARS segment
52; Returns:
53; AH: Int 13h return status
54; CF: 0 if succesfull, 1 if error
55; Corrupts registers:
56; AL, BX, CX, DI
57;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59AH0h_ResetOurControllers:
60 push dx
61 mov bx, ROMVARS.ideVars0 ; Load offset to first IDEVARS
62 call Initialize_GetIdeControllerCountToCX
63ALIGN JUMP_ALIGN
64.ResetLoop:
65 call AH0h_ResetIdevarsController
66 jc SHORT .Return
67 add bx, BYTE IDEVARS_size
68 loop .ResetLoop
69 xor ax, ax ; Clear AH and CF since no errors
70.Return:
71 pop dx
72 ret
73
74
75;--------------------------------------------------------------------
76; Resets master and slave drive based on either drive number.
77;
78; AH0h_ResetIdevarsController
79; Parameters:
80; CS:BX: Ptr to IDEVARS
81; DS: RAMVARS segment
82; Returns:
83; AH: Int 13h return status
84; CF: 0 if succesfull, 1 if error
85; Corrupts registers:
86; AL, DX, DI
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89AH0h_ResetIdevarsController:
90 mov dx, [cs:bx+IDEVARS.wPort]
91 call FindDPT_ForIdeMasterAtPort ; Find master drive to DL
92 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
93 call FindDPT_ForIdeSlaveAtPort ; Find slave if master not present
94 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
95 clc
96 ret
97
98
99;--------------------------------------------------------------------
100; Resets master and slave drive based on either drive number.
101;
102; AH0h_ResetMasterAndSlaveDriveWithRetries
103; Parameters:
104; DL: Drive number for master or slave drive
105; Returns:
106; AH: Int 13h return status
107; CF: 0 if succesfull, 1 if error
108; Corrupts registers:
109; AL, DX, DI
110;--------------------------------------------------------------------
111ALIGN JUMP_ALIGN
112AH0h_ResetMasterAndSlaveDriveWithRetries:
113 push cx
114 push bx
115 mov cx, RETRIES_IF_RESET_FAILS
116ALIGN JUMP_ALIGN
117.RetryLoop:
118 mov di, cx ; Backup counter
119 call AHDh_ResetDrive
120 jnc SHORT .Return
121 mov cx, TIMEOUT_BEFORE_RESET_RETRY
122 call SoftDelay_TimerTicks
123 mov cx, di
124 loop .RetryLoop
125 mov ah, RET_HD_RESETFAIL
126 stc
127ALIGN JUMP_ALIGN
128.Return:
129 pop bx
130 pop cx
131 ret
132
133
134;--------------------------------------------------------------------
135; Resets floppy drives and foreign hard disks.
136;
137; AH0h_ResetFloppyAndForeignHardDiskControllers
138; Parameters:
139; DL: Drive number (ignored so all drives are reset)
140; If bit 7 is set all hard disks and floppy disks reset.
141; Returns:
142; AH: Int 13h return status
143; CF: 0 if succesfull, 1 if error
144; Corrupts registers:
145; Nothing
146;--------------------------------------------------------------------
147ALIGN JUMP_ALIGN
148AH0h_ResetFloppyAndForeignHardDiskControllers:
149 xor ah, ah ; AH=0h, Disk Controller Reset
150 pushf ; Push flags to simulate INT
151 cli ; Disable interrupts
152 call FAR [RAMVARS.fpOldI13h]
153 ret
Note: See TracBrowser for help on using the repository browser.