Changeset 28 in xtideuniversalbios
- Timestamp:
- Aug 1, 2010, 5:57:24 PM (14 years ago)
- google:author:
- aitotat
- Location:
- trunk/XTIDE_Universal_BIOS
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Doc/changes.txt
r27 r28 1 XTIDE Universal BIOS v1.1. 2 (28July 2010)1 XTIDE Universal BIOS v1.1.3 (29 July 2010) 2 2 * v1.1.1 broke booting from foreign drives, it is now fixed. 3 * Improved error handling a bit. 4 * Longer DRQ and IRQ timeouts to minimize write timouts with some (bad) CF cards. 5 * Default boot menu drive should now be properly selected. 6 7 8 XTIDE Universal BIOS v1.1.2 (26 July 2010, no public release) 3 9 * Fixed a bug where Disk Parameter Table was accessed with wrong pointer register after writing last block. 4 10 * Cleaned AH=00h, Disk Controller Reset a bit. 5 * Timeout errors might now get translated for better error codes on certain situations.6 11 7 12 -
trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc
r3 r28 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
r3 r28 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
r3 r28 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
r3 r28 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
r27 r28 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 … … 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
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 27.9.2007 4 ; Last update : 2 8.7.20104 ; Last update : 29.7.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=0h, Disk Controller Reset. … … 47 47 xor al, al ; Zero AL... 48 48 cmp al, bh ; ...and set CF if error 49 jmp Int13h_ PopXRegsAndReturn49 jmp Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn 50 50 51 51 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH11h_HRecal.asm
r3 r28 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
r3 r28 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
r3 r28 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
r3 r28 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
r3 r28 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
r3 r28 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
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 9.12.2007 4 ; Last update : 28.7.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Int 13h function AH=Dh, Reset Hard Disk (Alternate reset). … … 26 26 AHDh_HandlerForResetHardDisk: 27 27 call AHDh_ResetDrive 28 jmp Int13h_ PopDiDsAndReturn28 jmp Int13h_StoreErrorCodeToBDAandPopDSDIandReturn 29 29 30 30 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 30.11.2007 4 ; Last update : 28.7.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 ; HError_ GetErrorCodeToAHforBitPollingTimeout12 ; HError_ProcessErrorsAfterPollingTaskFlag 13 13 ; Parameters: 14 ; AL: IDE Status Register contents 15 ; 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 16 18 ; Returns: 17 ; AH: Hard disk BIOS error code 18 ; CF: Set since error 19 ; Corrupts registers: 20 ; AL, CX 21 ;-------------------------------------------------------------------- 22 ALIGN JUMP_ALIGN 23 HError_GetErrorCodeToAHforBitPollingTimeout: 24 test al, FLG_IDE_ST_BSY ; Other bits undefined when BSY set 25 jnz SHORT HError_GetErrorCodeForStatusReg ; Busy, normal timeout 26 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 27 jnz SHORT HError_GetErrorCodeForStatusReg ; Not busy but some error 28 or al, FLG_IDE_ST_BSY ; Polled bit got never set, force timeout 29 ; Fall to HError_GetErrorCodeForStatusReg 30 31 ;-------------------------------------------------------------------- 32 ; Converts Status Register error to BIOS error code. 33 ; 34 ; HError_GetErrorCodeForStatusReg 35 ; Parameters: 36 ; AL: IDE Status Register contents 37 ; DX: IDE Status Register Address 38 ; Returns: 39 ; AH: Hard disk BIOS error code 40 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 41 ; 1 if some error 42 ; Corrupts registers: 43 ; AL, CX 44 ;-------------------------------------------------------------------- 45 ALIGN JUMP_ALIGN 46 HError_GetErrorCodeForStatusReg: 47 ; Get Error Register contents to AH 48 mov ah, al ; Backup Status Reg to AH 49 sub dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Status Reg to Error Reg 50 in al, dx ; Read Error Register to AL 51 xchg al, ah ; Swap status and error 52 add dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Restore DX 53 54 ; Store Register contents to BDA 55 push ds 56 LOAD_BDA_SEGMENT_TO ds, cx 57 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error to BDA 58 pop ds 59 ; Fall to HError_ConvertIdeErrorToBiosRet 60 61 ;-------------------------------------------------------------------- 62 ; Converts error flags from IDE status and error register contents 63 ; to BIOS Int 13h return value. 64 ; 65 ; HError_ConvertIdeErrorToBiosRet 66 ; Parameters: 67 ; AL: Status Register Contents 68 ; AH: Error Register Contents 69 ; Returns: 70 ; AH: Hard disk BIOS error code 71 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 72 ; 1 if any error 19 ; AH: BIOS error code 20 ; CF: Set if error 21 ; Cleared if no error 73 22 ; Corrupts registers: 74 23 ; AL 75 24 ;-------------------------------------------------------------------- 76 25 ALIGN JUMP_ALIGN 77 HError_ConvertIdeErrorToBiosRet: 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: 78 125 test al, FLG_IDE_ST_BSY 79 jnz SHORT .TimeoutError 126 jz SHORT .CheckErrorBitsFromStatusRegisterInAL 127 mov ah, RET_HD_TIMEOUT 128 jmp SHORT .ReturnBiosErrorCodeInAH 129 130 ALIGN JUMP_ALIGN 131 .CheckErrorBitsFromStatusRegisterInAL: 80 132 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 81 jnz SHORT . ReadErrorFromStatusReg133 jnz SHORT .ProcessErrorFromStatusRegisterInAL 82 134 xor ah, ah ; No errors, zero AH and CF 83 135 ret 84 136 85 .TimeoutError: 86 mov ah, RET_HD_TIMEOUT 87 stc 88 ret 89 90 ; Convert error code based on status or error register 91 .ReadErrorFromStatusReg: 137 .ProcessErrorFromStatusRegisterInAL: 92 138 test al, FLG_IDE_ST_ERR ; Error specified in Error register? 93 jnz SHORT . ReadErrorFromErrorReg139 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH 94 140 mov ah, RET_HD_ECC ; Assume ECC corrected error 95 141 test al, FLG_IDE_ST_CORR ; ECC corrected error? 96 jnz SHORT .Return 142 jnz SHORT .ReturnBiosErrorCodeInAH 97 143 mov ah, RET_HD_CONTROLLER ; Must be Device Fault 98 jmp SHORT .Return 144 jmp SHORT .ReturnBiosErrorCodeInAH 99 145 100 ; Convert error register to bios error code 101 .ReadErrorFromErrorReg: 146 .ConvertBiosErrorToAHfromErrorRegisterInAH: 102 147 push bx 103 mov al, ah ; Copy error reg to AL... 104 xor ah, ah ; ...and zero extend to AX 105 eBSF bx, ax ; Get bit index to BX 106 mov ah, RET_HD_STATUSERR ; Error code if Error Reg is zero 107 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: 108 156 mov ah, [cs:bx+.rgbRetCodeLookup] 109 .SkipLookup:110 157 pop bx 111 .Return: 158 159 .ReturnBiosErrorCodeInAH: 112 160 stc ; Set CF since error 113 161 ret … … 122 170 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error 123 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
r3 r28 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
r26 r28 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, get data portto DX233 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 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HStatus.asm
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 15.12.2009 4 ; Last update : 28.7.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : IDE Status Register polling functions. … … 26 26 HStatus_WaitIrqOrRdy: 27 27 test BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN 28 jnz SHORT .PollRdySinceI rqsAreDisabled28 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 … … 207 177 HStatus_PollBsyAndFlg: 208 178 call SoftDelay_InitTimeout ; Initialize timeout counter 179 in al, dx ; Discard contents for first read 180 ; (should read Alternate Status Register) 209 181 ALIGN JUMP_ALIGN 210 182 .PollLoop: … … 218 190 call SoftDelay_UpdTimeout ; Update timeout counter 219 191 jnc SHORT .PollLoop ; Loop if time left (sets CF on timeout) 220 jmp HError_ GetErrorCodeToAHforBitPollingTimeout192 jmp HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 221 193 222 194 ;-------------------------------------------------------------------- … … 239 211 HStatus_PollBsy: 240 212 call SoftDelay_InitTimeout ; Initialize timeout counter 213 in al, dx ; Discard contents for first read 214 ; (should read Alternate Status Register) 241 215 ALIGN JUMP_ALIGN 242 216 .PollLoop: … … 248 222 ALIGN JUMP_ALIGN 249 223 GetErrorCodeFromPollingToAH: 250 jmp HError_ GetErrorCodeForStatusReg224 jmp HError_ProcessErrorsAfterPollingBSY -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int19h.asm
r3 r28 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/Initialize.asm
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 23.3.2010 4 ; Last update : 28.7.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 xor bx, bx421 call ResetFloppyDrivesWithInt40h422 mov bl, 80h423 call ResetForeignHardDisks424 420 jmp AH0h_ResetHardDisksHandledByOurBIOS -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r27 r28 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 7/28/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. 2 (07/28/10)",STOP51 at ROMVARS.szVersion, db "v1.1.3 (08/01/10)",STOP 52 52 53 53 ;---------------------------;
Note:
See TracChangeset
for help on using the changeset viewer.