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

Last change on this file since 373 was 364, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Advanced ATA Module variables are now kept in DPTs.
  • Forced full mode when using Advanced ATA Module.
File size: 5.3 KB
RevLine 
[99]1; Project name : XTIDE Universal BIOS
[3]2; Description : Functions for accessing DPT data.
3
4; Section containing code
5SECTION .text
6
[364]7%ifdef MODULE_ADVANCED_ATA
[3]8;--------------------------------------------------------------------
[364]9; AccessDPT_GetIdeBasePortToBX
10; Parameters:
11; DS:DI: Ptr to Disk Parameter Table
12; Returns:
13; BX: IDE Base Port Address
14; Corrupts registers:
15; Nothing
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18AccessDPT_GetIdeBasePortToBX:
19 eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
20 mov bx, [cs:bx+IDEVARS.wPort]
21 ret
22
23%endif
24
25
26;--------------------------------------------------------------------
[150]27; AccessDPT_GetDriveSelectByteToAL
28; Parameters:
29; DS:DI: Ptr to Disk Parameter Table
30; Returns:
31; AL: Drive Select Byte
32; Corrupts registers:
33; Nothing
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36AccessDPT_GetDriveSelectByteToAL:
37 mov al, [di+DPT.wFlags]
38 and al, FLG_DRVNHEAD_LBA | FLG_DRVNHEAD_DRV
39 or al, MASK_DRVNHEAD_SET ; Bits set to 1 for old drives
40 ret
41
42
43;--------------------------------------------------------------------
44; AccessDPT_GetDeviceControlByteToAL
45; Parameters:
46; DS:DI: Ptr to Disk Parameter Table
47; Returns:
48; AL: Device Control Byte
49; Corrupts registers:
50; Nothing
51;--------------------------------------------------------------------
52ALIGN JUMP_ALIGN
53AccessDPT_GetDeviceControlByteToAL:
54 xor al, al
[158]55 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
[150]56 jnz SHORT .EnableDeviceIrq
57 or al, FLG_DEVCONTROL_nIEN ; Disable IRQ
58.EnableDeviceIrq:
59 ret
60
[227]61
[150]62;--------------------------------------------------------------------
[227]63; AccessDPT_GetLCHStoAXBLBH
[3]64; Parameters:
65; DS:DI: Ptr to Disk Parameter Table
66; Returns:
[227]67; AX: Number of L-CHS cylinders
68; BL: Number of L-CHS heads
69; BH: Number of L-CHS sectors per track
[3]70; Corrupts registers:
[227]71; CX, DX
[3]72;--------------------------------------------------------------------
[227]73AccessDPT_GetLCHStoAXBLBH:
74 ; Return LBA-assisted CHS if LBA addressing used
[173]75 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
[227]76 jz SHORT .ConvertPchsToLchs
[173]77
[227]78 call AccessDPT_GetLbaSectorCountToBXDXAX
[358]79 call LbaAssist_ConvertSectorCountFromBXDXAXtoLbaAssistedCHSinDXAXBLBH
80 LIMIT_LBA_CYLINDERS_IN_DXAX_TO_LCHS_CYLINDERS
[227]81 ret
[173]82
[227]83.ConvertPchsToLchs:
84 mov ax, [di+DPT.wPchsCylinders]
85 mov bx, [di+DPT.wPchsHeadsAndSectors]
[230]86 ; Fall to AccessDPT_ShiftPCHinAXBLtoLCH
[227]87
88
89;--------------------------------------------------------------------
90; AccessDPT_ShiftPCHinAXBLtoLCH
[173]91; Parameters:
[227]92; AX: P-CHS cylinders (1...16383)
93; BL: P-CHS heads (1...16)
[173]94; Returns:
[227]95; AX: Number of L-CHS cylinders (1...1024)
96; BL: Number of L-CHS heads (1...255)
[230]97; CX: Number of bits shifted (4 at most)
[173]98; Corrupts registers:
99; Nothing
100;--------------------------------------------------------------------
[227]101AccessDPT_ShiftPCHinAXBLtoLCH:
[173]102 xor cx, cx
103.ShiftLoop:
[227]104 cmp ax, MAX_LCHS_CYLINDERS ; Need to shift?
[231]105 jbe SHORT .Return ; If not, return
[173]106 inc cx ; Increment shift count
[227]107 shr ax, 1 ; Halve cylinders
108 shl bl, 1 ; Double heads
[231]109 jnz SHORT .ShiftLoop ; Falls through only on the last (4th) iteration and only if BL was 16 on entry
110 dec bl ; DOS doesn't support drives with 256 heads so we limit heads to 255
111 ; We can save a byte here by using DEC BX if we don't care about BH
112.Return:
[173]113 ret
114
[227]115
[173]116;--------------------------------------------------------------------
[230]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;--------------------------------------------------------------------
125AccessDPT_GetLbaSectorCountToBXDXAX:
126 mov ax, [di+DPT.twLbaSectors]
127 mov dx, [di+DPT.twLbaSectors+2]
128 mov bx, [di+DPT.twLbaSectors+4]
129 ret
130
131
132;--------------------------------------------------------------------
[3]133; Returns pointer to DRVPARAMS for master or slave drive.
134;
135; AccessDPT_GetPointerToDRVPARAMStoCSBX
136; Parameters:
137; DS:DI: Ptr to Disk Parameter Table
138; Returns:
139; CS:BX: Ptr to DRVPARAMS
140; Corrupts registers:
141; Nothing
142;--------------------------------------------------------------------
143ALIGN JUMP_ALIGN
144AccessDPT_GetPointerToDRVPARAMStoCSBX:
[150]145 eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
146 add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
[158]147 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
[150]148 jz SHORT .ReturnPointerToDRVPARAMS
149 add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
150.ReturnPointerToDRVPARAMS:
[3]151 ret
[200]152
153;--------------------------------------------------------------------
154; AccessDPT_GetUnshiftedAddressModeToALZF
155; Parameters:
156; DS:DI: Ptr to Disk Parameter Table
157; Returns:
[230]158; AL: Addressing Mode (L-CHS, P-CHS, LBA28, LBA48)
[200]159; unshifted (still shifted where it is in bFlagsLow)
160; ZF: Set based on value in AL
161; Corrupts registers:
162; AL
163;--------------------------------------------------------------------
[230]164;
165; Converted to a macro since only called in two places, and the call/ret overhead
[200]166; is not worth it for these two instructions (4 bytes total)
167;
168%macro AccessDPT_GetUnshiftedAddressModeToALZF 0
169 mov al, [di+DPT.bFlagsLow]
170 and al, MASKL_DPT_ADDRESSING_MODE
171%endmacro
Note: See TracBrowser for help on using the repository browser.