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

Last change on this file since 65 was 35, checked in by Tomi Tilli, 14 years ago

Cleaned recent changes a bit to save few bytes.

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