Changeset 218 in xtideuniversalbios


Ignore:
Timestamp:
Jan 23, 2012, 9:10:05 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Number of sectors to transfer is now limited to 1-128 for old INT 13h functions.
Location:
trunk/XTIDE_Universal_BIOS
Files:
1 added
11 edited

Legend:

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

    r170 r218  
    4141    .bSize                  resb    1   ; 0, Size of this packet in bytes
    4242    .bReservedAt1           resb    1   ; 1, Currently unused, must be zero
    43     .wSectorCount           resb    2   ; 2, Number of sectors to process (1...127)
     43    .bSectorCount           resb    1   ; 2, Number of sectors to process (0...127)
     44    .bReservedAt3           resb    1   ; 3, Currently unused, must be zero
    4445    .dwMemoryAddress:
    4546    .wOffset                resb    2   ; 4, Memory offset for transfer
  • trunk/XTIDE_Universal_BIOS/Inc/Int13h.inc

    r150 r218  
    4545
    4646
    47 MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS     EQU     64
    48 
    4947%define TIMEOUT_AND_STATUS_TO_WAIT(timeout, status)     (((timeout)<<8) | (status))
    5048
  • trunk/XTIDE_Universal_BIOS/Inc/RamVars.inc

    r203 r218  
    6161    .bCommand               resb    1
    6262    .bDeviceControl         resb    1   ; Offset 7 shared with PIOVARS
     63                            resb    1
    6364
    6465    ; Parameters for 48-bit LBA
    65     .wSectorCountHighAndLbaLowExt:
    66     .bSectorCountHighExt    resb    1
    6766    .bLbaLowExt             resb    1   ; LBA48 31...24
    68 
    6967    .wLbaMiddleAndHighExt:
    7068    .bLbaMiddleExt          resb    1   ; LBA48 39...32
  • trunk/XTIDE_Universal_BIOS/Src/Device/Device.asm

    r181 r218  
    5454;       BH:     Drive Select byte for Drive and Head Select Register
    5555;       DS:     Segment to RAMVARS
    56 ;       ES:SI:  Ptr to buffer to receive 512-byte IDE Information
     56;       ES:SI:  Ptr to normalized buffer to receive 512-byte IDE Information
    5757;       CS:BP:  Ptr to IDEVARS
    5858;   Returns:
     
    8080;       BH:     Default system timer ticks for timeout (can be ignored)
    8181;       BL:     IDE Status Register bit to poll after command
    82 ;       ES:SI:  Ptr to buffer (for data transfer commands)
     82;       ES:SI:  Ptr to normalized buffer (for data transfer commands)
    8383;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    8484;       SS:BP:  Ptr to IDEPACK
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r169 r218  
    128128
    129129    ; Output Sector Address High (only used by LBA48)
    130     mov     ax, [bp+IDEPACK.wSectorCountHighAndLbaLowExt]
     130    eMOVZX  ax, BYTE [bp+IDEPACK.bLbaLowExt]
    131131    mov     cx, [bp+IDEPACK.wLbaMiddleAndHighExt]
    132132    call    OutputSectorCountAndAddress
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r181 r218  
    55; This struct must not be larger than IDEPACK without INTPACK.
    66struc PIOVARS
    7     .wBlocksLeft            resb    2
    8     .wBlockSize             resb    2   ; Block size in WORDs (256...32768)
    9     .wDataPort              resb    2
    10     .bSectorsInLastBlock:   resb    1
    11                             resb    1   ; Offset 7 = IDEPACK.bDeviceControl
    12     .fnXfer                 resb    2   ; Offset to transfer function
     7    .wWordsInBlock          resb    2   ; 0, Block size in WORDs
     8    .wWordsLeft             resb    2   ; 2, WORDs left to transfer
     9    .wWordsDone             resb    2   ; 4, Number of sectors xferred
     10                            resb    1   ; 6,
     11                            resb    1   ; 7, IDEPACK.bDeviceControl
     12    .wDataPort              resb    2   ; 8, IDE Data Port
     13    .fnXfer                 resb    2   ; 10, Offset to transfer function
    1314endstruc
    1415
     
    2223;       AL:     IDE command that was used to start the transfer
    2324;               (all PIO read and write commands including Identify Device)
    24 ;       ES:SI:  Ptr to destination buffer or source data
     25;       ES:SI:  Ptr to normalized data buffer
    2526;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    2627;       SS:BP:  Ptr to IDEPACK
    2728;   Returns:
    2829;       AH:     INT 13h Error Code
     30;       CX:     Number of successfully transferred sectors
    2931;       CF:     Cleared if success, Set if error
    3032;   Corrupts registers:
    31 ;       AL, BX, CX, DX, SI, ES
     33;       AL, BX, DX, SI, ES
    3234;--------------------------------------------------------------------
    3335ALIGN JUMP_ALIGN
    3436IdeTransfer_StartWithCommandInAL:
    35     mov     ah, [bp+IDEPACK.bSectorCountHighExt]
     37    mov     ah, [bp+IDEPACK.bSectorCount]
    3638
    3739    ; Are we reading or writing?
     
    4345    ; Prepare to read data to ESSI
    4446    mov     bx, g_rgfnPioRead
    45     mov     al, [bp+IDEPACK.bSectorCount]
    46     call    InitializePiovarsInSSBPwithSectorCountInAX
     47    call    InitializePiovarsInSSBPwithSectorCountInAH
    4748    xchg    si, di
    48     call    Registers_NormalizeESDI
    4949    jmp     SHORT ReadFromDrive
    5050
     
    5252.PrepareToWriteDataFromESSI:
    5353    mov     bx, g_rgfnPioWrite
    54     mov     al, [bp+IDEPACK.bSectorCount]
    55     call    InitializePiovarsInSSBPwithSectorCountInAX
    56     call    Registers_NormalizeESSI
     54    call    InitializePiovarsInSSBPwithSectorCountInAH
    5755    ; Fall to WriteToDrive
    5856
     
    6664;   Returns:
    6765;       AH:     BIOS Error code
     66;       CX:     Number of successfully transferred sectors
    6867;       CF:     0 if transfer succesfull
    6968;               1 if any error
    7069;   Corrupts registers:
    71 ;       AL, BX, CX, DX, SI, ES
     70;       AL, BX, DX, SI, ES
    7271;--------------------------------------------------------------------
    7372WriteToDrive:
     
    7574    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
    7675    call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
    77     jc      SHORT .ReturnWithTransferErrorInAH
    78 ALIGN JUMP_ALIGN
    79 .WriteNextBlock:
     76    jc      SHORT ReturnWithTransferErrorInAH
     77
     78ALIGN JUMP_ALIGN
     79.WriteNextBlockToDrive:
     80    mov     cx, [bp+PIOVARS.wWordsInBlock]
    8081    mov     dx, [bp+PIOVARS.wDataPort]
    81     dec     WORD [bp+PIOVARS.wBlocksLeft]       ; Transferring last (possibly partial) block?
    82     jz      SHORT .XferLastBlock                ;  If so, jump to transfer
    83     mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
    84     call    [bp+PIOVARS.fnXfer]                 ; Transfer full block
    85 
    86     ; Normalize pointer when necessary
    87     mov     ax, si
    88     shr     ax, 1                               ; WORD offset
    89     add     ax, [bp+PIOVARS.wBlockSize]
    90     jns     SHORT .WaitUntilReadyToTransferNextBlock
    91     call    Registers_NormalizeESSI
    92 
    93 ALIGN JUMP_ALIGN
    94 .WaitUntilReadyToTransferNextBlock:
    95 %ifdef USE_186
    96     push    .WriteNextBlock
    97     jmp     IdeWait_IRQorDRQ
    98 %else
    99     call    IdeWait_IRQorDRQ
    100     jnc     SHORT .WriteNextBlock
    101 %endif
    102 .ReturnWithTransferErrorInAH:
    103     ret
    104 
    105 ALIGN JUMP_ALIGN
    106 .XferLastBlock:
    107     xor     cx, cx
     82    cmp     [bp+PIOVARS.wWordsLeft], cx
     83    jbe     SHORT .WriteLastBlockToDrive
     84    call    [bp+PIOVARS.fnXfer]
     85
     86    ; Wait until ready for next block and check for errors
     87    call    IdeWait_IRQorDRQ                    ; Wait until ready to transfer
     88    jc      SHORT ReturnWithTransferErrorInAH
     89
     90    ; Increment number of successfully written WORDs
     91    mov     ax, [bp+PIOVARS.wWordsInBlock]
     92    sub     [bp+PIOVARS.wWordsLeft], ax
     93    add     [bp+PIOVARS.wWordsDone], ax
     94    jmp     SHORT .WriteNextBlockToDrive
     95
     96ALIGN JUMP_ALIGN
     97.WriteLastBlockToDrive:
     98    mov     cx, [bp+PIOVARS.wWordsLeft]
     99    call    [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
     100
     101    ; Check for errors in last block
    108102    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
    109     mov     ch, [bp+PIOVARS.bSectorsInLastBlock]; CX = Partial block size in WORDs
    110 %ifdef USE_186
    111     push    IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
    112     jmp     [bp+PIOVARS.fnXfer]
    113 %else
    114     call    [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
    115     jmp     IdeWait_IRQorStatusFlagInBLwithTimeoutInBH  ; Check for errors
    116 %endif
     103    call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
     104    jmp     SHORT ReturnWithTransferErrorInAH
    117105
    118106
     
    126114;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    127115;       AH:     BIOS Error code
     116;       CX:     Number of successfully transferred sectors
    128117;       CF:     0 if transfer succesfull
    129118;               1 if any error
    130119;   Corrupts registers:
    131 ;       AL, BX, CX, DX, SI, ES
     120;       AL, BX, DX, SI, ES
    132121;--------------------------------------------------------------------
    133122ALIGN JUMP_ALIGN
     
    136125    xchg    di, si                              ; DS:DI now points DPT
    137126    call    IdeWait_IRQorDRQ                    ; Wait until ready to transfer
    138     jc      SHORT WriteToDrive.ReturnWithTransferErrorInAH
     127    jc      SHORT ReturnWithTransferErrorInAH
    139128    xchg    si, di                              ; ES:DI now points buffer
    140129
    141     ; Transfer full or last (possible partial) block
     130ALIGN JUMP_ALIGN
     131.ReadNextBlockFromDrive:
     132    mov     cx, [bp+PIOVARS.wWordsInBlock]
    142133    mov     dx, [bp+PIOVARS.wDataPort]
    143     dec     WORD [bp+PIOVARS.wBlocksLeft]
    144     jz      SHORT .XferLastBlock
    145     mov     cx, [bp+PIOVARS.wBlockSize]         ; Load block size in WORDs
    146     call    [bp+PIOVARS.fnXfer]                 ; Transfer full block
    147 
    148     ; Normalize pointer when necessary
    149     mov     ax, di
    150     shr     ax, 1                               ; WORD offset
    151     add     ax, [bp+PIOVARS.wBlockSize]
    152     jns     SHORT ReadFromDrive
    153 %ifdef USE_186
    154     push    ReadFromDrive
    155     jmp     Registers_NormalizeESDI
    156 %else
    157     call    Registers_NormalizeESDI
    158     jmp     SHORT ReadFromDrive                 ; Loop while blocks left
    159 %endif
    160 
    161 
    162 ALIGN JUMP_ALIGN
    163 .XferLastBlock:
    164     xor     cx, cx
    165     mov     ch, [bp+PIOVARS.bSectorsInLastBlock]; CX = Partial block size in WORDs
     134    cmp     [bp+PIOVARS.wWordsLeft], cx
     135    jbe     SHORT .ReadLastBlockFromDrive
     136    call    [bp+PIOVARS.fnXfer]
     137
     138    ; Wait until ready for next block and check for errors
     139    xchg    di, si                              ; DS:DI now points DPT
     140    call    IdeWait_IRQorDRQ                    ; Wait until ready to transfer
     141    jc      SHORT ReturnWithTransferErrorInAH
     142    xchg    si, di                              ; ES:DI now points buffer
     143
     144    ; Increment number of successfully read WORDs
     145    mov     ax, [bp+PIOVARS.wWordsInBlock]
     146    sub     [bp+PIOVARS.wWordsLeft], ax
     147    add     [bp+PIOVARS.wWordsDone], ax
     148    jmp     SHORT .ReadNextBlockFromDrive
     149
     150ALIGN JUMP_ALIGN
     151.ReadLastBlockFromDrive:
     152    mov     cx, [bp+PIOVARS.wWordsLeft]
    166153    call    [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
     154
     155    ; Check for errors in last block
    167156    mov     di, si                              ; DS:DI now points DPT
    168157    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
    169     jmp     IdeWait_PollStatusFlagInBLwithTimeoutInBH
    170 
    171 
    172 ;--------------------------------------------------------------------
    173 ; InitializePiovarsInSSBPwithSectorCountInAX
    174 ;   Parameters:
    175 ;       AX:     Number of sectors to transfer (1...65535)
     158    call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
     159
     160    ; Return number of successfully read sectors
     161ReturnWithTransferErrorInAH:
     162    mov     cx, [bp+PIOVARS.wWordsDone]
     163    jc      SHORT .ConvertTransferredWordsInCXtoSectors
     164    add     cx, [bp+PIOVARS.wWordsLeft]         ; Never sets CF
     165.ConvertTransferredWordsInCXtoSectors:
     166    xchg    cl, ch
     167    ret
     168
     169
     170;--------------------------------------------------------------------
     171; InitializePiovarsInSSBPwithSectorCountInAH
     172;   Parameters:
     173;       AH:     Number of sectors to transfer (1...128)
    176174;       BX:     Offset to transfer function lookup table
    177175;       DS:DI:  Ptr to DPT (in RAMVARS segment)
     
    183181;--------------------------------------------------------------------
    184182ALIGN JUMP_ALIGN
    185 InitializePiovarsInSSBPwithSectorCountInAX:
    186     ; Store number of blocks to transfer
    187     eMOVZX  cx, BYTE [di+DPT_ATA.bSetBlock]     ; Block size in sectors
    188     xor     dx, dx      ; DX:AX = Sectors to transfer (1...65535)
    189     div     cx          ; AX = Full blocks to transfer
    190     test    dx, dx
    191     mov     dh, cl      ; DH = Full block size if no partial blocks to transfer
    192     jz      SHORT .NoPartialBlocksToTransfer
    193     inc     ax          ; Partial block
    194     mov     dh, dl      ; DH = Size of partial block in sectors
    195 .NoPartialBlocksToTransfer:
    196     mov     [bp+PIOVARS.wBlocksLeft], ax
    197     mov     [bp+PIOVARS.bSectorsInLastBlock], dh
    198 
    199     ; Store block size in WORDs
    200     xchg    ch, cl      ; CX = Block size in WORDs
    201     mov     [bp+PIOVARS.wBlockSize], cx
     183InitializePiovarsInSSBPwithSectorCountInAH:
     184    ; Store sizes
     185    xor     al, al
     186    mov     [bp+PIOVARS.wWordsLeft], ax
     187    cbw
     188    mov     [bp+PIOVARS.wWordsDone], ax         ; Zero
     189    mov     ah, [di+DPT_ATA.bSetBlock]
     190    mov     [bp+PIOVARS.wWordsInBlock], ax
    202191
    203192    ; Get transfer function based on bus type
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r181 r218  
    4040Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
    4141    mov     [bp+IDEPACK.bCommand], ah
    42     mov     ax, [es:si+DAP.wSectorCount]
     42    mov     al, [es:si+DAP.bSectorCount]
    4343    mov     [bp+IDEPACK.bSectorCount], al
    44     mov     [bp+IDEPACK.bSectorCountHighExt], ah
    4544
    4645    mov     al, [es:si+DAP.qwLBA]       ; LBA byte 0
     
    6665;   Parameters:
    6766;       AH:     IDE command to issue
    68 ;       AL:     Number of sectors to transfer (1...255, 0=256)
     67;       AL:     Number of sectors to transfer
    6968;       BH:     Timeout ticks
    7069;       BL:     IDE Status Register flag to wait after command
     
    7372;               Bits 5...0: Starting sector number (1...63)
    7473;       DH:     Starting head number (0...255)
    75 ;       ES:SI:  Ptr to data buffer
    7674;       DS:DI:  Ptr to DPT (in RAMVARS segment)
    77 ;       SS:BP:  Ptr to IDEPACK
     75;       SS:BP:  Ptr to IDEPACK (containing INTPACK)
     76;   Parameters on INTPACK:
     77;       ES:BX:  Ptr to data buffer
    7878;   Returns:
    7979;       AH:     INT 13h Error Code
     
    8484ALIGN JUMP_ALIGN
    8585Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
     86    mov     [bp+IDEPACK.bSectorCount], al
    8687    mov     [bp+IDEPACK.bCommand], ah
    8788
    88     xor     ah, ah
    89     cmp     ah, al
    90     cmc
    91     adc     ah, ah
    92 
    93     mov     [bp+IDEPACK.bSectorCount], al
    94     mov     [bp+IDEPACK.bSectorCountHighExt], ah
    95 
    9689    push    bx
     90    call    PrepareBuffer_ToESSIforOldInt13hTransfer
    9791    call    Address_OldInt13hAddressToIdeAddress
    9892    call    AccessDPT_GetDriveSelectByteToAL
     
    135129    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
    136130    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
    137     mov     BYTE [bp+IDEPACK.bSectorCountHighExt], 0
    138131
    139132    ; Drive and Head select byte
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH24h_HSetBlocks.asm

    r181 r218  
    5353;ALIGN JUMP_ALIGN
    5454AH24h_SetBlockSize:
    55     MIN_U   al, MAX_SUPPORTED_BLOCK_SIZE_IN_SECTORS
    5655    push    ax
    5756    xchg    dx, ax          ; DL = Block size (Sector Count Register)
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r169 r218  
    3131    mov     ah, [cs:bx+g_rgbReadCommandLookup]
    3232    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
    33     mov     si, [bp+IDEPACK.intpack+INTPACK.bx]
    3433%ifdef USE_186
    3534    push    Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm

    r169 r218  
    5555    cmp     BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
    5656    jb      SHORT AH42h_ReturnWithInvalidFunctionError
    57     cmp     WORD [es:si+DAP.wSectorCount], BYTE 0
     57    cmp     WORD [es:si+DAP.bSectorCount], BYTE 0
    5858    je      SHORT AH42h_ReturnWithInvalidFunctionError
    5959    ret
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r199 r218  
    210210    %include "Address.asm"          ; For sector address translations
    211211    %include "CommandLookup.asm"    ; For getting correct transfer command
     212    %include "PrepareBuffer.asm"    ; For buffer pointer normalization
    212213    %include "Int13h.asm"           ; For Int 13h, Disk functions
    213214    %include "AH0h_HReset.asm"      ; Required by Int13h_Jump.asm
Note: See TracChangeset for help on using the changeset viewer.