source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/VariablesAndDPTs/FindDPT.asm@ 154

Last change on this file since 154 was 152, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • XTIDE mod should now be supported (untested).
  • Interrupt Service Routine no longer requires variable from RAMVARS.
  • Some small improvements.
File size: 5.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for finding Disk Parameter Table.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Finds pointer to first unused Disk Parameter Table.
9;
10; FindDPT_ForNewDriveToDSDI
11; Parameters:
12; DS: RAMVARS segment
13; Returns:
14; DS:DI: Ptr to first unused DPT
15; Corrupts registers:
16; DL
17;--------------------------------------------------------------------
18ALIGN JUMP_ALIGN
19FindDPT_ForNewDriveToDSDI:
20 mov dl, [RAMVARS.bFirstDrv]
21 add dl, [RAMVARS.bDrvCnt]
22 ; Fall to FindDPT_ForDriveNumber
23
24
25;--------------------------------------------------------------------
26; Finds Disk Parameter Table for drive number.
27; IDE Base Port address will be stored to RAMVARS if correct DPT is found.
28;
29; FindDPT_ForDriveNumber
30; Parameters:
31; DL: Drive number
32; DS: RAMVARS segment
33; Returns:
34; DS:DI: Ptr to DPT
35; Corrupts registers:
36; Nothing
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39FindDPT_ForDriveNumber:
40 push dx
41 push ax
42
43 mov al, LARGEST_DPT_SIZE
44 sub dl, [RAMVARS.bFirstDrv]
45 mul dl
46 add ax, BYTE RAMVARS_size
47 xchg di, ax
48
49 pop ax
50 pop dx
51 ret
52
53
54;--------------------------------------------------------------------
55; Finds Disk Parameter Table for
56; Master or Slave drive at wanted port.
57;
58; FindDPT_ToDSDIForIdeMasterAtPortDX
59; FindDPT_ToDSDIForIdeSlaveAtPortDX
60; Parameters:
61; DX: IDE Base Port address
62; DS: RAMVARS segment
63; Returns:
64; DL: Drive number (if DPT found)
65; DS:DI: Ptr to DPT
66; CF: Set if wanted DPT found
67; Cleared if DPT not found
68; Corrupts registers:
69; SI
70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
72FindDPT_ToDSDIForIdeMasterAtPortDX:
73 mov si, IterateToMasterAtPortCallback
74 jmp SHORT IterateAllDPTs
75
76ALIGN JUMP_ALIGN
77FindDPT_ToDSDIForIdeSlaveAtPortDX:
78 mov si, IterateToSlaveAtPortCallback
79 jmp SHORT IterateAllDPTs
80
81;--------------------------------------------------------------------
82; Iteration callback for finding DPT using
83; IDE base port for Master or Slave drive.
84;
85; IterateToSlaveAtPortCallback
86; IterateToMasterAtPortCallback
87; Parameters:
88; CH: Drive number
89; DX: IDE Base Port address
90; DS:DI: Ptr to DPT to examine
91; Returns:
92; DL: Drive number if correct DPT
93; CF: Set if wanted DPT found
94; Cleared if wrong DPT
95; Corrupts registers:
96; Nothing
97;--------------------------------------------------------------------
98ALIGN JUMP_ALIGN
99IterateToSlaveAtPortCallback:
100 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE ; Clears CF
101 jnz SHORT CompareBasePortAddress
102 ret ; Wrong DPT
103
104ALIGN JUMP_ALIGN
105IterateToMasterAtPortCallback:
106 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE
107 jnz SHORT ReturnWrongDPT ; Return if slave drive
108
109CompareBasePortAddress:
110 push bx
111 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS
112 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port?
113 pop bx
114 jne SHORT ReturnWrongDPT
115 mov dl, ch ; Return drive number in DL
116 stc ; Set CF since wanted DPT
117 ret
118
119
120;--------------------------------------------------------------------
121; FindDPT_ToDSDIforInterruptInService
122; Parameters:
123; DS: RAMVARS segment
124; Returns:
125; DS:DI: Ptr to DPT
126; CF: Set if wanted DPT found
127; Cleared if DPT not found
128; Corrupts registers:
129; SI
130;--------------------------------------------------------------------
131ALIGN JUMP_ALIGN
132FindDPT_ToDSDIforInterruptInService:
133 mov si, IterateToDptWithInterruptInServiceFlagSet
134 jmp SHORT IterateAllDPTs
135
136;--------------------------------------------------------------------
137; IterateToDptWithInterruptInServiceFlagSet
138; Parameters:
139; DS:DI: Ptr to DPT to examine
140; Returns:
141; CF: Set if wanted DPT found
142; Cleared if wrong DPT
143; Corrupts registers:
144; Nothing
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147IterateToDptWithInterruptInServiceFlagSet:
148 test WORD [di+DPT.wFlags], FLG_DPT_INTERRUPT_IN_SERVICE
149 jz SHORT ReturnWrongDPT
150 stc ; Set CF since wanted DPT
151 ret
152ReturnWrongDPT:
153 clc ; Clear CF since wrong DPT
154 ret
155
156
157;--------------------------------------------------------------------
158; Iterates all Disk Parameter Tables.
159;
160; IterateAllDPTs
161; Parameters:
162; AX,BX,DX: Parameters to callback function
163; CS:SI: Ptr to callback function
164; DS: RAMVARS segment
165; Returns:
166; DS:DI: Ptr to wanted DPT (if found)
167; CF: Set if wanted DPT found
168; Cleared if DPT not found
169; Corrupts registers:
170; Nothing unless corrupted by callback function
171;--------------------------------------------------------------------
172ALIGN JUMP_ALIGN
173IterateAllDPTs:
174 push cx
175 mov cx, [RAMVARS.wDrvCntAndFirst]
176 jcxz .AllDptsIterated ; Return if no drives
177 mov di, RAMVARS_size ; Point DS:DI to first DPT
178ALIGN JUMP_ALIGN
179.LoopWhileDPTsLeft:
180 call si ; Is wanted DPT?
181 jc SHORT .AllDptsIterated ; If so, return
182 inc ch ; Increment drive number
183 add di, BYTE LARGEST_DPT_SIZE ; Point to next DPT
184 dec cl ; Decrement drives left
185 jnz SHORT .LoopWhileDPTsLeft
186 clc ; Clear CF since DPT not found
187ALIGN JUMP_ALIGN
188.AllDptsIterated:
189 pop cx
190 ret
Note: See TracBrowser for help on using the repository browser.