Changeset 363 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src
- Timestamp:
- Mar 26, 2012, 4:20:43 PM (13 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS/Src
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuInfo.asm
r269 r363 17 17 ; ES:BX: Ptr to BOOTMENUINFO (if successful) 18 18 ; Corrupts registers: 19 ; AX, BX,CX, DX, DI19 ; AX, CX, DX, DI 20 20 ;-------------------------------------------------------------------- 21 21 BootMenuInfo_CreateForHardDisk: 22 22 call BootMenuInfo_ConvertDPTtoBX ; ES:BX now points to new BOOTMENUINFO 23 push ds ; Preserve RAMVARS... 24 push si ; ...and SI 25 26 push es ; ES to be copied to DS 27 28 %ifdef MODULE_ADVANCED_ATA 29 ; Copy DPT_ADVANCED_ATA to BOOTMENUINFO to keep DPTs small. 30 ; DPT_ADVANCED_ATA has variables that are only needed during initialization. 31 mov ax, [di+DPT_ADVANCED_ATA.wIdeBasePort] 32 mov [es:bx+BOOTMENUINFO.wIdeBasePort], ax 33 mov dx, [di+DPT_ADVANCED_ATA.wMinPioActiveTimeNs] 34 mov [es:bx+BOOTMENUINFO.wMinPioActiveTimeNs], dx 35 36 mov ax, [di+DPT_ADVANCED_ATA.wMinPioRecoveryTimeNs] 37 mov cx, [di+DPT_ADVANCED_ATA.wControllerID] 38 mov dx, [di+DPT_ADVANCED_ATA.wControllerBasePort] 39 pop ds ; ES copied to DS 40 mov [bx+BOOTMENUINFO.wMinPioRecoveryTimeNs], ax 41 mov [bx+BOOTMENUINFO.wControllerID], cx 42 mov [bx+BOOTMENUINFO.wControllerBasePort], dx 43 44 %else 45 pop ds ; ES copied to DS 46 %endif 23 47 24 48 ; Store Drive Name 25 push ds ; Preserve RAMVARS26 push si27 28 push es ; ES copied to DS29 pop ds30 31 49 add si, BYTE ATA1.strModel ; DS:SI now points drive name 32 50 lea di, [bx+BOOTMENUINFO.szDrvName] ; ES:DI now points to name destination … … 42 60 pop si 43 61 pop ds 44 45 62 ret 46 63 … … 55 72 ; CX 56 73 ;-------------------------------------------------------------------- 57 ALIGN JUMP_ALIGN58 74 BootMenuInfo_GetTotalSectorCount: 59 75 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA … … 62 78 .ReturnFullCapacity: 63 79 jmp AccessDPT_GetLbaSectorCountToBXDXAX 80 81 82 ;-------------------------------------------------------------------- 83 ; BootMenuInfo_IsAvailable 84 ; Parameters: 85 ; Nothing 86 ; Returns: 87 ; ES: Segment to BOOTVARS with BOOTMENUINFOs 88 ; ZF: Set if BOOTVARS with BOOTMENUINFOs is available 89 ; Cleared if not available (no longer initializing) 90 ; Corrupts registers: 91 ; BX 92 ;-------------------------------------------------------------------- 93 BootMenuInfo_IsAvailable: 94 LOAD_BDA_SEGMENT_TO es, bx 95 cmp WORD [es:BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD 96 ret 64 97 65 98 … … 73 106 ; BX: Offset to BOOTMENUINFO struct 74 107 ; Corrupts registers: 75 ; AX108 ; Nothing 76 109 ;-------------------------------------------------------------------- 77 ALIGN JUMP_ALIGN78 110 BootMenuInfo_ConvertDPTtoBX: 111 push ax 79 112 mov ax, di 80 sub ax, RAMVARS_size; subtract off base of DPTs113 sub ax, BYTE RAMVARS_size ; subtract off base of DPTs 81 114 mov bl, DPT_BOOTMENUINFO_SIZE_MULTIPLIER ; BOOTMENUINFO's are a whole number multiple of DPT size 82 115 mul bl 83 116 add ax, BOOTVARS.rgBootNfo ; add base of BOOTMENUINFO 84 117 xchg ax, bx 118 pop ax 85 119 ret -
trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrintCfg.asm
r294 r363 111 111 ; Nothing (falls to next push below) 112 112 ; Corrupts registers: 113 ; AX 113 ; AX, BX, DX, ES 114 114 ;-------------------------------------------------------------------- 115 115 .PushResetStatus: 116 mov al, [di+DPT.bFlagsHigh]117 and al, MASKH_DPT_RESET ; ah already zero from last push118 push ax116 call BootMenuInfo_IsAvailable ; Load segment to ES 117 call BootMenuInfo_ConvertDPTtoBX 118 push WORD [es:bx+BOOTMENUINFO.wInitErrorFlags] 119 119 120 120 ;;; fall-out to BootMenuPrint_HardDiskRefreshInformation. -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm
r294 r363 56 56 mov [di+DPT.bIdevarsOffset], bp 57 57 mov BYTE [di+DPT_ATA.bSetBlock], 1 ; Block = 1 sector 58 %ifdef MODULE_ADVANCED_ATA 59 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 60 %endif 58 61 %ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS 59 62 call IdeDPT_StoreReversedAddressLinesFlagIfNecessary -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm
r361 r363 14 14 ; CF: Clear, IDE interface only supports hard disks 15 15 ; Corrupts registers: 16 ; AX 16 ; AX, BX, CX, DX 17 17 ;-------------------------------------------------------------------- 18 18 IdeDPT_Finalize: 19 ; Fall to .StoreBlockMode20 19 21 20 ;-------------------------------------------------------------------- … … 34 33 mov ah, [es:si+ATA1.bBlckSize] ; Max block size in sectors 35 34 mov [di+DPT_ATA.wSetAndMaxBlock], ax 36 ; Fall to IdeDPT_StoreReversedAddressLinesFlagIfNecessary 35 36 %ifdef MODULE_ADVANCED_ATA 37 ;-------------------------------------------------------------------- 38 ; .StoreDeviceType 39 ; Parameters: 40 ; DS:DI: Ptr to Disk Parameter Table 41 ; ES:SI: Ptr to 512-byte ATA information read from the drive 42 ; CS:BP: Ptr to IDEVARS for the controller 43 ; Returns: 44 ; Nothing 45 ; Corrupts registers: 46 ; Nothing 47 ;-------------------------------------------------------------------- 48 .StoreDeviceType: 49 call IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 50 51 ;-------------------------------------------------------------------- 52 ; .StorePioModeAndTimings 53 ; Parameters: 54 ; DS:DI: Ptr to Disk Parameter Table 55 ; ES:SI: Ptr to 512-byte ATA information read from the drive 56 ; CS:BP: Ptr to IDEVARS for the controller 57 ; Returns: 58 ; Nothing 59 ; Corrupts registers: 60 ; AX, CX, DX 61 ;-------------------------------------------------------------------- 62 .StorePioMode: 63 call AtaID_GetMaxPioModeToAXandMinCycleTimeToDX 64 call AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime 65 mov [di+DPT_ATA.bPioMode], al 66 mov [di+DPT_ADVANCED_ATA.wMinPioActiveTimeNs], cx 67 mov [di+DPT_ADVANCED_ATA.wMinPioRecoveryTimeNs], dx 68 69 ;-------------------------------------------------------------------- 70 ; .DetectAdvancedIdeController 71 ; Parameters: 72 ; DS:DI: Ptr to Disk Parameter Table 73 ; ES:SI: Ptr to 512-byte ATA information read from the drive 74 ; CS:BP: Ptr to IDEVARS for the controller 75 ; Returns: 76 ; Nothing 77 ; Corrupts registers: 78 ; AX, BX, CX, DX 79 ;-------------------------------------------------------------------- 80 .DetectAdvancedIdeController: 81 mov dx, [cs:bp+IDEVARS.wPort] 82 mov [di+DPT_ADVANCED_ATA.wIdeBasePort], dx 83 call AdvAtaInit_DetectControllerForIdeBaseInDX 84 mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected 85 mov [di+DPT_ADVANCED_ATA.wControllerBasePort], cx 86 jnc SHORT .NoAdvancedControllerDetected 87 88 ; Use highest common PIO mode from controller and drive. 89 ; Many VLB controllers support PIO modes up to 2. 90 call AdvAtaInit_GetControllerMaxPioModeToAL 91 jnc SHORT .ChangeTo32bitDevice 92 MIN_U [di+DPT_ATA.bPioMode], al 93 94 ; We have detected 32-bit controller so change Device Type since 95 ; it might have been set to 16-bit on IDEVARS 96 .ChangeTo32bitDevice: 97 mov BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA 98 99 .NoAdvancedControllerDetected: 100 101 %endif ; MODULE_ADVANCED_ATA 37 102 38 103 ;-------------------------------------------------------------------- … … 42 107 ; CS:BP: Ptr to IDEVARS for the controller 43 108 ; Returns: 44 ; CF: Always clear , we don't support floppies on the IDE inteface109 ; CF: Always clear 45 110 ; Corrupts registers: 46 111 ; Nothing … … 53 118 .SetFlagForSwappedA0andA3: 54 119 or BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3 55 56 120 .EndDPT: 57 121 clc 58 122 ret 123 124 125 %ifdef MODULE_ADVANCED_ATA 126 ;-------------------------------------------------------------------- 127 ; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI 128 ; Parameters: 129 ; DS:DI: Ptr to Disk Parameter Table 130 ; CS:BP: Ptr to IDEVARS for the controller 131 ; Returns: 132 ; Nothing 133 ; Corrupts registers: 134 ; AL 135 ;-------------------------------------------------------------------- 136 IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI: 137 mov al, [cs:bp+IDEVARS.bDevice] 138 mov [di+DPT_ATA.bDevice], al 139 ret 140 %endif -
trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm
r361 r363 5 5 ; This struct must not be larger than IDEPACK without INTPACK. 6 6 struc PIOVARS 7 .w WordsInBlock resb 2 ; 0, Block size in WORDs8 . wWordsLeft resb 2 ; 2, WORDs left to transfer9 .w WordsDone resb 2 ; 4, Number of sectors xferred10 resb 1 ; 6,7 .wDataPort resb 2 ; 0, IDE Data Port 8 .fnXfer resb 2 ; 2, Offset to transfer function 9 .wSectorsInBlock resb 2 ; 4, Block size in sectors 10 .bSectorsLeft resb 1 ; 6, Sectors left to transfer 11 11 resb 1 ; 7, IDEPACK.bDeviceControl 12 .wDataPort resb 2 ; 8, IDE Data Port 13 .fnXfer resb 2 ; 10, Offset to transfer function 12 .bSectorsDone resb 1 ; 8, Number of sectors xferred 14 13 endstruc 15 14 … … 69 68 xchg si, di ; ES:DI now points buffer 70 69 71 mov cx, [bp+PIOVARS.w WordsInBlock]70 mov cx, [bp+PIOVARS.wSectorsInBlock] ; Max 128 72 71 73 72 ALIGN JUMP_ALIGN 74 73 .ReadNextBlockFromDrive: 75 74 mov dx, [bp+PIOVARS.wDataPort] 76 cmp [bp+PIOVARS. wWordsLeft], cx75 cmp [bp+PIOVARS.bSectorsLeft], cl 77 76 jbe SHORT .ReadLastBlockFromDrive 78 77 call [bp+PIOVARS.fnXfer] … … 84 83 xchg si, di ; ES:DI now points buffer 85 84 86 ; Increment number of successfully read WORDs87 mov cx, [bp+PIOVARS.w WordsInBlock]88 sub [bp+PIOVARS. wWordsLeft], cx89 add [bp+PIOVARS. wWordsDone], cx85 ; Increment number of successfully read sectors 86 mov cx, [bp+PIOVARS.wSectorsInBlock] 87 sub [bp+PIOVARS.bSectorsLeft], cl 88 add [bp+PIOVARS.bSectorsDone], cl 90 89 jmp SHORT .ReadNextBlockFromDrive 91 90 92 91 ALIGN JUMP_ALIGN 93 92 .ReadLastBlockFromDrive: 94 mov c x, [bp+PIOVARS.wWordsLeft]93 mov cl, [bp+PIOVARS.bSectorsLeft] ; CH is already zero 95 94 call [bp+PIOVARS.fnXfer] ; Transfer possibly partial block 96 95 … … 103 102 ; Return number of successfully read sectors 104 103 ReturnWithTransferErrorInAH: 105 mov cx, [bp+PIOVARS.wWordsDone] 106 jc SHORT .ConvertTransferredWordsInCXtoSectors 107 add cx, [bp+PIOVARS.wWordsLeft] ; Never sets CF 108 .ConvertTransferredWordsInCXtoSectors: 109 xchg cl, ch 104 mov cl, [bp+PIOVARS.bSectorsDone] 105 mov ch, 0 ; Preserve CF 110 106 ret 111 107 … … 137 133 jc SHORT ReturnWithTransferErrorInAH 138 134 139 mov cx, [bp+PIOVARS.w WordsInBlock]135 mov cx, [bp+PIOVARS.wSectorsInBlock] ; Max 128 140 136 141 137 ALIGN JUMP_ALIGN 142 138 .WriteNextBlockToDrive: 143 139 mov dx, [bp+PIOVARS.wDataPort] 144 cmp [bp+PIOVARS. wWordsLeft], cx140 cmp [bp+PIOVARS.bSectorsLeft], cl 145 141 jbe SHORT .WriteLastBlockToDrive 146 142 call [bp+PIOVARS.fnXfer] … … 150 146 jc SHORT ReturnWithTransferErrorInAH 151 147 152 ; Increment number of successfully written WORDs153 mov cx, [bp+PIOVARS.w WordsInBlock]154 sub [bp+PIOVARS. wWordsLeft], cx155 add [bp+PIOVARS. wWordsDone], cx148 ; Increment number of successfully written sectors 149 mov cx, [bp+PIOVARS.wSectorsInBlock] 150 sub [bp+PIOVARS.bSectorsLeft], cl 151 add [bp+PIOVARS.bSectorsDone], cl 156 152 jmp SHORT .WriteNextBlockToDrive 157 153 158 154 ALIGN JUMP_ALIGN 159 155 .WriteLastBlockToDrive: 160 mov c x, [bp+PIOVARS.wWordsLeft]156 mov cl, [bp+PIOVARS.bSectorsLeft] ; CH is already zero 161 157 %ifdef USE_186 162 158 push CheckErrorsAfterTransferringLastBlock … … 183 179 InitializePiovarsInSSBPwithSectorCountInAH: 184 180 ; Store sizes 185 xor al, al 186 mov [bp+PIOVARS.wWordsLeft], ax 187 mov ah, [di+DPT_ATA.bSetBlock] 188 mov [bp+PIOVARS.wWordsInBlock], ax 189 cbw 190 mov [bp+PIOVARS.wWordsDone], ax ; Zero 181 mov [bp+PIOVARS.bSectorsLeft], ah 182 eMOVZX ax, BYTE [di+DPT_ATA.bSetBlock] 183 mov [bp+PIOVARS.wSectorsInBlock], ax 184 mov [bp+PIOVARS.bSectorsDone], ah ; Zero 191 185 192 186 ; Get transfer function based on bus type … … 194 188 mov bl, [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS 195 189 mov dx, [cs:bx+IDEVARS.wPort] ; Load IDE Data port address 190 %ifdef MODULE_ADVANCED_ATA 191 mov bl, [di+DPT_ATA.bDevice] 192 %else 196 193 mov bl, [cs:bx+IDEVARS.bDevice] ; Load device type to BX 194 %endif 197 195 add bx, ax 196 198 197 mov [bp+PIOVARS.wDataPort], dx 199 198 mov ax, [cs:bx] ; Load offset to transfer function … … 208 207 ; ReadBlockFrom32bitDataPort VLB/PCI 32-bit IDE 209 208 ; Parameters: 210 ; CX: Block size in WORDs209 ; CX: Block size in 512 byte sectors 211 210 ; DX: IDE Data port address 212 211 ; ES:DI: Normalized ptr to buffer to receive data … … 218 217 ALIGN JUMP_ALIGN 219 218 ReadBlockFromXtideRev1: 220 eSHR_IM cx, 2 ; Loop unrolling219 UNROLL_SECTORS_IN_CX_TO_QWORDS 221 220 mov bx, 8 ; Bit mask for toggling data low/high reg 222 221 ALIGN JUMP_ALIGN … … 233 232 ALIGN JUMP_ALIGN 234 233 ReadBlockFromXtideRev2: 235 times 2 shr cx, 1 ; WORD count to QWORD count234 UNROLL_SECTORS_IN_CX_TO_QWORDS 236 235 ALIGN JUMP_ALIGN 237 236 .ReadNextQword: … … 251 250 ALIGN JUMP_ALIGN 252 251 ReadBlockFrom16bitDataPort: 252 xchg cl, ch ; Sectors to WORDs 253 253 rep 254 254 db 6Dh ; INSW (we want this in XT build) … … 258 258 ALIGN JUMP_ALIGN 259 259 ReadBlockFrom32bitDataPort: 260 shr cx, 1 ; WORD count to DWORD count 260 db 0C1h ; SHL 261 db 0E1h ; CX 262 db 7 ; 7 (Sectors to DWORDs) 261 263 rep 262 264 db 66h ; Override operand size to 32-bit … … 272 274 ; WriteBlockTo32bitDataPort VLB/PCI 32-bit IDE 273 275 ; Parameters: 274 ; CX: Block size in WORDs276 ; CX: Block size in 512-byte sectors 275 277 ; DX: IDE Data port address 276 278 ; ES:SI: Normalized ptr to buffer containing data … … 284 286 push ds 285 287 push bx 286 eSHR_IM cx, 2 ; Loop unrolling288 UNROLL_SECTORS_IN_CX_TO_QWORDS 287 289 mov bx, 8 ; Bit mask for toggling data low/high reg 288 290 push es ; Copy ES... … … 302 304 ALIGN JUMP_ALIGN 303 305 WriteBlockToXtideRev2: 306 UNROLL_SECTORS_IN_CX_TO_QWORDS 304 307 push ds 305 eSHR_IM cx, 2 ; Loop unrolling306 308 push es ; Copy ES... 307 309 pop ds ; ...to DS … … 320 322 ALIGN JUMP_ALIGN 321 323 WriteBlockToFastXtide: 322 times 2 shr cx, 1 ; WORD count to QWORD count324 UNROLL_SECTORS_IN_CX_TO_QWORDS 323 325 push ds 324 326 push es … … 342 344 ALIGN JUMP_ALIGN 343 345 WriteBlockTo16bitDataPort: 346 xchg cl, ch ; Sectors to WORDs 344 347 es ; Source is ES segment 345 348 rep … … 350 353 ALIGN JUMP_ALIGN 351 354 WriteBlockTo32bitDataPort: 352 shr cx, 1 ; WORD count to DWORD count 355 db 0C1h ; SHL 356 db 0E1h ; CX 357 db 7 ; 7 (Sectors to DWORDs) 353 358 es ; Source is ES segment 354 359 rep -
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 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm
r324 r363 72 72 mul WORD [di+ATA1.wCylCnt] ; DX:AX=Sectors per track * number of heads * number of cylinders 73 73 ret 74 75 76 %ifdef MODULE_ADVANCED_ATA 77 ;-------------------------------------------------------------------- 78 ; AtaID_GetMaxPioModeToAXandMinCycleTimeToDX 79 ; Parameters: 80 ; ES:SI: Ptr to 512-byte ATA information read from the drive 81 ; Returns: 82 ; AX: Max supported PIO mode 83 ; DX: Minimum Cycle Time in nanosecs 84 ; Corrupts registers: 85 ; BX 86 ;-------------------------------------------------------------------- 87 AtaID_GetMaxPioModeToAXandMinCycleTimeToDX: 88 ; Get PIO mode and cycle time for PIO 0...2 89 mov bx, [es:si+ATA1.bPioMode] 90 shl bx, 1 ; Shift for WORD lookup 91 mov dx, [cs:bx+.rgwPio0to2CycleTimeInNanosecs] 92 shr bx, 1 93 xchg ax, bx ; AL = PIO mode 0, 1 or 2 94 95 ; Check if Advanced PIO modes are supported (3 and above) 96 test BYTE [es:si+ATA2.wFields], A2_wFields_64to70 97 jz SHORT .ReturnPioTimings 98 99 ; Get Advanced PIO mode 100 ; (Hard Disks supports up to 4 but CF cards might support 5) 101 mov bx, [es:si+ATA2.bPIOSupp] 102 .CheckNextFlag: 103 inc ax 104 shr bx, 1 105 jnz SHORT .CheckNextFlag 106 mov dx, [es:si+ATA2.wPIOMinCyF] ; Advanced modes use IORDY 107 .ReturnPioTimings: 108 ret 109 110 111 .rgwPio0to2CycleTimeInNanosecs: 112 dw PIO_0_MIN_CYCLE_TIME_NS 113 dw PIO_1_MIN_CYCLE_TIME_NS 114 dw PIO_2_MIN_CYCLE_TIME_NS 115 116 117 ;-------------------------------------------------------------------- 118 ; AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime 119 ; Parameters: 120 ; AX: Max supported PIO mode 121 ; DX: Minimum PIO Cycle Time in nanosecs 122 ; Returns: 123 ; CX: Minimum Active time in nanosecs 124 ; DX: Minimum Recovery time in nanosecs 125 ; Corrupts registers: 126 ; BX 127 ;-------------------------------------------------------------------- 128 AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime: 129 ; Subtract Address Valid Time (t1) from Cycle Time (t0) 130 mov bx, ax 131 eMOVZX cx, BYTE [cs:bx+.rgbPioModeToAddressValidTimeNs] 132 sub dx, cx 133 134 ; Subtract Active Time (t2) from previous result to get Recovery Time (t2i) 135 shl bx, 1 ; Shift PIO Mode for WORD lookup 136 mov cx, [cs:bx+.rgwPioModeToActiveTimeNs] 137 sub dx, cx 138 ret 139 140 141 .rgbPioModeToAddressValidTimeNs: 142 db PIO_0_MIN_ADDRESS_VALID_NS 143 db PIO_1_MIN_ADDRESS_VALID_NS 144 db PIO_2_MIN_ADDRESS_VALID_NS 145 db PIO_3_MIN_ADDRESS_VALID_NS 146 db PIO_4_MIN_ADDRESS_VALID_NS 147 148 .rgwPioModeToActiveTimeNs: 149 dw PIO_0_MIN_ACTIVE_TIME_NS 150 dw PIO_1_MIN_ACTIVE_TIME_NS 151 dw PIO_2_MIN_ACTIVE_TIME_NS 152 dw PIO_3_MIN_ACTIVE_TIME_NS 153 dw PIO_4_MIN_ACTIVE_TIME_NS 154 155 %endif ; MODULE_ADVANCED_ATA -
trunk/XTIDE_Universal_BIOS/Src/Initialization/DetectDrives.asm
r294 r363 204 204 call BootMenuInfo_CreateForHardDisk 205 205 jmp short DetectPrint_DriveNameFromBootnfoInESBX 206 207 -
trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm
r271 r363 53 53 ;-------------------------------------------------------------------- 54 54 Initialize_AndDetectDrives: 55 mov WORD [es:BOOTVARS.wMagicWord], BOOTVARS_MAGIC_WORD 55 56 call BootMenuPrint_InitializeDisplayContext 56 57 call DetectPrint_RomFoundAtSegment … … 98 99 call AH0h_ResetAllOurHardDisksAtTheEndOfDriveInitialization 99 100 add sp, BYTE EXTRA_BYTES_FOR_INTPACK 101 mov WORD [es:BOOTVARS.wMagicWord], 0 100 102 ret -
trunk/XTIDE_Universal_BIOS/Src/Main.asm
r361 r363 34 34 %include "IDE_8bit.inc" ; For IDE 8-bit data port macros 35 35 %include "DeviceIDE.inc" ; For IDE device equates 36 %include "Vision.inc" ; For QDI Vision QD65xx VLB IDE Controllers 36 37 37 38 … … 69 70 %endif 70 71 72 %ifdef MODULE_ADVANCED_ATA 73 MAIN_FLG_MODULE_ADVATA equ FLG_ROMVARS_MODULE_ADVATA 74 %else 75 MAIN_FLG_MODULE_ADVATA equ 0 76 %endif 77 71 78 72 79 ;---------------------------; … … 74 81 ;---------------------------; 75 82 %ifdef USE_AT 76 at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE 83 at ROMVARS.wFlags, dw FLG_ROMVARS_FULLMODE | FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE | MAIN_FLG_MODULE_ADVATA 77 84 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE 78 85 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT … … 89 96 at ROMVARS.ideVars0+IDEVARS.drvParamsSlave+DRVPARAMS.wFlags, db DISABLE_WRITE_CACHE | FLG_DRVPARAMS_BLOCKMODE 90 97 91 at ROMVARS.ideVars1+IDEVARS.wPort, dw 170h ; Controller Command Block base port92 at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw 370h ; Controller Control Block base port98 at ROMVARS.ideVars1+IDEVARS.wPort, dw DEVICE_ATA_DEFAULT_SECONDARY_PORT 99 at ROMVARS.ideVars1+IDEVARS.wPortCtrl, dw DEVICE_ATA_DEFAULT_SECONDARY_PORTCTRL 93 100 at ROMVARS.ideVars1+IDEVARS.bDevice, db DEVICE_16BIT_ATA 94 101 at ROMVARS.ideVars1+IDEVARS.bIRQ, db 0 … … 117 124 ; XT and XT+ Build default settings ; 118 125 ;-----------------------------------; 119 at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE 126 at ROMVARS.wFlags, dw FLG_ROMVARS_DRVXLAT | MAIN_FLG_MODULE_SERIAL | MAIN_FLG_MODULE_EBIOS | MAIN_FLG_MODULE_JRIDE | MAIN_FLG_MODULE_ADVATA 120 127 at ROMVARS.wDisplayMode, dw DEFAULT_TEXT_MODE 121 128 at ROMVARS.wBootTimeout, dw BOOT_MENU_DEFAULT_TIMEOUT … … 205 212 206 213 ; IDE Device support 214 %ifdef MODULE_ADVANCED_ATA 215 %include "AdvAtaInit.asm" ; For initializing VLB and PCI controllers 216 %include "Vision.asm" ; QDI Vision QD6500 and QD6580 support 217 %endif 207 218 %define IDEDEVICE Ide 208 219 %define ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
Note:
See TracChangeset
for help on using the changeset viewer.