[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 |
---|
| 21 | SECTION .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] | 34 | IdeDPT_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: |
---|
[618] | 45 | ; AX |
---|
[150] | 46 | ;-------------------------------------------------------------------- |
---|
[399] | 47 | .DetectPowerManagementSupport: |
---|
[618] | 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) |
---|
[616] | 52 | or al, ah |
---|
[618] | 53 | or [di+DPT.bFlagsHigh], al ; FLGH_DPT_POWER_MANAGEMENT_SUPPORTED and FLGH_DPT_APM_SUPPORTED |
---|
[567] | 54 | %endif ; MODULE_POWER_MANAGEMENT |
---|
[399] | 55 | |
---|
[410] | 56 | |
---|
[399] | 57 | ;-------------------------------------------------------------------- |
---|
[410] | 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: |
---|
[473] | 68 | call IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP |
---|
[410] | 69 | |
---|
| 70 | |
---|
| 71 | ;-------------------------------------------------------------------- |
---|
[399] | 72 | ; .StoreBlockMode |
---|
| 73 | ; Parameters: |
---|
| 74 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 75 | ; Returns: |
---|
| 76 | ; Nothing |
---|
| 77 | ; Corrupts registers: |
---|
| 78 | ; Nothing |
---|
| 79 | ;-------------------------------------------------------------------- |
---|
[150] | 80 | .StoreBlockMode: |
---|
[365] | 81 | mov BYTE [di+DPT_ATA.bBlockSize], 1 |
---|
[150] | 82 | |
---|
[410] | 83 | |
---|
[363] | 84 | %ifdef MODULE_ADVANCED_ATA |
---|
[160] | 85 | ;-------------------------------------------------------------------- |
---|
[363] | 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: |
---|
[364] | 94 | ; AX, BX, CX |
---|
[363] | 95 | ;-------------------------------------------------------------------- |
---|
| 96 | .StorePioMode: |
---|
[364] | 97 | call AtaID_GetMaxPioModeToAXandMinCycleTimeToCX |
---|
| 98 | mov [di+DPT_ADVANCED_ATA.wMinPioCycleTime], cx |
---|
| 99 | mov [di+DPT_ADVANCED_ATA.bPioMode], al |
---|
[399] | 100 | or [di+DPT.bFlagsHigh], ah |
---|
[363] | 101 | |
---|
[410] | 102 | |
---|
[363] | 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: |
---|
[608] | 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 |
---|
[618] | 119 | |
---|
[473] | 120 | mov bx, [di+DPT.wBasePort] |
---|
[364] | 121 | call AdvAtaInit_DetectControllerForIdeBaseInBX |
---|
[363] | 122 | mov [di+DPT_ADVANCED_ATA.wControllerID], ax ; Store zero if none detected |
---|
[364] | 123 | mov [di+DPT_ADVANCED_ATA.wControllerBasePort], dx |
---|
[363] | 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. |
---|
[564] | 128 | call AdvAtaInit_GetControllerMaxPioModeToALandMinPioCycleTimeToBX |
---|
[582] | 129 | jnz SHORT .ChangeTo32bitDevice |
---|
[564] | 130 | |
---|
[592] | 131 | and [di+DPT.bFlagsHigh], ah ; Mask off FLGH_DPT_IORDY if IORDY not supported |
---|
[364] | 132 | MIN_U [di+DPT_ADVANCED_ATA.bPioMode], al |
---|
[564] | 133 | mov [di+DPT_ADVANCED_ATA.wMinPioCycleTime], bx |
---|
[363] | 134 | |
---|
[623] | 135 | ; We have detected 32-bit controller so change Device Type |
---|
| 136 | ; since it might have been set to 16-bit on IDEVARS |
---|
[363] | 137 | .ChangeTo32bitDevice: |
---|
[623] | 138 | ; *FIXME* We might need to add code to detect the IBM 486SLC2 CPU (and possibly other |
---|
| 139 | ; 386+ class CPUs with a 16-bit external bus?) to avoid changing to DEVICE_32BIT_ATA. |
---|
[400] | 140 | mov BYTE [di+DPT_ATA.bDevice], DEVICE_32BIT_ATA |
---|
[363] | 141 | .NoAdvancedControllerDetected: |
---|
[400] | 142 | %endif ; MODULE_ADVANCED_ATA |
---|
[363] | 143 | |
---|
[622] | 144 | ; End DPT |
---|
[410] | 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] | 159 | IdeDPT_StoreDeviceTypeToDPTinDSDIfromIdevarsInCSBP: |
---|
[363] | 160 | mov al, [cs:bp+IDEVARS.bDevice] |
---|
[400] | 161 | mov [di+DPT_ATA.bDevice], al |
---|
[363] | 162 | ret |
---|