[99] | 1 | ; Project name : XTIDE Universal BIOS |
---|
[3] | 2 | ; Description : Functions for accessing DPT data. |
---|
| 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 | |
---|
[3] | 20 | ; Section containing code |
---|
| 21 | SECTION .text |
---|
| 22 | |
---|
[364] | 23 | %ifdef MODULE_ADVANCED_ATA |
---|
[3] | 24 | ;-------------------------------------------------------------------- |
---|
[364] | 25 | ; AccessDPT_GetIdeBasePortToBX |
---|
| 26 | ; Parameters: |
---|
| 27 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 28 | ; Returns: |
---|
| 29 | ; BX: IDE Base Port Address |
---|
| 30 | ; Corrupts registers: |
---|
| 31 | ; Nothing |
---|
| 32 | ;-------------------------------------------------------------------- |
---|
| 33 | ALIGN JUMP_ALIGN |
---|
| 34 | AccessDPT_GetIdeBasePortToBX: |
---|
| 35 | eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS |
---|
| 36 | mov bx, [cs:bx+IDEVARS.wPort] |
---|
| 37 | ret |
---|
[421] | 38 | %endif ; MODULE_ADVANCED_ATA |
---|
[364] | 39 | |
---|
| 40 | |
---|
| 41 | ;-------------------------------------------------------------------- |
---|
[421] | 42 | ; AccessDPT_GetDriveSelectByteForOldInt13hToAL |
---|
| 43 | ; AccessDPT_GetDriveSelectByteForEbiosToAL |
---|
[150] | 44 | ; Parameters: |
---|
| 45 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 46 | ; Returns: |
---|
| 47 | ; AL: Drive Select Byte |
---|
| 48 | ; Corrupts registers: |
---|
| 49 | ; Nothing |
---|
| 50 | ;-------------------------------------------------------------------- |
---|
| 51 | ALIGN JUMP_ALIGN |
---|
[421] | 52 | AccessDPT_GetDriveSelectByteForOldInt13hToAL: |
---|
| 53 | mov al, [di+DPT.bFlagsLow] |
---|
| 54 | test al, FLGL_DPT_ASSISTED_LBA |
---|
| 55 | jnz SHORT GetDriveSelectByteForAssistedLBAtoAL |
---|
| 56 | |
---|
| 57 | and al, FLG_DRVNHEAD_DRV ; Clear all but drive select bit |
---|
[150] | 58 | or al, MASK_DRVNHEAD_SET ; Bits set to 1 for old drives |
---|
| 59 | ret |
---|
| 60 | |
---|
[421] | 61 | %ifdef MODULE_EBIOS |
---|
| 62 | ALIGN JUMP_ALIGN |
---|
| 63 | AccessDPT_GetDriveSelectByteForEbiosToAL: |
---|
| 64 | mov al, [di+DPT.wFlags] |
---|
| 65 | ; Fall to GetDriveSelectByteForAssistedLBAtoAL |
---|
| 66 | %endif ; MODULE_EBIOS |
---|
[150] | 67 | |
---|
[421] | 68 | ALIGN JUMP_ALIGN |
---|
| 69 | GetDriveSelectByteForAssistedLBAtoAL: |
---|
| 70 | and al, FLG_DRVNHEAD_DRV ; Master / Slave select |
---|
| 71 | or al, FLG_DRVNHEAD_LBA | MASK_DRVNHEAD_SET |
---|
| 72 | ret |
---|
| 73 | |
---|
| 74 | |
---|
[150] | 75 | ;-------------------------------------------------------------------- |
---|
| 76 | ; AccessDPT_GetDeviceControlByteToAL |
---|
| 77 | ; Parameters: |
---|
| 78 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 79 | ; Returns: |
---|
| 80 | ; AL: Device Control Byte |
---|
| 81 | ; Corrupts registers: |
---|
| 82 | ; Nothing |
---|
| 83 | ;-------------------------------------------------------------------- |
---|
| 84 | ALIGN JUMP_ALIGN |
---|
| 85 | AccessDPT_GetDeviceControlByteToAL: |
---|
[411] | 86 | %ifdef MODULE_IRQ |
---|
[150] | 87 | xor al, al |
---|
[158] | 88 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ |
---|
[150] | 89 | jnz SHORT .EnableDeviceIrq |
---|
| 90 | or al, FLG_DEVCONTROL_nIEN ; Disable IRQ |
---|
| 91 | .EnableDeviceIrq: |
---|
[411] | 92 | %else |
---|
| 93 | mov al, FLG_DEVCONTROL_nIEN ; Disable IRQ |
---|
| 94 | %endif |
---|
[150] | 95 | ret |
---|
| 96 | |
---|
[227] | 97 | |
---|
[150] | 98 | ;-------------------------------------------------------------------- |
---|
[227] | 99 | ; AccessDPT_GetLCHStoAXBLBH |
---|
[3] | 100 | ; Parameters: |
---|
| 101 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 102 | ; Returns: |
---|
[227] | 103 | ; AX: Number of L-CHS cylinders |
---|
| 104 | ; BL: Number of L-CHS heads |
---|
| 105 | ; BH: Number of L-CHS sectors per track |
---|
[3] | 106 | ; Corrupts registers: |
---|
[421] | 107 | ; Nothing |
---|
[3] | 108 | ;-------------------------------------------------------------------- |
---|
[227] | 109 | AccessDPT_GetLCHStoAXBLBH: |
---|
[421] | 110 | mov ax, [di+DPT.wLchsCylinders] |
---|
| 111 | mov bx, [di+DPT.wLchsHeadsAndSectors] |
---|
[227] | 112 | ret |
---|
[173] | 113 | |
---|
[227] | 114 | |
---|
[421] | 115 | %ifdef MODULE_EBIOS |
---|
[227] | 116 | ;-------------------------------------------------------------------- |
---|
[230] | 117 | ; AccessDPT_GetLbaSectorCountToBXDXAX |
---|
| 118 | ; Parameters: |
---|
| 119 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 120 | ; Returns: |
---|
| 121 | ; BX:DX:AX: 48-bit sector count |
---|
| 122 | ; Corrupts registers: |
---|
| 123 | ; Nothing |
---|
| 124 | ;-------------------------------------------------------------------- |
---|
| 125 | AccessDPT_GetLbaSectorCountToBXDXAX: |
---|
| 126 | mov ax, [di+DPT.twLbaSectors] |
---|
| 127 | mov dx, [di+DPT.twLbaSectors+2] |
---|
| 128 | mov bx, [di+DPT.twLbaSectors+4] |
---|
| 129 | ret |
---|
[421] | 130 | %endif ; MODULE_EBIOS |
---|
[230] | 131 | |
---|
| 132 | |
---|
| 133 | ;-------------------------------------------------------------------- |
---|
[3] | 134 | ; Returns pointer to DRVPARAMS for master or slave drive. |
---|
| 135 | ; |
---|
| 136 | ; AccessDPT_GetPointerToDRVPARAMStoCSBX |
---|
| 137 | ; Parameters: |
---|
| 138 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 139 | ; Returns: |
---|
| 140 | ; CS:BX: Ptr to DRVPARAMS |
---|
| 141 | ; Corrupts registers: |
---|
| 142 | ; Nothing |
---|
| 143 | ;-------------------------------------------------------------------- |
---|
| 144 | ALIGN JUMP_ALIGN |
---|
| 145 | AccessDPT_GetPointerToDRVPARAMStoCSBX: |
---|
[422] | 146 | eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS |
---|
[150] | 147 | add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS |
---|
[158] | 148 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE |
---|
[150] | 149 | jz SHORT .ReturnPointerToDRVPARAMS |
---|
| 150 | add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS |
---|
| 151 | .ReturnPointerToDRVPARAMS: |
---|
[3] | 152 | ret |
---|
[200] | 153 | |
---|
[421] | 154 | |
---|
[200] | 155 | ;-------------------------------------------------------------------- |
---|
[422] | 156 | ; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF |
---|
[200] | 157 | ; Parameters: |
---|
| 158 | ; DS:DI: Ptr to Disk Parameter Table |
---|
| 159 | ; Returns: |
---|
[422] | 160 | ; AX: Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA) |
---|
[200] | 161 | ; unshifted (still shifted where it is in bFlagsLow) |
---|
| 162 | ; ZF: Set based on value in AL |
---|
| 163 | ; Corrupts registers: |
---|
[421] | 164 | ; Nothing |
---|
[200] | 165 | ;-------------------------------------------------------------------- |
---|
[230] | 166 | ; |
---|
| 167 | ; Converted to a macro since only called in two places, and the call/ret overhead |
---|
[200] | 168 | ; is not worth it for these two instructions (4 bytes total) |
---|
| 169 | ; |
---|
[422] | 170 | %macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0 |
---|
[200] | 171 | mov al, [di+DPT.bFlagsLow] |
---|
[422] | 172 | and ax, BYTE MASKL_DPT_TRANSLATEMODE |
---|
[200] | 173 | %endmacro |
---|