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

Last change on this file since 438 was 392, checked in by aitotat@…, 13 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
RevLine 
[102]1; Project name : XTIDE Universal BIOS
[3]2; Description : Various floppy drive related functions that
3; Boot Menu uses.
4
[376]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
[3]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
[86]35;--------------------------------------------------------------------
[3]36FloppyDrive_IsInt40hInstalled:
[152]37 cmp WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h ; Any ROM segment?
[102]38%ifdef USE_AT ; No need to verify on XT systems.
[39]39 jb SHORT .Int40hHandlerIsNotInstalled
40 call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
[102]41.Int40hHandlerIsNotInstalled:
[99]42%endif
[27]43 cmc
[3]44 ret
45
[39]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
[86]55;--------------------------------------------------------------------
[99]56%ifdef USE_AT
[39]57.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
58 push es
59 push dx
60 push ax
[3]61
[39]62 call .LoadInt40hVerifyParameters
[152]63 int BIOS_DISK_INTERRUPT_13h
[99]64 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
65 push es
66 push di
[39]67
68 call .LoadInt40hVerifyParameters
[152]69 int BIOS_DISKETTE_INTERRUPT_40h
[39]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?
[99]77 je SHORT .Int40hIsInstalled
[39]78.Int40hNotInstalled:
79 stc
80.Int40hIsInstalled:
81 pop ax
82 pop dx
83 pop es
84 ret
85
[3]86;--------------------------------------------------------------------
[39]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
[86]96;--------------------------------------------------------------------
[39]97.LoadInt40hVerifyParameters:
[86]98 mov ah, 08h ; Get Drive Parameters
99 cwd ; Floppy drive 0
[39]100 mov di, dx
101 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
102 ret
[99]103%endif
[39]104
105
106;--------------------------------------------------------------------
[3]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;--------------------------------------------------------------------
[392]127%ifdef MODULE_BOOT_MENU
[3]128FloppyDrive_GetType:
129 mov ah, 08h ; Get Drive Parameters
130 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
[152]131 int BIOS_DISKETTE_INTERRUPT_40h
[3]132 ret
[392]133%endif
[3]134
135
136;--------------------------------------------------------------------
137; Returns number of Floppy Drives in system.
138;
[258]139; FloppyDrive_GetCountToAX
[3]140; Parameters:
[258]141; DS: RAMVARS Segment
[3]142; Returns:
[258]143; AX: Number of Floppy Drives
[3]144;--------------------------------------------------------------------
[294]145FloppyDrive_GetCountToAX:
[258]146%ifdef MODULE_SERIAL_FLOPPY
147 call RamVars_UnpackFlopCntAndFirstToAL
[270]148 js .UseBIOSorBDA ; We didn't add in any drives, counts here are not valid
[294]149
150 adc al,1 ; adds in the drive count bit, and adds 1 for count vs. 0-index,
[270]151 jmp .FinishCalc ; need to clear AH on the way out, and add in minimum drive numbers
[258]152
[294]153.UseBIOSorBDA:
[99]154%endif
[258]155 call FloppyDrive_GetCountFromBIOS_or_BDA
[270]156
[294]157.FinishCalc:
[258]158 mov ah, [cs:ROMVARS.bMinFddCnt]
159 MAX_U al, ah
160 cbw
[294]161
[3]162 ret
163
[258]164FloppyDrive_GetCountFromBIOS_or_BDA:
165 push es
[3]166
167;--------------------------------------------------------------------
168; Reads Floppy Drive Count from BIOS.
[294]169; Does not work on most XT systems. Call .GetCountFromBDA
[3]170; if this function fails.
171;
[294]172; .GetCountFromBIOS
[3]173; Parameters:
174; Nothing
175; Returns:
[274]176; AL: Number of Floppy Drives
[294]177; CF: Cleared if successful
[3]178; Set if BIOS function not supported
179; Corrupts registers:
[274]180; ES
[3]181;--------------------------------------------------------------------
[99]182%ifdef USE_AT
[258]183.GetCountFromBIOS:
[3]184 push di
[274]185 push bx
186 push cx
[3]187 push dx
188
189 mov ah, 08h ; Get Drive Parameters
[86]190 cwd ; Floppy Drive 00h
[152]191 int BIOS_DISKETTE_INTERRUPT_40h
[258]192 mov al, dl ; Number of Floppy Drives to AL
[3]193
[274]194 pop dx
195 pop cx
[3]196 pop bx
197 pop di
[99]198%endif
[3]199
200;--------------------------------------------------------------------
201; Reads Floppy Drive Count (0...4) from BIOS Data Area.
[294]202; This function should be used only if .GetCountFromBIOS fails.
[3]203;
[294]204; .GetCountFromBDA
[3]205; Parameters:
206; Nothing
207; Returns:
[294]208; AL: Number of Floppy Drives
[3]209; Corrupts registers:
[294]210; AH, ES
[3]211;--------------------------------------------------------------------
[99]212%ifndef USE_AT
[258]213.GetCountFromBDA:
214 LOAD_BDA_SEGMENT_TO es, ax
215 mov al, [es:BDA.wEquipment] ; Load Equipment WORD low byte
[294]216 mov ah, al ; Copy it to AH
[258]217 and ax, 0C001h ; Leave bits 15..14 and 0
218 eROL_IM ah, 2 ; EW low byte bits 7..6 to 1..0
[294]219 add al, ah ; AL = Floppy Drive count
[258]220%endif
221
222 pop es
[3]223 ret
Note: See TracBrowser for help on using the repository browser.