Ignore:
Timestamp:
Feb 9, 2013, 5:25:53 PM (11 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to Configurator v2:

  • XT-CF port can be selected again.
  • Auto Configure should now detect Sound Blaster 16 Tertiary and Quaternary IDE.
  • Auto Configure now properly sets Slave Drive variables.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS_Configurator_v2/Src/IdeAutodetect.asm

    r498 r502  
    2222
    2323;--------------------------------------------------------------------
    24 ; IdeAutodetect_DetectIdeDeviceFromPortDX
     24; IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX
    2525;   Parameters:
    2626;       DX:     IDE Base Port
     
    2828;   Returns:
    2929;       AL:     Device Type
     30;       CX:     Control Block Base port (detected since there is no
     31;               standard address for Tetriary and Quaternary IDE controllers)
    3032;       CF:     Clear if IDE Device found
    3133;               Set if IDE Device not found
    3234;   Corrupts registers:
    33 ;       AH, BX, CX
    34 ;--------------------------------------------------------------------
    35 IdeAutodetect_DetectIdeDeviceFromPortDX:
     35;       AH, BX
     36;--------------------------------------------------------------------
     37IdeAutodetect_DetectIdeDeviceFromPortDXAndReturnControlBlockInCX:
    3638    cmp     dx, FIRST_MEMORY_SEGMENT_ADDRESS
    3739    jb      SHORT .DetectPortMappedDevices
    3840
    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) ***
    4042    test    WORD [di+ROMVARS.wFlags], FLG_ROMVARS_MODULE_8BIT_IDE_ADVANCED
    4143    jz      SHORT .SkipRestOfDetection
     
    4345    push    ds
    4446    mov     ds, dx
    45     cli                         ; Disable Interrupts
     47    cli                                 ; Disable Interrupts
    4648    mov     ah, [JRIDE_COMMAND_BLOCK_REGISTER_WINDOW_OFFSET + STATUS_REGISTER_in]
    4749    mov     al, [JRIDE_CONTROL_BLOCK_REGISTER_WINDOW_OFFSET + ALTERNATE_STATUS_REGISTER_in]
    48     sti                         ; Enable Interrupts
     50    sti                                 ; Enable Interrupts
    4951    pop     ds
    5052    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
    5355.DetectPortMappedDevices:
    5456
    5557
    56     ; Try to detect Standard 16- and 32-bit IDE Devices
     58    ; *** Try to detect Standard 16- and 32-bit IDE Devices ***
    5759    mov     bh, DEVICE_16BIT_ATA        ; Assume 16-bit ISA slot for AT builds
    5860    call    Buffers_IsXTbuildLoaded
    5961    eCMOVE  bh, DEVICE_8BIT_ATA         ; Assume 8-bit ISA slot for XT builds
     62
    6063    mov     bl, STATUS_REGISTER_in
    6164    mov     cx, STANDARD_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in
     65.RedetectTertiaryOrQuaternaryWithDifferentAlternativeStatusRegisterPort:
    6266    call    DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX
    6367    mov     al, bh
    6468    jnc     SHORT .IdeDeviceFound
    6569
     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
    6684
    6785    ; Detect 8-bit devices only if MODULE_8BIT_IDE is available
     
    6987    jz      SHORT .SkipRestOfDetection
    7088
    71     ; Try to detect XT-CF
     89    ; *** Try to detect XT-CF ***
    7290    mov     bl, STATUS_REGISTER_in << 1
    7391    mov     cx, (XTIDE_CONTROL_BLOCK_OFFSET + ALTERNATE_STATUS_REGISTER_in) << 1
    7492    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
    7596    mov     al, DEVICE_8BIT_XTCF_PIO8
    7697    jnc     SHORT .IdeDeviceFound
    7798
    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 ***
    79101    ; Note that A0<->A3 address swaps Status Register and Alternative
    80102    ; Status Register addresses. That is why we need another step
    81103    ; to check is this XT-IDE rev 1 or rev 2.
    82     shr     cx, 1
    83104    call    DetectIdeDeviceFromPortDXwithStatusRegOffsetsInBLandCX
    84105    jc      SHORT .SkipRestOfDetection  ; No XT-IDE rev 1 or rev 2 found
     
    99120    je      SHORT .IdeDeviceFound
    100121    mov     al, DEVICE_8BIT_XTIDE_REV1  ; We must have rev 1
    101     clc
    102122.IdeDeviceFound:
     123    sub     cl, ALTERNATE_STATUS_REGISTER_in    ; Clear CF
     124    add     cx, dx                              ; CX = Control Block address
    103125    ret
    104126.SkipRestOfDetection:
     
    156178
    157179    ; 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.
    160184    test    al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_DRQ | FLG_STATUS_ERR
    161185    jnz     SHORT .InvalidStatusRegister    ; Busy or Errors cannot be set
Note: See TracChangeset for help on using the changeset viewer.