source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/AH0h_HReset.asm @ 128

Last change on this file since 128 was 128, checked in by krille_n_@…, 13 years ago

Changes to the XTIDE Universal BIOS:

  • Size optimizations in various files.
File size: 5.4 KB
RevLine 
[128]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Int 13h function AH=0h, Disk Controller Reset.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Int 13h function AH=0h, Disk Controller Reset.
9;
10; AH0h_HandlerForDiskControllerReset
11;   Parameters:
12;       AH:     Bios function 0h
13;       DL:     Drive number (ignored so all drives are reset)
14;               If bit 7 is set all hard disks and floppy disks reset.
15;   Parameters loaded by Int13h_Jump:
16;       DS:     RAMVARS segment
17;   Returns:
[23]18;       AH:     Int 13h return status (from drive requested in DL)
[3]19;       CF:     0 if succesfull, 1 if error
20;       IF:     1
21;   Corrupts registers:
22;       Flags
23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25AH0h_HandlerForDiskControllerReset:
26    push    dx
27    push    cx
28    push    bx
29    push    ax
30
[23]31    eMOVZX  bx, dl                      ; Copy requested drive to BL, zero BH to assume no errors
[26]32    call    ResetFloppyDrivesWithInt40h
[128]33    test    bl, bl
34    jns     SHORT .SkipHardDiskReset
[26]35    call    ResetForeignHardDisks
[27]36    call    AH0h_ResetHardDisksHandledByOurBIOS
[23]37ALIGN JUMP_ALIGN
[26]38.SkipHardDiskReset:
[23]39    mov     ah, bh                      ; Copy error code to AH
40    xor     al, al                      ; Zero AL...
[27]41    cmp     al, bh                      ; ...and set CF if error
[35]42    jmp     Int13h_PopXRegsAndReturn
[3]43
44
45;--------------------------------------------------------------------
[26]46; ResetFloppyDrivesWithInt40h
[3]47;   Parameters:
[23]48;       BL:     Requested drive (DL when entering AH=00h)
49;   Returns:
50;       BH:     Error code from requested drive (if available)
51;   Corrupts registers:
[27]52;       AX, DL, DI
[128]53;--------------------------------------------------------------------
[23]54ALIGN JUMP_ALIGN
[26]55ResetFloppyDrivesWithInt40h:
[27]56    call    GetDriveNumberForForeignBiosesToDL
57    and     dl, 7Fh                     ; Clear hard disk bit
[26]58    xor     ah, ah                      ; Disk Controller Reset
[23]59    int     INTV_FLOPPY_FUNC
[26]60    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
[23]61
62
63;--------------------------------------------------------------------
[26]64; ResetForeignHardDisks
[23]65;   Parameters:
66;       BL:     Requested drive (DL when entering AH=00h)
[3]67;       DS:     RAMVARS segment
68;   Returns:
[23]69;       BH:     Error code from requested drive (if available)
[3]70;   Corrupts registers:
[27]71;       AX, DL, DI
[128]72;--------------------------------------------------------------------
[23]73ALIGN JUMP_ALIGN
[26]74ResetForeignHardDisks:
[27]75    call    GetDriveNumberForForeignBiosesToDL
76    xor     ah, ah                      ; Disk Controller Reset
[32]77    call    Int13h_CallPreviousInt13hHandler
[26]78    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
[23]79
[26]80
[3]81;--------------------------------------------------------------------
[27]82; GetDriveNumberForForeignBiosesToDL
83;   Parameters:
84;       BL:     Requested drive (DL when entering AH=00h)
85;       DS:     RAMVARS segment
86;   Returns:
87;       DL:     BL if foreign drive
88;               80h if our drive
89;   Corrupts registers:
90;       DI
[128]91;--------------------------------------------------------------------
[27]92ALIGN JUMP_ALIGN
93GetDriveNumberForForeignBiosesToDL:
94    mov     dl, bl
95    call    RamVars_IsDriveHandledByThisBIOS
[84]96    jnc     SHORT .Return               ; Return what was in BL unmodified
97    mov     dl, 80h
[27]98ALIGN JUMP_ALIGN
[84]99.Return:
[27]100    ret
101
102
103;--------------------------------------------------------------------
[26]104; ResetHardDisksHandledByOurBIOS
[23]105;   Parameters:
106;       BL:     Requested drive (DL when entering AH=00h)
107;       DS:     RAMVARS segment
108;   Returns:
109;       BH:     Error code from requested drive (if available)
110;   Corrupts registers:
[27]111;       AX, CX, DX, DI
[23]112;--------------------------------------------------------------------
[3]113ALIGN JUMP_ALIGN
[27]114AH0h_ResetHardDisksHandledByOurBIOS:
[26]115    mov     dh, [RAMVARS.bDrvCnt]       ; Load drive count to DH
116    test    dh, dh
117    jz      SHORT .AllDrivesReset       ; Return if no drives
118    mov     dl, [RAMVARS.bFirstDrv]     ; Load number of first our drive
119    add     dh, dl                      ; DH = one past last drive to reset
[3]120ALIGN JUMP_ALIGN
[26]121.DriveResetLoop:
122    call    AHDh_ResetDrive
[27]123    call    .BackupErrorCodeFromMasterOrSlaveToBH
[26]124    inc     dx
125    cmp     dl, dh                      ; All done?
126    jb      SHORT .DriveResetLoop       ;  If not, reset next drive
127.AllDrivesReset:
[3]128    ret
129
130;--------------------------------------------------------------------
[27]131; .BackupErrorCodeFromMasterOrSlaveToBH
[3]132;   Parameters:
[27]133;       AH:     Error code for drive DL reset
134;       BL:     Requested drive (DL when entering AH=00h)
[26]135;       DL:     Drive just resetted
[3]136;       DS:     RAMVARS segment
137;   Returns:
[27]138;       BH:     Backuped error code
[26]139;       DL:     Incremented if next drive is slave drive
140;               (=already resetted)
[3]141;   Corrupts registers:
[27]142;       CX, DI
[3]143;--------------------------------------------------------------------
144ALIGN JUMP_ALIGN
[27]145.BackupErrorCodeFromMasterOrSlaveToBH:
146    call    BackupErrorCodeFromTheRequestedDriveToBH
147    mov     cx, [RAMVARS.wIdeBase]      ; Load base port for resetted drive
[26]148
[27]149    inc     dx                          ; DL to next drive
150    call    FindDPT_ForDriveNumber      ; Get DPT to DS:DI, store port to RAMVARS
151    jnc     SHORT .NoMoreDrivesOrNoSlaveDrive
152    cmp     cx, [RAMVARS.wIdeBase]      ; Next drive is from same controller?
153    je      SHORT BackupErrorCodeFromTheRequestedDriveToBH
154.NoMoreDrivesOrNoSlaveDrive:
155    dec     dx
[3]156    ret
157
158
159;--------------------------------------------------------------------
[26]160; BackupErrorCodeFromTheRequestedDriveToBH
[3]161;   Parameters:
[23]162;       AH:     Error code from the last resetted drive
163;       DL:     Drive last resetted
164;       BL:     Requested drive (DL when entering AH=00h)
[3]165;   Returns:
[23]166;       BH:     Backuped error code
[3]167;   Corrupts registers:
168;       Nothing
169;--------------------------------------------------------------------
170ALIGN JUMP_ALIGN
[26]171BackupErrorCodeFromTheRequestedDriveToBH:
172    cmp     dl, bl              ; Requested drive?
[23]173    jne     SHORT .Return
174    mov     bh, ah
175ALIGN JUMP_ALIGN
176.Return:
[3]177    ret
Note: See TracBrowser for help on using the repository browser.