1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
|
---|
3 |
|
---|
4 | ; Section containing code
|
---|
5 | SECTION .text
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
8 | ; Int 13h function AH=Dh, Reset Hard Disk (Alternate reset).
|
---|
9 | ;
|
---|
10 | ; AHDh_HandlerForResetHardDisk
|
---|
11 | ; Parameters:
|
---|
12 | ; DL: Translated Drive number
|
---|
13 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
14 | ; SS:BP: Ptr to IDEPACK
|
---|
15 | ; Returns with INTPACK:
|
---|
16 | ; AH: Int 13h return status
|
---|
17 | ; CF: 0 if succesfull, 1 if error
|
---|
18 | ;--------------------------------------------------------------------
|
---|
19 | ALIGN JUMP_ALIGN
|
---|
20 | AHDh_HandlerForResetHardDisk:
|
---|
21 | %ifndef USE_186
|
---|
22 | call AHDh_ResetDrive
|
---|
23 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
24 | %else
|
---|
25 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
26 | ; Fall to AHDh_ResetDrive
|
---|
27 | %endif
|
---|
28 |
|
---|
29 |
|
---|
30 | ;--------------------------------------------------------------------
|
---|
31 | ; Resets hard disk.
|
---|
32 | ;
|
---|
33 | ; AHDh_ResetDrive
|
---|
34 | ; Parameters:
|
---|
35 | ; DL: Drive number
|
---|
36 | ; DS: RAMVARS segment
|
---|
37 | ; SS:BP: Ptr to IDEPACK
|
---|
38 | ; Returns:
|
---|
39 | ; AH: Int 13h return status
|
---|
40 | ; CF: 0 if succesfull, 1 if error
|
---|
41 | ; Corrupts registers:
|
---|
42 | ; AL, CX, SI
|
---|
43 | ;--------------------------------------------------------------------
|
---|
44 | ;ALIGN JUMP_ALIGN
|
---|
45 | AHDh_ResetDrive:
|
---|
46 | push dx
|
---|
47 | push bx
|
---|
48 | push di
|
---|
49 |
|
---|
50 | call Interrupts_UnmaskInterruptControllerForDriveInDSDI
|
---|
51 | call Device_ResetMasterAndSlaveController
|
---|
52 | ;jc SHORT .ReturnError ; CF would be set if slave drive present without master
|
---|
53 | ; (error register has special values after reset)
|
---|
54 |
|
---|
55 | ; Initialize Master and Slave drives
|
---|
56 | mov al, [di+DPT.bIdevarsOffset] ; pointer to controller we are looking to reset
|
---|
57 | mov ah, 0 ; initialize error code, assume success
|
---|
58 |
|
---|
59 | mov si, IterateAndResetDrives
|
---|
60 | call IterateAllDPTs
|
---|
61 |
|
---|
62 | shr ah, 1 ; Move error code and CF into proper position
|
---|
63 |
|
---|
64 | pop di
|
---|
65 | pop bx
|
---|
66 | pop dx
|
---|
67 | ret
|
---|
68 |
|
---|
69 | ;--------------------------------------------------------------------
|
---|
70 | ; IterateAndResetDrives: Iteration routine for use with IterateAllDPTs.
|
---|
71 | ;
|
---|
72 | ; When a drive on the controller is found, it is reset, and the error code
|
---|
73 | ; merged into overall error code for this controller. Master will be reset
|
---|
74 | ; first. Note that the iteration will go until the end of the DPT list.
|
---|
75 | ;--------------------------------------------------------------------
|
---|
76 | IterateAndResetDrives:
|
---|
77 | cmp al, [di+DPT.bIdevarsOffset] ; The right controller?
|
---|
78 | jnz .done
|
---|
79 | push ax
|
---|
80 | call AH9h_InitializeDriveForUse ; Reset Master and Slave (Master will come first in DPT list)
|
---|
81 | pop ax
|
---|
82 | jc .done
|
---|
83 | or ah, (RET_HD_RESETFAIL << 1) | 1 ; OR in Reset Failed error code and CF, will SHR into position later
|
---|
84 | .done:
|
---|
85 | stc ; From IterateAllDPTs perspective, the DPT is never found
|
---|
86 | ret
|
---|
87 |
|
---|