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

Last change on this file since 380 was 376, checked in by gregli@…, 13 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 6.2 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-2012 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;--------------------------------------------------------------------
25; Checks is floppy drive handler installed to interrupt vector 40h.
26;
27; FloppyDrive_IsInt40hInstalled
28; Parameters:
29; ES: BDA and Interrupt Vector segment (zero)
30; Returns:
31; CF: Set if INT 40h is installed
32; Cleared if INT 40h is not installed
33; Corrupts registers:
34; BX, CX, DI
35;--------------------------------------------------------------------
36FloppyDrive_IsInt40hInstalled:
37 cmp WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h ; Any ROM segment?
38%ifdef USE_AT ; No need to verify on XT systems.
39 jb SHORT .Int40hHandlerIsNotInstalled
40 call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
41.Int40hHandlerIsNotInstalled:
42%endif
43 cmc
44 ret
45
46;--------------------------------------------------------------------
47; .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
48; Parameters:
49; Nothing
50; Returns:
51; CF: Cleared if INT 40h is installed
52; Set if INT 40h is not installed
53; Corrupts registers:
54; BX, CX, DI
55;--------------------------------------------------------------------
56%ifdef USE_AT
57.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
58 push es
59 push dx
60 push ax
61
62 call .LoadInt40hVerifyParameters
63 int BIOS_DISK_INTERRUPT_13h
64 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
65 push es
66 push di
67
68 call .LoadInt40hVerifyParameters
69 int BIOS_DISKETTE_INTERRUPT_40h
70
71 pop dx
72 pop cx
73 cmp dx, di ; Difference in offsets?
74 jne SHORT .Int40hNotInstalled
75 mov dx, es
76 cmp cx, dx ; Difference in segments?
77 je SHORT .Int40hIsInstalled
78.Int40hNotInstalled:
79 stc
80.Int40hIsInstalled:
81 pop ax
82 pop dx
83 pop es
84 ret
85
86;--------------------------------------------------------------------
87; .LoadInt40hVerifyParameters
88; Parameters:
89; Nothing
90; Returns:
91; AH: 08h (Get Drive Parameters)
92; DL: 00h (floppy drive)
93; ES:DI: 0:0h (to guard against BIOS bugs)
94; Corrupts registers:
95; DH
96;--------------------------------------------------------------------
97.LoadInt40hVerifyParameters:
98 mov ah, 08h ; Get Drive Parameters
99 cwd ; Floppy drive 0
100 mov di, dx
101 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
102 ret
103%endif
104
105
106;--------------------------------------------------------------------
107; Returns floppy drive type.
108; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
109; is still returned for them.
110;
111; FloppyDrive_GetType
112; Parameters:
113; DL: Floppy Drive number
114; Returns:
115; BX: Floppy Drive Type:
116; FLOPPY_TYPE_525_OR_35_DD
117; FLOPPY_TYPE_525_DD
118; FLOPPY_TYPE_525_HD
119; FLOPPY_TYPE_35_DD
120; FLOPPY_TYPE_35_HD
121; FLOPPY_TYPE_35_ED
122; CF: Set if AH=08h not supported (XT systems) or error
123; Cleared if type read correctly (AT systems)
124; Corrupts registers:
125; AX, CX, DX, DI, ES
126;--------------------------------------------------------------------
127FloppyDrive_GetType:
128 mov ah, 08h ; Get Drive Parameters
129 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
130 int BIOS_DISKETTE_INTERRUPT_40h
131 ret
132
133
134;--------------------------------------------------------------------
135; Returns number of Floppy Drives in system.
136;
137; FloppyDrive_GetCountToAX
138; Parameters:
139; DS: RAMVARS Segment
140; Returns:
141; AX: Number of Floppy Drives
142;--------------------------------------------------------------------
143FloppyDrive_GetCountToAX:
144%ifdef MODULE_SERIAL_FLOPPY
145 call RamVars_UnpackFlopCntAndFirstToAL
146 js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
147
148 adc al,1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
149 jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
150
151.UseBIOSorBDA:
152%endif
153 call FloppyDrive_GetCountFromBIOS_or_BDA
154
155.FinishCalc:
156 mov ah, [cs:ROMVARS.bMinFddCnt]
157 MAX_U al, ah
158 cbw
159
160 ret
161
162FloppyDrive_GetCountFromBIOS_or_BDA:
163 push es
164
165;--------------------------------------------------------------------
166; Reads Floppy Drive Count from BIOS.
167; Does not work on most XT systems. Call .GetCountFromBDA
168; if this function fails.
169;
170; .GetCountFromBIOS
171; Parameters:
172; Nothing
173; Returns:
174; AL: Number of Floppy Drives
175; CF: Cleared if successful
176; Set if BIOS function not supported
177; Corrupts registers:
178; ES
179;--------------------------------------------------------------------
180%ifdef USE_AT
181.GetCountFromBIOS:
182 push di
183 push bx
184 push cx
185 push dx
186
187 mov ah, 08h ; Get Drive Parameters
188 cwd ; Floppy Drive 00h
189 int BIOS_DISKETTE_INTERRUPT_40h
190 mov al, dl ; Number of Floppy Drives to AL
191
192 pop dx
193 pop cx
194 pop bx
195 pop di
196%endif
197
198;--------------------------------------------------------------------
199; Reads Floppy Drive Count (0...4) from BIOS Data Area.
200; This function should be used only if .GetCountFromBIOS fails.
201;
202; .GetCountFromBDA
203; Parameters:
204; Nothing
205; Returns:
206; AL: Number of Floppy Drives
207; Corrupts registers:
208; AH, ES
209;--------------------------------------------------------------------
210%ifndef USE_AT
211.GetCountFromBDA:
212 LOAD_BDA_SEGMENT_TO es, ax
213 mov al, [es:BDA.wEquipment] ; Load Equipment WORD low byte
214 mov ah, al ; Copy it to AH
215 and ax, 0C001h ; Leave bits 15..14 and 0
216 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0
217 add al, ah ; AL = Floppy Drive count
218%endif
219
220 pop es
221 ret
Note: See TracBrowser for help on using the repository browser.