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

Last change on this file since 101 was 99, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Even more initialization code inlining.
File size: 5.3 KB
RevLine 
[3]1; Project name : IDE BIOS
2; Description : Various floppy drive related functions that
3; Boot Menu uses.
4
5; Section containing code
6SECTION .text
7
8;--------------------------------------------------------------------
9; Checks is floppy drive handler installed to interrupt vector 40h.
10;
11; FloppyDrive_IsInt40hInstalled
12; Parameters:
13; ES: BDA and Interrupt Vector segment (zero)
14; Returns:
15; CF: Set if INT 40h is installed
16; Cleared if INT 40h is not installed
17; Corrupts registers:
18; BX, CX, DI
[86]19;--------------------------------------------------------------------
[3]20FloppyDrive_IsInt40hInstalled:
21 cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment?
[39]22 jb SHORT .Int40hHandlerIsNotInstalled
[99]23%ifdef USE_AT
[39]24 call .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
[99]25%else
26 clc ; INT 40h installed. No need to verify on XT systems.
27%endif
[39]28.Int40hHandlerIsNotInstalled:
[27]29 cmc
[3]30 ret
31
[39]32;--------------------------------------------------------------------
33; .VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h
34; Parameters:
35; Nothing
36; Returns:
37; CF: Cleared if INT 40h is installed
38; Set if INT 40h is not installed
39; Corrupts registers:
40; BX, CX, DI
[86]41;--------------------------------------------------------------------
[99]42%ifdef USE_AT
[39]43.VerifyInt40hHandlerSinceSomeBiosesSimplyReturnFromInt40h:
44 push es
45 push dx
46 push ax
[3]47
[39]48 call .LoadInt40hVerifyParameters
49 int INTV_DISK_FUNC
[99]50 jc SHORT .Int40hIsInstalled ; Maybe there are not any floppy drives at all
51 push es
52 push di
[39]53
54 call .LoadInt40hVerifyParameters
55 int INTV_FLOPPY_FUNC
56
57 pop dx
58 pop cx
59 cmp dx, di ; Difference in offsets?
60 jne SHORT .Int40hNotInstalled
61 mov dx, es
62 cmp cx, dx ; Difference in segments?
[99]63 je SHORT .Int40hIsInstalled
[39]64.Int40hNotInstalled:
65 stc
66.Int40hIsInstalled:
67 pop ax
68 pop dx
69 pop es
70 ret
71
[3]72;--------------------------------------------------------------------
[39]73; .LoadInt40hVerifyParameters
74; Parameters:
75; Nothing
76; Returns:
77; AH: 08h (Get Drive Parameters)
78; DL: 00h (floppy drive)
79; ES:DI: 0:0h (to guard against BIOS bugs)
80; Corrupts registers:
81; DH
[86]82;--------------------------------------------------------------------
[39]83.LoadInt40hVerifyParameters:
[86]84 mov ah, 08h ; Get Drive Parameters
85 cwd ; Floppy drive 0
[39]86 mov di, dx
87 mov es, dx ; ES:DI = 0000:0000h to guard against BIOS bugs
88 ret
[99]89%endif
[39]90
91
92;--------------------------------------------------------------------
[3]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;--------------------------------------------------------------------
113ALIGN JUMP_ALIGN
114FloppyDrive_GetType:
115 mov ah, 08h ; Get Drive Parameters
116 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
117 int INTV_FLOPPY_FUNC
118 ret
119
120
121;--------------------------------------------------------------------
122; Returns number of Floppy Drives in system.
123;
124; FloppyDrive_GetCount
125; Parameters:
126; Nothing
127; Returns:
128; CX: Number of Floppy Drives
129; Corrupts registers:
130; Nothing
131;--------------------------------------------------------------------
132ALIGN JUMP_ALIGN
133FloppyDrive_GetCount:
134 push es
[99]135%ifdef USE_AT
[3]136 call FloppyDrive_GetCountFromBIOS
[99]137%else
[3]138 call FloppyDrive_GetCountFromBDA
[99]139%endif
[3]140 MAX_U cl, [cs:ROMVARS.bMinFddCnt]
141 xor ch, ch
142 pop es
143 ret
144
145
146;--------------------------------------------------------------------
147; Reads Floppy Drive Count from BIOS.
148; Does not work on most XT systems. Call FloppyDrive_GetCountFromBDA
149; if this function fails.
150;
151; FloppyDrive_GetCountFromBIOS
152; Parameters:
153; Nothing
154; Returns:
155; CL: Number of Floppy Drives
156; CF: Cleared if successfull
157; Set if BIOS function not supported
158; Corrupts registers:
159; CH, ES
160;--------------------------------------------------------------------
[99]161%ifdef USE_AT
[3]162ALIGN JUMP_ALIGN
163FloppyDrive_GetCountFromBIOS:
164 push di
165 push dx
166 push bx
167 push ax
168
169 mov ah, 08h ; Get Drive Parameters
[86]170 cwd ; Floppy Drive 00h
[3]171 int INTV_FLOPPY_FUNC
172 mov cl, dl ; Number of Floppy Drives to CL
173
174 pop ax
175 pop bx
176 pop dx
177 pop di
178 ret
[99]179%endif
[3]180
181
182;--------------------------------------------------------------------
183; Reads Floppy Drive Count (0...4) from BIOS Data Area.
184; This function should be used only if FloppyDrive_GetCountFromBIOS fails.
185;
186; FloppyDrive_GetCountFromBDA
187; Parameters:
188; Nothing
189; Returns:
190; CL: Number of Floppy Drives
191; Corrupts registers:
192; CH, ES
193;--------------------------------------------------------------------
[99]194%ifndef USE_AT
[3]195ALIGN JUMP_ALIGN
196FloppyDrive_GetCountFromBDA:
197 LOAD_BDA_SEGMENT_TO es, cx
198 mov cl, [es:BDA.wEquipment] ; Load Equipment WORD low byte
199 mov ch, cl ; Copy it to CH
200 and cx, 0C001h ; Leave bits 15..14 and 0
201 eROL_IM ch, 2 ; EW low byte bits 7..6 to 1..0
202 add cl, ch ; CL = Floppy Drive count
203 ret
[99]204%endif
Note: See TracBrowser for help on using the repository browser.