source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm@ 527

Last change on this file since 527 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 6.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Various floppy drive related functions that
3; Boot Menu uses.
4
5;
6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
8;
9; This program is free software; you can redistribute it and/or modify
10; it under the terms of the GNU General Public License as published by
11; the Free Software Foundation; either version 2 of the License, or
12; (at your option) any later version.
13;
14; This program is distributed in the hope that it will be useful,
15; but WITHOUT ANY WARRANTY; without even the implied warranty of
16; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17; GNU General Public License for more details.
18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19;
20
21; Section containing code
22SECTION .text
23
24%ifdef COPY_13H_HANDLER_TO_40H
25;--------------------------------------------------------------------
26; Checks is floppy drive handler installed to interrupt vector 40h.
27;
28; FloppyDrive_IsInt40hInstalled
29; Parameters:
30; ES: BDA and Interrupt Vector segment (zero)
31; Returns:
32; CF: Set if INT 40h is installed
33; Cleared if INT 40h is not installed
34; Corrupts registers:
35; BX, CX, DI
36;--------------------------------------------------------------------
37FloppyDrive_IsInt40hInstalled:
38 cmp WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h ; Any ROM segment?
39%ifdef USE_AT ; No need to verify on XT systems.
40 jb SHORT .Int40hHandlerIsNotInstalled
41 call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
42.Int40hHandlerIsNotInstalled:
43%endif
44 cmc
45 ret
46
47;--------------------------------------------------------------------
48; .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
49; Parameters:
50; Nothing
51; Returns:
52; CF: Cleared if INT 40h is installed
53; Set if INT 40h is not installed
54; Corrupts registers:
55; BX, CX, DI
56;--------------------------------------------------------------------
57%ifdef USE_AT
58.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
59 push es
60 push dx
61 push ax
62
63 call .LoadInt40hVerifyParameters
64 int BIOS_DISK_INTERRUPT_13h
65 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
66 push es
67 push di
68
69 call .LoadInt40hVerifyParameters
70 int BIOS_DISKETTE_INTERRUPT_40h
71
72 pop dx
73 pop cx
74 cmp dx, di ; Difference in offsets?
75 jne SHORT .Int40hNotInstalled
76 mov dx, es
77 cmp cx, dx ; Difference in segments?
78 je SHORT .Int40hIsInstalled
79.Int40hNotInstalled:
80 stc
81.Int40hIsInstalled:
82 pop ax
83 pop dx
84 pop es
85 ret
86
87;--------------------------------------------------------------------
88; .LoadInt40hVerifyParameters
89; Parameters:
90; Nothing
91; Returns:
92; AH: 08h (Get Drive Parameters)
93; DL: 00h (floppy drive)
94; ES:DI: 0:0h (to guard against BIOS bugs)
95; Corrupts registers:
96; DH
97;--------------------------------------------------------------------
98.LoadInt40hVerifyParameters:
99 mov ah, 08h ; Get Drive Parameters
100 cwd ; Floppy drive 0
101 mov di, dx
102 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
103 ret
104%endif
105
106%endif ; COPY_13H_HANDLER_TO_40H
107
108
109;--------------------------------------------------------------------
110; Returns floppy drive type.
111; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
112; is still returned for them.
113;
114; FloppyDrive_GetType
115; Parameters:
116; DL: Floppy Drive number
117; Returns:
118; BX: Floppy Drive Type:
119; FLOPPY_TYPE_525_OR_35_DD
120; FLOPPY_TYPE_525_DD
121; FLOPPY_TYPE_525_HD
122; FLOPPY_TYPE_35_DD
123; FLOPPY_TYPE_35_HD
124; FLOPPY_TYPE_35_ED
125; CF: Set if AH=08h not supported (XT systems) or error
126; Cleared if type read correctly (AT systems)
127; Corrupts registers:
128; AX, CX, DX, DI, ES
129;--------------------------------------------------------------------
130%ifdef MODULE_BOOT_MENU
131FloppyDrive_GetType:
132 mov ah, 08h ; Get Drive Parameters
133 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
134 int BIOS_DISKETTE_INTERRUPT_40h
135 ret
136%endif
137
138
139;--------------------------------------------------------------------
140; Returns number of Floppy Drives in system.
141;
142; FloppyDrive_GetCountToAX
143; Parameters:
144; DS: RAMVARS Segment
145; Returns:
146; AX: Number of Floppy Drives
147;--------------------------------------------------------------------
148FloppyDrive_GetCountToAX:
149%ifdef MODULE_SERIAL_FLOPPY
150 call RamVars_UnpackFlopCntAndFirstToAL
151 js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
152
153 adc al,1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
154 jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
155
156.UseBIOSorBDA:
157%endif
158 call FloppyDrive_GetCountFromBIOS_or_BDA
159
160.FinishCalc:
161 mov ah, [cs:ROMVARS.bMinFddCnt]
162 MAX_U al, ah
163 cbw
164
165 ret
166
167FloppyDrive_GetCountFromBIOS_or_BDA:
168 push es
169
170;--------------------------------------------------------------------
171; Reads Floppy Drive Count from BIOS.
172; Does not work on most XT systems. Call .GetCountFromBDA
173; if this function fails.
174;
175; .GetCountFromBIOS
176; Parameters:
177; Nothing
178; Returns:
179; AL: Number of Floppy Drives
180; CF: Cleared if successful
181; Set if BIOS function not supported
182; Corrupts registers:
183; ES
184;--------------------------------------------------------------------
185%ifdef USE_AT
186.GetCountFromBIOS:
187 push di
188 push bx
189 push cx
190 push dx
191
192 mov ah, 08h ; Get Drive Parameters
193 cwd ; Floppy Drive 00h
194 int BIOS_DISKETTE_INTERRUPT_40h
195 mov al, dl ; Number of Floppy Drives to AL
196
197 pop dx
198 pop cx
199 pop bx
200 pop di
201%endif
202
203;--------------------------------------------------------------------
204; Reads Floppy Drive Count (0...4) from BIOS Data Area.
205; This function should be used only if .GetCountFromBIOS fails.
206;
207; .GetCountFromBDA
208; Parameters:
209; Nothing
210; Returns:
211; AL: Number of Floppy Drives
212; Corrupts registers:
213; AH, ES
214;--------------------------------------------------------------------
215%ifndef USE_AT
216.GetCountFromBDA:
217 LOAD_BDA_SEGMENT_TO es, ax
218 mov al, [es:BDA.wEquipment] ; Load Equipment WORD low byte
219 mov ah, al ; Copy it to AH
220 and ax, 0C001h ; Leave bits 15..14 and 0
221 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0
222 add al, ah ; AL = Floppy Drive count
223%endif
224
225 pop es
226 ret
Note: See TracBrowser for help on using the repository browser.