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

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

Changes to XTIDE Universal BIOS:

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