Changeset 155 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS


Ignore:
Timestamp:
May 1, 2011, 6:44:29 PM (14 years ago)
Author:
Tomi Tilli
google:author:
aitotat
Message:

Changes to XTIDE Universal BIOS:

  • AH=4h again uses VERIFY command (copy-pasting had changed it to WRITE).
  • Timeout should now work on all overflow situations.
  • Cleaned code a bit.
Location:
trunk/XTIDE_Universal_BIOS
Files:
14 edited
2 copied

Legend:

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

    r152 r155  
    2121struc RAMVARS
    2222    .fpOldI13h          resb    4   ; Far pointer to old INT 13h handler
    23     .wTimeoutCounter    resb    2
    2423    .wSignature         resb    2   ; Sign for finding stolen 1 kiB
     24    .bTimeoutTicksLeft  resb    1
     25    .bLastTimeoutUpdate resb    1
    2526
    2627    .wDrvCntAndFirst:
     
    6465endstruc
    6566
    66 EXTRA_WORDS_TO_RESERVE_FOR_INTPACK  EQU ((IDEPACK_size - INTPACK_size) / 2)
     67EXTRA_BYTES_FOR_INTPACK     EQU (IDEPACK_size - INTPACK_size)
    6768
    6869
  • trunk/XTIDE_Universal_BIOS/Src/Boot/BootMenuPrint.asm

    r150 r155  
    304304
    305305    ; Get and push L-CHS size
    306     mov     [RAMVARS.wTimeoutCounter], dl       ; Store drive number
     306    mov     [RAMVARS.bTimeoutTicksLeft], dl     ; Store drive number
    307307    call    AH15h_GetSectorCountToDXAX
    308308    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
    309309
    310310    ; Get and push total LBA size
    311     mov     dl, [RAMVARS.wTimeoutCounter]       ; Restore drive number
     311    mov     dl, [RAMVARS.bTimeoutTicksLeft]     ; Restore drive number
    312312    call    BootInfo_GetTotalSectorCount
    313313    call    ConvertSectorCountInBXDXAXtoSizeAndPushForFormat
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeCommand.asm

    r152 r155  
    2222    call    Device_OutputALtoIdeControlBlockRegisterInDL
    2323    mov     ax, HSR0_RESET_WAIT_US
    24     call    HTimer_DelayMicrosecondsFromAX
     24    call    Timer_DelayMicrosecondsFromAX
    2525
    2626    ; HSR1: Clear_wait
     
    3131    call    Device_OutputALtoIdeControlBlockRegisterInDL
    3232    mov     ax, HSR1_RESET_WAIT_US
    33     call    HTimer_DelayMicrosecondsFromAX
     33    call    Timer_DelayMicrosecondsFromAX
    3434
    3535    ; HSR2: Check_status
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r152 r155  
    381381    eSEG    es          ; Source is ES segment
    382382    rep
    383     db      6Fh         ; OUTSW
     383    db      6Fh         ; OUTSW (we want this in XT build)
    384384    ret
    385385
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm

    r150 r155  
    5353;--------------------------------------------------------------------
    5454IdeWait_PollStatusFlagInBLwithTimeoutInBH:
    55     eMOVZX  cx, bh      ; Timeout ticks now in CX
    5655    mov     ah, bl
    57     call    HTimer_InitializeTimeoutWithTicksInCX
     56    mov     cl, bh
     57    call    Timer_InitializeTimeoutWithTicksInCL
    5858    and     ah, ~FLG_STATUS_BSY
    5959    jz      SHORT PollBsyOnly
     
    8282    jnz     SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    8383.UpdateTimeout:
    84     call    HTimer_SetCFifTimeout
     84    call    Timer_SetCFifTimeout
    8585    jnc     SHORT .PollLoop                     ; Loop if time left
    8686    call    IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
     
    110110    test    al, FLG_STATUS_BSY                  ; Controller busy?
    111111    jz      SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    112     call    HTimer_SetCFifTimeout               ; Update timeout counter
     112    call    Timer_SetCFifTimeout                ; Update timeout counter
    113113    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    114114    jmp     SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
  • trunk/XTIDE_Universal_BIOS/Src/Device/Idepack.asm

    r150 r155  
    5050
    5151    push    bx
    52     call    HAddress_OldInt13hAddressToIdeAddress
     52    call    Address_OldInt13hAddressToIdeAddress
    5353    call    AccessDPT_GetDriveSelectByteToAL
    5454    or      al, bh          ; AL now has Drive and Head Select Byte
  • trunk/XTIDE_Universal_BIOS/Src/Device/Timer.asm

    r150 r155  
    66
    77;--------------------------------------------------------------------
    8 ; HTimer_InitializeTimeoutWithTicksInCX
     8; Timer_InitializeTimeoutWithTicksInCL
    99;   Parameters:
    10 ;       CX:     Timeout value in system timer ticks
     10;       CL:     Timeout value in system timer ticks
    1111;       DS:     Segment to RAMVARS
    1212;   Returns:
     
    1616;--------------------------------------------------------------------
    1717ALIGN JUMP_ALIGN
    18 HTimer_InitializeTimeoutWithTicksInCX:
    19     mov     [RAMVARS.wTimeoutCounter], cx   ; Store timeout ticks
     18Timer_InitializeTimeoutWithTicksInCL:
     19    mov     [RAMVARS.bTimeoutTicksLeft], cl     ; Ticks until timeout
    2020    call    ReadTimeFromBdaToCX
    21     add     [RAMVARS.wTimeoutCounter], cx   ; End time for timeout
     21    mov     [RAMVARS.bLastTimeoutUpdate], cl    ; Start time
    2222    ret
    2323
    2424
    2525;--------------------------------------------------------------------
    26 ; HTimer_SetCFifTimeout
     26; Timer_SetCFifTimeout
    2727;   Parameters:
    2828;       DS:     Segment to RAMVARS
     
    3434;--------------------------------------------------------------------
    3535ALIGN JUMP_ALIGN
    36 HTimer_SetCFifTimeout:
     36Timer_SetCFifTimeout:
    3737    call    ReadTimeFromBdaToCX
    38     cmp     [RAMVARS.wTimeoutCounter], cx
     38    cmp     cl, [RAMVARS.bLastTimeoutUpdate]
     39    je      SHORT .StillPollingTheSameTick
     40    mov     [RAMVARS.bLastTimeoutUpdate], cl
     41    sub     BYTE [RAMVARS.bTimeoutTicksLeft], 1 ; DEC does not update CF
     42.StillPollingTheSameTick:
    3943    ret
    4044
     
    4448; RTC resolution is 977 microsecs.
    4549;
    46 ; HTimer_DelayMicrosecondsFromAX
     50; Timer_DelayMicrosecondsFromAX
    4751;   Parameters:
    4852;       AX:     Number of microsecs to wait
     
    5256;       AX
    5357;--------------------------------------------------------------------
    54 HTimer_DelayMicrosecondsFromAX:
     58Timer_DelayMicrosecondsFromAX:
    5559%ifndef USE_AT
    5660    mov     ax, 2
     
    6973    pop     dx
    7074    mov     ax, 1                               ; Prepare to wait 1 timer tick
    71     jc      SHORT HTimer_DelayTimerTicksFromAX  ; Event Wait was unsupported or busy
     75    jc      SHORT Timer_DelayTimerTicksFromAX   ; Event Wait was unsupported or busy
    7276    ret
    7377%endif
     
    7882; will occur at 54.9 ms intervals.
    7983;
    80 ; HTimer_DelayTimerTicksFromAX
     84; Timer_DelayTimerTicksFromAX
    8185;   Parameters:
    8286;       AX:     Number of timer ticks to wait
     
    8690;       AX
    8791;--------------------------------------------------------------------
    88 HTimer_DelayTimerTicksFromAX:
     92Timer_DelayTimerTicksFromAX:
    8993    sti                             ; Make sure that interrupts are enabled
    9094    call    ReadTimeFromBdaToCX
     
    9397    call    ReadTimeFromBdaToCX
    9498    cmp     cx, ax
    95     jb      SHORT .WaitLoop         ; Loop until end time is reached
     99    jne     SHORT .WaitLoop         ; Loop until end time is reached
    96100    ret
    97101
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm

    r150 r155  
    2323    sti                                 ; Enable interrupts
    2424    cld                                 ; String instructions to increment pointers
    25     SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
     25    CREATE_FRAME_INTPACK_TO_SSBP    EXTRA_BYTES_FOR_INTPACK
    2626
    2727    call    RamVars_GetSegmentToDS
     
    3333
    3434    ; Jump to correct BIOS function
    35 JumpToBiosFunctionInAH:
    3635    cmp     ah, 25h                     ; Valid BIOS function?
    3736    ja      SHORT Int13h_UnsupportedFunction
     
    109108    or      WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF   ; Return with interrupts enabled
    110109    mov     sp, bp                                  ; Now we can exit anytime
    111     RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
     110    RESTORE_FRAME_INTPACK_FROM_SSBP     EXTRA_BYTES_FOR_INTPACK
    112111
    113112
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH15h_HSize.asm

    r150 r155  
    5959
    6060ConvertAH08hReturnValuesToSectorCount:
    61     call    HAddress_ExtractLCHSparametersFromOldInt13hAddress
     61    call    Address_ExtractLCHSparametersFromOldInt13hAddress
    6262    xor     ax, ax          ; Zero AX
    6363    inc     cx              ; Max cylinder number to cylinder count
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH2h_HRead.asm

    r150 r155  
    1515;       SS:BP:  Ptr to IDEPACK
    1616;   Parameters on INTPACK:
    17 ;       AL:     Number of sectors to read (1...255, 0=256)
     17;       AL:     Number of sectors to read (1...255)
    1818;       CH:     Cylinder number, bits 7...0
    1919;       CL:     Bits 7...6: Cylinder number bits 9 and 8
     
    2828ALIGN JUMP_ALIGN
    2929AH2h_HandlerForReadDiskSectors:
     30    call    AH2h_ExitInt13hIfSectorCountInIntpackIsZero
    3031    mov     ah, COMMAND_READ_SECTORS    ; Load sector mode command
    3132    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
     
    4041    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
    4142%endif
     43
     44
     45;--------------------------------------------------------------------
     46; AH2h_ExitInt13hIfSectorCountInIntpackIsZero
     47;   Parameters:
     48;       SS:BP:  Ptr to IDEPACK
     49;   Parameters on INTPACK:
     50;       AL:     Number of sectors to transfer (1...255)
     51;   Returns:
     52;       Nothing (does not return if error)
     53;   Corrupts registers:
     54;       Nothing
     55;--------------------------------------------------------------------
     56ALIGN JUMP_ALIGN
     57AH2h_ExitInt13hIfSectorCountInIntpackIsZero:
     58    cmp     BYTE [bp+IDEPACK.intpack+INTPACK.al], 0
     59    je      SHORT .InvalidSectorCount
     60    ret
     61.InvalidSectorCount:
     62    mov     ah, RET_HD_INVALID
     63    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH3h_HWrite.asm

    r150 r155  
    2727ALIGN JUMP_ALIGN
    2828AH3h_HandlerForWriteDiskSectors:
    29     ; Prepare parameters
     29    call    AH2h_ExitInt13hIfSectorCountInIntpackIsZero
    3030    mov     ah, COMMAND_WRITE_SECTORS   ; Load sector mode command
    3131    test    WORD [di+DPT.wFlags], FLG_DPT_BLOCK_MODE_SUPPORTED
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH4h_HVerify.asm

    r150 r155  
    2626ALIGN JUMP_ALIGN
    2727AH4h_HandlerForVerifyDiskSectors:
    28     mov     ah, COMMAND_WRITE_SECTORS
     28    call    AH2h_ExitInt13hIfSectorCountInIntpackIsZero
     29    mov     ah, COMMAND_VERIFY_SECTORS
    2930    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
    3031%ifdef USE_186
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Address.asm

    r150 r155  
    1515
    1616;--------------------------------------------------------------------
    17 ; HAddress_OldInt13hAddressToIdeAddress
     17; Address_OldInt13hAddressToIdeAddress
    1818;   Parameters:
    1919;       CH:     Cylinder number, bits 7...0
     
    3131;--------------------------------------------------------------------
    3232ALIGN JUMP_ALIGN
    33 HAddress_OldInt13hAddressToIdeAddress:
     33Address_OldInt13hAddressToIdeAddress:
    3434    call    AccessDPT_GetAddressingModeForWordLookToBX
    3535    push    WORD [cs:bx+g_rgfnAddressTranslation]       ; Push return address
    36     ; Fall to HAddress_ExtractLCHSparametersFromOldInt13hAddress
     36    ; Fall to Address_ExtractLCHSparametersFromOldInt13hAddress
    3737
    3838;---------------------------------------------------------------------
    39 ; HAddress_ExtractLCHSparametersFromOldInt13hAddress
     39; Address_ExtractLCHSparametersFromOldInt13hAddress
    4040;   Parameters:
    4141;       CH:     Cylinder number, bits 7...0
     
    5050;       Nothing
    5151;--------------------------------------------------------------------
    52 HAddress_ExtractLCHSparametersFromOldInt13hAddress:
     52Address_ExtractLCHSparametersFromOldInt13hAddress:
    5353    mov     bl, cl              ; Copy sector number...
    5454    and     bl, 3Fh             ; ...and limit to 1...63
     
    6666; PSector   = LSector
    6767;
    68 ; HAddress_ConvertLCHStoPCHS:
     68; Address_ConvertLCHStoPCHS:
    6969;   Parameters:
    7070;       BL:     Sector number (1...63)
     
    104104;
    105105; Returned address is in same registers that
    106 ; HAddress_DoNotConvertLCHS and HAddress_ConvertLCHStoPCHS returns.
     106; Address_DoNotConvertLCHS and Address_ConvertLCHStoPCHS returns.
    107107;
    108108; ConvertLCHStoLBARegisterValues:
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r152 r155  
    119119
    120120
    121 ; Include .asm files (static data and libraries)
     121; Libraries and data
    122122%include "AssemblyLibrary.asm"
    123123%include "Strings.asm"          ; For BIOS message strings
    124124
    125 ; Include .asm files (Initialization and drive detection)
     125; Initialization and drive detection
    126126%include "Initialize.asm"       ; For BIOS initialization
    127127%include "Interrupts.asm"       ; For Interrupt initialization
     
    135135%include "DetectPrint.asm"      ; For printing drive detection strings
    136136
    137 ; Include .asm files (boot menu)
     137; Boot menu
    138138%include "BootMenu.asm"         ; For Boot Menu operations
    139139%include "BootMenuEvent.asm"    ; For menu library event handling
     
    144144%include "BootMenuPrintCfg.asm" ; For printing hard disk configuration
    145145
    146 ; Include .asm files (general drive accessing)
    147 %include "DriveXlate.asm"       ; For swapping drive numbers
    148 %include "HAddress.asm"         ; For sector address translations
    149 %include "HTimer.asm"           ; For timeout and delay
    150 
    151 ; Include .asm files (Interrupt handlers)
    152 %include "Int13h.asm"           ; For Int 13h, Disk functions
     146; Boot loader
    153147%ifndef USE_AT
    154148    %include "Int19hLate.asm"   ; For late initialization
     
    156150%include "Int19hMenu.asm"       ; For Int 19h, Boot Loader for Boot Menu
    157151
    158 ; Include .asm files (Hard Disk BIOS functions)
     152; For all device types
     153%include "Device.asm"
     154%include "Idepack.asm"
     155%include "Timer.asm"            ; For timeout and delay
     156
     157; IDE Device support
     158%include "IdeCommand.asm"
     159%include "IdeDPT.asm"
     160%include "IdeIO.asm"
     161%include "IdeIrq.asm"
     162%include "IdeTransfer.asm"
     163%include "IdeWait.asm"
     164%include "IdeError.asm"         ; Must be included after IdeWait.asm
     165
     166; Serial Port Device support
     167%include "SerialCommand.asm"
     168%include "SerialDPT.asm"
     169
     170; INT 13h Hard Disk BIOS functions
     171%include "DriveXlate.asm"       ; For swapping drive numbers
     172%include "Address.asm"          ; For sector address translations
     173%include "Int13h.asm"           ; For Int 13h, Disk functions
    159174%include "AH0h_HReset.asm"      ; Required by Int13h_Jump.asm
    160175%include "AH1h_HStatus.asm"     ; Required by Int13h_Jump.asm
     
    172187%include "AH24h_HSetBlocks.asm" ; Required by Int13h_Jump.asm
    173188%include "AH25h_HDrvID.asm"     ; Required by Int13h_Jump.asm
    174 %include "Device.asm"
    175 %include "Idepack.asm"
    176 
    177 ; IDE Device support
    178 %include "IdeCommand.asm"
    179 %include "IdeDPT.asm"
    180 %include "IdeIO.asm"
    181 %include "IdeIrq.asm"
    182 %include "IdeTransfer.asm"
    183 %include "IdeWait.asm"
    184 %include "IdeError.asm"         ; Must be included after IdeWait.asm
    185 
    186 ; Serial Port Device support
    187 %include "SerialCommand.asm"
    188 %include "SerialDPT.asm"
    189189
    190190
  • trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/RamVars.asm

    r150 r155  
    123123;               Cleared if function belongs to some other BIOS
    124124;   Corrupts registers:
    125 ;       DI
     125;       Nothing
    126126;--------------------------------------------------------------------
    127127ALIGN JUMP_ALIGN
  • trunk/XTIDE_Universal_BIOS/makefile

    r150 r155  
    3838HEADERS += Src/Handlers/
    3939HEADERS += Src/Handlers/Int13h/
    40 HEADERS += Src/Handlers/Int13h/Common/
    4140HEADERS += Src/Device/
    4241HEADERS += Src/Device/IDE/
Note: See TracChangeset for help on using the changeset viewer.