1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Functions for accessing DPT data.
|
---|
3 |
|
---|
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 |
|
---|
20 | ; Section containing code
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | %ifdef MODULE_ADVANCED_ATA
|
---|
24 | ;--------------------------------------------------------------------
|
---|
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
|
---|
38 | %endif ; MODULE_ADVANCED_ATA
|
---|
39 |
|
---|
40 |
|
---|
41 | ;--------------------------------------------------------------------
|
---|
42 | ; AccessDPT_GetDriveSelectByteForOldInt13hToAL
|
---|
43 | ; AccessDPT_GetDriveSelectByteForEbiosToAL
|
---|
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
|
---|
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
|
---|
58 | or al, MASK_DRVNHEAD_SET ; Bits set to 1 for old drives
|
---|
59 | ret
|
---|
60 |
|
---|
61 | %ifdef MODULE_EBIOS
|
---|
62 | ALIGN JUMP_ALIGN
|
---|
63 | AccessDPT_GetDriveSelectByteForEbiosToAL:
|
---|
64 | mov al, [di+DPT.bFlagsLow]
|
---|
65 | ; Fall to GetDriveSelectByteForAssistedLBAtoAL
|
---|
66 | %endif ; MODULE_EBIOS
|
---|
67 |
|
---|
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 |
|
---|
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:
|
---|
86 | %ifdef MODULE_IRQ
|
---|
87 | xor al, al
|
---|
88 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
|
---|
89 | jnz SHORT .EnableDeviceIrq
|
---|
90 | or al, FLG_DEVCONTROL_nIEN ; Disable IRQ
|
---|
91 | .EnableDeviceIrq:
|
---|
92 | %else
|
---|
93 | mov al, FLG_DEVCONTROL_nIEN ; Disable IRQ
|
---|
94 | %endif
|
---|
95 | ret
|
---|
96 |
|
---|
97 |
|
---|
98 | ;--------------------------------------------------------------------
|
---|
99 | ; AccessDPT_GetLCHStoAXBLBH
|
---|
100 | ; Parameters:
|
---|
101 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
102 | ; Returns:
|
---|
103 | ; AX: Number of L-CHS cylinders
|
---|
104 | ; BL: Number of L-CHS heads
|
---|
105 | ; BH: Number of L-CHS sectors per track
|
---|
106 | ; Corrupts registers:
|
---|
107 | ; Nothing
|
---|
108 | ;--------------------------------------------------------------------
|
---|
109 | AccessDPT_GetLCHStoAXBLBH:
|
---|
110 | mov ax, [di+DPT.wLchsCylinders]
|
---|
111 | mov bx, [di+DPT.wLchsHeadsAndSectors]
|
---|
112 | ret
|
---|
113 |
|
---|
114 |
|
---|
115 | %ifdef MODULE_EBIOS
|
---|
116 | ;--------------------------------------------------------------------
|
---|
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
|
---|
130 | %endif ; MODULE_EBIOS
|
---|
131 |
|
---|
132 |
|
---|
133 | ;--------------------------------------------------------------------
|
---|
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:
|
---|
146 | eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
|
---|
147 | add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
|
---|
148 | test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
|
---|
149 | jz SHORT .ReturnPointerToDRVPARAMS
|
---|
150 | add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
|
---|
151 | .ReturnPointerToDRVPARAMS:
|
---|
152 | ret
|
---|
153 |
|
---|
154 |
|
---|
155 | ;--------------------------------------------------------------------
|
---|
156 | ; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
|
---|
157 | ; Parameters:
|
---|
158 | ; DS:DI: Ptr to Disk Parameter Table
|
---|
159 | ; Returns:
|
---|
160 | ; AX: Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
|
---|
161 | ; unshifted (still shifted where it is in bFlagsLow)
|
---|
162 | ; ZF: Set based on value in AL
|
---|
163 | ; Corrupts registers:
|
---|
164 | ; Nothing
|
---|
165 | ;--------------------------------------------------------------------
|
---|
166 | ;
|
---|
167 | ; Converted to a macro since only called in two places, and the call/ret overhead
|
---|
168 | ; is not worth it for these two instructions (4 bytes total)
|
---|
169 | ;
|
---|
170 | %macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
|
---|
171 | mov al, [di+DPT.bFlagsLow]
|
---|
172 | and ax, BYTE MASKL_DPT_TRANSLATEMODE
|
---|
173 | %endmacro
|
---|