source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeDPT.asm @ 622

Last change on this file since 622 was 622, checked in by aitotat, 2 years ago
  • Supported VLB controllers are now forced to 32-bit mode on 386 builds only. AT builds use 16-bit transfers unless configured to 32-bit from xtidecfg
  • Partially fixed support for PDC 20230C VLB IDE controller. PIO-1 drives stay at PIO-0 but PIO-2, 3 and 4 drives are set to maximum speed that PDC2030C supports
  • Large 386 build is now 12k instead of 10k (did not fit to 10k because of the fixes)
File size: 5.7 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Sets IDE Device specific parameters to DPT.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; IdeDPT_Finalize
25;   Parameters:
26;       DS:DI:  Ptr to Disk Parameter Table
27;       ES:SI:  Ptr to 512-byte ATA information read from the drive
28;       CS:BP:  Ptr to IDEVARS for the controller
29;   Returns:
30;       CF:     Clear, IDE interface only supports hard disks
31;   Corrupts registers:
32;       AX, BX, CX, DX
33;--------------------------------------------------------------------
34IdeDPT_Finalize:    ; Unused entrypoint OK
35
36%ifdef MODULE_POWER_MANAGEMENT
37;--------------------------------------------------------------------
38; .DetectPowerManagementSupport
39;   Parameters:
40;       DS:DI:  Ptr to Disk Parameter Table
41;       ES:SI:  Ptr to 512-byte ATA information read from the drive
42;   Returns:
43;       Nothing
44;   Corrupts registers:
45;       AX
46;--------------------------------------------------------------------
47.DetectPowerManagementSupport:
48    mov     ax, A6_wSetSup83_APM << 8 | A6_wSetSup82_POWERMAN   ; Both of these flags are bit 3
49    and     ah, [es:si+ATA6.wSetSup83]
50    and     al, [es:si+ATA6.wSetSup82]
51    eSHL_IM ah, 1                       ; APM bit 3 to bit 4 (same as FLGH_DPT_APM_SUPPORTED)
52    or      al, ah
53    or      [di+DPT.bFlagsHigh], al     ; FLGH_DPT_POWER_MANAGEMENT_SUPPORTED and FLGH_DPT_APM_SUPPORTED
54%endif ; MODULE_POWER_MANAGEMENT
55
56
57;--------------------------------------------------------------------
58; .StoreDeviceType
59;   Parameters:
60;       DS:DI:  Ptr to Disk Parameter Table
61;       CS:BP:  Ptr to IDEVARS for the controller
62;   Returns:
63;       Nothing
64;   Corrupts registers:
65;       AL
66;--------------------------------------------------------------------
67.StoreDeviceType:
68    call    IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
69
70
71;--------------------------------------------------------------------
72; .StoreBlockMode
73;   Parameters:
74;       DS:DI:  Ptr to Disk Parameter Table
75;   Returns:
76;       Nothing
77;   Corrupts registers:
78;       Nothing
79;--------------------------------------------------------------------
80.StoreBlockMode:
81    mov     BYTE [di+DPT_ATA.bBlockSize], 1
82
83
84%ifdef MODULE_ADVANCED_ATA
85;--------------------------------------------------------------------
86; .StorePioModeAndTimings
87;   Parameters:
88;       DS:DI:  Ptr to Disk Parameter Table
89;       ES:SI:  Ptr to 512-byte ATA information read from the drive
90;       CS:BP:  Ptr to IDEVARS for the controller
91;   Returns:
92;       Nothing
93;   Corrupts registers:
94;       AX, BX, CX
95;--------------------------------------------------------------------
96.StorePioMode:
97    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
98    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
99    mov     [di+DPT_ADVANCED_ATA.bPioMode], al
100    or      [di+DPT.bFlagsHigh], ah
101
102
103;--------------------------------------------------------------------
104; .DetectAdvancedIdeController
105;   Parameters:
106;       DS:DI:  Ptr to Disk Parameter Table
107;       ES:SI:  Ptr to 512-byte ATA information read from the drive
108;       CS:BP:  Ptr to IDEVARS for the controller
109;   Returns:
110;       Nothing
111;   Corrupts registers:
112;       AX, BX, CX, DX
113;--------------------------------------------------------------------
114.DetectAdvancedIdeController:
115    ; Detection is only relevant on standard devices. XT-CF seems to give false positive for
116    ; PDC20x30 detection so better to skip detection for 8-bit devices
117    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
118    ja      SHORT .NoAdvancedControllerDetected
119
120    mov     bx, [di+DPT.wBasePort]
121    call    AdvAtaInit_DetectControllerForIdeBaseInBX
122    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
123    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
124    jnc     SHORT .NoAdvancedControllerDetected
125
126    ; Use highest common PIO mode from controller and drive.
127    ; Many VLB controllers support PIO modes up to 2.
128    call    AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX
129    jnz     SHORT .ChangeTo32bitDevice
130
131    and     [di+DPT.bFlagsHigh], ah     ; Mask off FLGH_DPT_IORDY if IORDY not supported
132    MIN_U   [di+DPT_ADVANCED_ATA.bPioMode], al
133    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx
134
135    ; We have detected 32-bit controller so change Device Type since
136    ; it might have been set to 16-bit on IDEVARS
137    ;
138    ; Change to 32-bit on 386 builds only. We leave AT builds unchanged for faster troubleshooting
139    ; and for uncommon systems, like IBM 486SLC2 processors that can have VLB motherboard even though
140    ; the IBM 486SLC2 is externally 16-bit CPU
141.ChangeTo32bitDevice:
142%ifdef USE_386
143    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
144%endif
145.NoAdvancedControllerDetected:
146%endif  ; MODULE_ADVANCED_ATA
147
148    ; End DPT
149    clc
150    ret
151
152
153;--------------------------------------------------------------------
154; IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
155;   Parameters:
156;       DS:DI:  Ptr to Disk Parameter Table
157;       CS:BP:  Ptr to IDEVARS for the controller
158;   Returns:
159;       Nothing
160;   Corrupts registers:
161;       AL
162;--------------------------------------------------------------------
163IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP:
164    mov     al, [cs:bp+IDEVARS.bDevice]
165    mov     [di+DPT_ATA.bDevice], al
166    ret
Note: See TracBrowser for help on using the repository browser.