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

Last change on this file since 147 was 143, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • Removed "Boot sector found!" string.
  • Added option to specify display mode for boot menu.
File size: 3.8 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 HTimer_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 HTimer_MicrosecondsFromAX
99
100 ; HSR2: Check_status
101 mov cl, B_TIMEOUT_RESET ; Reset timeout delay
102 jmp HStatus_WaitBsy
103
104
105;--------------------------------------------------------------------
106; Initializes Master and Slave drive.
107;
108; AHDh_InitializeMasterAndSlave
109; Parameters:
110; DX: IDE Base Port address
111; Returns:
112; AH: Error code
113; CF: 0 if initialization succesfull
114; 1 if any error
115; Corrupts registers:
116; AL, BX, CX, DX, DI
117;--------------------------------------------------------------------
118ALIGN JUMP_ALIGN
119AHDh_InitializeMasterAndSlave:
120 push dx ; Store base port address
121 xor cx, cx ; Assume no errors
122 call FindDPT_ForIdeMasterAtPort
123 jnc SHORT .InitializeSlave ; Master drive not present
124 call AH9h_InitializeDriveForUse
125 mov cl, ah ; Copy error code to CL
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
132.CombineErrors:
133 or cl, ch ; OR error codes, clear CF
134 jz SHORT .Return
135 mov ah, RET_HD_RESETFAIL ; Load Reset Failed error code
136 stc
137.Return:
138 ret
Note: See TracBrowser for help on using the repository browser.