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

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

Changes to XTIDE Universal BIOS:

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