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

Last change on this file since 595 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 5.4 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;--------------------------------------------------------------------
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%ifdef USE_AT
38 push es
39 push dx
40 push ax
41
42 call LoadInt40hVerifyParameters
43 int BIOS_DISK_INTERRUPT_13h
44 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
45 push es ; Drive Parameter Table segment
46 push di ; Drive Parameter Table offset
47
48 call LoadInt40hVerifyParameters
49 int BIOS_DISKETTE_INTERRUPT_40h
50
51 pop dx
52 pop cx
53 cmp dx, di ; Difference in offsets?
54 jne SHORT .Int40hNotInstalled
55 mov dx, es
56 cmp cx, dx ; Difference in segments?
57 je SHORT .Int40hIsInstalled
58.Int40hNotInstalled:
59 stc
60.Int40hIsInstalled:
61 pop ax
62 pop dx
63 pop es
64
65%else ; if XT build
66 cmp BYTE [es:BIOS_DISKETTE_INTERRUPT_40h*4+3], 0C0h ; Any ROM segment? (set CF if not)
67%endif ; USE_AT
68 cmc
69 ret
70
71;--------------------------------------------------------------------
72; LoadInt40hVerifyParameters
73; Parameters:
74; Nothing
75; Returns:
76; AH: 08h (Get Drive Parameters)
77; DL: 00h (floppy drive)
78; ES:DI: 0:0h (to guard against BIOS bugs)
79; Corrupts registers:
80; DH
81;--------------------------------------------------------------------
82%ifdef USE_AT
83LoadInt40hVerifyParameters:
84 mov ah, GET_DRIVE_PARAMETERS
85 cwd ; Floppy drive 0
86 mov di, dx
87 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
88 ret
89%endif
90
91
92;--------------------------------------------------------------------
93; Returns floppy drive type.
94; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
95; is still returned for them.
96;
97; FloppyDrive_GetType
98; Parameters:
99; DL: Floppy Drive number
100; Returns:
101; BX: Floppy Drive Type:
102; FLOPPY_TYPE_525_OR_35_DD
103; FLOPPY_TYPE_525_DD
104; FLOPPY_TYPE_525_HD
105; FLOPPY_TYPE_35_DD
106; FLOPPY_TYPE_35_HD
107; FLOPPY_TYPE_35_ED
108; CF: Set if AH=08h not supported (XT systems) or error
109; Cleared if type read correctly (AT systems)
110; Corrupts registers:
111; AX, CX, DX, DI, ES
112;--------------------------------------------------------------------
113%ifdef MODULE_BOOT_MENU
114FloppyDrive_GetType:
115 mov ah, GET_DRIVE_PARAMETERS
116 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
117 int BIOS_DISKETTE_INTERRUPT_40h
118 ret
119%endif
120
121
122;--------------------------------------------------------------------
123; Returns number of Floppy Drives in system.
124;
125; FloppyDrive_GetCountToAX
126; Parameters:
127; DS: RAMVARS Segment
128; Returns:
129; AX: Number of Floppy Drives
130;--------------------------------------------------------------------
131FloppyDrive_GetCountToAX:
132%ifdef MODULE_SERIAL_FLOPPY
133 call RamVars_UnpackFlopCntAndFirstToAL
134 js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
135
136 adc al, 1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
137 jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
138
139.UseBIOSorBDA:
140%endif
141 call FloppyDrive_GetCountFromBIOS_or_BDA
142
143.FinishCalc:
144 mov ah, [cs:ROMVARS.bMinFddCnt]
145 MAX_U al, ah
146 cbw
147
148 ret
149
150
151;--------------------------------------------------------------------
152; FloppyDrive_GetCountFromBIOS_or_BDA
153; Parameters:
154; Nothing
155; Returns:
156; AL: Number of Floppy Drives
157; CF: Cleared if successful
158; Set if BIOS function not supported
159; Corrupts registers:
160; AH
161;--------------------------------------------------------------------
162FloppyDrive_GetCountFromBIOS_or_BDA:
163%ifdef USE_AT
164; Reads Floppy Drive Count from BIOS.
165; Does not work on most XT systems. Call .GetCountFromBDA
166; if this function fails.
167
168 push es
169 push di
170 push bx
171 push cx
172 push dx
173
174 mov ah, GET_DRIVE_PARAMETERS
175 cwd ; Floppy Drive 00h
176 int BIOS_DISKETTE_INTERRUPT_40h
177 xchg ax, dx ; Number of Floppy Drives to AL
178
179 pop dx
180 pop cx
181 pop bx
182 pop di
183 pop es
184
185%else ; ifndef USE_AT
186; Reads Floppy Drive Count (0...4) from BIOS Data Area.
187; This function should be used only if .GetCountFromBIOS fails.
188
189 push ds
190 LOAD_BDA_SEGMENT_TO ds, ax
191 mov al, [BDA.wEquipment] ; Load Equipment WORD low byte
192 and al, 0C1h ; Leave bits 7..6 and 0
193 eAAM 64
194 add al, ah ; AL = Floppy Drive count
195 pop ds
196%endif ; USE_AT
197
198 ret
Note: See TracBrowser for help on using the repository browser.