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

Last change on this file since 3 was 3, checked in by aitotat, 14 years ago
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   :   2.5.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    jae     SHORT .Int40hIsAlreadyInstalled
28    clc
29    ret
30ALIGN JUMP_ALIGN
31.Int40hIsAlreadyInstalled:
32    stc
33    ret
34
35
36;--------------------------------------------------------------------
37; Returns floppy drive type.
38; PC/XT system do not support AH=08h but FLOPPY_TYPE_525_OR_35_DD
39; is still returned for them.
40;
41; FloppyDrive_GetType
42;   Parameters:
43;       DL:     Floppy Drive number
44;   Returns:
45;       BX:     Floppy Drive Type:
46;                   FLOPPY_TYPE_525_OR_35_DD
47;                   FLOPPY_TYPE_525_DD
48;                   FLOPPY_TYPE_525_HD
49;                   FLOPPY_TYPE_35_DD
50;                   FLOPPY_TYPE_35_HD
51;                   FLOPPY_TYPE_35_ED
52;       CF:     Set if AH=08h not supported (XT systems) or error
53;               Cleared if type read correctly (AT systems)
54;   Corrupts registers:
55;       AX, CX, DX, DI, ES
56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
58FloppyDrive_GetType:
59    mov     ah, 08h         ; Get Drive Parameters
60    xor     bx, bx          ; FLOPPY_TYPE_525_OR_35_DD when function not supported
61    int     INTV_FLOPPY_FUNC
62    ret
63
64
65;--------------------------------------------------------------------
66; Returns number of Floppy Drives in system.
67;
68; FloppyDrive_GetCount
69;   Parameters:
70;       Nothing
71;   Returns:
72;       CX:     Number of Floppy Drives
73;   Corrupts registers:
74;       Nothing
75;--------------------------------------------------------------------
76ALIGN JUMP_ALIGN
77FloppyDrive_GetCount:
78    push    es
79    call    FloppyDrive_GetCountFromBIOS
80    jnc     SHORT .CompareToUserMinimum
81    call    FloppyDrive_GetCountFromBDA
82ALIGN JUMP_ALIGN
83.CompareToUserMinimum:
84    MAX_U   cl, [cs:ROMVARS.bMinFddCnt]
85    xor     ch, ch
86    pop     es
87    ret
88
89
90;--------------------------------------------------------------------
91; Reads Floppy Drive Count from BIOS.
92; Does not work on most XT systems. Call FloppyDrive_GetCountFromBDA
93; if this function fails.
94;
95; FloppyDrive_GetCountFromBIOS
96;   Parameters:
97;       Nothing
98;   Returns:
99;       CL:     Number of Floppy Drives
100;       CF:     Cleared if successfull
101;               Set if BIOS function not supported
102;   Corrupts registers:
103;       CH, ES
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106FloppyDrive_GetCountFromBIOS:
107    push    di
108    push    dx
109    push    bx
110    push    ax
111
112    mov     ah, 08h                 ; Get Drive Parameters
113    xor     dx, dx                  ; Floppy Drive 00h
114    int     INTV_FLOPPY_FUNC
115    mov     cl, dl                  ; Number of Floppy Drives to CL
116
117    pop     ax
118    pop     bx
119    pop     dx
120    pop     di
121    ret
122
123
124;--------------------------------------------------------------------
125; Reads Floppy Drive Count (0...4) from BIOS Data Area.
126; This function should be used only if FloppyDrive_GetCountFromBIOS fails.
127;
128; FloppyDrive_GetCountFromBDA
129;   Parameters:
130;       Nothing
131;   Returns:
132;       CL:     Number of Floppy Drives
133;   Corrupts registers:
134;       CH, ES
135;--------------------------------------------------------------------
136ALIGN JUMP_ALIGN
137FloppyDrive_GetCountFromBDA:
138    LOAD_BDA_SEGMENT_TO es, cx
139    mov     cl, [es:BDA.wEquipment]         ; Load Equipment WORD low byte
140    mov     ch, cl                          ; Copy it to CH
141    and     cx, 0C001h                      ; Leave bits 15..14 and 0
142    eROL_IM ch, 2                           ; EW low byte bits 7..6 to 1..0
143    add     cl, ch                          ; CL = Floppy Drive count
144    ret
Note: See TracBrowser for help on using the repository browser.