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

Last change on this file since 595 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 5.4 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
[531]66 cmp BYTE [es:BIOS_DISKETTE_INTERRUPT_40h*4+3], 0C0h ; Any ROM segment? (set CF if not)
[530]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
[531]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:
[547]160; AH
[3]161;--------------------------------------------------------------------
[530]162FloppyDrive_GetCountFromBIOS_or_BDA:
[567]163%ifdef USE_AT
[530]164; Reads Floppy Drive Count from BIOS.
165; Does not work on most XT systems. Call .GetCountFromBDA
166; if this function fails.
[567]167
168 push es
[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
[551]177 xchg ax, dx ; Number of Floppy Drives to AL
[3]178
[274]179 pop dx
180 pop cx
[3]181 pop bx
182 pop di
[567]183 pop es
[3]184
[567]185%else ; ifndef USE_AT
[3]186; Reads Floppy Drive Count (0...4) from BIOS Data Area.
[294]187; This function should be used only if .GetCountFromBIOS fails.
[531]188
[567]189 push ds
190 LOAD_BDA_SEGMENT_TO ds, ax
191 mov al, [BDA.wEquipment] ; Load Equipment WORD low byte
[592]192 and al, 0C1h ; Leave bits 7..6 and 0
[531]193 eAAM 64
[530]194 add al, ah ; AL = Floppy Drive count
[592]195 pop ds
[531]196%endif ; USE_AT
[258]197
[3]198 ret
Note: See TracBrowser for help on using the repository browser.