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

Last change on this file since 526 was 526, checked in by krille_n_@…, 11 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 4.9 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:
35
36%ifdef MODULE_FEATURE_SETS
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;       Nothing
46;--------------------------------------------------------------------
47.DetectPowerManagementSupport:
48    test    BYTE [es:si+ATA6.wSetSup82], A6_wSetSup82_POWERMAN
49    jz      SHORT .NoPowerManagementSupport
50    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_POWER_MANAGEMENT_SUPPORTED
51.NoPowerManagementSupport:
52%endif ; MODULE_FEATURE_SETS
53
54
55;--------------------------------------------------------------------
56; .StoreDeviceType
57;   Parameters:
58;       DS:DI:  Ptr to Disk Parameter Table
59;       CS:BP:  Ptr to IDEVARS for the controller
60;   Returns:
61;       Nothing
62;   Corrupts registers:
63;       AL
64;--------------------------------------------------------------------
65.StoreDeviceType:
66    call    IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
67
68
69;--------------------------------------------------------------------
70; .StoreBlockMode
71;   Parameters:
72;       DS:DI:  Ptr to Disk Parameter Table
73;   Returns:
74;       Nothing
75;   Corrupts registers:
76;       Nothing
77;--------------------------------------------------------------------
78.StoreBlockMode:
79    mov     BYTE [di+DPT_ATA.bBlockSize], 1
80
81
82%ifdef MODULE_ADVANCED_ATA
83;--------------------------------------------------------------------
84; .StorePioModeAndTimings
85;   Parameters:
86;       DS:DI:  Ptr to Disk Parameter Table
87;       ES:SI:  Ptr to 512-byte ATA information read from the drive
88;       CS:BP:  Ptr to IDEVARS for the controller
89;   Returns:
90;       Nothing
91;   Corrupts registers:
92;       AX, BX, CX
93;--------------------------------------------------------------------
94.StorePioMode:
95    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
96    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
97    mov     [di+DPT_ADVANCED_ATA.bPioMode], al
98    or      [di+DPT.bFlagsHigh], ah
99
100
101;--------------------------------------------------------------------
102; .DetectAdvancedIdeController
103;   Parameters:
104;       DS:DI:  Ptr to Disk Parameter Table
105;       ES:SI:  Ptr to 512-byte ATA information read from the drive
106;       CS:BP:  Ptr to IDEVARS for the controller
107;   Returns:
108;       Nothing
109;   Corrupts registers:
110;       AX, BX, CX, DX
111;--------------------------------------------------------------------
112.DetectAdvancedIdeController:
113    mov     bx, [di+DPT.wBasePort]
114    call    AdvAtaInit_DetectControllerForIdeBaseInBX
115    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
116    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
117    jnc     SHORT .NoAdvancedControllerDetected
118
119    ; Use highest common PIO mode from controller and drive.
120    ; Many VLB controllers support PIO modes up to 2.
121    call    AdvAtaInit_GetControllerMaxPioModeToAL
122    jnc     SHORT .ChangeTo32bitDevice
123    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY   ; No IORDY supported if need to limit
124    MIN_U   [di+DPT_ADVANCED_ATA.bPioMode], al
125
126    ; We have detected 32-bit controller so change Device Type since
127    ; it might have been set to 16-bit on IDEVARS
128.ChangeTo32bitDevice:
129    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
130.NoAdvancedControllerDetected:
131%endif  ; MODULE_ADVANCED_ATA
132
133
134; End DPT
135    clc
136    ret
137
138
139;--------------------------------------------------------------------
140; IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
141;   Parameters:
142;       DS:DI:  Ptr to Disk Parameter Table
143;       CS:BP:  Ptr to IDEVARS for the controller
144;   Returns:
145;       Nothing
146;   Corrupts registers:
147;       AL
148;--------------------------------------------------------------------
149IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP:
150    mov     al, [cs:bp+IDEVARS.bDevice]
151    mov     [di+DPT_ATA.bDevice], al
152    ret
Note: See TracBrowser for help on using the repository browser.