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

Last change on this file since 208 was 200, checked in by gregli@…, 13 years ago

Added logic to skip scanning COM ports if a COM port was already found during the normal detection process, to avoid finding the same serial drive twice and preseting the OS with two drives which in reality point to the same physical file on the server. Also added logic to skip scanning for the slave serial drive if the master was not found. And various small optimizations.

File size: 4.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for accessing DPT data.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
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
36 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_ENABLE_IRQ
37 jnz SHORT .EnableDeviceIrq
38 or al, FLG_DEVCONTROL_nIEN ; Disable IRQ
39.EnableDeviceIrq:
40 ret
41
42
43;--------------------------------------------------------------------
44; AccessDPT_GetLCHS
45; Parameters:
46; DS:DI: Ptr to Disk Parameter Table
47; Returns:
48; AX: Number of L-CHS sectors per track
49; BX: Number of L-CHS cylinders
50; DX: Number of L-CHS heads
51; Corrupts registers:
52; CX
53;--------------------------------------------------------------------
54AccessDPT_GetLCHS:
55 ; Load CHS from DPT
56 eMOVZX ax, BYTE [di+DPT.bSectors]
57 mov bx, [di+DPT.dwCylinders]
58 cwd
59 mov dl, [di+DPT.bHeads]
60
61 ; Only need to limit sectors for LBA assist
62 test BYTE [di+DPT.bFlagsLow], FLG_DRVNHEAD_LBA
63 jz SHORT AccessDPT_ShiftPCHinBXDXtoLCH
64
65 cmp WORD [di+DPT.dwCylinders+2], BYTE 0
66 jnz SHORT .Return_MAX_LCHS_CYLINDERS
67
68 ; Limit cylinders to 1024
69 cmp bx, MAX_LCHS_CYLINDERS
70 jb SHORT .Return
71ALIGN JUMP_ALIGN
72.Return_MAX_LCHS_CYLINDERS:
73 mov bx, MAX_LCHS_CYLINDERS
74ALIGN JUMP_ALIGN, ret
75.Return:
76 ret
77
78
79;--------------------------------------------------------------------
80; AccessDPT_ShiftPCHinBXDXtoLCH
81; Parameters:
82; BX: P-CHS cylinders (1...16383)
83; DX: P-CHS heads (1...16)
84; Returns:
85; BX: Number of L-CHS cylinders (1...1024)
86; DX: Number of L-CHS heads (1...255)
87; CX: Number of bits shifted
88; Corrupts registers:
89; Nothing
90;--------------------------------------------------------------------
91AccessDPT_ShiftPCHinBXDXtoLCH:
92 xor cx, cx
93.ShiftLoop:
94 cmp bx, MAX_LCHS_CYLINDERS ; Need to shift?
95 jbe SHORT .LimitHeadsTo255 ; If not, return
96 inc cx ; Increment shift count
97 shr bx, 1 ; Halve cylinders
98 shl dx, 1 ; Double heads
99 jmp SHORT .ShiftLoop
100.LimitHeadsTo255: ; DOS does not support drives with 256 heads
101 sub dl, dh ; DH set only when 256 logical heads
102 xor dh, dh
103 ret
104
105
106;--------------------------------------------------------------------
107; Returns pointer to DRVPARAMS for master or slave drive.
108;
109; AccessDPT_GetPointerToDRVPARAMStoCSBX
110; Parameters:
111; DS:DI: Ptr to Disk Parameter Table
112; Returns:
113; CS:BX: Ptr to DRVPARAMS
114; Corrupts registers:
115; Nothing
116;--------------------------------------------------------------------
117ALIGN JUMP_ALIGN
118AccessDPT_GetPointerToDRVPARAMStoCSBX:
119 eMOVZX bx, [di+DPT.bIdevarsOffset] ; CS:BX points to IDEVARS
120 add bx, BYTE IDEVARS.drvParamsMaster ; CS:BX points to Master Drive DRVPARAMS
121 test BYTE [di+DPT.bFlagsLow], FLGL_DPT_SLAVE
122 jz SHORT .ReturnPointerToDRVPARAMS
123 add bx, BYTE DRVPARAMS_size ; CS:BX points to Slave Drive DRVPARAMS
124.ReturnPointerToDRVPARAMS:
125 ret
126
127;--------------------------------------------------------------------
128; AccessDPT_GetUnshiftedAddressModeToALZF
129; Parameters:
130; DS:DI: Ptr to Disk Parameter Table
131; Returns:
132; AL: Addressing Mode (L-CHS, P-CHS, LBA28, LBA48)
133; unshifted (still shifted where it is in bFlagsLow)
134; ZF: Set based on value in AL
135; Corrupts registers:
136; AL
137;--------------------------------------------------------------------
138;
139; Converted to a macro since only called in two places, and the call/ret overhead
140; is not worth it for these two instructions (4 bytes total)
141;
142%macro AccessDPT_GetUnshiftedAddressModeToALZF 0
143 mov al, [di+DPT.bFlagsLow]
144 and al, MASKL_DPT_ADDRESSING_MODE
145%endmacro
146
147
Note: See TracBrowser for help on using the repository browser.