Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers
- Timestamp:
- Mar 26, 2012, 4:20:43 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h
- Files:
-
- 2 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 -
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AHDh_HReset.asm
r294 r363 53 53 54 54 ; Initialize Master and Slave drives 55 eMOVZX ax, [di+DPT.bIdevarsOffset]; (AL) pointer to controller we are looking to reset55 eMOVZX ax, BYTE [di+DPT.bIdevarsOffset] ; (AL) pointer to controller we are looking to reset 56 56 ; (AH) initialize error code, assume success 57 57 58 mov si, IterateAndResetDrives 58 mov si, IterateAndResetDrives ; Callback function for FindDPT_IterateAllDPTs 59 59 call FindDPT_IterateAllDPTs 60 60 … … 73 73 ; merged into overall error code for this controller. Master will be reset 74 74 ; first. Note that the iteration will go until the end of the DPT list. 75 ; 76 ; Parameters: 77 ; AL: Offset to IDEVARS for drives to initialize 78 ; AH: Error status from previous initialization 79 ; DS:DI: Ptr to DPT to examine 80 ; Returns: 81 ; AH: Error status from initialization 82 ; CF: Set to iterate all DPTs 83 ; Corrupts registers: 84 ; AL, BX, DX 75 85 ;-------------------------------------------------------------------- 76 86 IterateAndResetDrives: … … 78 88 jne .done 79 89 push ax 90 push cx 80 91 call AH9h_InitializeDriveForUse ; Reset Master and Slave (Master will come first in DPT list) 92 93 %ifdef MODULE_ADVANCED_ATA 94 jc SHORT .SkipControllerInitSinceError 95 call InitializeAdvancedIdeControllers ; Done after drive init so drives are first set to advanced PIO mode, then the controller 96 .SkipControllerInitSinceError: 97 %endif 98 99 pop cx 81 100 pop ax 82 101 jnc .done … … 85 104 stc ; From IterateAllDPTs perspective, the DPT is never found (continue iteration) 86 105 ret 106 107 108 %ifdef MODULE_ADVANCED_ATA 109 ;-------------------------------------------------------------------- 110 ; Here we initialize the more advanced controllers (VLB and PCI) 111 ; to get better performance for systems with 32-bit bus. 112 ; 113 ; This step is optional since the controllers use slowest possible 114 ; settings by default if they are not initialized. 115 ; 116 ; InitializeAdvancedIdeController 117 ; Parameters: 118 ; DS:DI: Ptr to DPT 119 ; Returns: 120 ; CF: Cleared if success or no controller to initialize 121 ; Set if error 122 ; Corrupts registers: 123 ; AX, BX, CX, DX 124 ;-------------------------------------------------------------------- 125 InitializeAdvancedIdeControllers: 126 ; We want to initialize the advanced controller only after both 127 ; Master and Slave drive are initialized to correct PIO mode. 128 ; We check if next DPT is for the same IDE controller. If it is, 129 ; we skip the initialization. 130 mov al, [di+DPT.bIdevarsOffset] 131 cmp al, [di++LARGEST_DPT_SIZE+DPT.bIdevarsOffset] 132 je SHORT .SkipInitializationUntilNextDrive ; CF cleared 133 134 jmp AdvAtaInit_InitializeControllerForDPTinDSDI 135 .SkipInitializationUntilNextDrive: 136 clc 137 ret 138 139 %endif ; MODULE_ADVANCED_ATA
Note:
See TracChangeset
for help on using the changeset viewer.