Rev 2900 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2900 | Rev 2901 | ||
---|---|---|---|
Line 112... | Line 112... | ||
112 | proc detect |
112 | proc detect |
113 | locals |
113 | locals |
114 | last_bus dd ? |
114 | last_bus dd ? |
115 | endl |
115 | endl |
Line -... | Line 116... | ||
- | 116 | ||
- | 117 | mov esi, msgSearch |
|
- | 118 | call SysMsgBoardStr |
|
116 | 119 | ||
117 | xor eax, eax |
120 | xor eax, eax |
118 | mov [bus], eax |
121 | mov [bus], eax |
119 | inc eax |
122 | inc eax |
120 | call PciApi ; get last bus |
123 | call PciApi ; get last bus |
Line 125... | Line 128... | ||
125 | .next_bus: |
128 | .next_bus: |
126 | and [devfn], 0 |
129 | and [devfn], 0 |
127 | .next_dev: |
130 | .next_dev: |
128 | stdcall PciRead16, [bus], [devfn], dword 0x0a ; read class/subclass |
131 | stdcall PciRead16, [bus], [devfn], dword 0x0a ; read class/subclass |
Line -... | Line 132... | ||
- | 132 | ||
- | 133 | cmp ax, 0x0300 ; display controller - vga compatable controller |
|
- | 134 | je .found |
|
129 | 135 | ||
130 | cmp ax, 0x0302 ; display controller - 3d controller |
136 | cmp ax, 0x0302 ; display controller - 3d controller |
Line 131... | Line 137... | ||
131 | je .found |
137 | je .found |
132 | 138 | ||
Line 164... | Line 170... | ||
164 | jmp .next |
170 | jmp .next |
Line 165... | Line 171... | ||
165 | 171 | ||
166 | .got_capabilities_list: |
172 | .got_capabilities_list: |
167 | stdcall PciRead8, [bus], [devfn], dword 0x34 ; read capabilities offset |
173 | stdcall PciRead8, [bus], [devfn], dword 0x34 ; read capabilities offset |
168 | and eax, 11111100b ; always dword aligned |
174 | and eax, 11111100b ; always dword aligned |
Line 169... | Line 175... | ||
169 | mov esi, eax |
175 | mov edi, eax |
170 | 176 | ||
171 | .read_capability: |
177 | .read_capability: |
172 | stdcall PciRead32, [bus], [devfn], esi ; read capability |
178 | stdcall PciRead32, [bus], [devfn], edi ; read capability |
173 | cmp al, 0x02 ; AGP |
179 | cmp al, 0x02 ; AGP |
174 | je .got_agp |
180 | je .got_agp |
175 | movzx esi, ah ; pointer to next capability |
181 | movzx edi, ah ; pointer to next capability |
176 | test esi, esi |
182 | test edi, edi |
Line 177... | Line 183... | ||
177 | jnz .read_capability |
183 | jnz .read_capability |
178 | jmp .next |
184 | jmp .next |
179 | 185 | ||
180 | .got_agp: |
186 | .got_agp: |
181 | shl eax, 16 |
187 | shr eax, 16 |
182 | mov [revision], al ; high nibble = major revision |
188 | mov [revision], al ; high nibble = major revision |
183 | ; low nibble = minor revision |
189 | ; low nibble = minor revision |
184 | add esi, 4 |
190 | add edi, 4 |
Line 185... | Line 191... | ||
185 | and al, 0xf0 |
191 | and al, 0xf0 |
- | 192 | cmp al, 0x30 |
|
- | 193 | je .agp_3 |
|
- | 194 | ||
186 | cmp al, 0x30 |
195 | .agp_2: |
- | 196 | mov esi, msgAGP2 |
|
187 | je .agp_3 |
197 | call SysMsgBoardStr |
188 | 198 | ||
Line 189... | Line 199... | ||
189 | .agp_2: |
199 | stdcall PciRead32, [bus], [devfn], edi ; read AGP status |
190 | stdcall PciRead32, [bus], [devfn], esi ; read AGP status |
200 | .agp_2_: |
Line 197... | Line 207... | ||
197 | test al, 1b |
207 | test al, 1b |
198 | jz .error |
208 | jz .error |
Line 199... | Line 209... | ||
199 | 209 | ||
200 | .001b: |
210 | .001b: |
- | 211 | mov [cmd], 001b |
|
- | 212 | mov esi, msg1 |
|
201 | mov [cmd], 001b |
213 | call SysMsgBoardStr |
Line 202... | Line 214... | ||
202 | jmp .agp_go |
214 | jmp .agp_go |
203 | 215 | ||
- | 216 | .010b: |
|
- | 217 | mov [cmd], 010b |
|
204 | .010b: |
218 | mov esi, msg2 |
Line 205... | Line 219... | ||
205 | mov [cmd], 010b |
219 | call SysMsgBoardStr |
206 | jmp .agp_go |
220 | jmp .agp_go |
- | 221 | ||
- | 222 | .100b: |
|
207 | 223 | mov [cmd], 100b |
|
Line -... | Line 224... | ||
- | 224 | mov esi, msg4 |
|
- | 225 | call SysMsgBoardStr |
|
- | 226 | jmp .agp_go |
|
- | 227 | ||
- | 228 | .agp_2m: |
|
208 | .100b: |
229 | mov esi, msgAGP2m |
- | 230 | call SysMsgBoardStr |
|
- | 231 | jmp .agp_2_ |
|
- | 232 | ||
209 | mov [cmd], 100b |
233 | .agp_3: |
210 | jmp .agp_go |
234 | mov esi, msgAGP3 |
211 | 235 | call SysMsgBoardStr |
|
212 | .agp_3: |
236 | |
- | 237 | stdcall PciRead32, [bus], [devfn], edi ; read AGP status |
|
213 | stdcall PciRead32, [bus], [devfn], esi ; read AGP status |
238 | test al, 1 shl 3 |
214 | test al, 1 shl 3 |
239 | jz .agp_2m |
- | 240 | test eax, 10b |
|
215 | jz .agp_2 |
241 | jnz .8x |
- | 242 | mov [cmd], 01b |
|
- | 243 | mov esi, msg4 |
|
216 | mov [cmd], eax |
244 | call SysMsgBoardStr |
- | 245 | jmp .agp_go |
|
- | 246 | ||
Line 217... | Line 247... | ||
217 | and [cmd], 11b |
247 | .8x: |
Line 218... | Line 248... | ||
218 | cmp [cmd], 11b |
248 | mov [cmd], 10b |
219 | jne .agp_go |
249 | mov esi, msg8 |
220 | mov [cmd], 10b |
250 | call SysMsgBoardStr |
221 | 251 | ||
- | 252 | .agp_go: |
|
- | 253 | ||
222 | .agp_go: |
254 | if FAST_WRITE |
223 | 255 | test ax, 1 shl 4 |
|
224 | if FAST_WRITE |
256 | jz @f |
225 | test ax, 1 shl 4 |
257 | or [cmd], 1 shl 4 |
226 | jz @f |
258 | mov esi, msgfast |
227 | or [cmd], 1 shl 4 |
259 | call SysMsgBoardStr |
- | 260 | @@: |
|
- | 261 | end if |
|
228 | @@: |
262 | if SIDE_BAND_ADDRESSING |
229 | end if |
263 | test ax, 1 shl 9 |
230 | if SIDE_BAND_ADDRESSING |
264 | jz @f |
- | 265 | or [cmd], 1 shl 9 |
|
- | 266 | mov esi, msgside |
|
- | 267 | call SysMsgBoardStr |
|
231 | test ax, 1 shl 9 |
268 | @@: |
232 | jz @f |
269 | end if |
233 | or [cmd], 1 shl 9 |
270 | add edi, 4 |
Line 234... | Line 271... | ||
234 | @@: |
271 | mov eax, [cmd] |
235 | end if |
272 | stdcall PciWrite32, [bus], [devfn], edi, eax ; write AGP cmd |
236 | add esi, 4 |
273 | |
237 | mov eax, [cmd] |
274 | mov eax, [cmd] |
Line 253... | Line 290... | ||
253 | align 4 |
290 | align 4 |
254 | version dd (5 shl 16) or (API_VERSION and 0xFFFF) |
291 | version dd (5 shl 16) or (API_VERSION and 0xFFFF) |
Line 255... | Line 292... | ||
255 | 292 | ||
Line -... | Line 293... | ||
- | 293 | my_service db 'AGP', 0 ; max 16 chars include zero |
|
256 | my_service db 'AGP', 0 ; max 16 chars include zero |
294 | |
257 | 295 | msgInit db 'AGP driver loaded.', 13, 10, 0 |
|
258 | msgInit db 'Searching AGP device...', 13, 10, 0 |
296 | msgSearch db 'Searching for AGP card...', 13, 10, 0 |
- | 297 | msgFail db 'device not found', 13, 10, 0 |
|
- | 298 | msgOK db 'AGP device enabled', 13, 10, 0 |
|
- | 299 | msgAGP2 db 'AGP2 device found', 13, 10, 0 |
|
- | 300 | msgAGP3 db 'AGP3 device found', 13, 10, 0 |
|
- | 301 | msgAGP2m db 'Running in AGP2 mode', 13, 10, 0 |
|
- | 302 | msg8 db '8x speed', 13, 10, 0 |
|
- | 303 | msg4 db '4x speed', 13, 10, 0 |
|
- | 304 | msg2 db '2x speed', 13, 10, 0 |
|
- | 305 | msg1 db '1x speed', 13, 10, 0 |
|
Line 259... | Line 306... | ||
259 | msgFail db 'device not found', 13, 10, 0 |
306 | msgfast db 'Fast Write', 13, 10, 0 |
Line 260... | Line 307... | ||
260 | msgOK db 'AGP device enabled', 13, 10, 0 |
307 | msgside db 'Side band addressing', 13, 10, 0 |