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
RevLine 
[102]1; Project name  :   XTIDE Universal BIOS
[3]2; Description   :   Various floppy drive related functions that
3;                   Boot Menu uses.
4
[376]5;
[526]6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[526]13;
[376]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
[526]17; GNU General Public License for more details.
[376]18; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[526]19;
[376]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:
[99]37%ifdef USE_AT
[39]38    push    es
39    push    dx
40    push    ax
[3]41
[530]42    call    LoadInt40hVerifyParameters
[152]43    int     BIOS_DISK_INTERRUPT_13h
[99]44    jc      SHORT .Int40hIsInstalled    ; Maybe there are not any floppy drives at all
[530]45    push    es                          ; Drive Parameter Table segment
46    push    di                          ; Drive Parameter Table offset
[39]47
[530]48    call    LoadInt40hVerifyParameters
[152]49    int     BIOS_DISKETTE_INTERRUPT_40h
[39]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?
[99]57    je      SHORT .Int40hIsInstalled
[39]58.Int40hNotInstalled:
59    stc
60.Int40hIsInstalled:
61    pop     ax
62    pop     dx
63    pop     es
[530]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
[39]69    ret
70
[3]71;--------------------------------------------------------------------
[530]72; LoadInt40hVerifyParameters
[39]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
[86]81;--------------------------------------------------------------------
[530]82%ifdef USE_AT
83LoadInt40hVerifyParameters:
84    mov     ah, GET_DRIVE_PARAMETERS
85    cwd                     ; Floppy drive 0
[39]86    mov     di, dx
[530]87    mov     es, dx          ; ES:DI = 0000:0000h to guard against BIOS bugs
[39]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;--------------------------------------------------------------------
[392]113%ifdef MODULE_BOOT_MENU
[3]114FloppyDrive_GetType:
[530]115    mov     ah, GET_DRIVE_PARAMETERS
[3]116    xor     bx, bx          ; FLOPPY_TYPE_525_OR_35_DD when function not supported
[152]117    int     BIOS_DISKETTE_INTERRUPT_40h
[3]118    ret
[392]119%endif
[3]120
121
122;--------------------------------------------------------------------
123; Returns number of Floppy Drives in system.
124;
[258]125; FloppyDrive_GetCountToAX
[3]126;   Parameters:
[258]127;       DS:     RAMVARS Segment
[3]128;   Returns:
[258]129;       AX:     Number of Floppy Drives
[3]130;--------------------------------------------------------------------
[294]131FloppyDrive_GetCountToAX:
[258]132%ifdef MODULE_SERIAL_FLOPPY
133    call    RamVars_UnpackFlopCntAndFirstToAL
[270]134    js      .UseBIOSorBDA               ; We didn't add in any drives, counts here are not valid
[294]135
[530]136    adc     al ,1                       ; adds in the drive count bit, and adds 1 for count vs. 0-index,
[270]137    jmp     .FinishCalc                 ; need to clear AH on the way out, and add in minimum drive numbers
[258]138
[294]139.UseBIOSorBDA:
[99]140%endif
[258]141    call    FloppyDrive_GetCountFromBIOS_or_BDA
[270]142
[294]143.FinishCalc:
[258]144    mov     ah, [cs:ROMVARS.bMinFddCnt]
145    MAX_U   al, ah
146    cbw
[294]147
[3]148    ret
149
150
151;--------------------------------------------------------------------
[530]152; FloppyDrive_GetCountFromBIOS_or_BDA
[3]153;   Parameters:
154;       Nothing
155;   Returns:
[274]156;       AL:     Number of Floppy Drives
[294]157;       CF:     Cleared if successful
[3]158;               Set if BIOS function not supported
159;   Corrupts registers:
[530]160;       AH, ES
[3]161;--------------------------------------------------------------------
[530]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.
[99]168%ifdef USE_AT
[3]169    push    di
[274]170    push    bx
171    push    cx
[3]172    push    dx
173
[530]174    mov     ah, GET_DRIVE_PARAMETERS
[86]175    cwd                             ; Floppy Drive 00h
[152]176    int     BIOS_DISKETTE_INTERRUPT_40h
[258]177    mov     al, dl                  ; Number of Floppy Drives to AL
[3]178
[274]179    pop     dx
180    pop     cx
[3]181    pop     bx
182    pop     di
183
184; Reads Floppy Drive Count (0...4) from BIOS Data Area.
[294]185; This function should be used only if .GetCountFromBIOS fails.
[530]186%else ; ifndef USE_AT
[258]187    LOAD_BDA_SEGMENT_TO es, ax
[530]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
[258]193%endif
194
195    pop     es
[3]196    ret
Note: See TracBrowser for help on using the repository browser.