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

Last change on this file since 530 was 530, checked in by aitotat@…, 11 years ago

Changes to XTIDE Universal BIOS:

  • AT builds again copy old INT 13h handler to 40h. It turned out it is needed, by XTIDE Universal BIOS at least (fixes disappearing floppy drive hotkey button when booting starts).
  • AH=48h no longer returns P-CHS parameteres for drives with more than 15,482,880 sectors (now works like described on Phoenix specification).
File size: 5.5 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     WORD [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], 0C000h   ; 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, ES
161;--------------------------------------------------------------------
162FloppyDrive_GetCountFromBIOS_or_BDA:
163    push    es
164
165; Reads Floppy Drive Count from BIOS.
166; Does not work on most XT systems. Call .GetCountFromBDA
167; if this function fails.
168%ifdef USE_AT
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    mov     al, dl                  ; Number of Floppy Drives to AL
178
179    pop     dx
180    pop     cx
181    pop     bx
182    pop     di
183
184; Reads Floppy Drive Count (0...4) from BIOS Data Area.
185; This function should be used only if .GetCountFromBIOS fails.
186%else ; ifndef USE_AT
187    LOAD_BDA_SEGMENT_TO es, ax
188    mov     al, [es:BDA.wEquipment] ; Load Equipment WORD low byte
189    mov     ah, al                  ; Copy it to AH
190    and     ax, 0C001h              ; Leave bits 15..14 and 0
191    eROL_IM ah, 2                   ; EW low byte bits 7..6 to 1..0
192    add     al, ah                  ; AL = Floppy Drive count
193%endif
194
195    pop     es
196    ret
Note: See TracBrowser for help on using the repository browser.