[88] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
[3] | 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:
|
---|
[148] | 12 | ; DL: Translated Drive number
|
---|
| 13 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[150] | 14 | ; SS:BP: Ptr to IDEPACK
|
---|
| 15 | ; Returns with INTPACK:
|
---|
[3] | 16 | ; AH: Int 13h return status
|
---|
| 17 | ; CF: 0 if succesfull, 1 if error
|
---|
| 18 | ;--------------------------------------------------------------------
|
---|
| 19 | ALIGN JUMP_ALIGN
|
---|
| 20 | AHDh_HandlerForResetHardDisk:
|
---|
[84] | 21 | %ifndef USE_186
|
---|
[3] | 22 | call AHDh_ResetDrive
|
---|
[148] | 23 | jmp Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[84] | 24 | %else
|
---|
[148] | 25 | push Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
|
---|
[162] | 26 | ; Fall to AHDh_ResetDrive
|
---|
[84] | 27 | %endif
|
---|
[3] | 28 |
|
---|
| 29 |
|
---|
| 30 | ;--------------------------------------------------------------------
|
---|
| 31 | ; Resets hard disk.
|
---|
| 32 | ;
|
---|
| 33 | ; AHDh_ResetDrive
|
---|
| 34 | ; Parameters:
|
---|
[271] | 35 | ; DS:DI: Ptr to DPT
|
---|
[150] | 36 | ; SS:BP: Ptr to IDEPACK
|
---|
[3] | 37 | ; Returns:
|
---|
| 38 | ; AH: Int 13h return status
|
---|
| 39 | ; CF: 0 if succesfull, 1 if error
|
---|
| 40 | ; Corrupts registers:
|
---|
[271] | 41 | ; AL, SI
|
---|
[3] | 42 | ;--------------------------------------------------------------------
|
---|
| 43 | AHDh_ResetDrive:
|
---|
[26] | 44 | push dx
|
---|
[271] | 45 | push cx
|
---|
[26] | 46 | push bx
|
---|
[262] | 47 | push di
|
---|
[26] | 48 |
|
---|
[33] | 49 | call Interrupts_UnmaskInterruptControllerForDriveInDSDI
|
---|
[150] | 50 | call Device_ResetMasterAndSlaveController
|
---|
[262] | 51 | ;jc SHORT .ReturnError ; CF would be set if slave drive present without master
|
---|
| 52 | ; (error register has special values after reset)
|
---|
[3] | 53 |
|
---|
| 54 | ; Initialize Master and Slave drives
|
---|
[262] | 55 | mov al, [di+DPT.bIdevarsOffset] ; pointer to controller we are looking to reset
|
---|
| 56 | mov ah, 0 ; initialize error code, assume success
|
---|
| 57 |
|
---|
| 58 | mov si, IterateAndResetDrives
|
---|
[271] | 59 | call FindDPT_IterateAllDPTs
|
---|
[26] | 60 |
|
---|
[262] | 61 | shr ah, 1 ; Move error code and CF into proper position
|
---|
| 62 |
|
---|
| 63 | pop di
|
---|
[26] | 64 | pop bx
|
---|
[271] | 65 | pop cx
|
---|
[26] | 66 | pop dx
|
---|
[3] | 67 | ret
|
---|
| 68 |
|
---|
| 69 | ;--------------------------------------------------------------------
|
---|
[262] | 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.
|
---|
[3] | 75 | ;--------------------------------------------------------------------
|
---|
[262] | 76 | IterateAndResetDrives:
|
---|
| 77 | cmp al, [di+DPT.bIdevarsOffset] ; The right controller?
|
---|
[271] | 78 | jne .done
|
---|
[262] | 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:
|
---|
[271] | 85 | stc ; From IterateAllDPTs perspective, the DPT is never found (continue iteration)
|
---|
[3] | 86 | ret
|
---|