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

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

Changes to XTIDE Universal BIOS:

  • Added Advanced ATA Module (MODULE_ADVANCED_ATA) with native support for QDI Vision QD6500 and QD6580 VLB IDE Controllers.
  • Hopefully optimized IDE transfer functions for 8088 (replaced some memory accesses from WORD to BYTE).
  • XT build does not fit in 8k at the moment!!!
File size: 4.6 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   Sets IDE Device specific parameters to DPT.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; IdeDPT_Finalize
9;   Parameters:
10;       DS:DI:  Ptr to Disk Parameter Table
11;       ES:SI:  Ptr to 512-byte ATA information read from the drive
12;       CS:BP:  Ptr to IDEVARS for the controller
13;   Returns:
14;       CF:     Clear, IDE interface only supports hard disks
15;   Corrupts registers:
16;       AX, BX, CX, DX
17;--------------------------------------------------------------------
18IdeDPT_Finalize:
19
20;--------------------------------------------------------------------
21; .StoreBlockMode
22;   Parameters:
23;       DS:DI:  Ptr to Disk Parameter Table
24;       ES:SI:  Ptr to 512-byte ATA information read from the drive
25;       CS:BP:  Ptr to IDEVARS for the controller
26;   Returns:
27;       Nothing
28;   Corrupts registers:
29;       AX
30;--------------------------------------------------------------------
31.StoreBlockMode:
32    mov     al, 1                           ; Block mode will be enabled on AH=9h
33    mov     ah, [es:si+ATA1.bBlckSize]      ; Max block size in sectors
34    mov     [di+DPT_ATA.wSetAndMaxBlock], ax
35
36%ifdef MODULE_ADVANCED_ATA
37;--------------------------------------------------------------------
38; .StoreDeviceType
39;   Parameters:
40;       DS:DI:  Ptr to Disk Parameter Table
41;       ES:SI:  Ptr to 512-byte ATA information read from the drive
42;       CS:BP:  Ptr to IDEVARS for the controller
43;   Returns:
44;       Nothing
45;   Corrupts registers:
46;       Nothing
47;--------------------------------------------------------------------
48.StoreDeviceType:
49    call    IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
50
51;--------------------------------------------------------------------
52; .StorePioModeAndTimings
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;       AX, CX, DX
61;--------------------------------------------------------------------
62.StorePioMode:
63    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToDX
64    call    AtaID_ConvertPioModeFromAXandMinCycleTimeFromDXtoActiveAndRecoveryTime
65    mov     [di+DPT_ATA.bPioMode], al
66    mov     [di+DPT_ADVANCED_ATA.wMinPioActiveTimeNs], cx
67    mov     [di+DPT_ADVANCED_ATA.wMinPioRecoveryTimeNs], dx
68
69;--------------------------------------------------------------------
70; .DetectAdvancedIdeController
71;   Parameters:
72;       DS:DI:  Ptr to Disk Parameter Table
73;       ES:SI:  Ptr to 512-byte ATA information read from the drive
74;       CS:BP:  Ptr to IDEVARS for the controller
75;   Returns:
76;       Nothing
77;   Corrupts registers:
78;       AX, BX, CX, DX
79;--------------------------------------------------------------------
80.DetectAdvancedIdeController:
81    mov     dx, [cs:bp+IDEVARS.wPort]
82    mov     [di+DPT_ADVANCED_ATA.wIdeBasePort], dx
83    call    AdvAtaInit_DetectControllerForIdeBaseInDX
84    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
85    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], cx
86    jnc     SHORT .NoAdvancedControllerDetected
87
88    ; Use highest common PIO mode from controller and drive.
89    ; Many VLB controllers support PIO modes up to 2.
90    call    AdvAtaInit_GetControllerMaxPioModeToAL
91    jnc     SHORT .ChangeTo32bitDevice
92    MIN_U   [di+DPT_ATA.bPioMode], al
93
94    ; We have detected 32-bit controller so change Device Type since
95    ; it might have been set to 16-bit on IDEVARS
96.ChangeTo32bitDevice:
97    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
98
99.NoAdvancedControllerDetected:
100
101%endif ; MODULE_ADVANCED_ATA
102
103;--------------------------------------------------------------------
104; IdeDPT_StoreReversedAddressLinesFlagIfNecessary
105;   Parameters:
106;       DS:DI:  Ptr to Disk Parameter Table
107;       CS:BP:  Ptr to IDEVARS for the controller
108;   Returns:
109;       CF:     Always clear
110;   Corrupts registers:
111;       Nothing
112;--------------------------------------------------------------------
113IdeDPT_StoreReversedAddressLinesFlagIfNecessary:
114    cmp     BYTE [cs:bp+IDEVARS.bDevice], DEVICE_XTIDE_REV2
115    je      SHORT .SetFlagForSwappedA0andA3
116    cmp     BYTE [cs:bp+IDEVARS.bDevice], DEVICE_FAST_XTIDE
117    jne     SHORT .EndDPT
118.SetFlagForSwappedA0andA3:
119    or      BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
120.EndDPT:
121    clc
122    ret
123
124
125%ifdef MODULE_ADVANCED_ATA
126;--------------------------------------------------------------------
127; IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI
128;   Parameters:
129;       DS:DI:  Ptr to Disk Parameter Table
130;       CS:BP:  Ptr to IDEVARS for the controller
131;   Returns:
132;       Nothing
133;   Corrupts registers:
134;       AL
135;--------------------------------------------------------------------
136IdeDPT_StoreDeviceTypeFromIdevarsInCSBPtoDPTinDSDI:
137    mov     al, [cs:bp+IDEVARS.bDevice]
138    mov     [di+DPT_ATA.bDevice], al
139    ret
140%endif
Note: See TracBrowser for help on using the repository browser.