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

Last change on this file since 157 was 152, checked in by Tomi Tilli, 14 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
RevLine 
[150]1; Project name : XTIDE Universal BIOS
[3]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;
[150]10; FindDPT_ForNewDriveToDSDI
[3]11; Parameters:
12; DS: RAMVARS segment
13; Returns:
14; DS:DI: Ptr to first unused DPT
15; Corrupts registers:
[150]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:
[3]36; Nothing
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
[150]39FindDPT_ForDriveNumber:
40 push dx
41 push ax
[3]42
[150]43 mov al, LARGEST_DPT_SIZE
44 sub dl, [RAMVARS.bFirstDrv]
45 mul dl
46 add ax, BYTE RAMVARS_size
47 xchg di, ax
[3]48
[150]49 pop ax
50 pop dx
51 ret
52
53
[3]54;--------------------------------------------------------------------
55; Finds Disk Parameter Table for
56; Master or Slave drive at wanted port.
57;
[150]58; FindDPT_ToDSDIForIdeMasterAtPortDX
59; FindDPT_ToDSDIForIdeSlaveAtPortDX
[3]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:
[150]69; SI
[3]70;--------------------------------------------------------------------
71ALIGN JUMP_ALIGN
[150]72FindDPT_ToDSDIForIdeMasterAtPortDX:
[152]73 mov si, IterateToMasterAtPortCallback
[150]74 jmp SHORT IterateAllDPTs
[3]75
76ALIGN JUMP_ALIGN
[150]77FindDPT_ToDSDIForIdeSlaveAtPortDX:
[152]78 mov si, IterateToSlaveAtPortCallback
[150]79 jmp SHORT IterateAllDPTs
[3]80
81;--------------------------------------------------------------------
82; Iteration callback for finding DPT using
83; IDE base port for Master or Slave drive.
84;
[152]85; IterateToSlaveAtPortCallback
86; IterateToMasterAtPortCallback
[3]87; Parameters:
[150]88; CH: Drive number
[3]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
[152]99IterateToSlaveAtPortCallback:
[150]100 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE ; Clears CF
101 jnz SHORT CompareBasePortAddress
102 ret ; Wrong DPT
[3]103
104ALIGN JUMP_ALIGN
[152]105IterateToMasterAtPortCallback:
[150]106 test BYTE [di+DPT.wFlags], FLG_DPT_SLAVE
107 jnz SHORT ReturnWrongDPT ; Return if slave drive
[3]108
[150]109CompareBasePortAddress:
[3]110 push bx
[150]111 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset] ; CS:BX now points to IDEVARS
112 cmp dx, [cs:bx+IDEVARS.wPort] ; Wanted port?
[3]113 pop bx
[150]114 jne SHORT ReturnWrongDPT
115 mov dl, ch ; Return drive number in DL
116 stc ; Set CF since wanted DPT
[3]117 ret
[152]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
[150]152ReturnWrongDPT:
[152]153 clc ; Clear CF since wrong DPT
[3]154 ret
155
156
157;--------------------------------------------------------------------
158; Iterates all Disk Parameter Tables.
159;
[150]160; IterateAllDPTs
[3]161; Parameters:
[152]162; AX,BX,DX: Parameters to callback function
163; CS:SI: Ptr to callback function
164; DS: RAMVARS segment
[3]165; Returns:
[152]166; DS:DI: Ptr to wanted DPT (if found)
167; CF: Set if wanted DPT found
168; Cleared if DPT not found
[3]169; Corrupts registers:
[150]170; Nothing unless corrupted by callback function
[3]171;--------------------------------------------------------------------
172ALIGN JUMP_ALIGN
[150]173IterateAllDPTs:
[3]174 push cx
[150]175 mov cx, [RAMVARS.wDrvCntAndFirst]
176 jcxz .AllDptsIterated ; Return if no drives
[152]177 mov di, RAMVARS_size ; Point DS:DI to first DPT
[3]178ALIGN JUMP_ALIGN
179.LoopWhileDPTsLeft:
180 call si ; Is wanted DPT?
[150]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
[3]186 clc ; Clear CF since DPT not found
187ALIGN JUMP_ALIGN
[150]188.AllDptsIterated:
[3]189 pop cx
190 ret
Note: See TracBrowser for help on using the repository browser.