source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm@ 11

Last change on this file since 11 was 3, checked in by Tomi Tilli, 15 years ago
File size: 3.9 KB
Line 
1; File name : AHDh_HReset.asm
2; Project name : IDE BIOS
3; Created date : 9.12.2007
4; Last update : 12.4.2010
5; Author : Tomi Tilli
6; Description : Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
13;
14; AHDh_HandlerForResetHardDisk
15; Parameters:
16; AH: Bios function Dh
17; DL: Drive number
18; Returns:
19; AH: Int 13h return status
20; CF: 0 if succesfull, 1 if error
21; IF: 1
22; Corrupts registers:
23; Flags
24;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26AHDh_HandlerForResetHardDisk:
27 push dx
28 push cx
29 push bx
30 push ax
31 call AHDh_ResetDrive
32 jmp Int13h_PopXRegsAndReturn
33
34
35;--------------------------------------------------------------------
36; Resets hard disk.
37;
38; AHDh_ResetDrive
39; Parameters:
40; DL: Drive number
41; DS: RAMVARS segment
42; Returns:
43; AH: Int 13h return status
44; CF: 0 if succesfull, 1 if error
45; Corrupts registers:
46; AL, BX, CX, DX
47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49AHDh_ResetDrive:
50 push di
51 call FindDPT_ForDriveNumber ; DS:DI now points to DPT
52 call AHDh_ResetMasterAndSlave
53 ;jc SHORT .ReturnError ; CF would be set if slave drive present without master
54 ; (error register has special values after reset)
55
56 ; Initialize Master and Slave drives
57 mov dx, [RAMVARS.wIdeBase] ; Load base port address
58 call AHDh_InitializeMasterAndSlave
59 jc SHORT .ReturnError
60 xor ax, ax ; Clear AH since success
61 pop di
62 ret
63.ReturnError:
64 mov ah, RET_HD_RESETFAIL ; Load Reset Failed error code
65 pop di
66 ret
67
68
69;--------------------------------------------------------------------
70; Resets Master and Slave drives at wanted port.
71; Both IDE drives will be reset. It is not possible to reset
72; Master or Slave only.
73;
74; AHDh_ResetMasterAndSlave
75; Parameters:
76; DS:DI: Ptr to DPT for Master or Slave drive
77; Returns:
78; CF: 0 if reset succesfull
79; 1 if any error
80; Corrupts registers:
81; AX, BX, CX, DX
82;--------------------------------------------------------------------
83ALIGN JUMP_ALIGN
84AHDh_ResetMasterAndSlave:
85 ; Reset controller
86 ; HSR0: Set_SRST
87 mov al, [di+DPT.bDrvCtrl] ; Load value for ACR
88 or al, FLG_IDE_CTRL_SRST ; Set Reset bit
89 call HDrvSel_OutputDeviceControlByte
90 mov cx, 5 ; Delay at least 5us
91 call SoftDelay_us
92
93 ; HSR1: Clear_wait
94 and al, ~FLG_IDE_CTRL_SRST ; Clear Reset bit
95 out dx, al ; End Reset
96 mov cx, 2000 ; Delay at least 2ms
97 call SoftDelay_us
98
99 ; HSR2: Check_status
100 mov cl, B_TIMEOUT_RESET ; Reset timeout delay
101 mov dx, [RAMVARS.wIdeBase] ; Load base port address
102 jmp HStatus_WaitBsyBase
103
104
105;--------------------------------------------------------------------
106; Initializes Master and Slave drive.
107;
108; AHDh_InitializeMasterAndSlave
109; Parameters:
110; DX: IDE Base Port address
111; Returns:
112; CF: 0 if initialization succesfull
113; 1 if any error
114; Corrupts registers:
115; AX, BX, CX, DX, DI
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118AHDh_InitializeMasterAndSlave:
119 push dx ; Store base port address
120 xor cx, cx ; Assume no errors
121 call FindDPT_ForIdeMasterAtPort
122 jnc SHORT .InitializeSlave ; Master drive not present
123 call AH9h_InitializeDriveForUse
124 mov cl, ah ; Copy error code to CL
125ALIGN JUMP_ALIGN
126.InitializeSlave:
127 pop dx ; Restore base port address
128 call FindDPT_ForIdeSlaveAtPort
129 jnc SHORT .CombineErrors ; Slave drive not present
130 call AH9h_InitializeDriveForUse
131 mov ch, ah ; Copy error code to CH
132ALIGN JUMP_ALIGN
133.CombineErrors:
134 or cl, ch ; OR error codes, clear CF
135 jnz SHORT .ReturnError
136 ret
137.ReturnError:
138 stc
139 ret
Note: See TracBrowser for help on using the repository browser.