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


Ignore:
Timestamp:
Feb 5, 2012, 12:59:20 PM (13 years ago)
Author:
aitotat@…
google:author:
aitotat@gmail.com
Message:

Changes to XTIDE Universal BIOS:

  • Makefile now builds small (8k) and large versions.
  • Completely untested support for JR-IDE/ISA.
Location:
trunk/XTIDE_Universal_BIOS/Src/Device/IDE
Files:
1 added
5 edited

Legend:

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

    r218 r238  
    1515;       AL, BX, CX, DX
    1616;--------------------------------------------------------------------
    17 IdeCommand_ResetMasterAndSlaveController:
     17IDEDEVICE%+Command_ResetMasterAndSlaveController:
    1818    ; HSR0: Set_SRST
    1919    call    AccessDPT_GetDeviceControlByteToAL
    2020    or      al, FLG_DEVCONTROL_SRST | FLG_DEVCONTROL_nIEN   ; Set Reset bit
    21     mov     dl, DEVICE_CONTROL_REGISTER_out
    22     call    IdeIO_OutputALtoIdeControlBlockRegisterInDL
     21    OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out
    2322    mov     ax, HSR0_RESET_WAIT_US
    2423    call    Timer_DelayMicrosecondsFromAX
     
    2827    or      al, FLG_DEVCONTROL_nIEN
    2928    and     al, ~FLG_DEVCONTROL_SRST                        ; Clear reset bit
    30     mov     dl, DEVICE_CONTROL_REGISTER_out
    31     call    IdeIO_OutputALtoIdeControlBlockRegisterInDL
     29    OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out
    3230    mov     ax, HSR1_RESET_WAIT_US
    3331    call    Timer_DelayMicrosecondsFromAX
     
    3533    ; HSR2: Check_status
    3634    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY)
    37     jmp     IdeWait_PollStatusFlagInBLwithTimeoutInBH
     35    jmp     IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
    3836
    3937
     
    5149;       AL, BL, CX, DX, SI, DI, ES
    5250;--------------------------------------------------------------------
    53 IdeCommand_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
     51IDEDEVICE%+Command_IdentifyDeviceToBufferInESSIwithDriveSelectByteInBH:
    5452    ; Create fake DPT to be able to use Device.asm functions
    5553    call    FindDPT_ForNewDriveToDSDI
     
    6664    jnz     SHORT .SkipLongWaitSinceDriveIsNotPrimaryMaster
    6765    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_MOTOR_STARTUP, FLG_STATUS_BSY)
    68     call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
     66    call    IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
    6967.SkipLongWaitSinceDriveIsNotPrimaryMaster:
    7068
     
    10098;--------------------------------------------------------------------
    10199ALIGN JUMP_ALIGN
    102 IdeCommand_OutputWithParameters:
     100IDEDEVICE%+Command_OutputWithParameters:
    103101    push    bx                      ; Store status register bits to poll
    104102
    105103    ; Select Master or Slave drive and output head number or LBA28 top bits
    106     call    IdeCommand_SelectDrive
     104    call    IDEDEVICE%+Command_SelectDrive
    107105    jc      SHORT .DriveNotReady
    108106
     
    119117    pop     ds
    120118.DoNotSetInterruptInServiceFlag:
    121     mov     dl, DEVICE_CONTROL_REGISTER_out
    122     call    IdeIO_OutputALtoIdeControlBlockRegisterInDL
     119    OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER DEVICE_CONTROL_REGISTER_out
    123120
    124121    ; Output Feature Number
    125     mov     dl, FEATURES_REGISTER_out
    126122    mov     al, [bp+IDEPACK.bFeatures]
    127     call    IdeIO_OutputALtoIdeRegisterInDL
     123    OUTPUT_AL_TO_IDE_REGISTER FEATURES_REGISTER_out
    128124
    129125    ; Output Sector Address High (only used by LBA48)
     
    138134
    139135    ; Output command
    140     mov     dl, COMMAND_REGISTER_out
    141136    mov     al, [bp+IDEPACK.bCommand]
    142     call    IdeIO_OutputALtoIdeRegisterInDL
     137    OUTPUT_AL_TO_IDE_REGISTER COMMAND_REGISTER_out
    143138
    144139    ; Wait until command completed
    145140    pop     bx                      ; Pop status and timeout for polling
    146141    cmp     bl, FLG_STATUS_DRQ      ; Data transfer started?
    147     je      SHORT IdeTransfer_StartWithCommandInAL
     142    je      SHORT IDEDEVICE%+Transfer_StartWithCommandInAL
    148143    test    BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
    149144    jz      SHORT .WaitForIrqOrRdy
    150     jmp     IdeWait_PollStatusFlagInBLwithTimeoutInBH
     145    jmp     IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
    151146
    152147ALIGN JUMP_ALIGN
    153148.WaitForIrqOrRdy:
    154     jmp     IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
     149    jmp     IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH
    155150
    156151.DriveNotReady:
    157152    pop     bx                          ; Clean stack
    158 ReturnSinceTimeoutWhenPollingBusy:
     153IDEDEVICE%+ReturnSinceTimeoutWhenPollingBusy:
    159154    ret
    160155
     
    172167;--------------------------------------------------------------------
    173168ALIGN JUMP_ALIGN
    174 IdeCommand_SelectDrive:
     169IDEDEVICE%+Command_SelectDrive:
    175170    ; Wait until neither Master or Slave Drive is busy
    176171    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_BSY, FLG_STATUS_BSY)
    177172    cmp     BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE
    178173    eCMOVE  bh, TIMEOUT_IDENTIFY_DEVICE
    179     call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
    180     jc      SHORT ReturnSinceTimeoutWhenPollingBusy
     174    call    IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
     175    jc      SHORT IDEDEVICE%+ReturnSinceTimeoutWhenPollingBusy
    181176
    182177    ; Select Master or Slave Drive
    183     mov     dl, DRIVE_AND_HEAD_SELECT_REGISTER
    184178    mov     al, [bp+IDEPACK.bDrvAndHead]
    185     call    IdeIO_OutputALtoIdeRegisterInDL
     179    OUTPUT_AL_TO_IDE_REGISTER DRIVE_AND_HEAD_SELECT_REGISTER
    186180    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRDY, FLG_STATUS_DRDY)
    187181    cmp     BYTE [bp+IDEPACK.bCommand], COMMAND_IDENTIFY_DEVICE
    188182    eCMOVE  bh, TIMEOUT_IDENTIFY_DEVICE
    189     jmp     IdeWait_PollStatusFlagInBLwithTimeoutInBH
     183    jmp     IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH
    190184
    191185
     
    203197;       AL, BX, DX
    204198;--------------------------------------------------------------------
     199%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
    205200ALIGN JUMP_ALIGN
    206201OutputSectorCountAndAddress:
    207     mov     dl, SECTOR_COUNT_REGISTER
    208     call    IdeIO_OutputALtoIdeRegisterInDL
     202    OUTPUT_AL_TO_IDE_REGISTER SECTOR_COUNT_REGISTER
    209203
    210204    mov     al, ah
    211     mov     dl, LBA_LOW_REGISTER
    212     call    IdeIO_OutputALtoIdeRegisterInDL
     205    OUTPUT_AL_TO_IDE_REGISTER LBA_LOW_REGISTER
    213206
    214207    mov     al, cl
    215     mov     dl, LBA_MIDDLE_REGISTER
    216     call    IdeIO_OutputALtoIdeRegisterInDL
     208    OUTPUT_AL_TO_IDE_REGISTER LBA_MIDDLE_REGISTER
    217209
    218210    mov     al, ch
    219     mov     dl, LBA_HIGH_REGISTER
    220     jmp     IdeIO_OutputALtoIdeRegisterInDL
     211    JUMP_TO_OUTPUT_AL_TO_IDE_REGISTER LBA_HIGH_REGISTER
     212%endif
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm

    r160 r238  
    1818;--------------------------------------------------------------------
    1919ALIGN JUMP_ALIGN
    20 IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
     20IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
    2121    mov     ah, al          ; IDE Status Register to AH
    22     mov     dl, ERROR_REGISTER_in
    23     call    IdeIO_InputToALfromIdeRegisterInDL
     22    INPUT_TO_AL_FROM_IDE_REGISTER ERROR_REGISTER_in
    2423    xchg    al, ah          ; Status Register now in AL, Error Register now in AH
    2524
     
    4544;       BX
    4645;--------------------------------------------------------------------
     46%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
    4747ALIGN JUMP_ALIGN
    4848GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
     
    9292    db  RET_HD_BADSECTOR    ; Bit7=BBK, Bad Block Detected
    9393    db  RET_HD_STATUSERR    ; When Error Register is zero
     94%endif
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIrq.asm

    r233 r238  
    111111    mov     bl, FLGH_DPT_INTERRUPT_IN_SERVICE
    112112    call    FindDPT_ToDSDIforFlagsHighInBL
    113     mov     dl, STATUS_REGISTER_in
    114     call    IdeIO_InputToALfromIdeRegisterInDL
     113    INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in
    115114
    116115    ; Clear Interrupt In-Service Flag from DPT
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeTransfer.asm

    r223 r238  
    9797.WriteLastBlockToDrive:
    9898    mov     cx, [bp+PIOVARS.wWordsLeft]
     99%ifdef USE_186
     100    push    CheckErrorsAfterTransferringLastBlock
     101    jmp     [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
     102%else
    99103    call    [bp+PIOVARS.fnXfer]                 ; Transfer possibly partial block
    100 
    101     ; Check for errors in last block
    102     mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
    103     call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
    104     jmp     SHORT ReturnWithTransferErrorInAH
     104    jmp     SHORT CheckErrorsAfterTransferringLastBlock
     105%endif
    105106
    106107
     
    155156    ; Check for errors in last block
    156157    mov     di, si                              ; DS:DI now points DPT
     158CheckErrorsAfterTransferringLastBlock:
    157159    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRDY)
    158160    call    IdeWait_PollStatusFlagInBLwithTimeoutInBH
  • trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeWait.asm

    r160 r238  
    1616;       AL, BX, CX, DX
    1717;--------------------------------------------------------------------
    18 IdeWait_IRQorDRQ:
     18IDEDEVICE%+Wait_IRQorDRQ:
    1919    mov     bx, TIMEOUT_AND_STATUS_TO_WAIT(TIMEOUT_DRQ, FLG_STATUS_DRQ)
     20%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS     ; JR-IDE/ISA does not support IRQ
    2021    test    BYTE [bp+IDEPACK.bDeviceControl], FLG_DEVCONTROL_nIEN
    21     jnz     SHORT IdeWait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled
     22    jnz     SHORT IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH ; Interrupt disabled
     23%endif
    2224    ; Fall to IdeWait_IRQorStatusFlagInBLwithTimeoutInBH
    2325
     
    3537;       AL, BX, CX, DX
    3638;--------------------------------------------------------------------
    37 IdeWait_IRQorStatusFlagInBLwithTimeoutInBH:
     39IDEDEVICE%+Wait_IRQorStatusFlagInBLwithTimeoutInBH:
     40%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS     ; JR-IDE/ISA does not support IRQ
    3841    call    IdeIrq_WaitForIRQ
     42%endif
    3943    ; Always fall to IdeWait_PollStatusFlagInBLwithTimeoutInBH for error processing
    4044
     
    5256;       AL, BX, CX, DX
    5357;--------------------------------------------------------------------
    54 IdeWait_PollStatusFlagInBLwithTimeoutInBH:
     58IDEDEVICE%+Wait_PollStatusFlagInBLwithTimeoutInBH:
    5559    mov     ah, bl
    5660    mov     cl, bh
    5761    call    Timer_InitializeTimeoutWithTicksInCL
    5862    and     ah, ~FLG_STATUS_BSY
    59     jz      SHORT PollBsyOnly
     63    jz      SHORT IDEDEVICE%+PollBsyOnly
    6064    ; Fall to PollBsyAndFlgInAH
    6165
     
    7276;       AL, BX, CX, DX
    7377;--------------------------------------------------------------------
     78%ifdef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS
    7479PollBsyAndFlgInAH:
    75     call    ReadIdeStatusRegisterToAL           ; Discard contents for first read
     80    call    IDEDEVICE%+ReadIdeStatusRegisterToAL; Discard contents for first read
    7681ALIGN JUMP_ALIGN
    7782.PollLoop:
    78     call    ReadIdeStatusRegisterToAL
     83    call    IDEDEVICE%+ReadIdeStatusRegisterToAL
    7984    test    al, FLG_STATUS_BSY                  ; Controller busy?
    8085    jnz     SHORT .UpdateTimeout                ;  If so, jump to timeout update
    8186    test    al, ah                              ; Test secondary flag
    82     jnz     SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
     87    jnz     SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    8388.UpdateTimeout:
    8489    call    Timer_SetCFifTimeout
    8590    jnc     SHORT .PollLoop                     ; Loop if time left
    86     call    IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
     91    call    IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    8792    jc      SHORT .ReturnErrorCodeInAH
    8893    mov     ah, RET_HD_TIMEOUT                  ; Expected bit never got set
     
    9095.ReturnErrorCodeInAH:
    9196    ret
     97%endif
    9298
    9399
     
    103109;       AL, BX, CX, DX
    104110;--------------------------------------------------------------------
    105 PollBsyOnly:
    106     call    ReadIdeStatusRegisterToAL           ; Discard contents for first read
     111IDEDEVICE%+PollBsyOnly:
     112    call    IDEDEVICE%+ReadIdeStatusRegisterToAL; Discard contents for first read
    107113ALIGN JUMP_ALIGN
    108114.PollLoop:
    109     call    ReadIdeStatusRegisterToAL
     115    call    IDEDEVICE%+ReadIdeStatusRegisterToAL
    110116    test    al, FLG_STATUS_BSY                  ; Controller busy?
    111     jz      SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
     117    jz      SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    112118    call    Timer_SetCFifTimeout                ; Update timeout counter
    113119    jnc     SHORT .PollLoop                     ; Loop if time left (sets CF on timeout)
    114     jmp     SHORT IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
     120    jmp     SHORT IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
    115121
    116122
     
    125131;--------------------------------------------------------------------
    126132ALIGN JUMP_ALIGN
    127 ReadIdeStatusRegisterToAL:
    128     mov     dl, STATUS_REGISTER_in
    129     jmp     IdeIO_InputToALfromIdeRegisterInDL
     133IDEDEVICE%+ReadIdeStatusRegisterToAL:
     134    JUMP_TO_INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in
Note: See TracChangeset for help on using the changeset viewer.