Changeset 169 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src


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
Files:
12 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
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r167 r169  
    3939Idepack_ConvertDapToIdepackAndIssueCommandFromAH:
    4040    mov     [bp+IDEPACK.bCommand], ah
    41     mov     al, [es:si+DAP.wSectorCount]
     41    mov     ax, [es:si+DAP.wSectorCount]
    4242    mov     [bp+IDEPACK.bSectorCount], al
     43    mov     [bp+IDEPACK.bSectorCountHighExt], ah
    4344
    4445    mov     al, [es:si+DAP.qwLBA]       ; LBA byte 0
     
    8182ALIGN JUMP_ALIGN
    8283Idepack_TranslateOldInt13hAddressAndIssueCommandFromAH:
     84    mov     [bp+IDEPACK.bCommand], ah
     85    test    al, al
     86    eCSETZ  ah
    8387    mov     [bp+IDEPACK.bSectorCount], al
    84     mov     [bp+IDEPACK.bCommand], ah
     88    mov     [bp+IDEPACK.bSectorCountHighExt], ah
    8589
    8690    push    bx
     
    125129    mov     [bp+IDEPACK.wSectorCountAndLbaLow], dx
    126130    mov     [bp+IDEPACK.wLbaMiddleAndHigh], cx
     131    mov     BYTE [bp+IDEPACK.bSectorCountHighExt], 0
    127132
    128133    ; Drive and Head select byte
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r167 r169  
    1515;       SS:BP:  Ptr to IDEPACK
    1616;   Parameters on INTPACK:
    17 ;       AL:     Number of sectors to read (1...127)
     17;       AL:     Number of sectors to read (1...255, 0=256)
    1818;       CH:     Cylinder number, bits 7...0
    1919;       CL:     Bits 7...6: Cylinder number bits 9 and 8
     
    2828ALIGN JUMP_ALIGN
    2929AH2h_HandlerForReadDiskSectors:
    30     cmp     al, 0
    31     jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    32 
    3330    call    CommandLookup_GetOldInt13hIndexToBX
    3431    mov     ah, [cs:bx+g_rgbReadCommandLookup]
     
    4239    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4340%endif
    44 
    45 
    46 ;--------------------------------------------------------------------
    47 ; AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    48 ;   Parameters:
    49 ;       Nothing
    50 ;   Returns:
    51 ;       Jumps to Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    52 ;--------------------------------------------------------------------
    53 AH2h_ExitInt13hSinceSectorCountInIntpackIsZero:
    54     mov     ah, RET_HD_INVALID
    55     jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm

    r167 r169  
    1515;       SS:BP:  Ptr to IDEREGS_AND_INTPACK
    1616;   Parameters on INTPACK:
    17 ;       AL:     Number of sectors to write (1...127)
     17;       AL:     Number of sectors to write (1...255, 0=256)
    1818;       CH:     Cylinder number, bits 7...0
    1919;       CL:     Bits 7...6: Cylinder number bits 9 and 8
     
    2727ALIGN JUMP_ALIGN
    2828AH3h_HandlerForWriteDiskSectors:
    29     cmp     al, 0
    30     jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    31 
    3229    call    CommandLookup_GetOldInt13hIndexToBX
    3330    mov     ah, [cs:bx+g_rgbWriteCommandLookup]
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm

    r167 r169  
    1515;       SS:BP:  Ptr to INTPACK
    1616;   Parameters on INTPACK in SS:BP:
    17 ;       AL:     Number of sectors to verify (1...127)
     17;       AL:     Number of sectors to verify (1...255, 0=256)
    1818;       CH:     Cylinder number, bits 7...0
    1919;       CL:     Bits 7...6: Cylinder number bits 9 and 8
     
    2626ALIGN JUMP_ALIGN
    2727AH4h_HandlerForVerifyDiskSectors:
    28     cmp     al, 0
    29     jle     SHORT AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
    30 
    3128    mov     ah, COMMAND_VERIFY_SECTORS
    3229    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH42h_ExtendedReadSectors.asm

    r167 r169  
    5454    mov     es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet
    5555    cmp     BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
    56     jb      SHORT .DapContentsNotValid
     56    jb      SHORT AH42h_ReturnWithInvalidFunctionError
    5757    cmp     WORD [es:si+DAP.wSectorCount], BYTE 0
    58     jle     SHORT .DapContentsNotValid          ; Must be 1...127
     58    je      SHORT AH42h_ReturnWithInvalidFunctionError
    5959    ret
    60 .DapContentsNotValid:
    61     jmp     AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
     60AH42h_ReturnWithInvalidFunctionError:
     61    mov     ah, RET_HD_INVALID
     62    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH43h_ExtendedWriteSectors.asm

    r165 r169  
    2727AH43h_HandlerForExtendedWriteSectors:
    2828    cmp     BYTE [bp+IDEPACK.intpack+INTPACK.al], 2 ; Verify requested?
    29     jae     SHORT .WriteWithVerifyNotSupported
     29    jae     SHORT AH42h_ReturnWithInvalidFunctionError
    3030
    3131    call    AH42h_LoadDapToESSIandVerifyForTransfer
     
    4040    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4141%endif
    42 
    43 .WriteWithVerifyNotSupported:
    44     jmp     AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH47h_ExtendedSeek.asm

    r165 r169  
    2525    mov     es, [bp+IDEPACK.intpack+INTPACK.ds] ; ES:SI to point Disk Address Packet
    2626    cmp     BYTE [es:si+DAP.bSize], MINIMUM_DAP_SIZE
    27     jb      SHORT .DapContentsNotValid
     27    jb      SHORT AH42h_ReturnWithInvalidFunctionError
    2828
    2929    mov     ah, COMMAND_SEEK
     
    3636    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    3737%endif
    38 
    39 .DapContentsNotValid:
    40     jmp     AH2h_ExitInt13hSinceSectorCountInIntpackIsZero
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/EBIOS/AH48h_GetExtendedDriveParameters.asm

    r167 r169  
    3434    call    AH25h_GetDriveInformationToBufferInESSI
    3535    jc      SHORT .ReturnWithError
    36     call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
    37     xchg    cx, ax      ; Sector count now in BX:DX:CX
    3836
    39     ; Point ES:DI to Destination buffer
     37    ; Point DS:DI to Destination buffer
    4038    mov     di, [bp+IDEPACK.intpack+INTPACK.si]
    41     mov     es, [bp+IDEPACK.intpack+INTPACK.ds]
     39    mov     ds, [bp+IDEPACK.intpack+INTPACK.ds]
    4240    mov     ax, MINIMUM_EDRIVEINFO_SIZE
    43     cmp     WORD [es:di+EDRIVE_INFO.wSize], ax
    44     jb      SHORT .BufferTooSmall
     41    cmp     WORD [di+EDRIVE_INFO.wSize], ax
     42    jb      SHORT AH42h_ReturnWithInvalidFunctionError
    4543    je      SHORT .SkipEddConfigurationParameters
    4644
     
    4846    xor     ax, ax
    4947    dec     ax          ; AX = FFFFh
    50     mov     [es:di+EDRIVE_INFO.fpEDDparams], ax
    51     mov     [es:di+EDRIVE_INFO.fpEDDparams+2], ax
     48    mov     [di+EDRIVE_INFO.fpEDDparams], ax
     49    mov     [di+EDRIVE_INFO.fpEDDparams+2], ax
    5250    mov     ax, EDRIVE_INFO_size
    5351
    54     ; Fill Extended Drive Information Table in ES:DI
     52    ; Fill Extended Drive Information Table in DS:DI
    5553.SkipEddConfigurationParameters:
    56     stosw               ; Store Extended Drive Information Table size
    57     mov     al, FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS
    58     stosw
    59     add     di, BYTE 12 ; Skip CHS parameters
    60     xchg    ax, cx
    61     stosw               ; LBA WORD 0
    62     xchg    ax, dx
    63     stosw               ; LBA WORD 1
    64     xchg    ax, bx
    65     stosw               ; LBA WORD 2
    66     xor     ax, ax
    67     stosw               ; LBA WORD 3 always zero since 48-bit address
    68     mov     ah, 512>>8
    69     stosw               ; Always 512-byte sectors
     54    mov     [di+EDRIVE_INFO.wSize], ax
     55    mov     WORD [di+EDRIVE_INFO.wFlags], FLG_DMA_BOUNDARY_ERRORS_HANDLED_BY_BIOS | FLG_CHS_INFORMATION_IS_VALID
     56
     57    call    AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
     58    xor     cx, cx
     59    mov     [di+EDRIVE_INFO.dwCylinders], ax
     60    mov     [di+EDRIVE_INFO.dwCylinders+2], cx
     61    eMOVZX  ax, bl
     62    mov     [di+EDRIVE_INFO.dwHeads], ax
     63    mov     [di+EDRIVE_INFO.dwHeads+2], cx
     64    mov     al, bh
     65    mov     [di+EDRIVE_INFO.dwSectorsPerTrack], ax
     66    mov     [di+EDRIVE_INFO.dwSectorsPerTrack+2], cx
     67
     68    call    AtaID_GetTotalSectorCountToBXDXAXfromAtaInfoInESSI
     69    mov     [di+EDRIVE_INFO.qwTotalSectors], ax
     70    mov     [di+EDRIVE_INFO.qwTotalSectors+2], dx
     71    mov     [di+EDRIVE_INFO.qwTotalSectors+4], bx
     72    mov     [di+EDRIVE_INFO.qwTotalSectors+6], cx
     73
     74    mov     WORD [di+EDRIVE_INFO.wSectorSize], 512
    7075
    7176    ; Return with success
    7277    xor     ah, ah
    73     jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    74 
    75 .BufferTooSmall:
    76     mov     ah, RET_HD_INVALID
    7778.ReturnWithError:
    7879    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/AtaID.asm

    r165 r169  
    77
    88;--------------------------------------------------------------------
    9 ; AtaID_GetPCHS
     9; AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
    1010;   Parameters:
    1111;       ES:SI:  Ptr to 512-byte ATA information read from the drive
     
    1717;       Nothing
    1818;--------------------------------------------------------------------
    19 AtaID_GetPCHS:
     19AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI:
    2020    mov     ax, [es:si+ATA1.wCylCnt]    ; Cylinders (1...16383)
    2121    mov     bl, [es:si+ATA1.wHeadCnt]   ; Heads (1...16)
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/CreateDPT.asm

    r162 r169  
    8383    call    AccessDPT_TestIdeVarsFlagsForMasterOrSlaveDrive
    8484    jnz     SHORT .GetUserSpecifiedPCHS
    85     call    AtaID_GetPCHS               ; Get from ATA information
     85    call    AtaID_GetPCHStoAXBLBHfromAtaInfoInESSI
    8686    jmp     SHORT .StorePCHStoDPT
    8787
Note: See TracChangeset for help on using the changeset viewer.