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

Last change on this file since 493 was 493, checked in by gregli@…, 11 years ago

Separated MODULE_8BIT_IDE into the basic part used by XTIDE rev 1 and rev 2 which is PIO based, and MODULE_8BIT_IDE_ADVANCED for JRIDE and XTCF support which requires memory mapping and/or DMA. This allows for creating an 8KB image with boot menu support (but no hotkeys) for the XTIDE rev 1. Cleaned up how we reset the drive translation information, ensuring it is properly set between boot attempt on a primary and secondary drive - as a result we clean it when needed, rather than trying to always keep it clean. Also fixed translation bugs in int13h.asm where I had previously missed converting some MODULE_HOTKEYS into MODULE_DRIVEXLATE.

File size: 6.2 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
70%ifndef USE_UNDOC_INTEL
71    xor     al, al
72%endif
73
74    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ    ; Clears CF
75
76%ifdef USE_UNDOC_INTEL
77    eSALC   ; Clears AL using CF while preserving flags
78%endif
79
80    jnz     SHORT .EnableDeviceIrq
81    or      al, FLG_DEVCONTROL_nIEN ; Disable IRQ
82.EnableDeviceIrq:
83%else
84    mov     al, FLG_DEVCONTROL_nIEN ; Disable IRQ
85%endif ; MODULE_IRQ
86    ret
87
88
89;--------------------------------------------------------------------
90; AccessDPT_GetLCHStoAXBLBH
91;   Parameters:
92;       DS:DI:  Ptr to Disk Parameter Table
93;   Returns:
94;       AX:     Number of L-CHS cylinders
95;       BL:     Number of L-CHS heads
96;       BH:     Number of L-CHS sectors per track
97;   Corrupts registers:
98;       Nothing
99;--------------------------------------------------------------------
100AccessDPT_GetLCHStoAXBLBH:
101    mov     ax, [di+DPT.wLchsCylinders]
102    mov     bx, [di+DPT.wLchsHeadsAndSectors]
103    ret
104
105
106%ifdef MODULE_8BIT_IDE_ADVANCED
107;--------------------------------------------------------------------
108; AccessDPT_IsThisDeviceXTCF
109;   Parameters:
110;       DS:DI:  Ptr to Disk Parameter Table
111;   Returns:
112;       AH:     Device Type
113;       ZF:     Set if XTCF
114;               Cleared if some other device
115;   Corrupts registers:
116;       Nothing
117;--------------------------------------------------------------------
118AccessDPT_IsThisDeviceXTCF:
119    mov     ah, [di+DPT_ATA.bDevice]
120    cmp     ah, DEVICE_8BIT_XTCF_PIO8
121    je      SHORT .DeviceIsXTCF
122    cmp     ah, DEVICE_8BIT_XTCF_DMA
123    je      SHORT .DeviceIsXTCF
124    cmp     ah, DEVICE_8BIT_XTCF_MEMMAP
125.DeviceIsXTCF:
126    ret
127%endif ; MODULE_8BIT_IDE_ADVANCED
128
129
130%ifdef MODULE_EBIOS
131;--------------------------------------------------------------------
132; AccessDPT_GetLbaSectorCountToBXDXAX
133;   Parameters:
134;       DS:DI:  Ptr to Disk Parameter Table
135;   Returns:
136;       BX:DX:AX:   48-bit sector count
137;   Corrupts registers:
138;       Nothing
139;--------------------------------------------------------------------
140AccessDPT_GetLbaSectorCountToBXDXAX:
141    mov     ax, [di+DPT.twLbaSectors]
142    mov     dx, [di+DPT.twLbaSectors+2]
143    mov     bx, [di+DPT.twLbaSectors+4]
144    ret
145%endif ; MODULE_EBIOS
146
147
148;--------------------------------------------------------------------
149; Returns pointer to DRVPARAMS for master or slave drive.
150;
151; AccessDPT_GetPointerToDRVPARAMStoCSBX
152;   Parameters:
153;       DS:DI:  Ptr to Disk Parameter Table
154;   Returns:
155;       CS:BX:  Ptr to DRVPARAMS
156;   Corrupts registers:
157;       Nothing
158;--------------------------------------------------------------------
159AccessDPT_GetPointerToDRVPARAMStoCSBX:
160    call    AccessDPT_GetIdevarsToCSBX
161    add     bx, BYTE IDEVARS.drvParamsMaster    ; CS:BX points to Master Drive DRVPARAMS
162    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
163    jz      SHORT .ReturnPointerToDRVPARAMS
164    add     bx, BYTE DRVPARAMS_size             ; CS:BX points to Slave Drive DRVPARAMS
165.ReturnPointerToDRVPARAMS:
166    ret
167
168
169;--------------------------------------------------------------------
170; Needed many times during initialization so it is better to
171; make it as a function to save bytes.
172;
173; AccessDPT_GetIdevarsToCSBX
174;   Parameters:
175;       DS:DI:  Ptr to Disk Parameter Table
176;   Returns:
177;       CS:BX:  Ptr to IDEVARS for the drive
178;   Corrupts registers:
179;       Nothing
180;--------------------------------------------------------------------
181AccessDPT_GetIdevarsToCSBX:
182    eMOVZX  bx, BYTE [di+DPT.bIdevarsOffset]
183    ret
184
185
186;--------------------------------------------------------------------
187; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
188;   Parameters:
189;       DS:DI:  Ptr to Disk Parameter Table
190;   Returns:
191;       AX:     Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
192;               unshifted (still shifted where it is in bFlagsLow)
193;       ZF:     Set based on value in AL
194;   Corrupts registers:
195;       Nothing
196;--------------------------------------------------------------------
197;
198; Converted to a macro since only called in two places, and the call/ret overhead
199; is not worth it for these two instructions (4 bytes total)
200;
201%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
202    mov     al, [di+DPT.bFlagsLow]
203    and     ax, BYTE MASKL_DPT_TRANSLATEMODE
204%endmacro
Note: See TracBrowser for help on using the repository browser.