Changeset 169 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Device/IDE


Ignore:
Timestamp:
Aug 21, 2011, 4:39:58 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Old Int 13h functions can now transfer 256 sectors per call.
  • eINT 13h functions can now transfer 65535 sectors per call.
Location:
trunk/XTIDE_Universal_BIOS/Src/Device/IDE
Files:
2 edited

Legend:

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

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

    r167 r169  
    55; This struct must not be larger than IDEPACK without INTPACK.
    66struc PIOVARS
    7     .wBlockLeftAndSectorsInLastBlock:
    8     .bBlocksLeft            resb    1
    9     .bSectorsInLastBlock:   resb    1
     7    .wBlocksLeft            resb    2
    108    .wBlockSize             resb    2   ; Block size in WORDs (256...32768)
    119    .wDataPort              resb    2
    12                             resb    1
     10    .bSectorsInLastBlock:   resb    1
    1311                            resb    1   ; Offset 7 = IDEPACK.bDeviceControl
    1412    .fnXfer                 resb    2   ; Offset to transfer function
     
    3432ALIGN JUMP_ALIGN
    3533IdeTransfer_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     call    InitializePiovarsToSSBPfromIdepackInSSBP
     44    mov     al, [bp+IDEPACK.bSectorCount]
     45    call    InitializePiovarsInSSBPwithSectorCountInAX
    4546    xchg    si, di
    46 %ifdef USE_186
    47     push    ReadFromDriveToESDI
    48     jmp     Registers_NormalizeESDI
    49 %else
    5047    call    Registers_NormalizeESDI
    51     jmp     SHORT ReadFromDriveToESDI
    52 %endif
     48    jmp     SHORT ReadFromDrive
    5349
    5450ALIGN JUMP_ALIGN
    5551.PrepareToWriteDataFromESSI:
    5652    mov     bx, g_rgfnPioWrite
    57     call    InitializePiovarsToSSBPfromIdepackInSSBP
     53    mov     al, [bp+IDEPACK.bSectorCount]
     54    call    InitializePiovarsInSSBPwithSectorCountInAX
    5855    call    Registers_NormalizeESSI
    59     ; Fall to WriteToDriveFromESSI
    60 
    61 
    62 ;--------------------------------------------------------------------
    63 ; WriteToDriveFromESSI
     56    ; Fall to WriteToDrive
     57
     58
     59;--------------------------------------------------------------------
     60; WriteToDrive
    6461;   Parameters:
    6562;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     
    7370;       AL, BX, CX, DX, SI, ES
    7471;--------------------------------------------------------------------
    75 WriteToDriveFromESSI:
     72WriteToDrive:
    7673    ; Always poll when writing first block (IRQs are generated for following blocks)
    7774    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     
    8178.WriteNextBlock:
    8279    mov     dx, [bp+PIOVARS.wDataPort]
    83     dec     BYTE [bp+PIOVARS.bBlocksLeft]       ; Transferring last (possibly partial) block?
     80    dec     WORD [bp+PIOVARS.wBlocksLeft]       ; Transferring last (possibly partial) block?
    8481    jz      SHORT .XferLastBlock                ;  If so, jump to transfer
    8582    mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
    8683    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
     92ALIGN JUMP_ALIGN
     93.WaitUntilReadyToTransferNextBlock:
    8794%ifdef USE_186
    8895    push    .WriteNextBlock
     
    110117
    111118;--------------------------------------------------------------------
    112 ; ReadFromDriveToESDI
     119; ReadFromDrive
    113120;   Parameters:
    114121;       ES:DI:  Normalized ptr to buffer to recieve data
     
    124131;--------------------------------------------------------------------
    125132ALIGN JUMP_ALIGN
    126 ReadFromDriveToESDI:
     133ReadFromDrive:
    127134    ; Wait until drive is ready to transfer
    128135    xchg    di, si                              ; DS:DI now points DPT
    129136    call    IdeWait_IRQorDRQ                    ; Wait until ready to transfer
    130     jc      SHORT WriteToDriveFromESSI.ReturnWithTransferErrorInAH
     137    jc      SHORT WriteToDrive.ReturnWithTransferErrorInAH
    131138    xchg    si, di                              ; ES:DI now points buffer
    132139
    133140    ; Transfer full or last (possible partial) block
    134141    mov     dx, [bp+PIOVARS.wDataPort]
    135     dec     BYTE [bp+PIOVARS.bBlocksLeft]
     142    dec     WORD [bp+PIOVARS.wBlocksLeft]
    136143    jz      SHORT .XferLastBlock
    137144    mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
    138 %ifdef USE_186
    139     push    ReadFromDriveToESDI
    140     jmp     [bp+PIOVARS.fnXfer]
    141 %else
    142145    call    [bp+PIOVARS.fnXfer]                 ; Transfer full block
    143     jmp     SHORT ReadFromDriveToESDI                   ; Loop while blocks left
    144 %endif
     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%ifdef USE_186
     153    push    ReadFromDrive
     154    jmp     Registers_NormalizeESDI
     155%else
     156    call    Registers_NormalizeESDI
     157    jmp     SHORT ReadFromDrive                 ; Loop while blocks left
     158%endif
     159
    145160
    146161ALIGN JUMP_ALIGN
     
    155170
    156171;--------------------------------------------------------------------
    157 ; InitializePiovarsToSSBPfromIdepackInSSBP
    158 ;   Parameters:
     172; InitializePiovarsInSSBPwithSectorCountInAX
     173;   Parameters:
     174;       AX:     Number of sectors to transfer (1...65535)
    159175;       BX:     Offset to transfer function lookup table
    160176;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    161 ;       SS:BP:  Ptr to IDEPACK
    162 ;   Returns:
    163177;       SS:BP:  Ptr to PIOVARS
     178;   Returns:
     179;       Nothing
    164180;   Corrupts registers:
    165181;       AX, BX, CX, DX
    166182;--------------------------------------------------------------------
    167183ALIGN JUMP_ALIGN
    168 InitializePiovarsToSSBPfromIdepackInSSBP:
     184InitializePiovarsInSSBPwithSectorCountInAX:
    169185    ; Store number of 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
     186    eMOVZX  cx, BYTE [di+DPT_ATA.bSetBlock]     ; Block size in sectors
     187    xor     dx, dx      ; DX:AX = Sectors to transfer (1...65535)
     188    div     cx          ; AX = Full blocks to transfer
     189    test    dx, dx
     190    mov     dh, cl      ; DH = Full block size if no partial blocks to transfer
    174191    jz      SHORT .NoPartialBlocksToTransfer
    175     inc     ax          ; Add partial block to total block count
    176     SKIP2B  dx          ; Skip mov ah, cl
     192    inc     ax          ; Partial block
     193    mov     dh, dl      ; DH = Size of partial block in sectors
    177194.NoPartialBlocksToTransfer:
    178     mov     ah, cl      ; Full block size if no partial blocks to transfer
    179     mov     [bp+PIOVARS.wBlockLeftAndSectorsInLastBlock], ax
     195    mov     [bp+PIOVARS.wBlocksLeft], ax
     196    mov     [bp+PIOVARS.bSectorsInLastBlock], dh
    180197
    181198    ; Store block size in WORDs
Note: See TracChangeset for help on using the changeset viewer.