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
RevLine 
[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
21SECTION .text
22
23;--------------------------------------------------------------------
[421]24; AccessDPT_GetDriveSelectByteForOldInt13hToAL
25; AccessDPT_GetDriveSelectByteForEbiosToAL
[150]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
[421]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
[150]40    or      al, MASK_DRVNHEAD_SET   ; Bits set to 1 for old drives
41    ret
42
[421]43%ifdef MODULE_EBIOS
44ALIGN JUMP_ALIGN
45AccessDPT_GetDriveSelectByteForEbiosToAL:
[443]46    mov     al, [di+DPT.bFlagsLow]
[421]47    ; Fall to GetDriveSelectByteForAssistedLBAtoAL
48%endif ; MODULE_EBIOS
[150]49
[421]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
[150]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:
[411]68%ifdef MODULE_IRQ
[150]69    xor     al, al
[158]70    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
[150]71    jnz     SHORT .EnableDeviceIrq
72    or      al, FLG_DEVCONTROL_nIEN ; Disable IRQ
73.EnableDeviceIrq:
[411]74%else
75    mov     al, FLG_DEVCONTROL_nIEN ; Disable IRQ
76%endif
[150]77    ret
78
[227]79
[150]80;--------------------------------------------------------------------
[227]81; AccessDPT_GetLCHStoAXBLBH
[3]82;   Parameters:
83;       DS:DI:  Ptr to Disk Parameter Table
84;   Returns:
[227]85;       AX:     Number of L-CHS cylinders
86;       BL:     Number of L-CHS heads
87;       BH:     Number of L-CHS sectors per track
[3]88;   Corrupts registers:
[421]89;       Nothing
[3]90;--------------------------------------------------------------------
[227]91AccessDPT_GetLCHStoAXBLBH:
[421]92    mov     ax, [di+DPT.wLchsCylinders]
93    mov     bx, [di+DPT.wLchsHeadsAndSectors]
[227]94    ret
[173]95
[227]96
[473]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
[421]121%ifdef MODULE_EBIOS
[227]122;--------------------------------------------------------------------
[230]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
[421]136%endif ; MODULE_EBIOS
[230]137
138
139;--------------------------------------------------------------------
[3]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:
[473]151    call    AccessDPT_GetIdevarsToCSBX
[150]152    add     bx, BYTE IDEVARS.drvParamsMaster    ; CS:BX points to Master Drive DRVPARAMS
[158]153    test    BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
[150]154    jz      SHORT .ReturnPointerToDRVPARAMS
155    add     bx, BYTE DRVPARAMS_size             ; CS:BX points to Slave Drive DRVPARAMS
156.ReturnPointerToDRVPARAMS:
[3]157    ret
[200]158
[421]159
[200]160;--------------------------------------------------------------------
[473]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;--------------------------------------------------------------------
[422]178; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
[200]179;   Parameters:
180;       DS:DI:  Ptr to Disk Parameter Table
181;   Returns:
[422]182;       AX:     Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
[200]183;               unshifted (still shifted where it is in bFlagsLow)
184;       ZF:     Set based on value in AL
185;   Corrupts registers:
[421]186;       Nothing
[200]187;--------------------------------------------------------------------
[230]188;
189; Converted to a macro since only called in two places, and the call/ret overhead
[200]190; is not worth it for these two instructions (4 bytes total)
191;
[422]192%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
[200]193    mov     al, [di+DPT.bFlagsLow]
[422]194    and     ax, BYTE MASKL_DPT_TRANSLATEMODE
[200]195%endmacro
Note: See TracBrowser for help on using the repository browser.