Changeset 23 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers
- Timestamp:
- Jul 1, 2010, 5:33:40 PM (15 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r3 r23 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 2.5.20104 ; Last update : 1.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=0h, Disk Controller Reset. … … 23 23 ; DS: RAMVARS segment 24 24 ; Returns: 25 ; AH: Int 13h return status 25 ; AH: Int 13h return status (from drive requested in DL) 26 26 ; CF: 0 if succesfull, 1 if error 27 27 ; IF: 1 … … 36 36 push ax 37 37 38 test dl, 80h ; Reset floppy drives only? 39 jz SHORT .ResetForeignControllers 40 call AH0h_ResetOurControllers 41 .ResetForeignControllers: 42 call AH0h_ResetFloppyAndForeignHardDiskControllers 43 jmp Int13h_PopXRegsAndReturn ; Return since error 38 eMOVZX bx, dl ; Copy requested drive to BL, zero BH to assume no errors 39 call AH0h_ResetFloppyDrivesWithInt40h 40 test bl, 80h ; Reset hard disks too? 41 jz SHORT .Return 42 call AH0h_ResetForeignHardDisks 43 call AH0h_ResetAllOurControllers 44 ALIGN JUMP_ALIGN 45 .Return: 46 mov ah, bh ; Copy error code to AH 47 xor al, al ; Zero AL... 48 sub al, ah ; ...and set CF if error 49 jmp Int13h_PopXRegsAndReturn 44 50 45 51 46 52 ;-------------------------------------------------------------------- 47 ; Resets all IDE controllers handled by this BIOS. 48 ; 49 ; AH0h_ResetOurControllers 53 ; AH0h_ResetFloppyDrivesWithInt40h 50 54 ; Parameters: 55 ; BL: Requested drive (DL when entering AH=00h) 56 ; DL: Drive number 57 ; Returns: 58 ; BH: Error code from requested drive (if available) 59 ; Corrupts registers: 60 ; AX, DL 61 ;-------------------------------------------------------------------- 62 ALIGN JUMP_ALIGN 63 AH0h_ResetFloppyDrivesWithInt40h: 64 xor ax, ax ; Disk Controller Reset 65 and dl, 7Fh ; Clear bit 7 66 int INTV_FLOPPY_FUNC 67 jmp SHORT AH0h_BackupErrorCodeFromTheRequestedDriveToBH 68 69 70 ;-------------------------------------------------------------------- 71 ; AH0h_ResetForeignHardDisks 72 ; Parameters: 73 ; BL: Requested drive (DL when entering AH=00h) 51 74 ; DS: RAMVARS segment 52 75 ; Returns: 53 ; AH: Int 13h return status 54 ; CF: 0 if succesfull, 1 if error 76 ; BH: Error code from requested drive (if available) 55 77 ; Corrupts registers: 56 ; A L, BX, CX, DI57 ;-------------------------------------------------------------------- 78 ; AX, DL 79 ;-------------------------------------------------------------------- 58 80 ALIGN JUMP_ALIGN 59 AH0h_ResetOurControllers: 60 push dx 61 mov bx, ROMVARS.ideVars0 ; Load offset to first IDEVARS 62 call Initialize_GetIdeControllerCountToCX 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 63 86 ALIGN JUMP_ALIGN 64 .ResetLoop: 65 call AH0h_ResetIdevarsController 66 jc SHORT .Return 67 add bx, BYTE IDEVARS_size 68 loop .ResetLoop 69 xor ax, ax ; Clear AH and CF since no errors 87 .DriveResetLoop: 88 mov ah, 0Dh ; Reset Hard Disk (Alternate reset) 89 pushf ; Push flags to simulate INT 90 cli ; Disable interrupts since INT does that 91 call FAR [RAMVARS.fpOldI13h] 92 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 70 97 .Return: 71 pop dx72 98 ret 73 99 74 100 75 101 ;-------------------------------------------------------------------- 76 ; Resets master and slave drive based on either drive number. 77 ; 78 ; AH0h_ResetIdevarsController 102 ; AH0h_ResetAllOurControllers 79 103 ; Parameters: 80 ; CS:BX: Ptr to IDEVARS104 ; BL: Requested drive (DL when entering AH=00h) 81 105 ; DS: RAMVARS segment 82 106 ; Returns: 83 ; AH: Int 13h return status 84 ; CF: 0 if succesfull, 1 if error 107 ; BH: Error code from requested drive (if available) 85 108 ; Corrupts registers: 86 ; A L, DX, DI109 ; AX, CX, DX, DI 87 110 ;-------------------------------------------------------------------- 88 111 ALIGN JUMP_ALIGN 89 AH0h_ResetIdevarsController: 90 mov dx, [cs:bx+IDEVARS.wPort] 112 AH0h_ResetAllOurControllers: 113 push si 114 mov si, ROMVARS.ideVars0 ; Load offset to first IDEVARS 115 call Initialize_GetIdeControllerCountToCX 116 ALIGN JUMP_ALIGN 117 .ResetLoop: 118 call AH0h_ResetIdevarsControllerMasterAndSlaveDrives 119 add si, BYTE IDEVARS_size 120 loop .ResetLoop 121 .Return: 122 pop si 123 ret 124 125 126 ;-------------------------------------------------------------------- 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] 91 140 call FindDPT_ForIdeMasterAtPort ; Find master drive to DL 92 141 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 93 142 call FindDPT_ForIdeSlaveAtPort ; Find slave if master not present 94 143 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 95 clc96 144 ret 97 145 98 99 146 ;-------------------------------------------------------------------- 100 ; Resets master and slave drive based on either drive number.101 ;102 147 ; AH0h_ResetMasterAndSlaveDriveWithRetries 103 148 ; Parameters: 149 ; BL: Requested drive (DL when entering AH=00h) 104 150 ; DL: Drive number for master or slave drive 151 ; DS: RAMVARS segment 105 152 ; Returns: 106 ; AH: Int 13h return status 107 ; CF: 0 if succesfull, 1 if error 153 ; BH: Error code from requested drive (if available) 108 154 ; Corrupts registers: 109 ; A L, DX, DI155 ; AX, DI 110 156 ;-------------------------------------------------------------------- 111 157 ALIGN JUMP_ALIGN 112 158 AH0h_ResetMasterAndSlaveDriveWithRetries: 159 push dx 113 160 push cx 114 161 push bx 115 mov cx, RETRIES_IF_RESET_FAILS162 mov di, RETRIES_IF_RESET_FAILS 116 163 ALIGN JUMP_ALIGN 117 164 .RetryLoop: 118 mov di, cx ; Backup counter119 165 call AHDh_ResetDrive 120 jnc SHORT .Return 166 jnc SHORT .Return ; Jump if successful 121 167 mov cx, TIMEOUT_BEFORE_RESET_RETRY 122 168 call SoftDelay_TimerTicks 123 mov cx, di 124 loop .RetryLoop 125 mov ah, RET_HD_RESETFAIL 126 stc 169 dec di 170 jnz SHORT .RetryLoop 127 171 ALIGN JUMP_ALIGN 128 172 .Return: 129 173 pop bx 130 174 pop cx 131 ret132 175 pop dx 176 ; Fall to AH0h_BackupErrorCodeFromTheRequestedDriveToBH 133 177 134 178 ;-------------------------------------------------------------------- 135 ; Resets floppy drives and foreign hard disks. 136 ; 137 ; AH0h_ResetFloppyAndForeignHardDiskControllers 179 ; AH0h_BackupErrorCodeFromTheRequestedDriveToBH 138 180 ; Parameters: 139 ; DL: Drive number (ignored so all drives are reset) 140 ; If bit 7 is set all hard disks and floppy disks reset. 181 ; AH: Error code from the last resetted drive 182 ; DL: Drive last resetted 183 ; BL: Requested drive (DL when entering AH=00h) 141 184 ; Returns: 142 ; AH: Int 13h return status 143 ; CF: 0 if succesfull, 1 if error 185 ; BH: Backuped error code 144 186 ; Corrupts registers: 145 187 ; Nothing 146 188 ;-------------------------------------------------------------------- 147 189 ALIGN JUMP_ALIGN 148 AH0h_ResetFloppyAndForeignHardDiskControllers: 149 xor ah, ah ; AH=0h, Disk Controller Reset 150 pushf ; Push flags to simulate INT 151 cli ; Disable interrupts 152 call FAR [RAMVARS.fpOldI13h] 190 AH0h_BackupErrorCodeFromTheRequestedDriveToBH: 191 cmp dl, bl ; Requested drive? 192 jne SHORT .Return 193 mov bh, ah 194 ALIGN JUMP_ALIGN 195 .Return: 153 196 ret
Note:
See TracChangeset
for help on using the changeset viewer.