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

Last change on this file since 376 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 5.2 KB
RevLine 
[150]1; Project name  :   XTIDE Universal BIOS
2; Description   :   Sets IDE Device specific parameters to DPT.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools 
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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
[150]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
[160]28;       CS:BP:  Ptr to IDEVARS for the controller
[150]29;   Returns:
[258]30;       CF:     Clear, IDE interface only supports hard disks
[150]31;   Corrupts registers:
[363]32;       AX, BX, CX, DX
[150]33;--------------------------------------------------------------------
34IdeDPT_Finalize:
35
36;--------------------------------------------------------------------
37; .StoreBlockMode
38;   Parameters:
39;       DS:DI:  Ptr to Disk Parameter Table
40;       ES:SI:  Ptr to 512-byte ATA information read from the drive
[160]41;       CS:BP:  Ptr to IDEVARS for the controller
[150]42;   Returns:
43;       Nothing
44;   Corrupts registers:
[242]45;       AX
[150]46;--------------------------------------------------------------------
47.StoreBlockMode:
[365]48    mov     BYTE [di+DPT_ATA.bBlockSize], 1
[150]49
[363]50%ifdef MODULE_ADVANCED_ATA
[160]51;--------------------------------------------------------------------
[363]52; .StoreDeviceType
53;   Parameters:
54;       DS:DI:  Ptr to Disk Parameter Table
55;       ES:SI:  Ptr to 512-byte ATA information read from the drive
56;       CS:BP:  Ptr to IDEVARS for the controller
57;   Returns:
58;       Nothing
59;   Corrupts registers:
60;       Nothing
61;--------------------------------------------------------------------
62.StoreDeviceType:
63    call    IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
64
65;--------------------------------------------------------------------
66; .StorePioModeAndTimings
67;   Parameters:
68;       DS:DI:  Ptr to Disk Parameter Table
69;       ES:SI:  Ptr to 512-byte ATA information read from the drive
70;       CS:BP:  Ptr to IDEVARS for the controller
71;   Returns:
72;       Nothing
73;   Corrupts registers:
[364]74;       AX, BX, CX
[363]75;--------------------------------------------------------------------
76.StorePioMode:
[364]77    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
78    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
79    mov     [di+DPT_ADVANCED_ATA.bPioMode], al
80    or      [di+DPT.bFlagsHigh], ah 
[363]81
82;--------------------------------------------------------------------
83; .DetectAdvancedIdeController
84;   Parameters:
85;       DS:DI:  Ptr to Disk Parameter Table
86;       ES:SI:  Ptr to 512-byte ATA information read from the drive
87;       CS:BP:  Ptr to IDEVARS for the controller
88;   Returns:
89;       Nothing
90;   Corrupts registers:
91;       AX, BX, CX, DX
92;--------------------------------------------------------------------
93.DetectAdvancedIdeController:
[364]94    call    AccessDPT_GetIdeBasePortToBX
95    call    AdvAtaInit_DetectControllerForIdeBaseInBX
[363]96    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
[364]97    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
[363]98    jnc     SHORT .NoAdvancedControllerDetected
99
100    ; Use highest common PIO mode from controller and drive.
101    ; Many VLB controllers support PIO modes up to 2.
102    call    AdvAtaInit_GetControllerMaxPioModeToAL
103    jnc     SHORT .ChangeTo32bitDevice
[364]104    and     BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_IORDY   ; No IORDY supported if need to limit
105    MIN_U   [di+DPT_ADVANCED_ATA.bPioMode], al
[363]106
107    ; We have detected 32-bit controller so change Device Type since
108    ; it might have been set to 16-bit on IDEVARS
109.ChangeTo32bitDevice:
[364]110    mov     BYTE [di+DPT_ADVANCED_ATA.bDevice], DEVICE_32BIT_ATA
[363]111
112.NoAdvancedControllerDetected:
113
114%endif ; MODULE_ADVANCED_ATA
115
116;--------------------------------------------------------------------
[160]117; IdeDPT_StoreReversedAddressLinesFlagIfNecessary
118;   Parameters:
119;       DS:DI:  Ptr to Disk Parameter Table
120;       CS:BP:  Ptr to IDEVARS for the controller
121;   Returns:
[363]122;       CF:     Always clear
[160]123;   Corrupts registers:
124;       Nothing
125;--------------------------------------------------------------------
126IdeDPT_StoreReversedAddressLinesFlagIfNecessary:
[361]127    cmp     BYTE [cs:bp+IDEVARS.bDevice], DEVICE_XTIDE_REV2
128    je      SHORT .SetFlagForSwappedA0andA3
129    cmp     BYTE [cs:bp+IDEVARS.bDevice], DEVICE_FAST_XTIDE
[160]130    jne     SHORT .EndDPT
[361]131.SetFlagForSwappedA0andA3:
[160]132    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
[150]133.EndDPT:
[258]134    clc
[150]135    ret
[363]136
137
138%ifdef MODULE_ADVANCED_ATA
139;--------------------------------------------------------------------
140; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
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_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI:
150    mov     al, [cs:bp+IDEVARS.bDevice]
[364]151    mov     [di+DPT_ADVANCED_ATA.bDevice], al
[363]152    ret
[364]153
[363]154%endif
Note: See TracBrowser for help on using the repository browser.