Changeset 26 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
- Timestamp:
- Jul 26, 2010, 6:30:33 PM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r23 r26 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 1.7.20104 ; Last update : 26.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=0h, Disk Controller Reset. … … 37 37 38 38 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors 39 call AH0h_ResetFloppyDrivesWithInt40h40 test bl, 80h ; Reset hard disks too?41 jz SHORT . Return42 call AH0h_ResetForeignHardDisks43 call AH0h_ResetAllOurControllers39 call ResetFloppyDrivesWithInt40h 40 test bl, 80h 41 jz SHORT .SkipHardDiskReset 42 call ResetForeignHardDisks 43 call ResetHardDisksHandledByOurBIOS 44 44 ALIGN JUMP_ALIGN 45 . Return:45 .SkipHardDiskReset: 46 46 mov ah, bh ; Copy error code to AH 47 47 xor al, al ; Zero AL... … … 51 51 52 52 ;-------------------------------------------------------------------- 53 ; AH0h_ResetFloppyDrivesWithInt40h53 ; ResetFloppyDrivesWithInt40h 54 54 ; Parameters: 55 55 ; BL: Requested drive (DL when entering AH=00h) … … 61 61 ;-------------------------------------------------------------------- 62 62 ALIGN JUMP_ALIGN 63 AH0h_ResetFloppyDrivesWithInt40h:64 xor a x, ax; Disk Controller Reset63 ResetFloppyDrivesWithInt40h: 64 xor ah, ah ; Disk Controller Reset 65 65 and dl, 7Fh ; Clear bit 7 66 66 int INTV_FLOPPY_FUNC 67 jmp SHORT AH0h_BackupErrorCodeFromTheRequestedDriveToBH67 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH 68 68 69 69 70 70 ;-------------------------------------------------------------------- 71 ; AH0h_ResetForeignHardDisks71 ; ResetForeignHardDisks 72 72 ; Parameters: 73 73 ; BL: Requested drive (DL when entering AH=00h) … … 79 79 ;-------------------------------------------------------------------- 80 80 ALIGN JUMP_ALIGN 81 AH0h_ResetForeignHardDisks: 82 mov cl, [RAMVARS.bFirstDrv] ; Load number of first our drive 83 and cx, BYTE 7Fh ; CX = number of drives to reset 84 jz SHORT .Return 85 mov dl, 80h ; Start resetting from drive 80h 86 ALIGN JUMP_ALIGN 87 .DriveResetLoop: 81 ResetForeignHardDisks: 82 mov dl, bl ; Drive to reset 88 83 mov ah, 0Dh ; Reset Hard Disk (Alternate reset) 84 89 85 pushf ; Push flags to simulate INT 90 86 cli ; Disable interrupts since INT does that 91 87 call FAR [RAMVARS.fpOldI13h] 92 88 sti ; Make sure interrupts are enabled again (some BIOSes fails to enable it) 93 call AH0h_BackupErrorCodeFromTheRequestedDriveToBH 94 inc dx ; Next drive to reset 95 loop .DriveResetLoop 96 ALIGN JUMP_ALIGN 97 .Return: 98 ret 89 90 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH 99 91 100 92 101 93 ;-------------------------------------------------------------------- 102 ; AH0h_ResetAllOurControllers94 ; ResetHardDisksHandledByOurBIOS 103 95 ; Parameters: 104 96 ; BL: Requested drive (DL when entering AH=00h) … … 107 99 ; BH: Error code from requested drive (if available) 108 100 ; Corrupts registers: 109 ; AX, CX, DX , DI101 ; AX, CX, DX 110 102 ;-------------------------------------------------------------------- 111 103 ALIGN JUMP_ALIGN 112 AH0h_ResetAllOurControllers: 113 push si 114 mov si, ROMVARS.ideVars0 ; Load offset to first IDEVARS 115 call Initialize_GetIdeControllerCountToCX 104 ResetHardDisksHandledByOurBIOS: 105 mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH 106 test dh, dh 107 jz SHORT .AllDrivesReset ; Return if no drives 108 mov dl, [RAMVARS.bFirstDrv] ; Load number of first our drive 109 add dh, dl ; DH = one past last drive to reset 116 110 ALIGN JUMP_ALIGN 117 .ResetLoop: 118 call AH0h_ResetIdevarsControllerMasterAndSlaveDrives 119 add si, BYTE IDEVARS_size 120 loop .ResetLoop 121 .Return: 122 pop si 111 .DriveResetLoop: 112 call AHDh_ResetDrive 113 call BackupErrorCodeFromTheRequestedDriveToBH 114 call .SkipNextDriveIfItIsSlaveForThisController 115 inc dx 116 cmp dl, dh ; All done? 117 jb SHORT .DriveResetLoop ; If not, reset next drive 118 .AllDrivesReset: 119 ret 120 121 ;-------------------------------------------------------------------- 122 ; .SkipNextDriveIfItIsSlaveForThisController 123 ; Parameters: 124 ; DL: Drive just resetted 125 ; DS: RAMVARS segment 126 ; Returns: 127 ; DL: Incremented if next drive is slave drive 128 ; (=already resetted) 129 ; Corrupts registers: 130 ; AX, CX 131 ;-------------------------------------------------------------------- 132 ALIGN JUMP_ALIGN 133 .SkipNextDriveIfItIsSlaveForThisController: 134 push di 135 136 call .GetBasePortToAXfromDriveInDL 137 xchg cx, ax 138 139 inc dx 140 call .GetBasePortToAXfromDriveInDL 141 jnc SHORT .SkipNextDrive 142 143 cmp ax, cx 144 je SHORT .SkipNextDrive ; Same controller so slave already reset 145 146 dec dx ; Restore DX 147 .SkipNextDrive: 148 pop di 149 ret 150 151 ;-------------------------------------------------------------------- 152 ; .GetBasePortToAXfromDriveInDL 153 ; Parameters: 154 ; DL: Drive whose base port to find 155 ; DS: RAMVARS segment 156 ; Returns: 157 ; AX: Base port (if drive found) 158 ; CF: Set if drive found 159 ; Cleared if drive not found 160 ; Corrupts registers: 161 ; DI 162 ;-------------------------------------------------------------------- 163 ALIGN JUMP_ALIGN 164 .GetBasePortToAXfromDriveInDL: 165 call FindDPT_ForDriveNumber ; Get DPT to DS:DI 166 jnc SHORT .DriveNotFound 167 eMOVZX di, BYTE [di+DPT.bIdeOff] ; CS:DI now points to IDEVARS 168 mov ax, [cs:di+IDEVARS.wPort] 169 .DriveNotFound: 123 170 ret 124 171 125 172 126 173 ;-------------------------------------------------------------------- 127 ; AH0h_ResetIdevarsControllerMasterAndSlaveDrives 128 ; Parameters: 129 ; BL: Requested drive (DL when entering AH=00h) 130 ; CS:SI: Ptr to IDEVARS 131 ; DS: RAMVARS segment 132 ; Returns: 133 ; BH: Error code from requested drive (if available) 134 ; Corrupts registers: 135 ; AX, DX, DI 136 ;-------------------------------------------------------------------- 137 ALIGN JUMP_ALIGN 138 AH0h_ResetIdevarsControllerMasterAndSlaveDrives: 139 mov dx, [cs:si+IDEVARS.wPort] 140 call FindDPT_ForIdeMasterAtPort ; Find master drive to DL 141 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 142 call FindDPT_ForIdeSlaveAtPort ; Find slave if master not present 143 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 144 ret 145 146 ;-------------------------------------------------------------------- 147 ; AH0h_ResetMasterAndSlaveDriveWithRetries 148 ; Parameters: 149 ; BL: Requested drive (DL when entering AH=00h) 150 ; DL: Drive number for master or slave drive 151 ; DS: RAMVARS segment 152 ; Returns: 153 ; BH: Error code from requested drive (if available) 154 ; Corrupts registers: 155 ; AX, DI 156 ;-------------------------------------------------------------------- 157 ALIGN JUMP_ALIGN 158 AH0h_ResetMasterAndSlaveDriveWithRetries: 159 push dx 160 push cx 161 push bx 162 mov di, RETRIES_IF_RESET_FAILS 163 ALIGN JUMP_ALIGN 164 .RetryLoop: 165 call AHDh_ResetDrive 166 jnc SHORT .Return ; Jump if successful 167 mov cx, TIMEOUT_BEFORE_RESET_RETRY 168 call SoftDelay_TimerTicks 169 dec di 170 jnz SHORT .RetryLoop 171 ALIGN JUMP_ALIGN 172 .Return: 173 pop bx 174 pop cx 175 pop dx 176 ; Fall to AH0h_BackupErrorCodeFromTheRequestedDriveToBH 177 178 ;-------------------------------------------------------------------- 179 ; AH0h_BackupErrorCodeFromTheRequestedDriveToBH 174 ; BackupErrorCodeFromTheRequestedDriveToBH 180 175 ; Parameters: 181 176 ; AH: Error code from the last resetted drive … … 188 183 ;-------------------------------------------------------------------- 189 184 ALIGN JUMP_ALIGN 190 AH0h_BackupErrorCodeFromTheRequestedDriveToBH:191 cmp dl, bl 185 BackupErrorCodeFromTheRequestedDriveToBH: 186 cmp dl, bl ; Requested drive? 192 187 jne SHORT .Return 193 188 mov bh, ah
Note:
See TracChangeset
for help on using the changeset viewer.