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

Last change on this file since 152 was 152, checked in by aitotat, 13 years ago

Changes to XTIDE Universal BIOS:

  • XTIDE mod should now be supported (untested).
  • Interrupt Service Routine no longer requires variable from RAMVARS.
  • Some small improvements.
File size: 5.6 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:
[148]12;       DL:     Translated Drive number (ignored so all drives are reset)
[3]13;               If bit 7 is set all hard disks and floppy disks reset.
[148]14;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]15;       SS:BP:  Ptr to IDEPACK
16;   Returns with INTPACK:
[23]17;       AH:     Int 13h return status (from drive requested in DL)
[3]18;       CF:     0 if succesfull, 1 if error
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21AH0h_HandlerForDiskControllerReset:
[23]22    eMOVZX  bx, dl                      ; Copy requested drive to BL, zero BH to assume no errors
[26]23    call    ResetFloppyDrivesWithInt40h
[128]24    test    bl, bl
25    jns     SHORT .SkipHardDiskReset
[26]26    call    ResetForeignHardDisks
[27]27    call    AH0h_ResetHardDisksHandledByOurBIOS
[26]28.SkipHardDiskReset:
[148]29    mov     ah, bh
30    jmp     Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[3]31
32
33;--------------------------------------------------------------------
[26]34; ResetFloppyDrivesWithInt40h
[3]35;   Parameters:
[23]36;       BL:     Requested drive (DL when entering AH=00h)
37;   Returns:
38;       BH:     Error code from requested drive (if available)
39;   Corrupts registers:
[27]40;       AX, DL, DI
[128]41;--------------------------------------------------------------------
[23]42ALIGN JUMP_ALIGN
[26]43ResetFloppyDrivesWithInt40h:
[27]44    call    GetDriveNumberForForeignBiosesToDL
45    and     dl, 7Fh                     ; Clear hard disk bit
[26]46    xor     ah, ah                      ; Disk Controller Reset
[148]47    int     BIOS_DISKETTE_INTERRUPT_40h
[26]48    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
[23]49
50
51;--------------------------------------------------------------------
[26]52; ResetForeignHardDisks
[23]53;   Parameters:
54;       BL:     Requested drive (DL when entering AH=00h)
[3]55;       DS:     RAMVARS segment
56;   Returns:
[23]57;       BH:     Error code from requested drive (if available)
[3]58;   Corrupts registers:
[27]59;       AX, DL, DI
[128]60;--------------------------------------------------------------------
[23]61ALIGN JUMP_ALIGN
[26]62ResetForeignHardDisks:
[27]63    call    GetDriveNumberForForeignBiosesToDL
64    xor     ah, ah                      ; Disk Controller Reset
[32]65    call    Int13h_CallPreviousInt13hHandler
[26]66    jmp     SHORT BackupErrorCodeFromTheRequestedDriveToBH
[23]67
[26]68
[3]69;--------------------------------------------------------------------
[27]70; GetDriveNumberForForeignBiosesToDL
71;   Parameters:
72;       BL:     Requested drive (DL when entering AH=00h)
73;       DS:     RAMVARS segment
74;   Returns:
75;       DL:     BL if foreign drive
76;               80h if our drive
77;   Corrupts registers:
78;       DI
[128]79;--------------------------------------------------------------------
[27]80ALIGN JUMP_ALIGN
81GetDriveNumberForForeignBiosesToDL:
82    mov     dl, bl
83    call    RamVars_IsDriveHandledByThisBIOS
[84]84    jnc     SHORT .Return               ; Return what was in BL unmodified
85    mov     dl, 80h
86.Return:
[27]87    ret
88
89
90;--------------------------------------------------------------------
[150]91; AH0h_ResetHardDisksHandledByOurBIOS
[23]92;   Parameters:
93;       BL:     Requested drive (DL when entering AH=00h)
94;       DS:     RAMVARS segment
[150]95;       SS:BP:  Ptr to IDEPACK
[23]96;   Returns:
97;       BH:     Error code from requested drive (if available)
98;   Corrupts registers:
[150]99;       AX, CX, DX, SI, DI
[23]100;--------------------------------------------------------------------
[3]101ALIGN JUMP_ALIGN
[27]102AH0h_ResetHardDisksHandledByOurBIOS:
[26]103    mov     dh, [RAMVARS.bDrvCnt]       ; Load drive count to DH
104    test    dh, dh
105    jz      SHORT .AllDrivesReset       ; Return if no drives
[150]106    mov     dl, [RAMVARS.bFirstDrv]     ; Load number of our first drive
[26]107    add     dh, dl                      ; DH = one past last drive to reset
[3]108ALIGN JUMP_ALIGN
[26]109.DriveResetLoop:
110    call    AHDh_ResetDrive
[27]111    call    .BackupErrorCodeFromMasterOrSlaveToBH
[26]112    inc     dx
113    cmp     dl, dh                      ; All done?
114    jb      SHORT .DriveResetLoop       ;  If not, reset next drive
115.AllDrivesReset:
[3]116    ret
117
118;--------------------------------------------------------------------
[27]119; .BackupErrorCodeFromMasterOrSlaveToBH
[3]120;   Parameters:
[27]121;       AH:     Error code for drive DL reset
122;       BL:     Requested drive (DL when entering AH=00h)
[26]123;       DL:     Drive just resetted
[3]124;       DS:     RAMVARS segment
125;   Returns:
[27]126;       BH:     Backuped error code
[26]127;       DL:     Incremented if next drive is slave drive
128;               (=already resetted)
[3]129;   Corrupts registers:
[27]130;       CX, DI
[3]131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
[27]133.BackupErrorCodeFromMasterOrSlaveToBH:
134    call    BackupErrorCodeFromTheRequestedDriveToBH
[150]135    call    GetBasePortToCX             ; Load base port for resetted drive
136    push    cx
[27]137    inc     dx                          ; DL to next drive
[150]138    call    GetBasePortToCX
139    pop     di
140    cmp     cx, di                      ; Next drive is from same controller?
[27]141    je      SHORT BackupErrorCodeFromTheRequestedDriveToBH
142.NoMoreDrivesOrNoSlaveDrive:
143    dec     dx
[3]144    ret
145
[150]146;--------------------------------------------------------------------
147; GetBasePortToCX
148;   Parameters:
149;       DL:     Drive number
150;       DS:     RAMVARS segment
151;   Returns:
152;       CX:     Base port address
153;       CF:     Set if valid drive number
154;               Cleared if invalid drive number
155;   Corrupts registers:
156;       DI
157;--------------------------------------------------------------------
158ALIGN JUMP_ALIGN
159GetBasePortToCX:
160    xchg    cx, bx
161    xor     bx, bx
162    call    FindDPT_ForDriveNumber
163    mov     bl, [di+DPT.bIdevarsOffset]
164    mov     bx, [cs:bx+IDEVARS.wPort]
165    xchg    bx, cx
166    ret
[3]167
[150]168
[3]169;--------------------------------------------------------------------
[26]170; BackupErrorCodeFromTheRequestedDriveToBH
[3]171;   Parameters:
[23]172;       AH:     Error code from the last resetted drive
173;       DL:     Drive last resetted
174;       BL:     Requested drive (DL when entering AH=00h)
[3]175;   Returns:
[23]176;       BH:     Backuped error code
[3]177;   Corrupts registers:
178;       Nothing
179;--------------------------------------------------------------------
180ALIGN JUMP_ALIGN
[26]181BackupErrorCodeFromTheRequestedDriveToBH:
182    cmp     dl, bl              ; Requested drive?
[148]183    eCMOVE  bh, ah
[3]184    ret
Note: See TracBrowser for help on using the repository browser.