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

Last change on this file since 616 was 616, checked in by aitotat, 3 years ago
  • Added check for APM
File size: 5.4 KB
RevLine 
[150]1; Project name  :   XTIDE Universal BIOS
2; Description   :   Sets IDE Device specific parameters to DPT.
3
[376]4;
[399]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[399]12;
[376]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.
[399]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
[376]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;--------------------------------------------------------------------
[596]34IdeDPT_Finalize:    ; Unused entrypoint OK
[150]35
[567]36%ifdef MODULE_POWER_MANAGEMENT
[150]37;--------------------------------------------------------------------
[399]38; .DetectPowerManagementSupport
[150]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:
[567]45;       AL
[150]46;--------------------------------------------------------------------
[399]47.DetectPowerManagementSupport:
[567]48    mov     al, [es:si+ATA6.wSetSup82]
[616]49    mov     ah, [es:si+ATA6.wSetSup83]
50    and     ah, A6_wSetSup83_APM
51    shl     ah, 1                       ; APM bit 3 to bit 4
[567]52    and     al, A6_wSetSup82_POWERMAN   ; A6_wSetSup82_POWERMAN (bit 3) is the same
[616]53    or      al, ah
54    or      [di+DPT.bFlagsHigh], al     ; bit as FLGH_DPT_POWER_MANAGEMENT_SUPPORTED and FLGH_DPT_APM_SUPPORTED
[567]55%endif ; MODULE_POWER_MANAGEMENT
[399]56
[410]57
[399]58;--------------------------------------------------------------------
[410]59; .StoreDeviceType
60;   Parameters:
61;       DS:DI:  Ptr to Disk Parameter Table
62;       CS:BP:  Ptr to IDEVARS for the controller
63;   Returns:
64;       Nothing
65;   Corrupts registers:
66;       AL
67;--------------------------------------------------------------------
68.StoreDeviceType:
[473]69    call    IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
[410]70
71
72;--------------------------------------------------------------------
[399]73; .StoreBlockMode
74;   Parameters:
75;       DS:DI:  Ptr to Disk Parameter Table
76;   Returns:
77;       Nothing
78;   Corrupts registers:
79;       Nothing
80;--------------------------------------------------------------------
[150]81.StoreBlockMode:
[365]82    mov     BYTE [di+DPT_ATA.bBlockSize], 1
[150]83
[410]84
[363]85%ifdef MODULE_ADVANCED_ATA
[160]86;--------------------------------------------------------------------
[363]87; .StorePioModeAndTimings
88;   Parameters:
89;       DS:DI:  Ptr to Disk Parameter Table
90;       ES:SI:  Ptr to 512-byte ATA information read from the drive
91;       CS:BP:  Ptr to IDEVARS for the controller
92;   Returns:
93;       Nothing
94;   Corrupts registers:
[364]95;       AX, BX, CX
[363]96;--------------------------------------------------------------------
97.StorePioMode:
[364]98    call    AtaID_GetMaxPioModeToAXandMinCycleTimeToCX
99    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx
100    mov     [di+DPT_ADVANCED_ATA.bPioMode], al
[399]101    or      [di+DPT.bFlagsHigh], ah
[363]102
[410]103
[363]104;--------------------------------------------------------------------
105; .DetectAdvancedIdeController
106;   Parameters:
107;       DS:DI:  Ptr to Disk Parameter Table
108;       ES:SI:  Ptr to 512-byte ATA information read from the drive
109;       CS:BP:  Ptr to IDEVARS for the controller
110;   Returns:
111;       Nothing
112;   Corrupts registers:
113;       AX, BX, CX, DX
114;--------------------------------------------------------------------
115.DetectAdvancedIdeController:
[608]116    ; Detection is only relevant on standard devices. XT-CF seems to give false positive for
117    ; PDC20x30 detection so better to skip detection for 8-bit devices
118    cmp     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
119    ja      SHORT .NoAdvancedControllerDetected
120   
[473]121    mov     bx, [di+DPT.wBasePort]
[364]122    call    AdvAtaInit_DetectControllerForIdeBaseInBX
[363]123    mov     [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected
[364]124    mov     [di+DPT_ADVANCED_ATA.wControllerBasePort], dx
[363]125    jnc     SHORT .NoAdvancedControllerDetected
126
127    ; Use highest common PIO mode from controller and drive.
128    ; Many VLB controllers support PIO modes up to 2.
[564]129    call    AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX
[582]130    jnz     SHORT .ChangeTo32bitDevice
[564]131
[592]132    and     [di+DPT.bFlagsHigh], ah     ; Mask off FLGH_DPT_IORDY if IORDY not supported
[364]133    MIN_U   [di+DPT_ADVANCED_ATA.bPioMode], al
[564]134    mov     [di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx
[363]135
136    ; We have detected 32-bit controller so change Device Type since
137    ; it might have been set to 16-bit on IDEVARS
138.ChangeTo32bitDevice:
[400]139    mov     BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA
[363]140.NoAdvancedControllerDetected:
[400]141%endif  ; MODULE_ADVANCED_ATA
[363]142
143
[410]144; End DPT
145    clc
146    ret
147
148
[363]149;--------------------------------------------------------------------
[473]150; IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP
[363]151;   Parameters:
152;       DS:DI:  Ptr to Disk Parameter Table
153;       CS:BP:  Ptr to IDEVARS for the controller
154;   Returns:
155;       Nothing
156;   Corrupts registers:
157;       AL
158;--------------------------------------------------------------------
[473]159IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP:
[363]160    mov     al, [cs:bp+IDEVARS.bDevice]
[400]161    mov     [di+DPT_ATA.bDevice], al
[363]162    ret
Note: See TracBrowser for help on using the repository browser.