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

Last change on this file since 531 was 526, checked in by krille_n_@…, 12 years ago

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 6.2 KB
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for accessing DPT data.
3
[376]4;
[491]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[491]12;
[376]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
[491]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[491]18;
[376]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
[491]69
70%ifndef USE_UNDOC_INTEL
[150]71 xor al, al
[491]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
[150]80 jnz SHORT .EnableDeviceIrq
81 or al, FLG_DEVCONTROL_nIEN ; Disable IRQ
82.EnableDeviceIrq:
[411]83%else
84 mov al, FLG_DEVCONTROL_nIEN ; Disable IRQ
[491]85%endif ; MODULE_IRQ
[150]86 ret
87
[227]88
[150]89;--------------------------------------------------------------------
[227]90; AccessDPT_GetLCHStoAXBLBH
[3]91; Parameters:
92; DS:DI: Ptr to Disk Parameter Table
93; Returns:
[227]94; AX: Number of L-CHS cylinders
95; BL: Number of L-CHS heads
96; BH: Number of L-CHS sectors per track
[3]97; Corrupts registers:
[421]98; Nothing
[3]99;--------------------------------------------------------------------
[227]100AccessDPT_GetLCHStoAXBLBH:
[421]101 mov ax, [di+DPT.wLchsCylinders]
102 mov bx, [di+DPT.wLchsHeadsAndSectors]
[227]103 ret
[173]104
[227]105
[493]106%ifdef MODULE_8BIT_IDE_ADVANCED
[473]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
[493]127%endif ; MODULE_8BIT_IDE_ADVANCED
[473]128
129
[421]130%ifdef MODULE_EBIOS
[227]131;--------------------------------------------------------------------
[230]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
[421]145%endif ; MODULE_EBIOS
[230]146
147
148;--------------------------------------------------------------------
[3]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:
[473]160 call AccessDPT_GetIdevarsToCSBX
[150]161 add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
[158]162 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
[150]163 jz SHORT .ReturnPointerToDRVPARAMS
164 add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
165.ReturnPointerToDRVPARAMS:
[3]166 ret
[200]167
[421]168
[200]169;--------------------------------------------------------------------
[473]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;--------------------------------------------------------------------
[422]187; ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF
[200]188; Parameters:
189; DS:DI: Ptr to Disk Parameter Table
190; Returns:
[422]191; AX: Translate Mode (TRANSLATEMODE_NORMAL, TRANSLATEMODE_LARGE or TRANSLATEMODE_ASSISTED_LBA)
[200]192; unshifted (still shifted where it is in bFlagsLow)
193; ZF: Set based on value in AL
194; Corrupts registers:
[421]195; Nothing
[200]196;--------------------------------------------------------------------
[230]197;
198; Converted to a macro since only called in two places, and the call/ret overhead
[200]199; is not worth it for these two instructions (4 bytes total)
200;
[422]201%macro ACCESSDPT__GET_UNSHIFTED_TRANSLATE_MODE_TO_AXZF 0
[200]202 mov al, [di+DPT.bFlagsLow]
[422]203 and ax, BYTE MASKL_DPT_TRANSLATEMODE
[200]204%endmacro
Note: See TracBrowser for help on using the repository browser.