Changeset 504 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS_Configurator_v2/Src
- Timestamp:
- Feb 13, 2013, 6:12:52 PM (12 years ago)
- google:author:
- aitotat@gmail.com
- Location:
- trunk/XTIDE_Universal_BIOS_Configurator_v2/Src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/AutoConfigure.asm
r502 r504 101 101 call IdeAutodetect_IncrementDXtoNextIdeBasePort 102 102 jz SHORT .AllPortsAlreadyDetected 103 push cx104 call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockIn CX105 mov bx, cx106 pop cx103 push si 104 call IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI 105 mov bx, si 106 pop si 107 107 jc SHORT .DetectFromNextPort 108 108 -
trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm
r502 r504 24 24 ; IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX 25 25 ; Parameters: 26 ; DX: IDE Base Port 26 ; DX: IDE Base Port or segment address (Command Block) 27 27 ; DS:DI: Ptr to ROMVARS 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 ; SI: IDE Control Block Base port (port mapped devices only) 32 31 ; CF: Clear if IDE Device found 33 32 ; Set if IDE Device not found … … 35 34 ; AH, BX 36 35 ;-------------------------------------------------------------------- 37 IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockIn CX:36 IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInSI: 38 37 cmp dx, FIRST_MEMORY_SEGMENT_ADDRESS 39 jb SHORT .DetectPortMappedDevices 40 38 jb SHORT DetectPortMappedDeviceFromPortDX 39 ; Fall to DetectMemoryMappedDeviceFromSegmentDX 40 41 ;-------------------------------------------------------------------- 42 ; DetectMemoryMappedDeviceFromSegmentDX 43 ; Parameters: 44 ; DX: Segment address for Memory Mapped Device 45 ; DS:DI: Ptr to ROMVARS 46 ; Returns: 47 ; AL: Device Type 48 ; CF: Clear if IDE Device found 49 ; Set if IDE Device not found 50 ; Corrupts registers: 51 ; AH, BX 52 ;-------------------------------------------------------------------- 53 DetectMemoryMappedDeviceFromSegmentDX: 41 54 ; *** Try to detect JR-IDE/ISA (only if MODULE_8BIT_IDE_ADVANCED is present) *** 42 55 test WORD [di+ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED 43 jz SHORT .SkipRestOfDetection56 jz SHORT NoIdeDeviceFound 44 57 45 58 push ds … … 53 66 mov al, DEVICE_8BIT_JRIDE_ISA ; Assume CF was cleared 54 67 ret ; No need to return Control Block Port 55 .DetectPortMappedDevices: 56 57 68 69 70 ;-------------------------------------------------------------------- 71 ; DetectPortMappedDeviceFromPortDX 72 ; Parameters: 73 ; DX: IDE Base Port (Command Block) 74 ; DS:DI: Ptr to ROMVARS 75 ; Returns: 76 ; AL: Device Type 77 ; SI: IDE Control Block Base port 78 ; CF: Clear if IDE Device found 79 ; Set if IDE Device not found 80 ; Corrupts registers: 81 ; AH, BX 82 ;-------------------------------------------------------------------- 83 DetectPortMappedDeviceFromPortDX: 58 84 ; *** Try to detect Standard 16- and 32-bit IDE Devices *** 59 mov bh, DEVICE_16BIT_ATA ; Assume 16-bit ISA slot for AT builds85 mov al, DEVICE_16BIT_ATA ; Assume 16-bit ISA slot for AT builds 60 86 call Buffers_IsXTbuildLoaded 61 eCMOVE bh, DEVICE_8BIT_ATA ; Assume 8-bit ISA slot for XT builds 62 63 mov bl, STATUS_REGISTER_in 64 mov cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in 65 .RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort: 66 call DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 67 mov al, bh 87 eCMOVE al, DEVICE_8BIT_ATA ; Assume 8-bit ISA slot for XT builds 88 89 ; Start with standard Control Block base port used by Primary and Secondary IDE 90 mov si, dx 91 add si, STANDARD_CONTROL_BLOCK_OFFSET 92 mov bx, STATUS_REGISTER_in | (ALTERNATE_STATUS_REGISTER_in << 8) 93 .RedetectTertiaryOrQuaternaryWithDifferentControlBlockAddress: 94 push ax ; Store device type 95 call DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH 96 pop ax ; Restore device type 68 97 jnc SHORT .IdeDeviceFound 69 98 … … 72 101 ; example Promise FloppyMAX has Control Block at STANDARD_CONTROL_BLOCK_OFFSET but Sound Blaster 16 (CT2290) 73 102 ; 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: 103 call ChangeDifferentControlBlockAddressToSI 104 je SHORT .RedetectTertiaryOrQuaternaryWithDifferentControlBlockAddress 83 105 84 106 85 107 ; Detect 8-bit devices only if MODULE_8BIT_IDE is available 86 108 test BYTE [di+ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE 87 jz SHORT .SkipRestOfDetection109 jz SHORT NoIdeDeviceFound 88 110 89 111 ; *** Try to detect XT-CF *** 90 mov bl, STATUS_REGISTER_in << 1 91 mov cx, (XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in) << 1 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 112 mov si, dx 113 add si, BYTE XTCF_CONTROL_BLOCK_OFFSET 114 shl bx, 1 ; SHL 1 register offsets for XT-CF 115 call DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH 96 116 mov al, DEVICE_8BIT_XTCF_PIO8 97 117 jnc SHORT .IdeDeviceFound … … 102 122 ; Status Register addresses. That is why we need another step 103 123 ; to check is this XT-IDE rev 1 or rev 2. 104 call DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 105 jc SHORT .SkipRestOfDetection ; No XT-IDE rev 1 or rev 2 found 124 sub si, BYTE XTCF_CONTROL_BLOCK_OFFSET >> 1 125 shr bx, 1 126 call DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH 127 jc SHORT NoIdeDeviceFound ; No XT-IDE rev 1 or rev 2 found 106 128 107 129 ; Now we can be sure that we have XT-IDE rev 1 or rev 2. … … 121 143 mov al, DEVICE_8BIT_XTIDE_REV1 ; We must have rev 1 122 144 .IdeDeviceFound: 123 sub cl, ALTERNATE_STATUS_REGISTER_in ; Clear CF124 add cx, dx ; CX = Control Block address125 145 ret 126 .SkipRestOfDetection: 127 stc 128 ret 129 130 131 ;-------------------------------------------------------------------- 132 ; DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX 146 147 148 ;-------------------------------------------------------------------- 149 ; DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH 133 150 ; Parameters: 134 151 ; BL: Offset to IDE Status Register 135 ; CX: Offset to Alternative Status Register 136 ; DX: IDE Base Port 152 ; BH: Offset to Alternative Status Register 153 ; DX: IDE Base Port address 154 ; SI: IDE Control Block address 137 155 ; Returns: 138 156 ; CF: Clear if IDE Device found … … 141 159 ; AX 142 160 ;-------------------------------------------------------------------- 143 DetectIdeDeviceFromPort DXwithStatusRegOffsetsInBLandCX:161 DetectIdeDeviceFromPortsDXandSIwithOffsetsInBLandBH: 144 162 ; Read Status and Alternative Status Registers 145 push cx146 163 push dx 147 164 148 add cx, dx ; CX = Address to Alternative Status Register 149 add dl, bl ; DX = Address to Status Register 165 add dl, bl 150 166 cli ; Disable Interrupts 151 in al, dx ; Read Status Register 152 mov ah, al 153 mov dx, cx 154 in al, dx ; Read Alternative Status Register 167 in al, dx ; Read Status Register... 168 mov ah, al ; ...to AH 169 mov dx, si 170 add dl, bh 171 in al, dx ; Read Alternative Status Register to AL 155 172 sti ; Enable Interrupts 156 173 157 174 pop dx 158 pop cx159 175 ; Fall to CompareIdeStatusRegistersFromALandAH 160 176 … … 163 179 ; CompareIdeStatusRegistersFromALandAH 164 180 ; Parameters: 165 ; A L: Possible IDE Status Register contents166 ; A H: Possible IDE Alternative Status Register contents181 ; AH: Possible IDE Status Register contents 182 ; AL: Possible IDE Alternative Status Register contents 167 183 ; Returns: 168 184 ; CF: Clear if valid Status Register Contents … … 180 196 ; example. We must make sure bits are what is expected from valid 181 197 ; 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. 198 ; (FLG_STATUS_DRDY and FLG_STATUS_DSC set) unless there is only 199 ; one drive present but wrong drive is selected. For example if Master 200 ; drive is present but Slave is selected from IDE Drive and Head Select Register, 201 ; then the Status Register can be 00h. 184 202 test al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_DRQ | FLG_STATUS_ERR 185 203 jnz SHORT .InvalidStatusRegister ; Busy or Errors cannot be set … … 189 207 190 208 .InvalidStatusRegister: 191 AllPortsAlreadyDetected:209 NoIdeDeviceFound: 192 210 stc 211 ret 212 213 214 ;-------------------------------------------------------------------- 215 ; ChangeDifferentControlBlockAddressToSI 216 ; Parameters: 217 ; DX: IDE Base Port address 218 ; SI: IDE Control Block address 219 ; Returns: 220 ; ZF: Set if SI changed 221 ; Cleared if different control block address is not possible 222 ; Corrupts registers: 223 ; AH 224 ;-------------------------------------------------------------------- 225 ChangeDifferentControlBlockAddressToSI: 226 cmp si, 368h 227 je SHORT .TrySecondAlternative 228 cmp si, 3E8h 229 je SHORT .TrySecondAlternative 230 231 cmp si, 360h 232 je SHORT .TryLastAlternative 233 cmp si, 3E0h 234 je SHORT .TryLastAlternative 235 ret ; Return with ZF cleared 236 237 .TryLastAlternative: 238 mov si, DEVICE_ATA_SECONDARY_PORTCTRL + 8 ; Changes to 370h used by Sound Blaster 16 (CT2290) 239 ; Fall to .TrySecondAlternative 240 .TrySecondAlternative: 241 sub si, BYTE 8h ; 368h to 360h, 3E8h to 3E0h 242 xor ah, ah ; Set ZF 193 243 ret 194 244
Note:
See TracChangeset
for help on using the changeset viewer.