- Files:
-
- 91 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
/trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 23.3.2010 4 ; Last update : 2 3.3.20104 ; Last update : 29.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Equates used in INT 13h functions. … … 44 44 B_TIMEOUT_BSY EQU (1000/55) ; 1000 ms 45 45 B_TIMEOUT_RDY EQU (1000/55) ; 1000 ms 46 B_TIMEOUT_DRQ EQU (5000/55) ; 5000 ms46 B_TIMEOUT_DRQ EQU 255 ; 14 s (some CF cards occasionally have long write delays) 47 47 B_TIMEOUT_DRVINFO EQU (500/55) ; 500 ms 48 48 B_TIMEOUT_RESET EQU 255 ; 14 s 49 49 50 50 51 -
/trunk/XTIDE_Universal_BIOS/Inc/emulate.inc
r20 r30 152 152 %ifndef USE_386 153 153 %ifidni %1, ax 154 xor ax, ax155 154 mov al, %2 155 xor ah, ah 156 156 %elifidni %1, bx 157 157 mov bl, %2 158 158 xor bh, bh ; %2 may use BX in effective address 159 159 %elifidni %1, cx 160 xor cx, cx161 160 mov cl, %2 161 xor ch, ch 162 162 %elifidni %1, dx 163 xor dx, dx164 163 mov dl, %2 164 xor dh, dh 165 165 %else ; SI, DI, BP (all may be used in effective address) 166 166 push ax 167 xor ax, ax168 167 mov al, %2 168 xor ah, ah 169 169 xchg ax, %1 170 170 pop ax -
/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenu.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 25.3.2010 4 ; Last update : 1.4.20104 ; Last update : 29.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Displays Boot Menu. … … 323 323 ; DS: RAMVARS segment 324 324 ; Returns: 325 ; SF: Set if drive number is valid325 ; CF: Set if drive number is valid 326 326 ; Clear if drive is not present in system 327 327 ; Corrupts registers: 328 ; AX 328 ; AX, CX 329 329 ;-------------------------------------------------------------------- 330 330 ALIGN JUMP_ALIGN … … 332 332 test dl, 80h ; Floppy drive? 333 333 jz SHORT .IsFloppyDriveIsInSystem 334 call RamVars_GetDriveCounts 335 mov ax, 7Fh ; Load mask to clear floppy bit 336 and ax, dx ; AX = Hard Disk index 337 cmp ax, cx ; Valid drive index? 338 ret 339 ALIGN JUMP_ALIGN 334 call RamVars_GetDriveCounts ; Hard Disk count to CX 335 or cl, 80h ; Set Hard Disk bit to CX 336 jmp SHORT .CompareDriveNumberToDriveCount 340 337 .IsFloppyDriveIsInSystem: 341 call FloppyDrive_GetCount 338 call FloppyDrive_GetCount ; Floppy Drive count to CX 339 .CompareDriveNumberToDriveCount: 342 340 cmp dl, cl 343 341 ret -
/trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuEvent.asm
r20 r30 283 283 mov dl, [cs:ROMVARS.bBootDrv] ; Default boot drive 284 284 call BootMenu_IsDriveInSystem 285 jns SHORT .DoNotSetDefaultMenuitem 285 jnc SHORT .DoNotSetDefaultMenuitem 286 call DriveXlate_SetDriveToSwap 286 287 call BootMenu_ConvertDriveToMenuitem 287 288 mov ax, 1 -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 21.9.2007 4 ; Last update : 1 2.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h BIOS functions (Floppy and Hard disk). … … 57 57 call RamVars_IsFunctionHandledByThisBIOS 58 58 jnc SHORT Int13h_DirectCallToAnotherBios 59 ;DEBUG_PRINT_DRIVE_AND_FUNCTION 59 60 60 61 ; Jump to correct BIOS function … … 88 89 Int13h_UnsupportedFunction: 89 90 Int13h_DirectCallToAnotherBios: 90 ; Temporarily store original DI and DS to RAMVARS91 ; Temporarily store original DI and DS from stack to RAMVARS 91 92 pop WORD [RAMVARS.wI13hDI] 92 93 pop WORD [RAMVARS.wI13hDS] … … 147 148 ; 148 149 ; Int13h_ReturnWithoutSwappingDrives 150 ; Int13h_StoreErrorCodeToBDAandPopDSDIandReturn 151 ; Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn 149 152 ; Int13h_PopXRegsAndReturn 150 153 ; Int13h_PopDiDsAndReturn … … 160 163 Int13h_ReturnWithoutSwappingDrives: 161 164 pushf 162 dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt] 163 jmp SHORT Int13h_StoreErrorCodeAndLeave 165 dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt] ; Preserves CF 166 call HError_StoreBiosErrorCodeFromAHtoBDA 167 jmp SHORT Int13h_Leave 168 169 ALIGN JUMP_ALIGN 170 Int13h_StoreErrorCodeToBDAandPopDSDIandReturn: 171 call HError_StoreBiosErrorCodeFromAHtoBDA 172 jmp SHORT Int13h_PopDiDsAndReturn 173 174 ALIGN JUMP_ALIGN 175 Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn: 176 call HError_StoreBiosErrorCodeFromAHtoBDA 164 177 ALIGN JUMP_ALIGN 165 178 Int13h_PopXRegsAndReturn: … … 173 186 pushf 174 187 call DriveXlate_WhenLeavingInt13h 175 Int13h_StoreErrorCodeAndLeave:176 LOAD_BDA_SEGMENT_TO ds, di177 mov [BDA.bHDLastSt], ah ; Store error code178 188 Int13h_Leave: 179 189 popf -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 2 .5.20104 ; Last update : 29.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 ResetFloppyDrivesWithInt40h 40 test bl, 80h 41 jz SHORT .SkipHardDiskReset 42 call ResetForeignHardDisks 43 call AH0h_ResetHardDisksHandledByOurBIOS 44 ALIGN JUMP_ALIGN 45 .SkipHardDiskReset: 46 mov ah, bh ; Copy error code to AH 47 xor al, al ; Zero AL... 48 cmp al, bh ; ...and set CF if error 49 jmp Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn 44 50 45 51 46 52 ;-------------------------------------------------------------------- 47 ; Resets all IDE controllers handled by this BIOS. 48 ; 49 ; AH0h_ResetOurControllers 53 ; ResetFloppyDrivesWithInt40h 50 54 ; Parameters: 55 ; BL: Requested drive (DL when entering AH=00h) 56 ; Returns: 57 ; BH: Error code from requested drive (if available) 58 ; Corrupts registers: 59 ; AX, DL, DI 60 ;-------------------------------------------------------------------- 61 ALIGN JUMP_ALIGN 62 ResetFloppyDrivesWithInt40h: 63 call GetDriveNumberForForeignBiosesToDL 64 and dl, 7Fh ; Clear hard disk bit 65 xor ah, ah ; Disk Controller Reset 66 int INTV_FLOPPY_FUNC 67 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH 68 69 70 ;-------------------------------------------------------------------- 71 ; 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 ; AL, BX, CX, DI 78 ; AX, DL, DI 79 ;-------------------------------------------------------------------- 80 ALIGN JUMP_ALIGN 81 ResetForeignHardDisks: 82 call GetDriveNumberForForeignBiosesToDL 83 xor ah, ah ; Disk Controller Reset 84 pushf ; Push flags to simulate INT 85 cli ; Disable interrupts since INT does that 86 call FAR [RAMVARS.fpOldI13h] 87 sti ; Make sure interrupts are enabled again (some BIOSes fails to enable it) 88 jmp SHORT BackupErrorCodeFromTheRequestedDriveToBH 89 90 57 91 ;-------------------------------------------------------------------- 92 ; GetDriveNumberForForeignBiosesToDL 93 ; Parameters: 94 ; BL: Requested drive (DL when entering AH=00h) 95 ; DS: RAMVARS segment 96 ; Returns: 97 ; DL: BL if foreign drive 98 ; 80h if our drive 99 ; Corrupts registers: 100 ; DI 101 ;-------------------------------------------------------------------- 58 102 ALIGN JUMP_ALIGN 59 AH0h_ResetOurControllers: 60 push dx 61 mov bx, ROMVARS.ideVars0 ; Load offset to first IDEVARS 62 call Initialize_GetIdeControllerCountToCX 103 GetDriveNumberForForeignBiosesToDL: 104 mov dl, bl 105 call RamVars_IsDriveHandledByThisBIOS 106 jc SHORT .GetFirstDriveForForeignBios 107 ret ; Return what was in BL unmodified 63 108 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 70 .Return: 71 pop dx 109 .GetFirstDriveForForeignBios: 110 mov dl, 80h 72 111 ret 73 112 74 113 75 114 ;-------------------------------------------------------------------- 76 ; Resets master and slave drive based on either drive number. 77 ; 78 ; AH0h_ResetIdevarsController 115 ; ResetHardDisksHandledByOurBIOS 79 116 ; Parameters: 80 ; CS:BX: Ptr to IDEVARS117 ; BL: Requested drive (DL when entering AH=00h) 81 118 ; DS: RAMVARS segment 82 119 ; Returns: 83 ; AH: Int 13h return status 84 ; CF: 0 if succesfull, 1 if error 120 ; BH: Error code from requested drive (if available) 85 121 ; Corrupts registers: 86 ; A L, DX, DI122 ; AX, CX, DX, DI 87 123 ;-------------------------------------------------------------------- 88 124 ALIGN JUMP_ALIGN 89 AH0h_ResetIdevarsController: 90 mov dx, [cs:bx+IDEVARS.wPort] 91 call FindDPT_ForIdeMasterAtPort ; Find master drive to DL 92 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 93 call FindDPT_ForIdeSlaveAtPort ; Find slave if master not present 94 jc SHORT AH0h_ResetMasterAndSlaveDriveWithRetries 95 clc 125 AH0h_ResetHardDisksHandledByOurBIOS: 126 mov dh, [RAMVARS.bDrvCnt] ; Load drive count to DH 127 test dh, dh 128 jz SHORT .AllDrivesReset ; Return if no drives 129 mov dl, [RAMVARS.bFirstDrv] ; Load number of first our drive 130 add dh, dl ; DH = one past last drive to reset 131 ALIGN JUMP_ALIGN 132 .DriveResetLoop: 133 call AHDh_ResetDrive 134 call .BackupErrorCodeFromMasterOrSlaveToBH 135 inc dx 136 cmp dl, dh ; All done? 137 jb SHORT .DriveResetLoop ; If not, reset next drive 138 .AllDrivesReset: 139 ret 140 141 ;-------------------------------------------------------------------- 142 ; .BackupErrorCodeFromMasterOrSlaveToBH 143 ; Parameters: 144 ; AH: Error code for drive DL reset 145 ; BL: Requested drive (DL when entering AH=00h) 146 ; DL: Drive just resetted 147 ; DS: RAMVARS segment 148 ; Returns: 149 ; BH: Backuped error code 150 ; DL: Incremented if next drive is slave drive 151 ; (=already resetted) 152 ; Corrupts registers: 153 ; CX, DI 154 ;-------------------------------------------------------------------- 155 ALIGN JUMP_ALIGN 156 .BackupErrorCodeFromMasterOrSlaveToBH: 157 call BackupErrorCodeFromTheRequestedDriveToBH 158 mov cx, [RAMVARS.wIdeBase] ; Load base port for resetted drive 159 160 inc dx ; DL to next drive 161 call FindDPT_ForDriveNumber ; Get DPT to DS:DI, store port to RAMVARS 162 jnc SHORT .NoMoreDrivesOrNoSlaveDrive 163 cmp cx, [RAMVARS.wIdeBase] ; Next drive is from same controller? 164 je SHORT BackupErrorCodeFromTheRequestedDriveToBH 165 .NoMoreDrivesOrNoSlaveDrive: 166 dec dx 96 167 ret 97 168 98 169 99 170 ;-------------------------------------------------------------------- 100 ; Resets master and slave drive based on either drive number. 101 ; 102 ; AH0h_ResetMasterAndSlaveDriveWithRetries 171 ; BackupErrorCodeFromTheRequestedDriveToBH 103 172 ; Parameters: 104 ; DL: Drive number for master or slave drive 173 ; AH: Error code from the last resetted drive 174 ; DL: Drive last resetted 175 ; BL: Requested drive (DL when entering AH=00h) 105 176 ; Returns: 106 ; AH: Int 13h return status 107 ; CF: 0 if succesfull, 1 if error 108 ; Corrupts registers: 109 ; AL, DX, DI 110 ;-------------------------------------------------------------------- 111 ALIGN JUMP_ALIGN 112 AH0h_ResetMasterAndSlaveDriveWithRetries: 113 push cx 114 push bx 115 mov cx, RETRIES_IF_RESET_FAILS 116 ALIGN JUMP_ALIGN 117 .RetryLoop: 118 mov di, cx ; Backup counter 119 call AHDh_ResetDrive 120 jnc SHORT .Return 121 mov cx, TIMEOUT_BEFORE_RESET_RETRY 122 call SoftDelay_TimerTicks 123 mov cx, di 124 loop .RetryLoop 125 mov ah, RET_HD_RESETFAIL 126 stc 127 ALIGN JUMP_ALIGN 128 .Return: 129 pop bx 130 pop cx 131 ret 132 133 134 ;-------------------------------------------------------------------- 135 ; Resets floppy drives and foreign hard disks. 136 ; 137 ; AH0h_ResetFloppyAndForeignHardDiskControllers 138 ; Parameters: 139 ; DL: Drive number (ignored so all drives are reset) 140 ; If bit 7 is set all hard disks and floppy disks reset. 141 ; Returns: 142 ; AH: Int 13h return status 143 ; CF: 0 if succesfull, 1 if error 177 ; BH: Backuped error code 144 178 ; Corrupts registers: 145 179 ; Nothing 146 180 ;-------------------------------------------------------------------- 147 181 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] 182 BackupErrorCodeFromTheRequestedDriveToBH: 183 cmp dl, bl ; Requested drive? 184 jne SHORT .Return 185 mov bh, ah 186 ALIGN JUMP_ALIGN 187 .Return: 153 188 ret -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 28.9.2007 4 ; Last update : 12.4.20104 ; Last update : 29.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=11h, Recalibrate. … … 55 55 mov cx, 1 ; Seek to Cylinder 0, Sector 1 56 56 xor dh, dh ; Head 0 57 call AHCh_SeekToCylinder 58 ret 57 jmp AHCh_SeekToCylinder -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH14h_HDiag.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 28.9.2007 4 ; Last update : 1 2.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=14h, Controller Internal Diagnostic. … … 33 33 jnz SHORT .ReturnError 34 34 xor ah, ah ; Zero AH and CF since success 35 jmp Int13h_ PopDiDsAndReturn35 jmp Int13h_StoreErrorCodeToBDAandPopDSDIandReturn 36 36 .ReturnError: 37 37 mov ah, RET_HD_RESETFAIL 38 38 stc 39 jmp Int13h_ PopDiDsAndReturn39 jmp Int13h_StoreErrorCodeToBDAandPopDSDIandReturn -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH1h_HStatus.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 12.4.20104 ; Last update : 29.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=1h, Read Disk Status. … … 28 28 AH1h_HandlerForReadDiskStatus: 29 29 push ds 30 30 31 LOAD_BDA_SEGMENT_TO ds, di 31 32 xor ah, ah ; Zero AH 32 33 cmp ah, [BDA.bHDLastSt] ; Set CF if error code is non-zero 33 mov ah, [BDA.bHDLastSt] 34 xchg ah, [BDA.bHDLastSt] ; Last error to AH, zero to BDA 35 34 36 pop ds 35 37 jmp Int13h_PopDiDsAndReturn -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 1 2.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=2h, Read Disk Sectors. … … 63 63 mov ah, RET_HD_INVALID ; Invalid value passed 64 64 stc ; Set CF since error 65 jmp Int13h_ PopDiDsAndReturn65 jmp Int13h_StoreErrorCodeToBDAandPopDSDIandReturn -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH8h_HParams.asm
r20 r30 41 41 ; Returns L-CHS parameters for drive and total hard disk count. 42 42 ; 43 ; AH8h_ HParams43 ; AH8h_GetDriveParameters 44 44 ; Parameters: 45 45 ; DL: Drive number -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 9.12.2007 4 ; Last update : 26.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=9h, Initialize Drive Parameters. … … 78 78 .InitializeBlockMode: 79 79 call AH9h_InitializeBlockMode 80 ;mov dl, [di+DPT.bDrvNum] ; Restore DL80 ;mov dl, [di+DPT.bDrvNum] ; Restore DL 81 81 jc SHORT .ReturnNotSuccessfull 82 82 and BYTE [di+DPT.bReset], ~FLG_RESET_nSETBLOCK 83 84 ; Force PIO mode 0 85 ;call AH9h_ForcePioMode0 83 86 84 87 .ReturnNotSuccessfull: … … 149 152 .Return: 150 153 ret 154 155 156 ;-------------------------------------------------------------------- 157 ; AH9h_ForcePioMode0 158 ; Parameters: 159 ; DL: Drive number 160 ; DS:DI: Ptr to DPT 161 ; Returns: 162 ; AH: BIOS Error code 163 ; CF: Cleared if succesfull 164 ; Set if any error 165 ; Corrupts registers: 166 ; AX, BX 167 ;-------------------------------------------------------------------- 168 ;ALIGN JUMP_ALIGN 169 ;AH9h_ForcePioMode0: 170 ; mov bh, 08h ; Parameter to Sector Count Register (PIO Flow Control Transfer Mode 0) 171 ; mov ax, 2303h ; Feature: Set transfer mode based on value in Sector Count register 172 ; int 13h 173 ; jc SHORT .FailedToForcePIO0 174 ; ; Debug output here 175 ; ret 176 ;.FailedToForcePIO0: 177 ; ; Debug output here 178 ; ret -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 9.12.2007 4 ; Last update : 1 2.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=Dh, Reset Hard Disk (Alternate reset). … … 25 25 ALIGN JUMP_ALIGN 26 26 AHDh_HandlerForResetHardDisk: 27 push dx28 push cx29 push bx30 push ax31 27 call AHDh_ResetDrive 32 jmp Int13h_ PopXRegsAndReturn28 jmp Int13h_StoreErrorCodeToBDAandPopDSDIandReturn 33 29 34 30 … … 44 40 ; CF: 0 if succesfull, 1 if error 45 41 ; Corrupts registers: 46 ; AL, BX, CX, DX42 ; DI 47 43 ;-------------------------------------------------------------------- 48 44 ALIGN JUMP_ALIGN 49 45 AHDh_ResetDrive: 50 push di 46 push dx 47 push cx 48 push bx 49 push ax 50 51 51 call FindDPT_ForDriveNumber ; DS:DI now points to DPT 52 52 call AHDh_ResetMasterAndSlave … … 57 57 mov dx, [RAMVARS.wIdeBase] ; Load base port address 58 58 call AHDh_InitializeMasterAndSlave 59 jc SHORT .ReturnError 60 xor ax, ax ; Clear AH since success 61 pop di 62 ret 63 .ReturnError: 64 mov ah, RET_HD_RESETFAIL ; Load Reset Failed error code 65 pop di 59 60 pop bx ; Pop old AX 61 mov al, bl ; Restore AL 62 pop bx 63 pop cx 64 pop dx 66 65 ret 67 66 … … 110 109 ; DX: IDE Base Port address 111 110 ; Returns: 111 ; AH: Error code 112 112 ; CF: 0 if initialization succesfull 113 113 ; 1 if any error 114 114 ; Corrupts registers: 115 ; A X, BX, CX, DX, DI115 ; AL, BX, CX, DX, DI 116 116 ;-------------------------------------------------------------------- 117 117 ALIGN JUMP_ALIGN … … 136 136 ret 137 137 .ReturnError: 138 mov ah, RET_HD_RESETFAIL ; Load Reset Failed error code 138 139 stc 139 140 ret -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 30.11.2007 4 ; Last update : 8.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Error checking functions for BIOS Hard disk functions. … … 10 10 11 11 ;-------------------------------------------------------------------- 12 ; Converts Status Register error to BIOS error code. 13 ; 14 ; HError_GetErrorCodeForStatusReg 12 ; HError_ProcessErrorsAfterPollingTaskFlag 15 13 ; Parameters: 16 ; AL: IDE Status Register contents 17 ; DX: IDE Status Register Address 14 ; DS: RAMVARS segment 15 ; ES: BDA segment (zero) 16 ; CF: Set if timeout 17 ; Cleared if task flag was properly set 18 18 ; Returns: 19 ; AH: Hard disk BIOS error code 20 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 21 ; 1 if some error 22 ; Corrupts registers: 23 ; AL, CX 24 ;-------------------------------------------------------------------- 25 ALIGN JUMP_ALIGN 26 HError_GetErrorCodeForStatusReg: 27 ; Get Error Register contents to AH 28 mov ah, al ; Backup Status Reg to AH 29 sub dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Status Reg to Error Reg 30 in al, dx ; Read Error Register to AL 31 xchg al, ah ; Swap status and error 32 add dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Restore DX 33 34 ; Store Register contents to BDA 35 push ds 36 LOAD_BDA_SEGMENT_TO ds, cx 37 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error to BDA 38 pop ds 39 40 ; Translate registers to BIOS error code 41 ; Fall to HError_ConvertIdeErrorToBiosRet 42 43 ;-------------------------------------------------------------------- 44 ; Converts error flags from IDE status and error register contents 45 ; to BIOS Int 13h return value. 46 ; 47 ; HError_ConvertIdeErrorToBiosRet 48 ; Parameters: 49 ; AL: Status Register Contents 50 ; AH: Error Register Contents 51 ; Returns: 52 ; AH: Hard disk BIOS error code 53 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 54 ; 1 if any error 19 ; AH: BIOS error code 20 ; CF: Set if error 21 ; Cleared if no error 55 22 ; Corrupts registers: 56 23 ; AL 57 24 ;-------------------------------------------------------------------- 58 25 ALIGN JUMP_ALIGN 59 HError_ConvertIdeErrorToBiosRet: 60 ; Any error? 26 HError_ProcessErrorsAfterPollingTaskFlag: 27 jc SHORT HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 28 mov ax, [es:HDBDA.wHDStAndErr] 29 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 30 mov [es:BDA.bHDLastSt], ah 31 mov BYTE [es:BDA.bHDTaskFlg], 0 32 ret 33 34 ;-------------------------------------------------------------------- 35 ; HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 36 ; HError_ProcessErrorsAfterPollingBSY 37 ; Parameters: 38 ; DS: RAMVARS segment 39 ; Returns: 40 ; AH: BIOS error code 41 ; CF: Set if error 42 ; Cleared if no error 43 ; Corrupts registers: 44 ; AL 45 ;-------------------------------------------------------------------- 46 ALIGN JUMP_ALIGN 47 HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit: 48 push ds 49 push dx 50 51 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 52 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 53 jc SHORT StoreErrorCodeFromAHtoBDA 54 mov ah, RET_HD_TIMEOUT ; Force timeout since no actual error... 55 stc ; ...but wanted bit was never set 56 jmp SHORT StoreErrorCodeFromAHtoBDA 57 58 59 ALIGN JUMP_ALIGN 60 HError_ProcessErrorsAfterPollingBSY: 61 push ds 62 push dx 63 64 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 65 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 66 StoreErrorCodeFromAHtoBDA: 67 mov [BDA.bHDLastSt], ah ; Store BIOS error code to BDA 68 69 pop dx 70 pop ds 71 ret 72 73 74 ;-------------------------------------------------------------------- 75 ; HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 76 ; Parameters: 77 ; DS: RAMVARS segment 78 ; Returns: 79 ; AL: IDE Status Register contents 80 ; AH: IDE Error Register contents 81 ; DS: BDA segment 82 ; Corrupts registers: 83 ; DX 84 ;-------------------------------------------------------------------- 85 ALIGN JUMP_ALIGN 86 HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA: 87 mov dx, [RAMVARS.wIdeBase] ; Load IDE base port address 88 inc dx ; Increment to Error Register 89 in al, dx ; Read Error Register... 90 mov ah, al ; ...and copy it to AH 91 add dx, BYTE REGR_IDE_ST - REGR_IDE_ERROR 92 in al, dx ; Read Status Register to AL 93 ; Fall to .StoreStatusAndErrorRegistersFromAXtoBDA 94 95 ;-------------------------------------------------------------------- 96 ; .StoreStatusAndErrorRegistersFromAXtoBDA 97 ; Parameters: 98 ; AL: IDE Status Register contents 99 ; AH: IDE Error Register contents 100 ; Returns: 101 ; DS: BDA segment (zero) 102 ; Corrupts registers: 103 ; DX 104 ;-------------------------------------------------------------------- 105 .StoreStatusAndErrorRegistersFromAXtoBDA: 106 LOAD_BDA_SEGMENT_TO ds, dx 107 mov [HDBDA.wHDStAndErr], ax 108 ret 109 110 111 ;-------------------------------------------------------------------- 112 ; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 113 ; Parameters: 114 ; AL: IDE Status Register contents 115 ; AH: IDE Error Register contents 116 ; Returns: 117 ; AH: BIOS INT 13h error code 118 ; CF: Set if error 119 ; Cleared if no error 120 ; Corrupts registers: 121 ; Nothing 122 ;-------------------------------------------------------------------- 123 ALIGN JUMP_ALIGN 124 GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX: 125 test al, FLG_IDE_ST_BSY 126 jz SHORT .CheckErrorBitsFromStatusRegisterInAL 127 mov ah, RET_HD_TIMEOUT 128 jmp SHORT .ReturnBiosErrorCodeInAH 129 130 ALIGN JUMP_ALIGN 131 .CheckErrorBitsFromStatusRegisterInAL: 61 132 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 62 jnz SHORT . ReadErrorFromStatusReg133 jnz SHORT .ProcessErrorFromStatusRegisterInAL 63 134 xor ah, ah ; No errors, zero AH and CF 64 135 ret 65 136 66 ; Convert error code based on status or error register 67 .ReadErrorFromStatusReg: 137 .ProcessErrorFromStatusRegisterInAL: 68 138 test al, FLG_IDE_ST_ERR ; Error specified in Error register? 69 jnz SHORT . ReadErrorFromErrorReg139 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH 70 140 mov ah, RET_HD_ECC ; Assume ECC corrected error 71 141 test al, FLG_IDE_ST_CORR ; ECC corrected error? 72 jnz SHORT .Return 142 jnz SHORT .ReturnBiosErrorCodeInAH 73 143 mov ah, RET_HD_CONTROLLER ; Must be Device Fault 74 jmp SHORT .Return 144 jmp SHORT .ReturnBiosErrorCodeInAH 75 145 76 ; Convert error register to bios error code 77 .ReadErrorFromErrorReg: 146 .ConvertBiosErrorToAHfromErrorRegisterInAH: 78 147 push bx 79 mov al, ah ; Copy error reg to AL... 80 xor ah, ah ; ...and zero extend to AX 81 eBSF bx, ax ; Get bit index to BX 82 mov ah, RET_HD_STATUSERR ; Error code if Error Reg is zero 83 jz SHORT .SkipLookup ; Return if error register is zero 148 mov bx, .rgbRetCodeLookup 149 .ErrorBitLoop: 150 rcr ah, 1 ; Set CF if error bit set 151 jc SHORT .LookupErrorCode 152 inc bx 153 cmp bx, .rgbRetCodeLookup + 8 154 jb SHORT .ErrorBitLoop ; Loop until all bits checked 155 .LookupErrorCode: 84 156 mov ah, [cs:bx+.rgbRetCodeLookup] 85 .SkipLookup:86 157 pop bx 87 .Return: 158 159 .ReturnBiosErrorCodeInAH: 88 160 stc ; Set CF since error 89 161 ret … … 98 170 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error 99 171 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected 172 db RET_HD_STATUSERR ; When Error Register is zero 173 174 175 ;-------------------------------------------------------------------- 176 ; HError_StoreBiosErrorCodeFromAHtoBDA 177 ; Parameters: 178 ; AH: BIOS error code 179 ; Returns: 180 ; Nothing 181 ; Corrupts registers: 182 ; DI 183 ;-------------------------------------------------------------------- 184 ALIGN JUMP_ALIGN 185 HError_StoreBiosErrorCodeFromAHtoBDA: 186 push ds 187 mov di, 0 ; Zero DI and preserve FLAGS 188 mov ds, di ; Copy BDA segment to DS 189 mov [BDA.bHDLastSt], ah 190 pop ds 191 ret -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 11.12.2009 4 ; Last update : 28.3.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Interrupt handling related functions. … … 20 20 ; Set if any error 21 21 ; Corrupts registers: 22 ; AL , CX22 ; AL 23 23 ;-------------------------------------------------------------------- 24 24 ALIGN JUMP_ALIGN 25 25 HIRQ_WaitIRQ: 26 ; Load BDA segment to ES27 26 push es 28 xor ax, ax ; Zero AX and clear CF29 mov es, ax ; Copy BDA segment (zero) to ES30 27 31 ; Check if interrupt has already occurred 28 LOAD_BDA_SEGMENT_TO es, ax 29 %ifdef USE_AT ; OS hook only available on AT+ machines 30 call .NotifyOperatingSystemAboutWaitingForIRQ 31 cmc 32 jnc SHORT .TaskFlagPollingComplete 33 %endif 34 call .WaitUntilTaskFlagIsSet ; Process errors 35 36 ALIGN JUMP_ALIGN 37 .TaskFlagPollingComplete: 38 call HError_ProcessErrorsAfterPollingTaskFlag 39 pop es 40 ret 41 42 ;-------------------------------------------------------------------- 43 ; .NotifyOperatingSystemAboutWaitingForIRQ 44 ; Parameters: 45 ; ES: BDA segment (zero) 46 ; Returns: 47 ; CF: Set if wait done by operating system 48 ; Cleared if BIOS must perform task flag polling 49 ; Corrupts registers: 50 ; AX 51 ;-------------------------------------------------------------------- 52 %ifdef USE_AT 53 ALIGN JUMP_ALIGN 54 .NotifyOperatingSystemAboutWaitingForIRQ: 32 55 cli ; Disable interrupts 33 cmp [es:BDA.bHDTaskFlg], al ; Interrupt ready? 34 jne SHORT .CheckIdeErrors ; If so, return 56 xor ax, ax 57 cmp al, [es:BDA.bHDTaskFlg] ; Task flag already set? 58 jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification 35 59 36 %ifdef USE_AT ; OS hook only available on AT+ machines37 ; OS device busy notification38 60 mov ah, 90h ; Hard disk busy (AX=9000h) 39 61 int INTV_SYSTEM_SERVICES ; OS hook, device busy 40 jnc SHORT .WaitUntilTaskFlagSet ; CF cleared, BIOS handles waiting 41 test ah, ah ; OS hook supported? (clear CF) 42 jz SHORT .CheckIdeErrors ; If so, waiting completed 43 ALIGN JUMP_ALIGN 44 .WaitUntilTaskFlagSet: 45 %endif 62 jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting 46 63 47 ; Poll task flag until it has been set by interrupt service routine 48 call HIRQ_WaitUntilTaskFlagIsSet 49 jc SHORT .ReturnTimeout ; Return if timeout 50 51 ALIGN JUMP_ALIGN 52 .CheckIdeErrors: 53 mov ax, [es:HDBDA.wHDStAndErr] ; Load Status and Error regs stored by ISR 54 call HError_ConvertIdeErrorToBiosRet 55 .ReturnTimeout: 56 mov BYTE [es:BDA.bHDTaskFlg], 0 ; Clear Task Flag 57 pop es 64 ; Make sure that OS hooks are supported, otherwise the CF means unsupported function 65 test ah, ah ; OS hook supported? (clears CF) 66 jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait 67 stc ; Set CF since wait done by OS 68 .ReturnFromWaitNotify: 58 69 sti ; Enable interrupts 59 70 ret 60 71 %endif 61 72 62 73 ;-------------------------------------------------------------------- 63 74 ; Polls IRQ Task Flag until it has been set or timeout. 64 75 ; 65 ; HIRQ_WaitUntilTaskFlagIsSet76 ; .WaitUntilTaskFlagIsSet 66 77 ; Parameters: 67 78 ; DS: RAMVARS segment 68 79 ; ES: BDA segment 69 80 ; Returns: 70 ; AH: BIOS Error code 71 ; CF: Cleared if wait succesfull 72 ; Set if timeout 81 ; CF: Set if timeout 82 ; Cleared if Task Flag set 73 83 ; Corrupts registers: 74 ; A L, CX84 ; AX 75 85 ;-------------------------------------------------------------------- 76 86 ALIGN JUMP_ALIGN 77 HIRQ_WaitUntilTaskFlagIsSet: 78 sti ; Enable interrupts 87 .WaitUntilTaskFlagIsSet: 88 push cx 89 79 90 mov cl, B_TIMEOUT_DRQ ; Load timeout ticks 80 91 call SoftDelay_InitTimeout ; Initialize timeout counter … … 82 93 ALIGN JUMP_ALIGN 83 94 .PollIrqFlag: 84 cli ; Disable interrupt s85 cmp [es:BDA.bHDTaskFlg], al ; Task flag set? 86 jne SHORT . TaskFlagIsSet ; If so, return95 cli ; Disable interrupt until next HLT 96 cmp [es:BDA.bHDTaskFlg], al ; Task flag set? (clears CF) 97 jne SHORT .Return 87 98 call SoftDelay_UpdTimeout ; Update timeout 88 jc SHORT . Timeout; Return if timeout89 sti ; Enable interrupts ( one instruction delay)99 jc SHORT .Return ; Return if timeout 100 sti ; Enable interrupts (STI has delay so HLT will catch all interrupts) 90 101 hlt ; Sleep until any interrupt 91 102 jmp SHORT .PollIrqFlag ; Jump to check if IDE interrupt 92 93 103 ALIGN JUMP_ALIGN 94 .TaskFlagIsSet: 95 xor ah, ah ; Zero AH, clear CF 96 ret 97 .Timeout: 98 mov ah, RET_HD_TIMEOUT ; Load error code for timeout 104 .Return: 105 pop cx 106 sti 99 107 ret 100 108 … … 134 142 ALIGN JUMP_ALIGN 135 143 HIRQ_InterruptServiceRoutineForIrqs2to7: 136 ; Acknowledge IDE interrupt by reading status register137 144 push ax 138 call ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA 145 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 146 139 147 mov al, CMD_END_OF_INTERRUPT 140 jmp SHORT HIRQ_AcknowledgeMasterController148 jmp SHORT AcknowledgeMasterInterruptController 141 149 142 150 ALIGN JUMP_ALIGN 143 151 HIRQ_InterruptServiceRoutineForIrqs8to15: 144 152 push ax 145 call ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA153 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 146 154 147 155 mov al, CMD_END_OF_INTERRUPT ; Load EOI command to AL 148 156 out WPORT_8259SL_COMMAND, al ; Acknowledge Slave 8259 149 HIRQ_AcknowledgeMasterController:157 AcknowledgeMasterInterruptController: 150 158 out WPORT_8259MA_COMMAND, al ; Acknowledge Master 8259 151 159 … … 156 164 %endif 157 165 158 ; Restore registers and return from interrupt159 166 pop ax ; Restore AX 160 167 iret 161 162 168 163 169 ;-------------------------------------------------------------------- … … 166 172 ; also be set. 167 173 ; 168 ; ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA174 ; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 169 175 ; Parameters: 170 176 ; Nothing … … 175 181 ;-------------------------------------------------------------------- 176 182 ALIGN JUMP_ALIGN 177 ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA:183 AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA: 178 184 push ds 179 185 push di 180 186 push dx 181 187 182 ; Read Status and Error registers.183 188 ; Reading Status Register acknowledges IDE interrupt 184 189 call RamVars_GetSegmentToDS 185 mov dx, [RAMVARS.wIdeBase] ; Load IDE base port address 186 inc dx ; Increment to Error Register 187 in al, dx ; Read Error Register... 188 mov ah, al ; ...and copy it to AH 189 add dx, REGR_IDE_ST-REGR_IDE_ERROR 190 in al, dx ; Read Status Register to AL 191 192 ; Store Status and Error register to BDA and set task flag 193 LOAD_BDA_SEGMENT_TO ds, dx 194 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error Registers 195 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag 190 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 191 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag 196 192 197 193 pop dx -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HPIO.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 14.12.2007 4 ; Last update : 1 4.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : PIO transfer functions. … … 168 168 add cx, [bp+PIOVARS.wWordsLeft] ; CX to partial block size 169 169 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 170 call HStatus_ReadAndIgnoreAlternateStatus171 170 jmp HStatus_WaitBsyDefTime ; Check for errors 172 171 .RetError: … … 232 231 HPIO_WriteToDrive: 233 232 cld ; OUTS to increment SI 234 call HStatus_WaitDrqDefTime ; Always poll DRQ for first block 233 call HStatus_WaitDrqDefTime ; Always poll DRQ for first block, get status reg to DX 235 234 jc SHORT .RetError ; Return if error (code in AH) 236 235 sub dx, BYTE REGR_IDE_ST ; DX to Data Port address … … 251 250 jmp HStatus_WaitIrqOrRdy ; Check for errors 252 251 253 252 254 253 ;-------------------------------------------------------------------- 255 254 ; Bus specific transfer functions and lookup table. -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 15.12.2009 4 ; Last update : 25.5.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : IDE Status Register polling functions. … … 25 25 ALIGN JUMP_ALIGN 26 26 HStatus_WaitIrqOrRdy: 27 test BYTE [ di+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN28 jnz SHORT .PollRdySinceI rqsAreDisabled27 test BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN 28 jnz SHORT .PollRdySinceInterruptsAreDisabled 29 29 jmp HIRQ_WaitIRQ 30 ALIGN JUMP_ALIGN 31 .PollRdySinceIrqsAreDisabled: 32 call HStatus_ReadAndIgnoreAlternateStatus 30 31 ALIGN JUMP_ALIGN 32 .PollRdySinceInterruptsAreDisabled: 33 33 mov cl, B_TIMEOUT_DRQ ; Load DRQ (not RDY) timeout 34 34 jmp SHORT HStatus_WaitRdy ; Jump to poll RDY … … 36 36 37 37 ;-------------------------------------------------------------------- 38 ; Reads Alternate Status Register and ignores result.39 ; Alternate Status Register is read to prevent polling host from40 ; reading status before it is valid.41 ;42 ; HStatus_ReadAndIgnoreAlternateStatus43 ; Parameters:44 ; DS:BX: Ptr to DPT45 ; Returns:46 ; Nothing47 ; Corrupts registers:48 ; AL, CX, DX49 ;--------------------------------------------------------------------50 ALIGN JUMP_ALIGN51 HStatus_ReadAndIgnoreAlternateStatus:52 mov cx, bx ; Backup BX53 eMOVZX bx, BYTE [bx+DPT.bIdeOff] ; CS:BX now points to IDEVARS54 mov dx, [cs:bx+IDEVARS.wPortCtrl] ; DX = Control Block base port55 add dx, BYTE REGR_IDEC_AST ; DX = Alternate Status Register address56 in al, dx ; Read Alternate Status Register57 mov bx, cx ; Restore BX58 ret59 60 61 ;--------------------------------------------------------------------62 38 ; Waits until Hard Disk is ready to transfer data. 63 39 ; … … 74 50 ALIGN JUMP_ALIGN 75 51 HStatus_WaitIrqOrDrq: 52 test BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN 53 jnz SHORT .PollDrqSinceInterruptsAreDisabled 54 jmp HIRQ_WaitIRQ 55 56 ALIGN JUMP_ALIGN 57 .PollDrqSinceInterruptsAreDisabled: 76 58 push dx 77 59 push cx 78 79 ; Check if interrupts are enabled80 test BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN81 jnz SHORT .PollDRQ ; Poll DRQ if IRQ disabled82 call HIRQ_WaitIRQ ; Wait for IRQ83 jmp SHORT .Return84 85 ALIGN JUMP_ALIGN86 .PollDRQ:87 call HStatus_ReadAndIgnoreAlternateStatus88 60 call HStatus_WaitDrqDefTime 89 ALIGN JUMP_ALIGN90 .Return:91 61 pop cx 92 62 pop dx … … 189 159 ; IDE Status register polling. 190 160 ; This function first waits until controller is not busy. 191 ; When not busy, IDE Status Register is polled until wanted 192 ; flag (HBIT_ST_DRDY or HBIT_ST_DRQ) is set. 161 ; When not busy, IDE Status Register is polled until wanted flag is set. 193 162 ; 194 163 ; HStatus_PollBusyAndFlg … … 207 176 ALIGN JUMP_ALIGN 208 177 HStatus_PollBsyAndFlg: 209 call SoftDelay_InitTimeout ; Initialize timeout counter 178 call SoftDelay_InitTimeout ; Initialize timeout counter 179 in al, dx ; Discard contents for first read 180 ; (should read Alternate Status Register) 210 181 ALIGN JUMP_ALIGN 211 182 .PollLoop: 212 in al, dx ; Load IDE Status Register213 test al, FLG_IDE_ST_BSY ; Controller busy?214 jnz SHORT .UpdateTimeout ; If so, jump to timeout update215 test al, ah ; Test secondary flag216 jnz SHORT HStatus_PollCompleted; If set, break loop183 in al, dx ; Load IDE Status Register 184 test al, FLG_IDE_ST_BSY ; Controller busy? 185 jnz SHORT .UpdateTimeout ; If so, jump to timeout update 186 test al, ah ; Test secondary flag 187 jnz SHORT GetErrorCodeFromPollingToAH ; If set, break loop 217 188 ALIGN JUMP_ALIGN 218 189 .UpdateTimeout: 219 call SoftDelay_UpdTimeout ; Update timeout counter 220 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 221 mov ah, RET_HD_TIMEOUT ; Load error code for timeout 222 ret 223 190 call SoftDelay_UpdTimeout ; Update timeout counter 191 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 192 jmp HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 224 193 225 194 ;-------------------------------------------------------------------- … … 241 210 ALIGN JUMP_ALIGN 242 211 HStatus_PollBsy: 243 call SoftDelay_InitTimeout ; Initialize timeout counter 212 call SoftDelay_InitTimeout ; Initialize timeout counter 213 in al, dx ; Discard contents for first read 214 ; (should read Alternate Status Register) 244 215 ALIGN JUMP_ALIGN 245 216 .PollLoop: 246 in al, dx ; Load IDE Status Reg 247 test al, FLG_IDE_ST_BSY ; Controller busy? (clears CF) 248 jz SHORT HStatus_PollCompleted ; If not, jump to check errors 249 call SoftDelay_UpdTimeout ; Update timeout counter 250 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 251 mov ah, RET_HD_TIMEOUT ; Load error code for timeout 252 ret 253 254 ALIGN JUMP_ALIGN 255 HStatus_PollCompleted: 256 test al, FLG_IDE_ST_DF | FLG_IDE_ST_ERR 257 jnz SHORT .GetErrorCode ; If errors, jump to get error code 258 xor ah, ah ; Zero AH and clear CF 259 ret 260 .GetErrorCode: 261 jmp HError_GetErrorCodeForStatusReg 217 in al, dx ; Load IDE Status Reg 218 test al, FLG_IDE_ST_BSY ; Controller busy? 219 jz SHORT GetErrorCodeFromPollingToAH ; If not, jump to check errors 220 call SoftDelay_UpdTimeout ; Update timeout counter 221 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 222 ALIGN JUMP_ALIGN 223 GetErrorCodeFromPollingToAH: 224 jmp HError_ProcessErrorsAfterPollingBSY -
/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 3.8.2007 4 ; Last update : 2.5.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 19h BIOS functions (Boot Strap Loader). … … 10 10 11 11 B_READ_RETRY_TIMES EQU 3 ; Number of times to retry 12 B_READ_RETRY_DELAY EQU 3 ; Timer ticks between retries13 12 14 13 … … 110 109 ALIGN JUMP_ALIGN 111 110 .ReadRetryLoop: 112 call Int19h_LoadFirstSectorFromDLToESBX 111 call .ResetBootDriveFromDL 112 call .LoadFirstSectorFromDLtoESBX 113 113 jnc SHORT .Return 114 call Int19h_ResetDriveOrWait115 114 dec di ; Decrement retry counter 116 115 jnz SHORT .ReadRetryLoop ; Loop while retries left … … 121 120 122 121 ;-------------------------------------------------------------------- 122 ; .ResetBootDriveFromDL 123 ; Parameters: 124 ; DL: Drive to boot from (translated, 00h or 80h) 125 ; Returns: 126 ; AH: INT 13h error code 127 ; CF: Cleared if read successfull 128 ; Set if any error 129 ; Corrupts registers: 130 ; AL 131 ;-------------------------------------------------------------------- 132 ALIGN JUMP_ALIGN 133 .ResetBootDriveFromDL: 134 xor ax, ax ; AH=0h, Disk Controller Reset 135 test dl, 80h ; Floppy drive? 136 jz SHORT .ResetDriveFromDL ; If so, jump to reset 137 mov ah, 0Dh ; AH=Dh, Reset Hard Disk (Alternate reset) 138 .ResetDriveFromDL: 139 int INTV_DISK_FUNC 140 ret 141 142 ;-------------------------------------------------------------------- 123 143 ; Reads first sector (boot sector) from drive DL to ES:BX. 124 144 ; 125 ; Int19h_LoadFirstSectorFromDLToESBX145 ; .LoadFirstSectorFromDLtoESBX 126 146 ; Parameters: 127 147 ; DL: Drive to boot from (translated, 00h or 80h) … … 136 156 ;-------------------------------------------------------------------- 137 157 ALIGN JUMP_ALIGN 138 Int19h_LoadFirstSectorFromDLToESBX:158 .LoadFirstSectorFromDLtoESBX: 139 159 mov ax, 0201h ; Read 1 sector 140 160 mov cx, 1 ; Cylinder 0, Sector 1 141 161 xor dh, dh ; Head 0 142 162 int INTV_DISK_FUNC 143 ret144 145 146 ;--------------------------------------------------------------------147 ; Reset drive controller or waits a while before retrying148 ; to load boot sector.149 ;150 ; Int19h_ResetDriveOrWait151 ; Parameters:152 ; DL: Drive to boot from (translated, 00h or 80h)153 ; DI: Retry counter154 ; Returns:155 ; Nothing156 ; Corrupts registers:157 ; CX158 ;--------------------------------------------------------------------159 ALIGN JUMP_ALIGN160 Int19h_ResetDriveOrWait:161 test di, 1<<0 ; Reset on every other retry162 jnz SHORT .ResetDrive163 mov cx, B_READ_RETRY_DELAY ; Wait for a while164 jmp SoftDelay_TimerTicks165 ALIGN JUMP_ALIGN166 .ResetDrive:167 xor cx, cx168 xchg cx, ax ; AH=0h, Disk Controller Reset169 int INTV_DISK_FUNC170 xchg ax, cx ; Restore AX171 163 ret 172 164 -
/trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 25.3.2010 4 ; Last update : 2 .5.20104 ; Last update : 28.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Various floppy drive related functions that … … 25 25 FloppyDrive_IsInt40hInstalled: 26 26 cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment? 27 jae SHORT .Int40hIsAlreadyInstalled 28 clc 29 ret 30 ALIGN JUMP_ALIGN 31 .Int40hIsAlreadyInstalled: 32 stc 27 cmc 33 28 ret 34 29 -
/trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
r20 r30 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 23.3.2010 4 ; Last update : 2.5.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Functions for initializing the BIOS. … … 418 418 ALIGN JUMP_ALIGN 419 419 Initialize_ResetDetectedDrives: 420 ; Initialize to speed up POST. DOS will reset drives anyway. 421 eMOVZX cx, BYTE [RAMVARS.bDrvCnt] 422 jcxz .Return 423 mov dl, [RAMVARS.bFirstDrv] 424 ALIGN JUMP_ALIGN 425 .InitLoop: 426 call AH9h_InitializeDriveForUse 427 inc dx ; Next drive 428 loop .InitLoop 429 .Return: 430 ret 420 jmp AH0h_ResetHardDisksHandledByOurBIOS -
/trunk/XTIDE_Universal_BIOS/Src/Main.asm
r20 r30 2 2 ; Project name : XTIDE Universal BIOS 3 3 ; Created date : 28.7.2007 4 ; Last update : 2 .5.20104 ; Last update : 26.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Main file for BIOS. This is the only file that needs … … 38 38 at ROMVARS.bRomSize, db CNT_ROM_BLOCKS ; ROM size in 512B blocks 39 39 at ROMVARS.rgbJump, jmp Initialize_FromMainBiosRomSearch 40 at ROMVARS.rgbDate, db "0 5/02/10" ; Build data (mm/dd/yy)40 at ROMVARS.rgbDate, db "08/01/10" ; Build data (mm/dd/yy) 41 41 at ROMVARS.rgbSign, db "XTIDE110" ; Signature for flash program 42 42 at ROMVARS.szTitle … … 49 49 db " (XT)=-",STOP 50 50 %endif 51 at ROMVARS.szVersion, db "v1.1. 0 (05/02/10)",STOP51 at ROMVARS.szVersion, db "v1.1.3 (08/01/10)",STOP 52 52 53 53 ;---------------------------; -
/wiki/DriveCompatibility.wiki
r20 r30 1 1 #summary XTIDE Universal BIOS compatibility with hard disks, microdrives and CF cards 2 #labels Featured 2 3 <wiki:toc max_depth="1" /> 3 4 -
/wiki/Manual.wiki
r20 r30 1 1 #summary Instructions for XTIDE Universal BIOS v1.1.0 2 #labels Featured,Phase-Deploy 2 3 *Table of Contents* 3 4 <wiki:toc max_depth="3" />
Note:
See TracChangeset
for help on using the changeset viewer.