Changeset 535 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src


Ignore:
Timestamp:
Apr 8, 2013, 5:09:44 PM (12 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.
Location:
trunk/XTIDE_Universal_BIOS/Src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm

    r526 r535  
    2626;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    2727;   Returns:
    28 ;       CF:     Set if wait done by operating system
    29 ;               Cleared if BIOS must perform task flag polling
     28;       Nothing
    3029;   Corrupts registers:
    3130;       AX
     
    3332ALIGN JUMP_ALIGN
    3433IdeIrq_WaitForIRQ:
    35 
    36 ;--------------------------------------------------------------------
    37 ; .NotifyOperatingSystemAboutWaitingForIRQ
    38 ;   Parameters:
    39 ;       Nothing
    40 ;   Returns:
    41 ;       CF:     Set if wait done by operating system
    42 ;               Cleared if BIOS must perform task flag polling
    43 ;   Corrupts registers:
    44 ;       AX
    45 ;--------------------------------------------------------------------
    46 .NotifyOperatingSystemAboutWaitingForIRQ:
    4734    push    ds
    4835
     
    5340    jc      SHORT .ReturnFromWaitNotify ;  If so, skip OS notification
    5441    int     BIOS_SYSTEM_INTERRUPT_15h   ; OS hook, device busy
    55     jnc     SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
    5642
    57     ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
    58     test    ah, ah                      ; OS hook supported? (clears CF)
    59     jnz     SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
    60     stc                                 ; Set CF since wait done by OS
    6143.ReturnFromWaitNotify:
    6244    sti                                 ; Enable interrupts
     
    9981
    10082    ; Issue Int 15h, function AX=9100h (Interrupt ready)
     83    clc                                 ; Must be called with CF clear
    10184    mov     ax, OS_HOOK_DEVICE_POST<<8  ; Interrupt ready, device 0 (HD)
    10285    int     BIOS_SYSTEM_INTERRUPT_15h
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm

    r526 r535  
    4343    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], EBIOS_VERSION
    4444    mov     WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h
     45
     46%ifdef RETURN_DPTE_ON_AH48H
     47    call    AH41h_GetSupportBitsToCX
     48    mov     [bp+IDEPACK.intpack+INTPACK.cx], cx
     49%else
    4550    mov     WORD [bp+IDEPACK.intpack+INTPACK.cx], ENHANCED_DRIVE_ACCESS_SUPPORT
     51%endif
     52
    4653    and     BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF  ; Return with CF cleared
    4754    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
    4855.EbiosNotSupported:
    4956    jmp     Int13h_DirectCallToAnotherBios
     57
     58
     59%ifdef RETURN_DPTE_ON_AH48H
     60;--------------------------------------------------------------------
     61; AH41h_GetSupportBitsToCX
     62;   Parameters:
     63;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     64;   Returns:
     65;       CX:     Support bits returned by AH=41h
     66;   Corrupts registers:
     67;       Nothing
     68;--------------------------------------------------------------------
     69AH41h_GetSupportBitsToCX:
     70    mov     cx, ENHANCED_DRIVE_ACCESS_SUPPORT
     71
     72    ; DPTE needs buffer from RAM so do not return it in lite mode
     73%ifndef USE_AT
     74    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
     75    jz      SHORT .DoNotSetEDDflag
     76%endif
     77
     78%ifdef MODULE_8BIT_IDE OR MODULE_SERIAL
     79    ; DPTE contains information for device drivers. We should not return
     80    ; DPTE for 8-bit devices since software would think they are 16-bit devices.
     81    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_8BIT_ATA
     82    jae     SHORT .DoNotSetEDDflag
     83%endif
     84
     85    or      cl, ENHANCED_DISK_DRIVE_SUPPORT ; AH=48h returns DPTE
     86.DoNotSetEDDflag:
     87    ret
     88
     89%endif ; RETURN_DPTE_ON_AH48H
  • 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
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r533 r535  
    120120    mov     [di+DPT.bPchsSectorsPerTrack], bh
    121121
     122; This is what Award BIOS from 1997 Pentium motherboard does. I can't think
     123; of any good reason to do the same but let's keep this here just in case,
     124; at least for a while.
     125%if 0
    122126%ifdef RESERVE_DIAGNOSTIC_CYLINDER
    123127    ; Do not store P-Cylinders, instead calculate it from L-CHS total sector count.
     
    130134    div     bx                          ; AX = Calculated cylinders
    131135%endif ; RESERVE_DIAGNOSTIC_CYLINDER
     136%endif ; 0
    132137
    133138    mov     [di+DPT.wPchsCylinders], ax
Note: See TracChangeset for help on using the changeset viewer.