Changeset 23 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src


Ignore:
Timestamp:
Jul 1, 2010, 5:33:40 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Booting is now possible from hard disks if floppy controller reset fails.
AH=00h, Disk Controller Reset now returns error code for the requested drive only.

Location:
trunk/XTIDE_Universal_BIOS/Src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm

    r3 r23  
    22; Project name  :   IDE BIOS
    33; Created date  :   27.9.2007
    4 ; Last update   :   2.5.2010
     4; Last update   :   1.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Int 13h function AH=0h, Disk Controller Reset.
     
    2323;       DS:     RAMVARS segment
    2424;   Returns:
    25 ;       AH:     Int 13h return status
     25;       AH:     Int 13h return status (from drive requested in DL)
    2626;       CF:     0 if succesfull, 1 if error
    2727;       IF:     1
     
    3636    push    ax
    3737
    38     test    dl, 80h                     ; Reset floppy drives only?
    39     jz      SHORT .ResetForeignControllers
    40     call    AH0h_ResetOurControllers
    41 .ResetForeignControllers:
    42     call    AH0h_ResetFloppyAndForeignHardDiskControllers
    43     jmp     Int13h_PopXRegsAndReturn    ; Return since error
     38    eMOVZX  bx, dl                      ; Copy requested drive to BL, zero BH to assume no errors
     39    call    AH0h_ResetFloppyDrivesWithInt40h
     40    test    bl, 80h                     ; Reset hard disks too?
     41    jz      SHORT .Return
     42    call    AH0h_ResetForeignHardDisks
     43    call    AH0h_ResetAllOurControllers
     44ALIGN JUMP_ALIGN
     45.Return:
     46    mov     ah, bh                      ; Copy error code to AH
     47    xor     al, al                      ; Zero AL...
     48    sub     al, ah                      ; ...and set CF if error
     49    jmp     Int13h_PopXRegsAndReturn
    4450
    4551
    4652;--------------------------------------------------------------------
    47 ; Resets all IDE controllers handled by this BIOS.
    48 ;
    49 ; AH0h_ResetOurControllers
     53; AH0h_ResetFloppyDrivesWithInt40h
    5054;   Parameters:
     55;       BL:     Requested drive (DL when entering AH=00h)
     56;       DL:     Drive number
     57;   Returns:
     58;       BH:     Error code from requested drive (if available)
     59;   Corrupts registers:
     60;       AX, DL
     61;--------------------------------------------------------------------   
     62ALIGN JUMP_ALIGN
     63AH0h_ResetFloppyDrivesWithInt40h:
     64    xor     ax, ax                      ; Disk Controller Reset
     65    and     dl, 7Fh                     ; Clear bit 7
     66    int     INTV_FLOPPY_FUNC
     67    jmp     SHORT AH0h_BackupErrorCodeFromTheRequestedDriveToBH
     68
     69
     70;--------------------------------------------------------------------
     71; AH0h_ResetForeignHardDisks
     72;   Parameters:
     73;       BL:     Requested drive (DL when entering AH=00h)
    5174;       DS:     RAMVARS segment
    5275;   Returns:
    53 ;       AH:     Int 13h return status
    54 ;       CF:     0 if succesfull, 1 if error
     76;       BH:     Error code from requested drive (if available)
    5577;   Corrupts registers:
    56 ;       AL, BX, CX, DI
    57 ;--------------------------------------------------------------------
     78;       AX, DL
     79;--------------------------------------------------------------------   
    5880ALIGN JUMP_ALIGN
    59 AH0h_ResetOurControllers:
    60     push    dx
    61     mov     bx, ROMVARS.ideVars0            ; Load offset to first IDEVARS
    62     call    Initialize_GetIdeControllerCountToCX
     81AH0h_ResetForeignHardDisks:
     82    mov     cl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
     83    and     cx, BYTE 7Fh                ; CX = number of drives to reset
     84    jz      SHORT .Return
     85    mov     dl, 80h                     ; Start resetting from drive 80h
    6386ALIGN JUMP_ALIGN
    64 .ResetLoop:
    65     call    AH0h_ResetIdevarsController
    66     jc      SHORT .Return
    67     add     bx, BYTE IDEVARS_size
    68     loop    .ResetLoop
    69     xor     ax, ax                          ; Clear AH and CF since no errors
     87.DriveResetLoop:
     88    mov     ah, 0Dh                     ; Reset Hard Disk (Alternate reset)
     89    pushf                               ; Push flags to simulate INT
     90    cli                                 ; Disable interrupts since INT does that
     91    call    FAR [RAMVARS.fpOldI13h]
     92    sti                                 ; Make sure interrupts are enabled again (some BIOSes fails to enable it)
     93    call    AH0h_BackupErrorCodeFromTheRequestedDriveToBH
     94    inc     dx                          ; Next drive to reset
     95    loop    .DriveResetLoop
     96ALIGN JUMP_ALIGN
    7097.Return:
    71     pop     dx
    7298    ret
    7399
    74100
    75101;--------------------------------------------------------------------
    76 ; Resets master and slave drive based on either drive number.
    77 ;
    78 ; AH0h_ResetIdevarsController
     102; AH0h_ResetAllOurControllers
    79103;   Parameters:
    80 ;       CS:BX:  Ptr to IDEVARS
     104;       BL:     Requested drive (DL when entering AH=00h)
    81105;       DS:     RAMVARS segment
    82106;   Returns:
    83 ;       AH:     Int 13h return status
    84 ;       CF:     0 if succesfull, 1 if error
     107;       BH:     Error code from requested drive (if available)
    85108;   Corrupts registers:
    86 ;       AL, DX, DI
     109;       AX, CX, DX, DI
    87110;--------------------------------------------------------------------
    88111ALIGN JUMP_ALIGN
    89 AH0h_ResetIdevarsController:
    90     mov     dx, [cs:bx+IDEVARS.wPort]
     112AH0h_ResetAllOurControllers:
     113    push    si
     114    mov     si, ROMVARS.ideVars0            ; Load offset to first IDEVARS
     115    call    Initialize_GetIdeControllerCountToCX
     116ALIGN JUMP_ALIGN
     117.ResetLoop:
     118    call    AH0h_ResetIdevarsControllerMasterAndSlaveDrives
     119    add     si, BYTE IDEVARS_size
     120    loop    .ResetLoop
     121.Return:
     122    pop     si
     123    ret
     124
     125
     126;--------------------------------------------------------------------
     127; AH0h_ResetIdevarsControllerMasterAndSlaveDrives
     128;   Parameters:
     129;       BL:     Requested drive (DL when entering AH=00h)
     130;       CS:SI:  Ptr to IDEVARS
     131;       DS:     RAMVARS segment
     132;   Returns:
     133;       BH:     Error code from requested drive (if available)
     134;   Corrupts registers:
     135;       AX, DX, DI
     136;--------------------------------------------------------------------
     137ALIGN JUMP_ALIGN
     138AH0h_ResetIdevarsControllerMasterAndSlaveDrives:
     139    mov     dx, [cs:si+IDEVARS.wPort]
    91140    call    FindDPT_ForIdeMasterAtPort      ; Find master drive to DL
    92141    jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
    93142    call    FindDPT_ForIdeSlaveAtPort       ; Find slave if master not present
    94143    jc      SHORT AH0h_ResetMasterAndSlaveDriveWithRetries
    95     clc
    96144    ret
    97145
    98 
    99146;--------------------------------------------------------------------
    100 ; Resets master and slave drive based on either drive number.
    101 ;
    102147; AH0h_ResetMasterAndSlaveDriveWithRetries
    103148;   Parameters:
     149;       BL:     Requested drive (DL when entering AH=00h)
    104150;       DL:     Drive number for master or slave drive
     151;       DS:     RAMVARS segment
    105152;   Returns:
    106 ;       AH:     Int 13h return status
    107 ;       CF:     0 if succesfull, 1 if error
     153;       BH:     Error code from requested drive (if available)
    108154;   Corrupts registers:
    109 ;       AL, DX, DI
     155;       AX, DI
    110156;--------------------------------------------------------------------
    111157ALIGN JUMP_ALIGN
    112158AH0h_ResetMasterAndSlaveDriveWithRetries:
     159    push    dx
    113160    push    cx
    114161    push    bx
    115     mov     cx, RETRIES_IF_RESET_FAILS
     162    mov     di, RETRIES_IF_RESET_FAILS
    116163ALIGN JUMP_ALIGN
    117164.RetryLoop:
    118     mov     di, cx                      ; Backup counter
    119165    call    AHDh_ResetDrive
    120     jnc     SHORT .Return
     166    jnc     SHORT .Return               ; Jump if successful
    121167    mov     cx, TIMEOUT_BEFORE_RESET_RETRY
    122168    call    SoftDelay_TimerTicks
    123     mov     cx, di
    124     loop    .RetryLoop
    125     mov     ah, RET_HD_RESETFAIL
    126     stc
     169    dec     di
     170    jnz     SHORT .RetryLoop
    127171ALIGN JUMP_ALIGN
    128172.Return:
    129173    pop     bx
    130174    pop     cx
    131     ret
    132 
     175    pop     dx
     176    ; Fall to AH0h_BackupErrorCodeFromTheRequestedDriveToBH
    133177
    134178;--------------------------------------------------------------------
    135 ; Resets floppy drives and foreign hard disks.
    136 ;
    137 ; AH0h_ResetFloppyAndForeignHardDiskControllers
     179; AH0h_BackupErrorCodeFromTheRequestedDriveToBH
    138180;   Parameters:
    139 ;       DL:     Drive number (ignored so all drives are reset)
    140 ;               If bit 7 is set all hard disks and floppy disks reset.
     181;       AH:     Error code from the last resetted drive
     182;       DL:     Drive last resetted
     183;       BL:     Requested drive (DL when entering AH=00h)
    141184;   Returns:
    142 ;       AH:     Int 13h return status
    143 ;       CF:     0 if succesfull, 1 if error
     185;       BH:     Backuped error code
    144186;   Corrupts registers:
    145187;       Nothing
    146188;--------------------------------------------------------------------
    147189ALIGN JUMP_ALIGN
    148 AH0h_ResetFloppyAndForeignHardDiskControllers:
    149     xor     ah, ah                      ; AH=0h, Disk Controller Reset
    150     pushf                               ; Push flags to simulate INT
    151     cli                                 ; Disable interrupts
    152     call    FAR [RAMVARS.fpOldI13h]
     190AH0h_BackupErrorCodeFromTheRequestedDriveToBH:
     191    cmp     dl, bl                      ; Requested drive?
     192    jne     SHORT .Return
     193    mov     bh, ah
     194ALIGN JUMP_ALIGN
     195.Return:
    153196    ret
  • trunk/XTIDE_Universal_BIOS/Src/Initialization/Initialize.asm

    r3 r23  
    22; Project name  :   IDE BIOS
    33; Created date  :   23.3.2010
    4 ; Last update   :   2.5.2010
     4; Last update   :   1.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for initializing the BIOS.
     
    418418ALIGN JUMP_ALIGN
    419419Initialize_ResetDetectedDrives:
    420     ; Initialize to speed up POST. DOS will reset drives anyway.
    421     eMOVZX  cx, BYTE [RAMVARS.bDrvCnt]
    422     jcxz    .Return
    423     mov     dl, [RAMVARS.bFirstDrv]
    424 ALIGN JUMP_ALIGN
    425 .InitLoop:
    426     call    AH9h_InitializeDriveForUse
    427     inc     dx                  ; Next drive
    428     loop    .InitLoop
    429 .Return:
    430     ret
     420    xor     ah, ah              ; Disk Controller Reset
     421    mov     dl, 80h             ; Reset all floppy drives and hard disks
     422    int     INTV_DISK_FUNC
     423    ret
  • trunk/XTIDE_Universal_BIOS/Src/Main.asm

    r3 r23  
    22; Project name  :   XTIDE Universal BIOS
    33; Created date  :   28.7.2007
    4 ; Last update   :   2.5.2010
     4; Last update   :   1.7.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Main file for BIOS. This is the only file that needs
     
    3838    at  ROMVARS.bRomSize,   db  CNT_ROM_BLOCKS  ; ROM size in 512B blocks
    3939    at  ROMVARS.rgbJump,    jmp Initialize_FromMainBiosRomSearch
    40     at  ROMVARS.rgbDate,    db  "05/02/10"      ; Build data (mm/dd/yy)
     40    at  ROMVARS.rgbDate,    db  "07/01/10"      ; Build data (mm/dd/yy)
    4141    at  ROMVARS.rgbSign,    db  "XTIDE110"      ; Signature for flash program
    4242    at  ROMVARS.szTitle
     
    4949        db  " (XT)=-",STOP
    5050%endif
    51     at  ROMVARS.szVersion,  db  "v1.1.0 (05/02/10)",STOP
     51    at  ROMVARS.szVersion,  db  "v1.1.1 (07/01/10)",STOP
    5252
    5353;---------------------------;
Note: See TracChangeset for help on using the changeset viewer.