source: xtideuniversalbios/tags/v2.0.0_beta_3/XTIDE_Universal_BIOS/Src/Initialization/FloppyDrive.asm@ 539

Last change on this file since 539 was 392, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Greatly improved Hotkey Bar is displayed during drive detection.
  • 8k builds no longer include boot menu.
  • Boot menu is displayed only if F2 is pressed during drive detection.
  • Some changes to directory structure.


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-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;--------------------------------------------------------------------
127%ifdef MODULE_BOOT_MENU
128FloppyDrive_GetType:
129 mov ah, 08h ; Get Drive Parameters
130 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
131 int BIOS_DISKETTE_INTERRUPT_40h
132 ret
133%endif
134
135
136;--------------------------------------------------------------------
137; Returns number of Floppy Drives in system.
138;
139; FloppyDrive_GetCountToAX
140; Parameters:
141; DS: RAMVARS Segment
142; Returns:
143; AX: Number of Floppy Drives
144;--------------------------------------------------------------------
145FloppyDrive_GetCountToAX:
146%ifdef MODULE_SERIAL_FLOPPY
147 call RamVars_UnpackFlopCntAndFirstToAL
148 js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
149
150 adc al,1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
151 jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
152
153.UseBIOSorBDA:
154%endif
155 call FloppyDrive_GetCountFromBIOS_or_BDA
156
157.FinishCalc:
158 mov ah, [cs:ROMVARS.bMinFddCnt]
159 MAX_U al, ah
160 cbw
161
162 ret
163
164FloppyDrive_GetCountFromBIOS_or_BDA:
165 push es
166
167;--------------------------------------------------------------------
168; Reads Floppy Drive Count from BIOS.
169; Does not work on most XT systems. Call .GetCountFromBDA
170; if this function fails.
171;
172; .GetCountFromBIOS
173; Parameters:
174; Nothing
175; Returns:
176; AL: Number of Floppy Drives
177; CF: Cleared if successful
178; Set if BIOS function not supported
179; Corrupts registers:
180; ES
181;--------------------------------------------------------------------
182%ifdef USE_AT
183.GetCountFromBIOS:
184 push di
185 push bx
186 push cx
187 push dx
188
189 mov ah, 08h ; Get Drive Parameters
190 cwd ; Floppy Drive 00h
191 int BIOS_DISKETTE_INTERRUPT_40h
192 mov al, dl ; Number of Floppy Drives to AL
193
194 pop dx
195 pop cx
196 pop bx
197 pop di
198%endif
199
200;--------------------------------------------------------------------
201; Reads Floppy Drive Count (0...4) from BIOS Data Area.
202; This function should be used only if .GetCountFromBIOS fails.
203;
204; .GetCountFromBDA
205; Parameters:
206; Nothing
207; Returns:
208; AL: Number of Floppy Drives
209; Corrupts registers:
210; AH, ES
211;--------------------------------------------------------------------
212%ifndef USE_AT
213.GetCountFromBDA:
214 LOAD_BDA_SEGMENT_TO es, ax
215 mov al, [es:BDA.wEquipment] ; Load Equipment WORD low byte
216 mov ah, al ; Copy it to AH
217 and ax, 0C001h ; Leave bits 15..14 and 0
218 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0
219 add al, ah ; AL = Floppy Drive count
220%endif
221
222 pop es
223 ret
Note: See TracBrowser for help on using the repository browser.