Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
- Timestamp:
- Mar 26, 2012, 4:20:43 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH9h_HInit.asm
r294 r363 38 38 ; CF: 0 if successful, 1 if error 39 39 ; Corrupts registers: 40 ; AL, BX, DX40 ; AL, BX, CX, DX 41 41 ;-------------------------------------------------------------------- 42 42 AH9h_InitializeDriveForUse: 43 push es 43 44 push si 44 push cx45 call ClearErrorFlagFromBootMenuInfo ; Do this for serial devices as well 45 46 46 47 %ifdef MODULE_SERIAL 47 ; 48 ; no need to do this for serial devices, and we use the DPT_RESET flag bits 49 ; to store the drive type for serial floppy drives (MODULE_SERIAL_FLOPPY) 50 ; 48 ; no need to do this for serial devices 51 49 xor ah, ah 52 50 test byte [di+DPT.bFlagsHigh], FLGH_DPT_SERIAL_DEVICE ; Clears CF 53 jnz .ReturnNotSuccessful 51 jnz .ReturnWithErrorCodeInAH 52 53 %else 54 ; Clear Initialization Error flag from DPT 55 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INITERROR 54 56 %endif 55 57 56 58 ; Try to select drive and wait until ready 57 or BYTE [di+DPT.bFlagsHigh], MASKH_DPT_RESET ; Everything uninitialized58 59 call AccessDPT_GetDriveSelectByteToAL 59 60 mov [bp+IDEPACK.bDrvAndHead], al 60 61 call Device_SelectDrive 61 jc SHORT .ReturnNotSuccessful 62 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nDRDY ; Clear since success 62 mov al, FLG_INIT_FAILED_TO_SELECT_DRIVE 63 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 64 jc SHORT .ReturnWithErrorCodeInAH 63 65 64 66 ; Initialize CHS parameters if LBA is not used 65 67 call InitializeDeviceParameters 66 jc SHORT .SetWriteCache67 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nINITPRMS68 mov al, FLG_INIT_FAILED_TO_INITIALIZE_CHS_PARAMETERS 69 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 68 70 69 71 ; Enable or Disable Write Cache 70 .SetWriteCache:71 72 call SetWriteCache 73 mov al, FLG_INIT_FAILED_TO_SET_WRITE_CACHE 74 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 72 75 73 76 ; Recalibrate drive by seeking to cylinder 0 74 77 .RecalibrateDrive: 75 78 call AH11h_RecalibrateDrive 76 jc SHORT .InitializeBlockMode77 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nRECALIBRATE79 mov al, FLG_INIT_FAILED_TO_RECALIBRATE_DRIVE 80 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 78 81 79 82 ; Initialize block mode transfers 80 83 .InitializeBlockMode: 81 84 call InitializeBlockMode 82 jc SHORT .ReturnNotSuccessful 83 and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_RESET_nSETBLOCK ; Keeps CF clear 84 85 .ReturnNotSuccessful: 86 pop cx 85 mov al, FLG_INIT_FAILED_TO_SET_BLOCK_MODE 86 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 87 88 %ifdef MODULE_ADVANCED_ATA 89 ; Initialize fastest supported PIO mode 90 .InitializePioMode: 91 call InitializePioMode 92 mov al, FLG_INIT_FAILED_TO_SET_PIO_MODE 93 call SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 94 %endif 95 96 ; There might have been several errors so just return 97 ; one error code for them all 98 test BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR 99 jz SHORT .ReturnWithErrorCodeInAH 100 mov ah, RET_HD_RESETFAIL 101 stc 102 103 .ReturnWithErrorCodeInAH: 87 104 pop si 105 pop es 88 106 ret 89 107 … … 140 158 141 159 160 %ifdef MODULE_ADVANCED_ATA 161 ;-------------------------------------------------------------------- 162 ; InitializePioMode 163 ; Parameters: 164 ; DS:DI: Ptr to DPT (in RAMVARS segment) 165 ; Returns: 166 ; AH: BIOS Error code 167 ; CF: Cleared if successful 168 ; Set if any error 169 ; Corrupts registers: 170 ; AL, BX, CX, DX 171 ;-------------------------------------------------------------------- 172 InitializePioMode: 173 xor dx, dx ; Parameter to Sector Count Register = 0 = PIO_DEFAULT_MODE 174 mov al, [di+DPT_ATA.bPioMode] 175 cmp al, 3 ; PIO mode 3 and above require IORDY 176 jb SHORT .SetTransferMode 177 or dl, al 178 .SetTransferMode: 179 mov si, FEATURE_SET_TRANSFER_MODE 180 jmp AH23h_SetControllerFeatures 181 %endif 182 183 142 184 ;-------------------------------------------------------------------- 143 185 ; InitializeBlockMode … … 160 202 eCMOVNZ al, [di+DPT_ATA.bMaxBlock] ; Load max block size 161 203 jmp AH24h_SetBlockSize 204 205 206 ;-------------------------------------------------------------------- 207 ; ClearErrorFlagFromBootMenuInfo 208 ; Parameters: 209 ; DS:DI: Ptr to DPT 210 ; Returns: 211 ; Nothing 212 ; Corrupts registers: 213 ; BX, ES 214 ;-------------------------------------------------------------------- 215 ClearErrorFlagFromBootMenuInfo: 216 call BootMenuInfo_IsAvailable ; Load BOOTMENUINFO segment to ES 217 jne SHORT .DoNotStoreErrorFlags 218 call BootMenuInfo_ConvertDPTtoBX 219 mov WORD [es:bx+BOOTMENUINFO.wInitErrorFlags], 0 ; Must clear whole WORD! 220 .DoNotStoreErrorFlags: 221 ret 222 223 224 ;-------------------------------------------------------------------- 225 ; SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo 226 ; Parameters: 227 ; AH: BIOS Error Code 228 ; AL: Error flag to set 229 ; DS:DI: Ptr to DPT 230 ; Returns: 231 ; CF: Clear if no error 232 ; Set if error flag was set 233 ; Corrupts registers: 234 ; BX, ES 235 ;-------------------------------------------------------------------- 236 SetErrorFlagFromALwithErrorCodeInAHtoBootMenuInfo: 237 jnc SHORT NoErrorFlagToSet 238 cmp ah, RET_HD_INVALID 239 jbe SHORT .IgnoreInvalidCommandError 240 241 call BootMenuInfo_IsAvailable 242 jne SHORT .BootvarsNotAvailableSoDoNotSetErrorFlag 243 244 call BootMenuInfo_ConvertDPTtoBX 245 or [es:bx+BOOTMENUINFO.wInitErrorFlags], al 246 .BootvarsNotAvailableSoDoNotSetErrorFlag: 247 or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_INITERROR 248 stc 249 ret 250 .IgnoreInvalidCommandError: 162 251 ReturnSuccessSinceInitializationNotNeeded: 163 252 xor ah, ah 164 ret 253 NoErrorFlagToSet: 254 ret
Note:
See TracChangeset
for help on using the changeset viewer.