Ignore:
Timestamp:
Apr 8, 2013, 5:09:44 PM (11 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • AH=48h now returns Device Parameter Table Extension when RETURN_DPTE_ON_AH48H is defined.
  • Removed few unnecessary instructions from hardware interrupt handler.
  • P-Cylinders returned by AH=48h are no longer calculated from L-CHS capacity.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r533 r535  
    5959; BIOS that does just that.
    6060;
    61 ; Since I don't have any better knowledge, I decided that when RESERVE_DIAGNOSTIC_CYLINDER
    62 ; is defined, we do what the Award BIOS does. When it is not defined, we multiply
    63 ; P-CHS values together and use that as total sector count.
     61; I decided that we multiply P-CHS values and do not waste space like the
     62; Award BIOS does.
    6463;
    6564;
     
    7877;--------------------------------------------------------------------
    7978AH48h_HandlerForGetExtendedDriveParameters:
     79    mov     si, di
     80    push    ds
     81    pop     es      ; ES = RAMVARS segment
     82    xor     bx, bx
     83    dec     bx      ; Set to FFFFh to assume we do not return DPTE
     84
     85    ; Create DPTE (hardware information for device drivers)
     86%ifdef RETURN_DPTE_ON_AH48H
     87    call    AH41h_GetSupportBitsToCX
     88    test    cl, ENHANCED_DISK_DRIVE_SUPPORT
     89    jz      SHORT .DoNotCreateDPTE
     90    call    CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
     91.DoNotCreateDPTE:
     92%endif
     93
     94    ; Point DS:DI to Extended Drive Information Table to fill
     95    mov     di, [bp+IDEPACK.intpack+INTPACK.si]
     96    mov     ds, [bp+IDEPACK.intpack+INTPACK.ds]
     97
     98    ; Check and adjust Extended Drive Information Table size
     99    ; to MINIMUM_EDRIVEINFO_SIZE or EDRIVEINFO_SIZE_WITH_DPTE
     100    mov     ax, MINIMUM_EDRIVEINFO_SIZE
     101    mov     cx, [di+EDRIVE_INFO.wSize]
     102    cmp     cx, ax
     103    jb      Prepare_ReturnFromInt13hWithInvalidFunctionError
     104    mov     [di+EDRIVE_INFO.wSize], ax
     105    add     al, EDRIVEINFO_SIZE_WITH_DPTE - MINIMUM_EDRIVEINFO_SIZE
     106    cmp     cx, ax
     107    jb      SHORT .SkipEddConfigurationParameters
     108    mov     [di+EDRIVE_INFO.wSize], ax
     109
     110    ; Store DPTE for standard controllers only,
     111    ; FFFF:FFFF for non standard controllers
     112%ifdef RETURN_DPTE_ON_AH48H
     113    mov     [di+EDRIVE_INFO.fpDPTE], bx
     114    mov     [di+EDRIVE_INFO.fpDPTE+2], es
     115    inc     bx
     116    jnz     SHORT .SkipEddConfigurationParameters   ; Already stored
     117    dec     bx
     118    mov     [di+EDRIVE_INFO.fpDPTE+2], bx   ; Segment = FFFFh
     119%else
     120    mov     [di+EDRIVE_INFO.fpDPTE], bx
     121    mov     [di+EDRIVE_INFO.fpDPTE+2], bx
     122%endif
     123
     124    ; Fill Extended Drive Information Table in DS:DI from DPT in ES:SI
     125.SkipEddConfigurationParameters:
     126    mov     WORD [di+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
     127
     128    ; Store total sector count
     129    call    Registers_ExchangeDSSIwithESDI
    80130    call    AccessDPT_GetLbaSectorCountToBXDXAX
    81 
    82     ; Point DS:SI to Extended Drive Information Table to fill
    83     push    ds
    84     pop     es          ; DPT now in ES:DI
    85     mov     ds, [bp+IDEPACK.intpack+INTPACK.ds]
    86     mov     cx, MINIMUM_EDRIVEINFO_SIZE
    87     cmp     [si+EDRIVE_INFO.wSize], cx
    88     jb      Prepare_ReturnFromInt13hWithInvalidFunctionError
    89     je      SHORT .SkipEddConfigurationParameters
    90 
    91     ; We do not support EDD Configuration Parameters so set to FFFF:FFFFh
    92     sub     cx, BYTE MINIMUM_EDRIVEINFO_SIZE+1  ; CX => FFFFh
    93     mov     [si+EDRIVE_INFO.fpEDDparams], cx
    94     mov     [si+EDRIVE_INFO.fpEDDparams+2], cx
    95     mov     cx, EDRIVE_INFO_size
    96 
    97     ; Fill Extended Drive Information Table in DS:SI
    98 .SkipEddConfigurationParameters:
    99     mov     [si+EDRIVE_INFO.wSize], cx
    100     mov     WORD [si+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
    101 
    102     ; Store total sector count
    103     mov     [si+EDRIVE_INFO.qwTotalSectors], ax
    104     mov     [si+EDRIVE_INFO.qwTotalSectors+2], dx
    105     mov     [si+EDRIVE_INFO.qwTotalSectors+4], bx
     131    call    Registers_ExchangeDSSIwithESDI
     132    mov     [di+EDRIVE_INFO.qwTotalSectors], ax
     133    mov     [di+EDRIVE_INFO.qwTotalSectors+2], dx
     134    mov     [di+EDRIVE_INFO.qwTotalSectors+4], bx
    106135    xor     cx, cx
    107     mov     [si+EDRIVE_INFO.qwTotalSectors+6], cx   ; Always zero
    108     mov     WORD [si+EDRIVE_INFO.wSectorSize], 512
     136    mov     [di+EDRIVE_INFO.qwTotalSectors+6], cx   ; Always zero
     137    mov     WORD [di+EDRIVE_INFO.wSectorSize], 512
    109138
    110139    ; Store P-CHS. Based on phoenix specification this is returned only if
     
    114143    sbb     bx, cx      ; Zero
    115144    jnc     SHORT .ReturnWithSuccess    ; More than EC4000h
    116     or      WORD [si+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
    117 
    118     eMOVZX  dx, BYTE [es:di+DPT.bPchsHeads]
    119     mov     [si+EDRIVE_INFO.dwHeads], dx
    120     mov     [si+EDRIVE_INFO.dwHeads+2], cx
    121 
    122     mov     dl, [es:di+DPT.bPchsSectorsPerTrack]
    123     mov     [si+EDRIVE_INFO.dwSectorsPerTrack], dx
    124     mov     [si+EDRIVE_INFO.dwSectorsPerTrack+2], cx
    125 
    126     mov     dx, [es:di+DPT.wPchsCylinders]
    127     mov     [si+EDRIVE_INFO.dwCylinders], dx
    128     mov     [si+EDRIVE_INFO.dwCylinders+2], cx
     145    or      WORD [di+EDRIVE_INFO.wFlags], FLG_CHS_INFORMATION_IS_VALID
     146
     147    eMOVZX  dx, BYTE [es:si+DPT.bPchsHeads]
     148    mov     [di+EDRIVE_INFO.dwHeads], dx
     149    mov     [di+EDRIVE_INFO.dwHeads+2], cx
     150
     151    mov     dl, [es:si+DPT.bPchsSectorsPerTrack]
     152    mov     [di+EDRIVE_INFO.dwSectorsPerTrack], dx
     153    mov     [di+EDRIVE_INFO.dwSectorsPerTrack+2], cx
     154
     155    mov     dx, [es:si+DPT.wPchsCylinders]
     156    mov     [di+EDRIVE_INFO.dwCylinders], dx
     157    mov     [di+EDRIVE_INFO.dwCylinders+2], cx
    129158
    130159.ReturnWithSuccess:
     
    132161.ReturnWithError:
    133162    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
     163
     164
     165%ifdef RETURN_DPTE_ON_AH48H
     166;--------------------------------------------------------------------
     167; CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI
     168;   Parameters:
     169;       DS:SI:  Ptr to DPT (in RAMVARS segment)
     170;       ES:     RAMVARS segment
     171;   Returns:
     172;       ES:BX:  Ptr to Device Parameter Table Extension (DPTE)
     173;   Corrupts registers:
     174;       AX, CX, DX, DI
     175;--------------------------------------------------------------------
     176CreateDeviceParameterTableExtensionToESBXfromDPTinDSSI:
     177    ; Point ES:DI to DPTE buffer (valid until next AH=48h call)
     178    mov     di, [cs:ROMVARS.bStealSize]
     179    eSHL_IM di, 10                          ; DI = RAMVARS size in bytes
     180    sub     di, BYTE DPTE_size              ; DI = Offset to DPTE
     181    xor     dx, dx                          ; Clear for checksum
     182
     183    ; Set 32-bit flag for 32-bit controllers
     184    mov     cx, FLG_LBA_TRANSLATION_ENABLED ; DPTE.wFlags
     185    cmp     BYTE [si+DPT_ATA.bDevice], DEVICE_32BIT_ATA
     186    eCMOVE  cl, FLG_LBA_TRANSLATION_ENABLED | FLG_32BIT_XFER_MODE
     187
     188    ; DPTE.wBasePort
     189    mov     ax, [si+DPT.wBasePort]
     190    call    StoswThenAddALandAHtoDL         ; Bytes 0 and 1
     191
     192    ; DPTE.wControlBlockPort
     193    eMOVZX  bx, BYTE [si+DPT.bIdevarsOffset]
     194    mov     ax, [cs:bx+IDEVARS.wControlBlockPort]
     195    call    StoswThenAddALandAHtoDL         ; Bytes 2 and 3
     196
     197    ; DPTE.bDrvnhead and DPTE.bBiosVendor
     198    xchg    di, si
     199    call    AccessDPT_GetDriveSelectByteForEbiosToAL
     200    xchg    si, di
     201    call    StoswThenAddALandAHtoDL         ; Bytes 4 and 5
     202
     203    ; DPTE.bIRQ and DPTE.bBlockSize
     204    mov     al, [cs:bx+IDEVARS.bIRQ]        ; No way to define that we might not use IRQ
     205    mov     ah, [si+DPT_ATA.bBlockSize]
     206    cmp     ah, 1
     207    jbe     SHORT .DoNotSetBlockModeFlag
     208    or      cl, FLG_BLOCK_MODE_ENABLED
     209.DoNotSetBlockModeFlag:
     210    call    StoswThenAddALandAHtoDL         ; Bytes 6 and 7
     211
     212    ; DPTE.bDmaChannelAndType and DPTE.bPioMode
     213    xor     ax, ax
     214%ifdef MODULE_ADVANCED_ATA
     215    or      ah, [si+DPT_ADVANCED_ATA.bPioMode]
     216    jz      SHORT .NoDotSetFastPioFlag
     217    cmp     WORD [si+DPT_ADVANCED_ATA.wControllerID], BYTE 0
     218    je      SHORT .NoDotSetFastPioFlag
     219    inc     cx      ; FLG_FAST_PIO_ENABLED
     220.NoDotSetFastPioFlag:
     221%endif
     222    call    StoswThenAddALandAHtoDL         ; Bytes 8 and 9
     223
     224    ; Set CHS translation flags and store DPTE.wFlags
     225    mov     al, [si+DPT.bFlagsLow]
     226    and     al, MASKL_DPT_TRANSLATEMODE
     227    jz      SHORT .NoChsTranslationOrBitShiftTranslationSet
     228    or      cl, FLG_CHS_TRANSLATION_ENABLED
     229    test    al, FLGL_DPT_ASSISTED_LBA
     230    jz      SHORT .NoChsTranslationOrBitShiftTranslationSet
     231    or      cx, LBA_ASSISTED_TRANSLATION << TRANSLATION_TYPE_FIELD_POSITION
     232.NoChsTranslationOrBitShiftTranslationSet:
     233    xchg    ax, cx
     234    call    StoswThenAddALandAHtoDL         ; Bytes 10 and 11
     235
     236    ; DPTE.wReserved (must be zero)
     237    xor     ax, ax
     238    call    StoswThenAddALandAHtoDL         ; Bytes 12 and 13
     239
     240    ; DPTE.bRevision and DPTE.bChecksum
     241    mov     ax, DPTE_REVISION | (DPTE_REVISION<<8)
     242    add     ah, dl
     243    neg     ah
     244    stosw
     245    lea     bx, [di-DPTE_size]
     246    ret
     247
     248
     249;--------------------------------------------------------------------
     250; StoswThenAddALandAHtoDL
     251;   Parameters:
     252;       AX:     WORD to store
     253;       ES:DI:  Ptr to where to store AX
     254;       DL:     Checksum byte
     255;   Returns:
     256;       DL:     Checksum byte
     257;       DI:     Incremented by 2
     258;   Corrupts registers:
     259;       Nothing
     260;--------------------------------------------------------------------
     261StoswThenAddALandAHtoDL:
     262    stosw
     263    add     dl, al
     264    add     dl, ah
     265    ret
     266
     267%endif ; RETURN_DPTE_ON_AH48H
Note: See TracChangeset for help on using the changeset viewer.