Changeset 502 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm
- Timestamp:
- Feb 9, 2013, 5:25:53 PM (10 years ago)
- google:author:
- aitotat@gmail.com
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm
r498 r502 22 22 23 23 ;-------------------------------------------------------------------- 24 ; IdeAutodetect_DetectIdeDeviceFromPortDX 24 ; IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX 25 25 ; Parameters: 26 26 ; DX: IDE Base Port … … 28 28 ; Returns: 29 29 ; AL: Device Type 30 ; CX: Control Block Base port (detected since there is no 31 ; standard address for Tetriary and Quaternary IDE controllers) 30 32 ; CF: Clear if IDE Device found 31 33 ; Set if IDE Device not found 32 34 ; Corrupts registers: 33 ; AH, BX , CX34 ;-------------------------------------------------------------------- 35 IdeAutodetect_DetectIdeDeviceFromPortDX :35 ; AH, BX 36 ;-------------------------------------------------------------------- 37 IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX: 36 38 cmp dx, FIRST_MEMORY_SEGMENT_ADDRESS 37 39 jb SHORT .DetectPortMappedDevices 38 40 39 ; Try to detect JR-IDE/ISA (only if MODULE_8BIT_IDE_ADVANCED is present)41 ; *** Try to detect JR-IDE/ISA (only if MODULE_8BIT_IDE_ADVANCED is present) *** 40 42 test WORD [di+ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED 41 43 jz SHORT .SkipRestOfDetection … … 43 45 push ds 44 46 mov ds, dx 45 cli ; Disable Interrupts47 cli ; Disable Interrupts 46 48 mov ah, [JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET + STATUS_REGISTER_in] 47 49 mov al, [JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET + ALTERNATE_STATUS_REGISTER_in] 48 sti ; Enable Interrupts50 sti ; Enable Interrupts 49 51 pop ds 50 52 call CompareIdeStatusRegistersFromALandAH 51 mov al, DEVICE_8BIT_JRIDE_ISA 52 ret 53 mov al, DEVICE_8BIT_JRIDE_ISA ; Assume CF was cleared 54 ret ; No need to return Control Block Port 53 55 .DetectPortMappedDevices: 54 56 55 57 56 ; Try to detect Standard 16- and 32-bit IDE Devices58 ; *** Try to detect Standard 16- and 32-bit IDE Devices *** 57 59 mov bh, DEVICE_16BIT_ATA ; Assume 16-bit ISA slot for AT builds 58 60 call Buffers_IsXTbuildLoaded 59 61 eCMOVE bh, DEVICE_8BIT_ATA ; Assume 8-bit ISA slot for XT builds 62 60 63 mov bl, STATUS_REGISTER_in 61 64 mov cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in 65 .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort: 62 66 call DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 63 67 mov al, bh 64 68 jnc SHORT .IdeDeviceFound 65 69 70 ; 16- or 32-bit IDE Device was not found but we may have used wrong Control Block port if we were trying 71 ; to detect Tertiary or Quaternary IDE controllers. Control Block port location is not standardized. For 72 ; example Promise FloppyMAX has Control Block at STANDARD_CONTROL_BLOCK_OFFSET but Sound Blaster 16 (CT2290) 73 ; use DEVICE_ATA_SECONDARY_PORTCTRL for Tertiary and Quaternary even though only Secondary should use that. 74 cmp cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in 75 jne SHORT .AlreadyTriedAlternativeControlBlock 76 mov cx, DEVICE_ATA_SECONDARY_PORTCTRL + ALTERNATE_STATUS_REGISTER_in 77 sub cx, dx ; Offset to add to DX 78 cmp dx, DEVICE_ATA_TERTIARY_PORT 79 je SHORT .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort 80 cmp dx, DEVICE_ATA_QUATERNARY_PORT 81 je SHORT .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort 82 .AlreadyTriedAlternativeControlBlock: 83 66 84 67 85 ; Detect 8-bit devices only if MODULE_8BIT_IDE is available … … 69 87 jz SHORT .SkipRestOfDetection 70 88 71 ; Try to detect XT-CF89 ; *** Try to detect XT-CF *** 72 90 mov bl, STATUS_REGISTER_in << 1 73 91 mov cx, (XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in) << 1 74 92 call DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 93 rcl ax, 1 ; Store CF 94 shr cx, 1 ; XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in 95 rcr ax, 1 ; Restore CF 75 96 mov al, DEVICE_8BIT_XTCF_PIO8 76 97 jnc SHORT .IdeDeviceFound 77 98 78 ; Try to detect 8-bit XT-IDE rev 1 or rev 2. 99 100 ; *** Try to detect 8-bit XT-IDE rev 1 or rev 2 *** 79 101 ; Note that A0<->A3 address swaps Status Register and Alternative 80 102 ; Status Register addresses. That is why we need another step 81 103 ; to check is this XT-IDE rev 1 or rev 2. 82 shr cx, 183 104 call DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 84 105 jc SHORT .SkipRestOfDetection ; No XT-IDE rev 1 or rev 2 found … … 99 120 je SHORT .IdeDeviceFound 100 121 mov al, DEVICE_8BIT_XTIDE_REV1 ; We must have rev 1 101 clc102 122 .IdeDeviceFound: 123 sub cl, ALTERNATE_STATUS_REGISTER_in ; Clear CF 124 add cx, dx ; CX = Control Block address 103 125 ret 104 126 .SkipRestOfDetection: … … 156 178 157 179 ; Bytes were the same but it is possible they were both FFh, for 158 ; example. We must make sure bit are what is expected from valid 159 ; IDE Status Register. 180 ; example. We must make sure bits are what is expected from valid 181 ; IDE Status Register. So far all drives I've tested return 50h 182 ; (FLG_STATUS_DRDY and FLG_STATUS_DSC set) but I don't want to assume 183 ; just yet that all drives report 50h. 160 184 test al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_DRQ | FLG_STATUS_ERR 161 185 jnz SHORT .InvalidStatusRegister ; Busy or Errors cannot be set
Note: See TracChangeset
for help on using the changeset viewer.