source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/AccessDPT.asm @ 473

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

Changes to XTIDE Universal BIOS:

  • Large changes to prepare full XT-CF support (DMA not yet implemented and memory mapped transfers are not working).
File size: 6.0 KB
Line 
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
21SECTION .text
22
23;--------------------------------------------------------------------
24; AccessDPT_GetDriveSelectByteForOldInt13hToAL
25; AccessDPT_GetDriveSelectByteForEbiosToAL
26;   Parameters:
27;       DS:DI:  Ptr to Disk Parameter Table
28;   Returns:
29;       AL:     Drive Select Byte
30;   Corrupts registers:
31;       Nothing
32;--------------------------------------------------------------------
33ALIGN JUMP_ALIGN
34AccessDPT_GetDriveSelectByteForOldInt13hToAL:
35    mov     al, [di+DPT.bFlagsLow]
36    test    al, FLGL_DPT_ASSISTED_LBA
37    jnz     SHORT GetDriveSelectByteForAssistedLBAtoAL
38
39    and     al, FLG_DRVNHEAD_DRV    ; Clear all but drive select bit
40    or      al, MASK_DRVNHEAD_SET   ; Bits set to 1 for old drives
41    ret
42
43%ifdef MODULE_EBIOS
44ALIGN JUMP_ALIGN
45AccessDPT_GetDriveSelectByteForEbiosToAL:
46    mov     al, [di+DPT.bFlagsLow]
47    ; Fall to GetDriveSelectByteForAssistedLBAtoAL
48%endif ; MODULE_EBIOS
49
50ALIGN JUMP_ALIGN
51GetDriveSelectByteForAssistedLBAtoAL:
52    and     al, FLG_DRVNHEAD_DRV    ; Master / Slave select
53    or      al, FLG_DRVNHEAD_LBA | MASK_DRVNHEAD_SET
54    ret
55
56
57;--------------------------------------------------------------------
58; AccessDPT_GetDeviceControlByteToAL
59;   Parameters:
60;       DS:DI:  Ptr to Disk Parameter Table
61;   Returns:
62;       AL:     Device Control Byte
63;   Corrupts registers:
64;       Nothing
65;--------------------------------------------------------------------
66ALIGN JUMP_ALIGN
67AccessDPT_GetDeviceControlByteToAL:
68%ifdef MODULE_IRQ
69    xor     al, al
70    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
71    jnz     SHORT .EnableDeviceIrq
72    or      al, FLG_DEVCONTROL_nIEN ; Disable IRQ
73.EnableDeviceIrq:
74%else
75    mov     al, FLG_DEVCONTROL_nIEN ; Disable IRQ
76%endif
77    ret
78
79
80;--------------------------------------------------------------------
81; AccessDPT_GetLCHStoAXBLBH
82;   Parameters:
83;       DS:DI:  Ptr to Disk Parameter Table
84;   Returns:
85;       AX:     Number of L-CHS cylinders
86;       BL:     Number of L-CHS heads
87;       BH:     Number of L-CHS sectors per track
88;   Corrupts registers:
89;       Nothing
90;--------------------------------------------------------------------
91AccessDPT_GetLCHStoAXBLBH:
92    mov     ax, [di+DPT.wLchsCylinders]
93    mov     bx, [di+DPT.wLchsHeadsAndSectors]
94    ret
95
96
97%ifdef MODULE_8BIT_IDE
98;--------------------------------------------------------------------
99; AccessDPT_IsThisDeviceXTCF
100;   Parameters:
101;       DS:DI:  Ptr to Disk Parameter Table
102;   Returns:
103;       AH:     Device Type
104;       ZF:     Set if XTCF
105;               Cleared if some other device
106;   Corrupts registers:
107;       Nothing
108;--------------------------------------------------------------------
109AccessDPT_IsThisDeviceXTCF:
110    mov     ah, [di+DPT_ATA.bDevice]
111    cmp     ah, DEVICE_8BIT_XTCF_PIO8
112    je      SHORT .DeviceIsXTCF
113    cmp     ah, DEVICE_8BIT_XTCF_DMA
114    je      SHORT .DeviceIsXTCF
115    cmp     ah, DEVICE_8BIT_XTCF_MEMMAP
116.DeviceIsXTCF:
117    ret
118%endif ; MODULE_8BIT_IDE
119
120
121%ifdef MODULE_EBIOS
122;--------------------------------------------------------------------
123; AccessDPT_GetLbaSectorCountToBXDXAX
124;   Parameters:
125;       DS:DI:  Ptr to Disk Parameter Table
126;   Returns:
127;       BX:DX:AX:   48-bit sector count
128;   Corrupts registers:
129;       Nothing
130;--------------------------------------------------------------------
131AccessDPT_GetLbaSectorCountToBXDXAX:
132    mov     ax, [di+DPT.twLbaSectors]
133    mov     dx, [di+DPT.twLbaSectors+2]
134    mov     bx, [di+DPT.twLbaSectors+4]
135    ret
136%endif ; MODULE_EBIOS
137
138
139;--------------------------------------------------------------------
140; Returns pointer to DRVPARAMS for master or slave drive.
141;
142; AccessDPT_GetPointerToDRVPARAMStoCSBX
143;   Parameters:
144;       DS:DI:  Ptr to Disk Parameter Table
145;   Returns:
146;       CS:BX:  Ptr to DRVPARAMS
147;   Corrupts registers:
148;       Nothing
149;--------------------------------------------------------------------
150AccessDPT_GetPointerToDRVPARAMStoCSBX:
151    call    AccessDPT_GetIdevarsToCSBX
152    add     bx, BYTE IDEVARS.drvParamsMaster    ; CS:BX points to Master Drive DRVPARAMS
153    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
154    jz      SHORT .ReturnPointerToDRVPARAMS
155    add     bx, BYTE DRVPARAMS_size             ; CS:BX points to Slave Drive DRVPARAMS
156.ReturnPointerToDRVPARAMS:
157    ret
158
159
160;--------------------------------------------------------------------
161; Needed many times during initialization so it is better to
162; make it as a function to save bytes.
163;
164; AccessDPT_GetIdevarsToCSBX
165;   Parameters:
166;       DS:DI:  Ptr to Disk Parameter Table
167;   Returns:
168;       CS:BX:  Ptr to IDEVARS for the drive
169;   Corrupts registers:
170;       Nothing
171;--------------------------------------------------------------------
172AccessDPT_GetIdevarsToCSBX:
173    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
174    ret
175
176
177;--------------------------------------------------------------------
178; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
179;   Parameters:
180;       DS:DI:  Ptr to Disk Parameter Table
181;   Returns:
182;       AX:     Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
183;               unshifted (still shifted where it is in bFlagsLow)
184;       ZF:     Set based on value in AL
185;   Corrupts registers:
186;       Nothing
187;--------------------------------------------------------------------
188;
189; Converted to a macro since only called in two places, and the call/ret overhead
190; is not worth it for these two instructions (4 bytes total)
191;
192%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
193    mov     al, [di+DPT.bFlagsLow]
194    and     ax, BYTE MASKL_DPT_TRANSLATEMODE
195%endmacro
Note: See TracBrowser for help on using the repository browser.