Changeset 167 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS


Ignore:
Timestamp:
Aug 21, 2011, 3:42:15 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Old Int 13h transfer functions work again.
  • Fixes to eINT13h (EBIOS) support.
Location:
trunk/XTIDE_Universal_BIOS
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Inc/EBIOS.inc

    r165 r167  
    2222    .qwTotalSectors         resb    8   ; 16, Total number of addressable sectors
    2323    .wSectorSize            resb    2   ; 24, Number of bytes per sector
    24 
    2524    .fpEDDparams            resb    8   ; 26, Optional pointer to Enhanced Disk Drive (EDD) configuration parameters
    2625endstruc
  • trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc

    r155 r167  
    5454
    5555    ; Parameters for 48-bit LBA
    56     .wSectorCountHighAndLbaLowExt:
    57     .bSectorCountHighExt    resb    1   ; LBA48 Sector Count 15...8
     56                            resb    1
    5857    .bLbaLowExt             resb    1   ; LBA48 31...24
    5958
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r160 r167  
    128128
    129129    ; Output Sector Address High (only used by LBA48)
    130     mov     ax, [bp+IDEPACK.wSectorCountHighAndLbaLowExt]
     130    xor     ax, ax  ; Sector Count High always zero since 127 sector limit
     131    mov     ah, BYTE [bp+IDEPACK.bLbaLowExt]
    131132    mov     cx, [bp+IDEPACK.wLbaMiddleAndHighExt]
    132133    call    OutputSectorCountAndAddress
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r161 r167  
    55; This struct must not be larger than IDEPACK without INTPACK.
    66struc PIOVARS
    7     .wBlocksLeft            resb    2
     7    .wBlockLeftAndSectorsInLastBlock:
     8    .bBlocksLeft            resb    1
     9    .bSectorsInLastBlock:   resb    1
    810    .wBlockSize             resb    2   ; Block size in WORDs (256...32768)
    911    .wDataPort              resb    2
    10     .bSectorsInLastBlock:   resb    1
     12                            resb    1
    1113                            resb    1   ; Offset 7 = IDEPACK.bDeviceControl
    1214    .fnXfer                 resb    2   ; Offset to transfer function
     
    3234ALIGN JUMP_ALIGN
    3335IdeTransfer_StartWithCommandInAL:
    34     mov     ah, [bp+IDEPACK.bSectorCountHighExt]
    35 
    3636    ; Are we reading or writing?
    3737    test    al, 16  ; Bit 4 is cleared on all the read commands but set on 3 of the 4 write commands
     
    4242    ; Prepare to read data to ESSI
    4343    mov     bx, g_rgfnPioRead
    44     mov     al, [bp+IDEPACK.bSectorCount]
    45     call    InitializePiovarsInSSBPwithSectorCountInAX
     44    call    InitializePiovarsToSSBPfromIdepackInSSBP
    4645    xchg    si, di
     46%ifdef USE_186
     47    push    ReadFromDriveToESDI
     48    jmp     Registers_NormalizeESDI
     49%else
    4750    call    Registers_NormalizeESDI
    48     jmp     SHORT ReadFromDrive
     51    jmp     SHORT ReadFromDriveToESDI
     52%endif
    4953
    5054ALIGN JUMP_ALIGN
    5155.PrepareToWriteDataFromESSI:
    5256    mov     bx, g_rgfnPioWrite
    53     mov     al, [bp+IDEPACK.bSectorCount]
    54     call    InitializePiovarsInSSBPwithSectorCountInAX
     57    call    InitializePiovarsToSSBPfromIdepackInSSBP
    5558    call    Registers_NormalizeESSI
    56     ; Fall to WriteToDrive
    57 
    58 
    59 ;--------------------------------------------------------------------
    60 ; WriteToDrive
     59    ; Fall to WriteToDriveFromESSI
     60
     61
     62;--------------------------------------------------------------------
     63; WriteToDriveFromESSI
    6164;   Parameters:
    6265;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     
    7073;       AL, BX, CX, DX, SI, ES
    7174;--------------------------------------------------------------------
    72 WriteToDrive:
     75WriteToDriveFromESSI:
    7376    ; Always poll when writing first block (IRQs are generated for following blocks)
    7477    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     
    7881.WriteNextBlock:
    7982    mov     dx, [bp+PIOVARS.wDataPort]
    80     dec     WORD [bp+PIOVARS.wBlocksLeft]       ; Transferring last (possibly partial) block?
     83    dec     BYTE [bp+PIOVARS.bBlocksLeft]       ; Transferring last (possibly partial) block?
    8184    jz      SHORT .XferLastBlock                ;  If so, jump to transfer
    8285    mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
    8386    call    [bp+PIOVARS.fnXfer]                 ; Transfer full block
    84 
    85     ; Normalize pointer when necessary
    86     mov     ax, si
    87     shr     ax, 1                               ; WORD offset
    88     add     ax, [bp+PIOVARS.wBlockSize]
    89     jns     SHORT .WaitUntilReadyToTransferNextBlock
    90     call    Registers_NormalizeESSI
    91 
    92 ALIGN JUMP_ALIGN
    93 .WaitUntilReadyToTransferNextBlock:
    9487%ifdef USE_186
    9588    push    .WriteNextBlock
     
    117110
    118111;--------------------------------------------------------------------
    119 ; ReadFromDrive
     112; ReadFromDriveToESDI
    120113;   Parameters:
    121114;       ES:DI:  Normalized ptr to buffer to recieve data
     
    131124;--------------------------------------------------------------------
    132125ALIGN JUMP_ALIGN
    133 ReadFromDrive:
     126ReadFromDriveToESDI:
    134127    ; Wait until drive is ready to transfer
    135128    xchg    di, si                              ; DS:DI now points DPT
    136129    call    IdeWait_IRQorDRQ                    ; Wait until ready to transfer
    137     jc      SHORT WriteToDrive.ReturnWithTransferErrorInAH
     130    jc      SHORT WriteToDriveFromESSI.ReturnWithTransferErrorInAH
    138131    xchg    si, di                              ; ES:DI now points buffer
    139132
    140133    ; Transfer full or last (possible partial) block
    141134    mov     dx, [bp+PIOVARS.wDataPort]
    142     dec     WORD [bp+PIOVARS.wBlocksLeft]
     135    dec     BYTE [bp+PIOVARS.bBlocksLeft]
    143136    jz      SHORT .XferLastBlock
    144137    mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
     138%ifdef USE_186
     139    push    ReadFromDriveToESDI
     140    jmp     [bp+PIOVARS.fnXfer]
     141%else
    145142    call    [bp+PIOVARS.fnXfer]                 ; Transfer full block
    146 
    147     ; Normalize pointer when necessary
    148     mov     ax, di
    149     shr     ax, 1                               ; WORD offset
    150     add     ax, [bp+PIOVARS.wBlockSize]
    151     jns     SHORT ReadFromDrive
    152     call    Registers_NormalizeESDI
    153     jmp     SHORT ReadFromDrive                 ; Loop while blocks left
     143    jmp     SHORT ReadFromDriveToESDI                   ; Loop while blocks left
     144%endif
    154145
    155146ALIGN JUMP_ALIGN
     
    164155
    165156;--------------------------------------------------------------------
    166 ; InitializePiovarsInSSBPwithSectorCountInAX
    167 ;   Parameters:
    168 ;       AX:     Number of sectors to transfer (1...65535)
     157; InitializePiovarsToSSBPfromIdepackInSSBP
     158;   Parameters:
    169159;       BX:     Offset to transfer function lookup table
    170160;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     161;       SS:BP:  Ptr to IDEPACK
     162;   Returns:
    171163;       SS:BP:  Ptr to PIOVARS
    172 ;   Returns:
    173 ;       Nothing
    174164;   Corrupts registers:
    175165;       AX, BX, CX, DX
    176166;--------------------------------------------------------------------
    177167ALIGN JUMP_ALIGN
    178 InitializePiovarsInSSBPwithSectorCountInAX:
     168InitializePiovarsToSSBPfromIdepackInSSBP:
    179169    ; Store number of blocks to transfer
    180     eMOVZX  cx, BYTE [di+DPT_ATA.bSetBlock]     ; Block size in sectors
    181     xor     dx, dx      ; DX:AX = Sectors to transfer (1...65535)
    182     div     cx          ; AX = Full blocks to transfer
    183     test    dx, dx
    184     mov     dh, cl      ; DH = Full block size if no partial blocks to transfer
     170    eMOVZX  cx, BYTE [di+DPT_ATA.bSetBlock]     ; Block size in sectors, zero CH
     171    eMOVZX  ax, BYTE [bp+IDEPACK.bSectorCount]  ; AX = sectors to transfer (1...128)
     172    div     cl          ; AL = Full blocks to transfer
     173    test    ah, ah      ; AH = Sectors in partial block
    185174    jz      SHORT .NoPartialBlocksToTransfer
    186     inc     ax          ; Partial block
    187     mov     dh, dl      ; DH = Size of partial block in sectors
     175    inc     ax          ; Add partial block to total block count
     176    SKIP2B  dx          ; Skip mov ah, cl
    188177.NoPartialBlocksToTransfer:
    189     mov     [bp+PIOVARS.wBlocksLeft], ax
    190     mov     [bp+PIOVARS.bSectorsInLastBlock], dh
     178    mov     ah, cl      ; Full block size if no partial blocks to transfer
     179    mov     [bp+PIOVARS.wBlockLeftAndSectorsInLastBlock], ax
    191180
    192181    ; Store block size in WORDs
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r165 r167  
    3939Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
    4040    mov     [bp+IDEPACK.bCommand], ah
    41     mov     ax, [es:si+DAP.wSectorCount]
     41    mov     al, [es:si+DAP.wSectorCount]
    4242    mov     [bp+IDEPACK.bSectorCount], al
    43     mov     [bp+IDEPACK.bSectorCountHighExt], ah    ; Always zero
    4443
    4544    mov     al, [es:si+DAP.qwLBA]       ; LBA byte 0
     
    8483    mov     [bp+IDEPACK.bSectorCount], al
    8584    mov     [bp+IDEPACK.bCommand], ah
    86     mov     BYTE [bp+IDEPACK.bSectorCountHighExt], 0
    8785
    8886    push    bx
     
    127125    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
    128126    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
    129     mov     BYTE [bp+IDEPACK.bSectorCountHighExt], 0
    130127
    131128    ; Drive and Head select byte
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r165 r167  
    4242ALIGN JUMP_ALIGN
    4343.JumpToEbiosFunction:
    44     test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE  ; Full mode?
    45     jz      SHORT Int13h_UnsupportedFunction
    46     test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA       ; LBA supported?
    47     jz      SHORT Int13h_UnsupportedFunction
    48     cmp     ah, 48h                     ; Above last valid function?
     44    test    BYTE [cs:ROMVARS.wFlags], FLG_ROMVARS_FULLMODE
     45    jz      SHORT Int13h_UnsupportedFunction    ; No eINT 13h in lite mode
     46    test    BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
     47    jz      SHORT Int13h_UnsupportedFunction    ; No eINT 13h for CHS drives
     48    cmp     ah, 48h
    4949    ja      SHORT Int13h_UnsupportedFunction
    50     sub     bx, 41h<<1                  ; BX = Offset to EBIOS jump table
     50    sub     bx, 41h<<1                  ; BX = Offset to eINT 13h jump table
    5151    jl      SHORT Int13h_UnsupportedFunction
    5252    jmp     [cs:bx+g_rgwEbiosFunctionJumpTable]
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH25h_HDrvID.asm

    r165 r167  
    2525%ifdef USE_186
    2626    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    27     ; Fall to AH25h_GetDriveInformationToBufferInESSIfromDriveInDL
     27    ; Fall to AH25h_GetDriveInformationToBufferInESSI
    2828%else
    29     call    AH25h_GetDriveInformationToBufferInESSIfromDriveInDL
     29    call    AH25h_GetDriveInformationToBufferInESSI
    3030    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    3131%endif
     
    3333
    3434;--------------------------------------------------------------------
    35 ; AH25h_GetDriveInformationToBufferInESSIfromDriveInDL
     35; AH25h_GetDriveInformationToBufferInESSI
    3636;   Parameters:
    37 ;       DL:     Translated Drive number
    3837;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    3938;       ES:SI:  Ptr to buffer to receive 512-byte drive information
     
    4443;       AL, BX, CX, DX
    4544;--------------------------------------------------------------------
    46 AH25h_GetDriveInformationToBufferInESSIfromDriveInDL:
     45ALIGN JUMP_ALIGN
     46AH25h_GetDriveInformationToBufferInESSI:
    4747    push    es
    4848    push    bp
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r165 r167  
    2828ALIGN JUMP_ALIGN
    2929AH2h_HandlerForReadDiskSectors:
    30     cmp     BYTE [bp+IDEPACK.intpack+INTPACK.al], 0
     30    cmp     al, 0
    3131    jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    3232
    33     xor     bx, bx
    34     call    CommandLookup_OrOldInt13hIndexToBL
     33    call    CommandLookup_GetOldInt13hIndexToBX
    3534    mov     ah, [cs:bx+g_rgbReadCommandLookup]
    3635    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     
    5554    mov     ah, RET_HD_INVALID
    5655    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    57 
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm

    r165 r167  
    2727ALIGN JUMP_ALIGN
    2828AH3h_HandlerForWriteDiskSectors:
    29     cmp     BYTE [bp+IDEPACK.intpack+INTPACK.al], 0
     29    cmp     al, 0
    3030    jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    3131
    32     xor     bx, bx
    33     call    CommandLookup_OrOldInt13hIndexToBL
     32    call    CommandLookup_GetOldInt13hIndexToBX
    3433    mov     ah, [cs:bx+g_rgbWriteCommandLookup]
    3534    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm

    r165 r167  
    2626ALIGN JUMP_ALIGN
    2727AH4h_HandlerForVerifyDiskSectors:
    28     cmp     BYTE [bp+IDEPACK.intpack+INTPACK.al], 0
     28    cmp     al, 0
    2929    jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    3030
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH41h_CheckIfExtensionsPresent.asm

    r165 r167  
    1717;   Returns with INTPACK:
    1818;       AH:     Major version of EBIOS extensions
    19 ;       BX:     55AAh
     19;       BX:     AA55h
    2020;       CX:     Support bits
    2121;       CF:     0 if succesfull, 1 if error
     
    2626    jne     SHORT .EbiosNotSupported
    2727
     28    mov     BYTE [bp+IDEPACK.intpack+INTPACK.ah], EBIOS_VERSION
     29    mov     WORD [bp+IDEPACK.intpack+INTPACK.bx], 0AA55h
    2830    mov     WORD [bp+IDEPACK.intpack+INTPACK.cx], ENHANCED_DRIVE_ACCESS_SUPPORT
    29     mov     ah, EBIOS_VERSION
    3031    and     BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF  ; Return with CF cleared
    3132    jmp     Int13h_ReturnFromHandlerWithoutStoringErrorCode
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm

    r165 r167  
    5555    cmp     BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
    5656    jb      SHORT .DapContentsNotValid
    57     cmp     BYTE [es:si+DAP.bSectorCount], 0
     57    cmp     WORD [es:si+DAP.wSectorCount], BYTE 0
    5858    jle     SHORT .DapContentsNotValid          ; Must be 1...127
    5959    ret
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r165 r167  
    2323ALIGN JUMP_ALIGN
    2424AH48h_HandlerForGetExtendedDriveParameters:
    25     ; Get ATA Drive Information and total sector count from it
     25    ; Get our buffer to ES:SI
     26    push    di
     27    call    FindDPT_ForNewDriveToDSDI
     28    lea     si, [di+LARGEST_DPT_SIZE]   ; IdeCommand.asm required fake DPT
     29    pop     di
    2630    push    ds
    27     pop     es          ; ES now points RAMVARS segment
    28     mov     si, [cs:ROMVARS.bStealSize]
    29     and     si, BYTE 7Fh
    30     eSHL_IM si, 10      ; Kilobytes to bytes
    31     sub     si, 512     ; Subtract buffer size for offset in RAMVARS
    32     call    AH25h_GetDriveInformationToBufferInESSIfromDriveInDL
     31    pop     es
     32
     33    ; Get Drive ID and total sector count from it
     34    call    AH25h_GetDriveInformationToBufferInESSI
     35    jc      SHORT .ReturnWithError
    3336    call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
    34     xchg    cx, ax
     37    xchg    cx, ax      ; Sector count now in BX:DX:CX
    3538
    3639    ; Point ES:DI to Destination buffer
    3740    mov     di, [bp+IDEPACK.intpack+INTPACK.si]
    3841    mov     es, [bp+IDEPACK.intpack+INTPACK.ds]
    39     cmp     WORD [es:di+EDRIVE_INFO.wSize], MINIMUM_EDRIVEINFO_SIZE
     42    mov     ax, MINIMUM_EDRIVEINFO_SIZE
     43    cmp     WORD [es:di+EDRIVE_INFO.wSize], ax
    4044    jb      SHORT .BufferTooSmall
     45    je      SHORT .SkipEddConfigurationParameters
     46
     47    ; We do not support EDD Configuration Parameters so set to FFFF:FFFFh
     48    xor     ax, ax
     49    dec     ax          ; AX = FFFFh
     50    mov     [es:di+EDRIVE_INFO.fpEDDparams], ax
     51    mov     [es:di+EDRIVE_INFO.fpEDDparams+2], ax
     52    mov     ax, EDRIVE_INFO_size
    4153
    4254    ; Fill Extended Drive Information Table in ES:DI
    43     mov     ax, MINIMUM_EDRIVEINFO_SIZE
    44     stosw
     55.SkipEddConfigurationParameters:
     56    stosw               ; Store Extended Drive Information Table size
    4557    mov     al, FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
    4658    stosw
     
    6375.BufferTooSmall:
    6476    mov     ah, RET_HD_INVALID
     77.ReturnWithError:
    6578    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Tools/CommandLookup.asm

    r165 r167  
    77;--------------------------------------------------------------------
    88; CommandLookup_GetEbiosIndexToBX
    9 ; CommandLookup_OrOldInt13hIndexToBL
    109;   Parameters:
    1110;       DS:DI:  Ptr to DPT
     
    1413;       BX:     Index to command lookup table
    1514;   Corrupts registers:
    16 ;       AX
     15;       AX, DX
    1716;--------------------------------------------------------------------
    1817ALIGN JUMP_ALIGN
    1918CommandLookup_GetEbiosIndexToBX:
    2019    ; LBA28 or LBA48 command
    21     xor     bx, bx
    22     mov     ax, [es:si+DAP.qwLBA+3] ; Load LBA48 bytes 3 and 4
    23     and     al, ~0Fh                ; Clear LBA28 bits 24...27
    24     or      al, [es:si+DAP.qwLBA+5]
    25     cmp     bx, ax                  ; Set CF if any of bits 28...47 set
    26     rcl     bx, 1                   ; BX = 0 for LBA28, BX = 1 for LBA48
     20    xor     dx, dx
     21    mov     al, [es:si+DAP.qwLBA+3] ; Load LBA48 byte 3 (bits 24...31)
     22    and     ax, 00F0h               ; Clear LBA28 bits 24...27
     23    or      ax, [es:si+DAP.qwLBA+4] ; Set bits from LBA bytes 4 and 5
     24    cmp     dx, ax                  ; Set CF if any of bits 28...47 set
     25    rcl     dx, 1                   ; DX = 0 for LBA28, DX = 1 for LBA48
     26    call    CommandLookup_GetOldInt13hIndexToBX
     27    or      bx, dx                  ; Set block mode / single sector bit
     28    ret
    2729
     30;--------------------------------------------------------------------
     31; CommandLookup_GetOldInt13hIndexToBX
     32;   Parameters:
     33;       DS:DI:  Ptr to DPT
     34;   Returns:
     35;       BX:     Index to command lookup table
     36;   Corrupts registers:
     37;       Nothing
     38;--------------------------------------------------------------------
     39ALIGN JUMP_ALIGN
     40CommandLookup_GetOldInt13hIndexToBX:
    2841    ; Block mode or single sector
    29 ALIGN JUMP_ALIGN
    30 CommandLookup_OrOldInt13hIndexToBL:
    31     mov     al, FLGH_DPT_BLOCK_MODE_SUPPORTED   ; Bit 1
    32     and     al, [di+DPT.bFlagsHigh]
    33     or      bl, al                  ; BX = index to lookup table
     42    mov     bl, [di+DPT.bFlagsHigh]
     43    and     bx, BYTE FLGH_DPT_BLOCK_MODE_SUPPORTED  ; Bit 1
    3444    ret
    3545
     
    5262    db      COMMAND_VERIFY_SECTORS
    5363    db      COMMAND_VERIFY_SECTORS_EXT     
    54 
Note: See TracChangeset for help on using the changeset viewer.