source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/AdvancedAta/AdvAtaInit.asm@ 593

Last change on this file since 593 was 593, checked in by Tomi Tilli, 6 years ago

Flashing now works again.
Hack to get Windows 95 to work properly (MODULE_WIN95_CMOS_HACK included for 386 builds by default).
Edited makefile to produce large 386 build.
Fixed recovery time for QDI Vision VLB-IDE controllers.
No more warnings with Nasm 2.13.xx and later.
File dialog now properly restores default drive when file selection is cancelled.

File size: 6.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Common functions for initializing different
3; VLB and PCI IDE Controllers.
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; AdvAtaInit_DetectControllerForIdeBaseInBX
26; Parameters:
27; BX: IDE Controller base port
28; Returns:
29; AX: ID WORD specific for detected controller
30; Zero if no controller detected
31; DX: Controller base port (not IDE)
32; CF: Set if controller detected
33; Cleared if no controller
34; Corrupts registers:
35; BX, CX
36;--------------------------------------------------------------------
37AdvAtaInit_DetectControllerForIdeBaseInBX:
38 ; Detect if system has PCI bus. If it does, we can skip VLB detection. This is
39 ; good thing since detecting Vision QD6850 is dangerous since Intel PIIX4 south bridge
40 ; mirrors Interrupt Controller registers from Axh to Bxh. This can lead to faulty
41 ; detection of QD6850 that will eventually crash the system when ports are written.
42
43 ; We should save the 32-bit registers but we don't since system BIOS has stored
44 ; them already and we don't use the 32-bit registers ourselves anywhere at the moment.
45 push bx
46 push di
47 xor edi, edi ; Some BIOSes require this to be set to zero
48 mov ax, PCI_INSTALLATION_CHECK
49 int BIOS_TIME_PCI_PNP_1Ah
50 pop di
51 pop bx
52 test ah, ah
53 jz SHORT .ThisSystemHasPCIbus
54
55 ; Detect VLB controllers
56 call Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent
57 jnz SHORT .NoVisionControllerFound
58
59 call Vision_DoesIdePortInBXbelongToControllerWithIDinAX
60 jz SHORT .AdvancedControllerFoundForPortBX
61
62.NoVisionControllerFound:
63 call PDC20x30_DetectControllerForIdeBaseInBX
64 jnc SHORT .NoAdvancedControllerForPortBX
65
66.AdvancedControllerFoundForPortBX:
67 stc
68 ret
69
70.NoAdvancedControllerForPortBX:
71.ThisSystemHasPCIbus:
72 xor ax, ax ; Clear ID in AX and CF
73 ret
74
75
76;--------------------------------------------------------------------
77; AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX
78; Parameters:
79; AX: ID WORD specific for detected controller
80; Returns:
81; AL: Max supported PIO mode (only if ZF set)
82; AH: ~FLGH_DPT_IORDY if IORDY not supported, -1 otherwise (only if ZF set)
83; BX: Min PIO cycle time (only if ZF set)
84; ZF: Set if PIO limit necessary
85; Cleared if no need to limit timings
86; Corrupts registers:
87; Nothing
88;--------------------------------------------------------------------
89AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX:
90 cmp ah, ID_QD6580_ALTERNATE
91%ifdef USE_386
92 jae Vision_GetMaxPioModeToALandMinCycleTimeToBX
93 jmp PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX
94%else
95 jae SHORT .Vision
96 jmp PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX
97.Vision:
98 jmp Vision_GetMaxPioModeToALandMinCycleTimeToBX
99%endif
100
101
102;--------------------------------------------------------------------
103; AdvAtaInit_InitializeControllerForDPTinDSDI
104; Parameters:
105; DS:DI: Ptr to DPT for Single or Slave Drive
106; Returns:
107; AH: Int 13h return status
108; CF: Cleared if success or no controller to initialize
109; Set if error
110; Corrupts registers:
111; AL, BX, CX, DX
112;--------------------------------------------------------------------
113AdvAtaInit_InitializeControllerForDPTinDSDI:
114 ; Call Controller Specific initialization function
115 mov ax, [di+DPT_ADVANCED_ATA.wControllerID]
116 test ax, ax
117 jz SHORT .NoAdvancedController ; Return with CF cleared
118
119 cmp ah, ID_QD6580_ALTERNATE
120 jae SHORT .Vision
121 jmp PDC20x30_InitializeForDPTinDSDI
122
123.Vision:
124 push bp
125 push si
126
127 call AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
128 call Vision_InitializeWithIDinAH
129 xor ax, ax ; Success
130
131 pop si
132 pop bp
133
134.NoAdvancedController:
135 ret
136
137
138;--------------------------------------------------------------------
139; AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI
140; Parameters:
141; DS:DI: Ptr to DPT for Single or Slave Drive
142; Returns:
143; SI: Offset to Master DPT if Slave Drive present
144; Zero if Slave Drive not present
145; Corrupts registers:
146; AL
147;--------------------------------------------------------------------
148AdvAtaInit_LoadMasterDPTtoDSSIifSlaveInDSDI:
149 ; Must be Slave Drive if previous DPT has same IDEVARS offset
150 lea si, [di-LARGEST_DPT_SIZE] ; DS:SI points to previous DPT
151 mov al, [di+DPT.bIdevarsOffset]
152 cmp al, [si+DPT.bIdevarsOffset]
153 je SHORT .MasterAndSlaveDrivePresent
154
155 ; We only have single drive so zero SI
156 xor si, si
157.MasterAndSlaveDrivePresent:
158 ret
159
160
161;--------------------------------------------------------------------
162; AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI
163; Parameters:
164; DS:DI: Ptr to DPT for Single or Slave Drive
165; SI: Offset to Master DPT if Slave Drive present
166; Zero if Slave Drive not present
167; Returns:
168; BX: Best common PIO mode
169; CX: Slowest common PIO Cycle Time in nanosecs
170; Corrupts registers:
171; Nothing
172;--------------------------------------------------------------------
173AdvAtaInit_SelectSlowestCommonPioTimingsToBXandCXfromDSSIandDSDI:
174 eMOVZX bx, [di+DPT_ADVANCED_ATA.bPioMode]
175 mov cx, [di+DPT_ADVANCED_ATA.wMinPioCycleTime]
176 test si, si
177 jz SHORT .PioTimingsLoadedToBXandCX
178 MIN_U bl, [si+DPT_ADVANCED_ATA.bPioMode]
179 MAX_U cx, [si+DPT_ADVANCED_ATA.wMinPioCycleTime]
180.PioTimingsLoadedToBXandCX:
181 ret
Note: See TracBrowser for help on using the repository browser.