source: xtideuniversalbios/tags/XTIDE_Universal_BIOS_v1.1.4/Src/Initialization/FloppyDrive.asm@ 579

Last change on this file since 579 was 27, checked in by Tomi Tilli, 14 years ago
  • v1.1.1 broke booting from foreign drives, it is now fixed.
  • Fixed a bug where Disk Parameter Table was accessed with wrong pointer register after writing last block.
  • Cleaned AH=00h, Disk Controller Reset a bit.
  • Timeout errors might now get translated for better error codes on certain situations.
File size: 3.8 KB
Line 
1; File name : FloppyDrive.asm
2; Project name : IDE BIOS
3; Created date : 25.3.2010
4; Last update : 28.7.2010
5; Author : Tomi Tilli
6; Description : Various floppy drive related functions that
7; Boot Menu uses.
8
9; Section containing code
10SECTION .text
11
12;--------------------------------------------------------------------
13; Checks is floppy drive handler installed to interrupt vector 40h.
14;
15; FloppyDrive_IsInt40hInstalled
16; Parameters:
17; ES: BDA and Interrupt Vector segment (zero)
18; Returns:
19; CF: Set if INT 40h is installed
20; Cleared if INT 40h is not installed
21; Corrupts registers:
22; BX, CX, DI
23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25FloppyDrive_IsInt40hInstalled:
26 cmp WORD [es:INTV_FLOPPY_FUNC*4+2], 0C000h ; Any ROM segment?
27 cmc
28 ret
29
30
31;--------------------------------------------------------------------
32; Returns floppy drive type.
33; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
34; is still returned for them.
35;
36; FloppyDrive_GetType
37; Parameters:
38; DL: Floppy Drive number
39; Returns:
40; BX: Floppy Drive Type:
41; FLOPPY_TYPE_525_OR_35_DD
42; FLOPPY_TYPE_525_DD
43; FLOPPY_TYPE_525_HD
44; FLOPPY_TYPE_35_DD
45; FLOPPY_TYPE_35_HD
46; FLOPPY_TYPE_35_ED
47; CF: Set if AH=08h not supported (XT systems) or error
48; Cleared if type read correctly (AT systems)
49; Corrupts registers:
50; AX, CX, DX, DI, ES
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53FloppyDrive_GetType:
54 mov ah, 08h ; Get Drive Parameters
55 xor bx, bx ; FLOPPY_TYPE_525_OR_35_DD when function not supported
56 int INTV_FLOPPY_FUNC
57 ret
58
59
60;--------------------------------------------------------------------
61; Returns number of Floppy Drives in system.
62;
63; FloppyDrive_GetCount
64; Parameters:
65; Nothing
66; Returns:
67; CX: Number of Floppy Drives
68; Corrupts registers:
69; Nothing
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72FloppyDrive_GetCount:
73 push es
74 call FloppyDrive_GetCountFromBIOS
75 jnc SHORT .CompareToUserMinimum
76 call FloppyDrive_GetCountFromBDA
77ALIGN JUMP_ALIGN
78.CompareToUserMinimum:
79 MAX_U cl, [cs:ROMVARS.bMinFddCnt]
80 xor ch, ch
81 pop es
82 ret
83
84
85;--------------------------------------------------------------------
86; Reads Floppy Drive Count from BIOS.
87; Does not work on most XT systems. Call FloppyDrive_GetCountFromBDA
88; if this function fails.
89;
90; FloppyDrive_GetCountFromBIOS
91; Parameters:
92; Nothing
93; Returns:
94; CL: Number of Floppy Drives
95; CF: Cleared if successfull
96; Set if BIOS function not supported
97; Corrupts registers:
98; CH, ES
99;--------------------------------------------------------------------
100ALIGN JUMP_ALIGN
101FloppyDrive_GetCountFromBIOS:
102 push di
103 push dx
104 push bx
105 push ax
106
107 mov ah, 08h ; Get Drive Parameters
108 xor dx, dx ; Floppy Drive 00h
109 int INTV_FLOPPY_FUNC
110 mov cl, dl ; Number of Floppy Drives to CL
111
112 pop ax
113 pop bx
114 pop dx
115 pop di
116 ret
117
118
119;--------------------------------------------------------------------
120; Reads Floppy Drive Count (0...4) from BIOS Data Area.
121; This function should be used only if FloppyDrive_GetCountFromBIOS fails.
122;
123; FloppyDrive_GetCountFromBDA
124; Parameters:
125; Nothing
126; Returns:
127; CL: Number of Floppy Drives
128; Corrupts registers:
129; CH, ES
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132FloppyDrive_GetCountFromBDA:
133 LOAD_BDA_SEGMENT_TO es, cx
134 mov cl, [es:BDA.wEquipment] ; Load Equipment WORD low byte
135 mov ch, cl ; Copy it to CH
136 and cx, 0C001h ; Leave bits 15..14 and 0
137 eROL_IM ch, 2 ; EW low byte bits 7..6 to 1..0
138 add cl, ch ; CL = Floppy Drive count
139 ret
Note: See TracBrowser for help on using the repository browser.