Rev 1981 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1356 | diamond | 1 | ;*************************************************************** |
132 | diamond | 2 | ; project name: PCI Device Enumeration |
475 | Ghost | 3 | ; target platform: KolibriOS |
1351 | art_zh | 4 | ; compiler: flat assembler 1.68 |
1982 | mario79 | 5 | ; version: 2.3 |
6 | ; last update: June 2011 |
||
475 | Ghost | 7 | ; maintained by: Jason Delozier (cordata51@hotmail.com) |
8 | ; Sergey Kuzmin (kuzmin_serg@list.ru) |
||
9 | ; Mihailov Ilia (ghost.nsk@gmail.com) |
||
1982 | mario79 | 10 | ; Marat Zakiyanov |
1351 | art_zh | 11 | ; Artem Jerdev (art_zh@yahoo.com) |
1982 | mario79 | 12 | ; Evgeny Grechnikov |
13 | ; Veroniņa (Clever Mouse) |
||
14 | ; Yogev Ezra |
||
15 | ; old project site: http://www.coolthemes.narod.ru/pcidev.html |
||
16 | ; new project site: http://board.kolibrios.org/viewtopic.php?f=42&t=73 |
||
132 | diamond | 17 | ;*************************************************************** |
18 | ;Summary: This program will attempt to scan the PCI Bus |
||
19 | ; and display basic information about each device |
||
20 | ; connected to the PCI Bus. |
||
21 | ;*************************************************************** |
||
1982 | mario79 | 22 | ;----------------------------------------------------------------------------- |
1364 | diamond | 23 | include '../../../macros.inc' |
1351 | art_zh | 24 | |
1982 | mario79 | 25 | include '../../../develop/libraries/box_lib/load_lib.mac' |
26 | ;----------------------------------------------------------------------------- |
||
27 | use32 |
||
28 | org 0x0 |
||
29 | db 'MENUET01' ; 8 byte id |
||
30 | dd 0x01 ; header version |
||
31 | dd START ; start of code |
||
32 | dd IM_END ; size of image |
||
33 | dd I_END ; memory for app |
||
34 | dd stacktop ; esp |
||
35 | dd 0 ; I_Param |
||
36 | dd path ; APPLICATION PACH |
||
37 | ;----------------------------------------------------------------------------- |
||
38 | @use_library ; load_lib macro |
||
39 | ;----------------------------------------------------------------------------- |
||
40 | START: |
||
41 | mcall 68,11 |
||
42 | mcall 66,1,1 |
||
43 | ;----------------------------------------------------------------------------- |
||
44 | load_libraries l_libs_start,end_l_libs |
||
45 | ;----------------------------------------------------------------------------- |
||
46 | ;OpenDialog initialisation |
||
47 | push dword OpenDialog_data |
||
48 | call [OpenDialog_Init] |
||
49 | |||
50 | mov edi,filename_area |
||
51 | mov esi,start_temp_file_name |
||
52 | call copy_file_name_path |
||
53 | ;----------------------------------------------------------------------------- |
||
54 | mcall 68,12,4096 |
||
55 | mov [store_text_area_start],eax |
||
56 | ;----------------------------------------------------------------------------- |
||
475 | Ghost | 57 | call draw_window |
1982 | mario79 | 58 | still: |
59 | mcall 10 ; wait here for event |
||
475 | Ghost | 60 | dec eax ; redraw request ? |
61 | jz red |
||
62 | dec eax ; key in buffer ? |
||
63 | jz key |
||
64 | dec eax ; button in buffer ? |
||
65 | jz button |
||
66 | jmp still |
||
1982 | mario79 | 67 | ;----------------------------------------------------------------------------- |
475 | Ghost | 68 | red: ; redraw |
69 | mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size |
||
485 | heavyiron | 70 | mov eax, [Proc_Info.box.left]; store the window coordinates into the Form Structure |
475 | Ghost | 71 | mov [Form + 2], ax ; x start position |
485 | heavyiron | 72 | mov eax, [Proc_Info.box.top]; |
475 | Ghost | 73 | mov [Form + 6], ax ; ystart position |
485 | heavyiron | 74 | mov eax, [Proc_Info.box.width] ; |
475 | Ghost | 75 | mov [Form], ax ; window width |
485 | heavyiron | 76 | mov eax, [Proc_Info.box.height] ; |
475 | Ghost | 77 | mov [Form + 4] ,ax ; window height |
78 | call draw_window ; go redraw window now |
||
79 | jmp still |
||
1982 | mario79 | 80 | ;----------------------------------------------------------------------------- |
475 | Ghost | 81 | key: ; key |
82 | mcall 2 ; just read it and ignore |
||
1982 | mario79 | 83 | cmp [extended_key],1 |
84 | je .extended_key |
||
85 | test al, al |
||
86 | jnz still |
||
87 | cmp ah, 0xE0 |
||
88 | jne @f |
||
89 | mov [extended_key],1 |
||
475 | Ghost | 90 | jmp still |
1982 | mario79 | 91 | @@: |
92 | cmp ah,129 ; Esc |
||
93 | je button.exit |
||
94 | cmp ah,159 |
||
95 | je call_OpenDialog |
||
96 | jmp still |
||
97 | .extended_key: |
||
98 | mov [extended_key],0 |
||
99 | cmp ah,129 ; Esc |
||
100 | je button.exit |
||
101 | cmp ah,159 |
||
102 | je call_OpenDialog |
||
103 | jmp still |
||
104 | ;----------------------------------------------------------------------------- |
||
1351 | art_zh | 105 | button: ; button |
475 | Ghost | 106 | mcall 17 ; get id |
1982 | mario79 | 107 | cmp ah,2 |
108 | je call_OpenDialog |
||
475 | Ghost | 109 | cmp ah, 1 ; button id = 1 ? |
110 | jne still |
||
1982 | mario79 | 111 | .exit: |
475 | Ghost | 112 | mcall -1 ; close this program |
1982 | mario79 | 113 | ;----------------------------------------------------------------------------- |
114 | call_OpenDialog: |
||
115 | mov [OpenDialog_data.type],1 ; Save |
||
116 | |||
117 | push dword OpenDialog_data |
||
118 | call [OpenDialog_Start] |
||
132 | diamond | 119 | |
1982 | mario79 | 120 | cmp [OpenDialog_data.status],2 ; OpenDialog does not start |
121 | je .save_file_default_path |
||
122 | |||
123 | cmp [OpenDialog_data.status],1 |
||
124 | jne still |
||
125 | |||
126 | call store_data |
||
127 | jmp still |
||
128 | ;---------------------------------------- |
||
129 | .save_file_default_path: |
||
130 | mov edi,file_name |
||
131 | mov esi,file_default_path |
||
132 | call copy_file_name_path |
||
133 | call store_data |
||
134 | jmp still |
||
135 | ;---------------------------------------- |
||
136 | copy_file_name_path: |
||
137 | xor eax,eax |
||
138 | cld |
||
139 | @@: |
||
140 | lodsb |
||
141 | stosb |
||
142 | test eax,eax |
||
143 | jnz @r |
||
144 | ret |
||
145 | ;----------------------------------------------------------------------------- |
||
146 | prepare_text_area: |
||
147 | mov edi,[store_text_area_start] |
||
148 | |||
149 | push edi |
||
150 | mov ecx,4096/4 ; I hope this will be enough for store of data |
||
151 | mov eax,dword ' ' |
||
152 | cld |
||
153 | rep stosd |
||
154 | pop edi |
||
155 | |||
156 | mov esi,PCIWin |
||
157 | xor ecx,ecx |
||
158 | @@: |
||
159 | mov cl,[esi] |
||
160 | inc esi |
||
161 | rep movsb |
||
162 | mov al,0Ah ; CR - carriage return |
||
163 | stosb |
||
164 | cmp [esi],byte 0xFF |
||
165 | jne @r |
||
166 | |||
167 | mov [store_text_area_end],edi |
||
168 | |||
169 | xor edi,edi |
||
170 | ret |
||
171 | ;----------------------------------------------------------------------------- |
||
132 | diamond | 172 | draw_window: |
1982 | mario79 | 173 | call prepare_text_area |
174 | |||
475 | Ghost | 175 | mov byte [total], 0 |
176 | mcall 12, 1 ; start of draw |
||
177 | ; DRAW WINDOW |
||
1982 | mario79 | 178 | mcall 0,dword [Form],dword [Form + 4],0x13ffffff,0x805080d0,title |
179 | mcall 8,<450,100>,<25,25>,2,0xC0C0C0 |
||
180 | shr ecx,16 |
||
181 | mov bx,cx |
||
182 | add ebx,13 shl 16+4 |
||
183 | mcall 4,,0x80000000,text_save_button |
||
184 | add bx,11 |
||
185 | mcall ,,,text_save_button.1 |
||
475 | Ghost | 186 | ; Insert horizontal bars in list area |
1351 | art_zh | 187 | mov eax, 13 ; draw bar system function |
188 | mov ebx, 18 ; set Xstart position of bar |
||
189 | shl ebx, 16 ; |
||
190 | mov bx, word [Form] ; get width of window |
||
475 | Ghost | 191 | sub bx, 32 ; bar is 32 pixels shorter then window width |
192 | mov ecx, 119 * 65536 + 10 ; set Ystart(109) and Height(10) of bar 109 |
||
193 | mov edx, 0xC0C0C0 ; set color of bar |
||
194 | again: ;begin draw bar loop |
||
195 | mcall ; draw bar to window area |
||
1351 | art_zh | 196 | shr ecx, 16 ; move the Ystart position to working area |
197 | add ecx, 34 ; add 34 pixels to Y Start (moves bar down) |
||
475 | Ghost | 198 | cmp cx, word [Form + 4] ; is the Ystart position outside of window area |
199 | jae nomo ; if so stop drawing bars |
||
1351 | art_zh | 200 | sub ecx, 14 ; if not, we only need 20 pixels between bar tops |
201 | shl ecx, 16 ; set that values as Ystart |
||
202 | add ecx, 10 ; Bar Height is always 10 pixels |
||
475 | Ghost | 203 | jmp again ; draw another bar |
1982 | mario79 | 204 | ;----------------------------------------------------------------------------- |
475 | Ghost | 205 | nomo: ;done drawing bars here |
206 | ; start PCI stuff |
||
207 | call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device |
||
132 | diamond | 208 | |
475 | Ghost | 209 | ; Window inteface |
210 | mov cx, [PCI_Version] |
||
211 | add ch, '0' |
||
1351 | art_zh | 212 | mov [PCIWin + 85], ch ; 0xBADCODE but it works ! |
475 | Ghost | 213 | mov ch, cl |
214 | shr cl, 4 |
||
215 | and ch, 0x0f |
||
216 | add cx, '00' |
||
217 | mov [PCIWin + 87], cx |
||
1351 | art_zh | 218 | mov cl, [PCI_LastBus] ; will only work if [PCI_LastBus] < 10 |
475 | Ghost | 219 | add cl, '0' |
1351 | art_zh | 220 | mov [PCIWin + 106], cl |
221 | |||
475 | Ghost | 222 | mov edx, PCIWin |
223 | mov ebx, 20 * 65536 + 25 ; x start, ystart of text |
||
224 | mov ecx, 0x224466 ; color of text |
||
225 | mov eax, 4 |
||
1982 | mario79 | 226 | @@: |
227 | movzx esi, byte[edx] |
||
475 | Ghost | 228 | inc edx |
229 | mcall |
||
230 | add ebx, 10 |
||
231 | add edx, esi |
||
232 | cmp byte[edx], -1 |
||
233 | jne @b |
||
234 | ; Quantity of devices... |
||
235 | movzx ecx, byte [total] ; number to draw |
||
236 | mcall 47, 0x00020000,,150 * 65536 + 65, 0x224466 |
||
1386 | art_zh | 237 | |
238 | mov ah, [MMIO_allowed] |
||
239 | or ah, ah |
||
240 | jz @f |
||
241 | mov ah, [MMIO_Bus] ; =255 if MMIO disabled / not found |
||
242 | and ah, 0x7f |
||
243 | inc ah |
||
244 | jo @f |
||
1351 | art_zh | 245 | call Try_MMIO |
1386 | art_zh | 246 | @@: |
475 | Ghost | 247 | mcall 12, 2 ; end of draw |
248 | ret |
||
1982 | mario79 | 249 | ;----------------------------------------------------------------------------- |
250 | store_data: |
||
251 | mov eax,[store_text_area_start] |
||
252 | mov [fileinfo.return],eax |
||
253 | mov ebx,[store_text_area_end] |
||
254 | sub ebx,eax |
||
255 | inc ebx |
||
256 | mov [fileinfo.size],ebx |
||
257 | mcall 70,fileinfo |
||
258 | ret |
||
259 | ;----------------------------------------------------------------------------- |
||
205 | heavyiron | 260 | ;* Gets the PCI Version and Last Bus |
132 | diamond | 261 | Get_PCI_Info: |
475 | Ghost | 262 | mcall 62, 0 |
263 | mov word [PCI_Version], ax |
||
264 | mcall 62, 1 |
||
265 | mov byte [PCI_LastBus], al |
||
266 | ;---------------------------------------------------------- |
||
267 | ;* Get all devices on PCI Bus |
||
268 | cmp al, 0xff ; 0xFF means no pci bus found |
||
269 | jne Pci_Exists ; |
||
270 | ret ; if no bus then leave |
||
1982 | mario79 | 271 | ;----------------------------------------------------------------------------- |
132 | diamond | 272 | Pci_Exists: |
1351 | art_zh | 273 | mov byte [V_Bus], 0 ; reset varibles |
274 | mov byte [V_Dev], 0 ; |
||
475 | Ghost | 275 | mov edx, 20 * 65536 + 110 ; set start write position |
132 | diamond | 276 | Start_Enum: |
475 | Ghost | 277 | mov bl, 6 ; get a dword |
278 | mov bh, byte [V_Bus] ; bus of pci device |
||
279 | mov ch, byte [V_Dev] ; device number/function |
||
280 | mov cl, 0 ; offset to device/vendor id |
||
281 | mcall 62 ; get ID's |
||
132 | diamond | 282 | |
475 | Ghost | 283 | cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF |
1351 | art_zh | 284 | je nextDev ; check next device if nothing exists here |
1982 | mario79 | 285 | |
475 | Ghost | 286 | cmp ax, 0xffff ; |
1351 | art_zh | 287 | je nextDev ; |
132 | diamond | 288 | |
475 | Ghost | 289 | mov word [PCI_Vendor], ax ; There is a device here, save the ID's |
1351 | art_zh | 290 | shr eax, 16 ; |
475 | Ghost | 291 | mov word [PCI_Device], ax ; |
292 | mov bl, 4 ; Read config byte |
||
293 | mov bh, byte [V_Bus] ; Bus # |
||
294 | mov ch, byte [V_Dev] ; Device # on bus |
||
295 | mov cl, 0x08 ; Register to read (Get Revision) |
||
296 | mcall 62 ; Read it |
||
1982 | mario79 | 297 | |
475 | Ghost | 298 | mov byte [PCI_Rev], al ; Save it |
299 | mov cl, 0x0b ; Register to read (Get class) |
||
300 | mcall 62 ; Read it |
||
1351 | art_zh | 301 | |
475 | Ghost | 302 | mov byte [PCI_Class], al ; Save it |
303 | mov cl, 0x0a ; Register to read (Get Subclass) |
||
304 | mcall 62 ; Read it |
||
305 | mov byte [PCI_SubClass], al; Save it |
||
1351 | art_zh | 306 | ; by Mario79 august 2006 |
475 | Ghost | 307 | mov cl, 0x09 ; Register to read (Get Interface) |
308 | mcall 62 ; Read it |
||
1982 | mario79 | 309 | |
475 | Ghost | 310 | mov [PCI_Interface], al ; Save it |
205 | heavyiron | 311 | ; |
1351 | art_zh | 312 | ; by Ghost april 2007 |
475 | Ghost | 313 | mov cl, 0x3c ; Register to read (Get IRQ) |
1982 | mario79 | 314 | @@: |
315 | mcall 62 ; Read it |
||
316 | |||
475 | Ghost | 317 | mov [PCI_IRQ], al ; Save it |
1946 | clevermous | 318 | ; by CleverMouse juny 2011 |
319 | mov cl, 0x0e |
||
320 | mcall 62 |
||
1982 | mario79 | 321 | |
1946 | clevermous | 322 | push eax |
475 | Ghost | 323 | inc byte [total] ; one more device found |
324 | call Print_New_Device ; print device info to screen |
||
1946 | clevermous | 325 | ; don't scan for nonzero functions if zero function says "not multifunction device" |
326 | pop eax |
||
327 | test al, al |
||
328 | js nextDev |
||
1982 | mario79 | 329 | |
1946 | clevermous | 330 | test byte [V_Dev], 7 |
1947 | clevermous | 331 | jnz nextDev |
1982 | mario79 | 332 | |
1946 | clevermous | 333 | or byte [V_Dev], 7 |
132 | diamond | 334 | nextDev: |
475 | Ghost | 335 | inc byte [V_Dev] ; next device on this bus |
336 | jnz Start_Enum ; jump until we reach zero |
||
337 | ;(used to be JNO which caused bug!!! 30-4-2006, JMD) |
||
1351 | art_zh | 338 | mov byte [V_Dev], 0 ; reset device number |
475 | Ghost | 339 | inc byte [V_Bus] ; next bus |
340 | mov al, byte [PCI_LastBus] ; get last bus |
||
341 | cmp byte [V_Bus], al ; was it last bus |
||
342 | jbe Start_Enum ; if not jump to keep searching |
||
343 | ret |
||
1982 | mario79 | 344 | ;----------------------------------------------------------------------------- |
1386 | art_zh | 345 | no_ummio_allowed: |
346 | xor al,al |
||
347 | mov [MMIO_allowed],al ; re-enter the subroutine |
||
475 | Ghost | 348 | ;------------------------------------------------------------------ |
132 | diamond | 349 | ;* Print device info to screen |
1386 | art_zh | 350 | |
132 | diamond | 351 | Print_New_Device: |
1386 | art_zh | 352 | xor esi, esi ; default text color |
353 | mov cl, [MMIO_allowed] |
||
354 | or cl,cl |
||
355 | jz no_ummio_here |
||
356 | mov ch, byte [V_Bus] |
||
357 | mov cl, byte [V_Dev] |
||
1351 | art_zh | 358 | mcall 62, 11 ; detect uMMIO |
1982 | mario79 | 359 | |
1386 | art_zh | 360 | and ax,0x7fff |
361 | inc ax ; -1 returned? |
||
362 | jo no_ummio_allowed |
||
1982 | mario79 | 363 | |
1386 | art_zh | 364 | inc ax ; -2 returned? |
365 | jo no_ummio_here |
||
1982 | mario79 | 366 | |
1386 | art_zh | 367 | inc ax ; -3 returned? |
368 | jo no_ummio_here |
||
1982 | mario79 | 369 | |
1386 | art_zh | 370 | mov esi, 0x990033 ; highlighted text color |
371 | mov bh, byte [V_Bus] |
||
372 | mov bl, byte [V_Dev] |
||
373 | mov byte [MMIO_Bus], bh |
||
374 | mov byte [MMIO_Dev], bl |
||
375 | add bh,'0' |
||
376 | mov [PCIWin + 129], bh ; uMMIO bus |
||
377 | mov al, bl |
||
378 | shr al, 1 |
||
379 | shr al, 1 |
||
380 | shr al, 1 |
||
381 | add al,'0' |
||
382 | mov [PCIWin + 131], al ; uMMIO device |
||
383 | and bl, 7 |
||
384 | add bl, '0' |
||
385 | mov [PCIWin + 133], bl ; uMMIO function |
||
1351 | art_zh | 386 | |
387 | no_ummio_here: |
||
475 | Ghost | 388 | movzx ecx,word [PCI_Vendor] ; Pointer to number to be written |
389 | mcall 47, 0x00040100 ; Write Vendor ID |
||
1982 | mario79 | 390 | |
391 | call store_4_digits |
||
392 | |||
475 | Ghost | 393 | and edx, 0xFFFF ;***************************************** |
1351 | art_zh | 394 | or edx, 54 * 65536 ; X start becomes 54 |
475 | Ghost | 395 | movzx ecx, word [PCI_Device] ; get Vendor ID |
396 | mcall ; Draw Vendor ID to Window |
||
1982 | mario79 | 397 | |
398 | call store_4_digits |
||
399 | |||
475 | Ghost | 400 | and edx, 0xFFFF ;***************************************** |
1351 | art_zh | 401 | or edx, 98 * 65536 ; X start becomes 98 |
475 | Ghost | 402 | movzx ecx, byte [V_Bus] ; get bus number |
403 | mcall ,0x00020100 ; draw bus number to screen |
||
1982 | mario79 | 404 | |
405 | call store_2_digits |
||
406 | |||
475 | Ghost | 407 | and edx, 0xFFFF ;***************************************** |
408 | or edx, 128 * 65536 ; X start becomes 128 |
||
409 | movzx ecx, byte [V_Dev] ; get device number |
||
410 | shr ecx, 3 ; device number is bits 3-7 |
||
411 | mcall ; Draw device Number To Window |
||
1351 | art_zh | 412 | |
1982 | mario79 | 413 | call store_2_digits |
414 | |||
475 | Ghost | 415 | and edx, 0xFFFF ;***************************************** |
416 | or edx, 155 * 65536 ; X start becomes 155 |
||
417 | movzx ecx, byte [V_Dev] ; get Function number |
||
418 | and ecx, 7 ; function is first 3 bits |
||
419 | mcall ; Draw Function Number To Window |
||
1982 | mario79 | 420 | |
421 | call store_2_digits |
||
422 | |||
475 | Ghost | 423 | and edx, 0xFFFF ;***************************************** |
424 | or edx, 179 * 65536 ; X start becomes 179 |
||
425 | movzx ecx, byte [PCI_Rev] ; get revision number |
||
426 | mcall ; Draw Revision to screen |
||
1982 | mario79 | 427 | |
428 | call store_2_digits |
||
429 | |||
475 | Ghost | 430 | and edx, 0xFFFF ;***************************************** |
431 | or edx, 215*65536 ; X start becomes 215 |
||
432 | movzx ecx, byte [PCI_Class] ; get PCI_Class |
||
433 | mcall ; Draw Class to screen |
||
1982 | mario79 | 434 | |
435 | call store_2_digits |
||
436 | |||
475 | Ghost | 437 | and edx, 0xFFFF ;***************************************** |
438 | or edx, 250*65536 ; X start becomes 250 |
||
439 | movzx ecx, byte [PCI_SubClass]; get sub class |
||
440 | mcall ; Draw Sub Class to screen |
||
1982 | mario79 | 441 | |
442 | call store_2_digits |
||
443 | |||
205 | heavyiron | 444 | ; from Mario79 august 2006 |
475 | Ghost | 445 | and edx, 0xFFFF ;***************************************** |
446 | or edx, 280 * 65536 ; X start becomes 280 |
||
447 | movzx ecx, [PCI_Interface] ; get Interface |
||
448 | mcall |
||
1982 | mario79 | 449 | |
450 | call store_2_digits |
||
451 | |||
205 | heavyiron | 452 | ; |
1351 | art_zh | 453 | ; from Ghost april 2007 ;***************************************** |
475 | Ghost | 454 | movzx ecx, [PCI_IRQ] ; get Interface |
455 | cmp cl, 0x0f ; IRQ between 0..15 |
||
456 | ja @f |
||
1982 | mario79 | 457 | |
475 | Ghost | 458 | and edx, 0xFFFF |
459 | or edx, 310 * 65536 ; X start becomes 310 |
||
460 | mcall |
||
1982 | mario79 | 461 | |
462 | call store_2_digits |
||
463 | |||
475 | Ghost | 464 | @@: |
465 | ;Write Names |
||
1351 | art_zh | 466 | movzx ebx, dx ; Set y position |
475 | Ghost | 467 | or ebx, 340 * 65536 ; set Xposition to 340 |
132 | diamond | 468 | |
475 | Ghost | 469 | ;------------------------------------------------------------------ |
470 | ; Prints the Vendor's Name based on Vendor ID |
||
132 | diamond | 471 | ; |
475 | Ghost | 472 | ; Modified on ??-04-2007 by Ghost for size |
473 | ;------------------------------------------------------------------ |
||
474 | mov edx, VendorsTab |
||
475 | mov cx, word[PCI_Vendor] |
||
1351 | art_zh | 476 | |
1982 | mario79 | 477 | .fn: |
478 | mov ax, [edx] |
||
475 | Ghost | 479 | add edx, 6 |
480 | test ax, ax |
||
481 | jz .find |
||
1982 | mario79 | 482 | |
475 | Ghost | 483 | cmp ax, cx |
484 | jne .fn |
||
1982 | mario79 | 485 | |
486 | .find: |
||
487 | mov edx, [edx - 4] |
||
475 | Ghost | 488 | mcall 4,, 0x80000000 ; lets print the vendor Name |
1982 | mario79 | 489 | |
490 | mov [store_text_size],42 |
||
491 | call store_text |
||
132 | diamond | 492 | ;------------------------------------------------------------------ |
475 | Ghost | 493 | ; Get description based on Class/Subclass |
494 | ; |
||
495 | ; Modified on ??-04-2007 by Ghost for size |
||
496 | ;------------------------------------------------------------------ |
||
497 | mov eax, dword [PCI_Class] |
||
498 | and eax, 0xffffff |
||
499 | xor edx, edx |
||
500 | xor esi, esi |
||
1982 | mario79 | 501 | .fnc: |
502 | inc esi |
||
475 | Ghost | 503 | mov ecx, [Classes + esi * 8 - 8] |
504 | cmp cx, 0xffff |
||
505 | je .endfc |
||
1982 | mario79 | 506 | |
475 | Ghost | 507 | cmp cx, ax |
508 | jne .fnc |
||
1982 | mario79 | 509 | |
475 | Ghost | 510 | test ecx, 0xff000000 |
511 | jz @f |
||
1982 | mario79 | 512 | |
475 | Ghost | 513 | mov edx, [Classes + esi * 8 - 4] |
514 | jmp .fnc |
||
1982 | mario79 | 515 | @@: |
516 | cmp eax, ecx |
||
475 | Ghost | 517 | jne .fnc |
1982 | mario79 | 518 | |
475 | Ghost | 519 | xor edx, edx |
1982 | mario79 | 520 | .endfc: |
521 | test edx, edx |
||
475 | Ghost | 522 | jnz @f |
1982 | mario79 | 523 | |
475 | Ghost | 524 | mov edx, [Classes + esi * 8 - 4] |
1351 | art_zh | 525 | @@: |
526 | and ebx, 0x0000FFFF ; clear X position |
||
475 | Ghost | 527 | or ebx, 0x24E0000 ; set X position to 590 pixels |
528 | mcall 4,, 0x80000000,, 32 ; draw the text |
||
1982 | mario79 | 529 | |
530 | mov [store_text_size],0 |
||
531 | call store_text |
||
532 | call store_CR |
||
533 | |||
1351 | art_zh | 534 | movzx edx, bx ; get y coordinate |
535 | add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 |
||
536 | mov [gr_pos], edx |
||
475 | Ghost | 537 | ret |
1351 | art_zh | 538 | ;------------------------------------------------------------------ |
539 | ; Get the user-MMIO related info |
||
540 | ; |
||
541 | ; Added on ??-12-2009 by art_zh |
||
542 | ;------------------------------------------------------------------ |
||
543 | Try_MMIO: |
||
544 | xor ebx, ebx |
||
545 | mov edx, ebx |
||
1358 | art_zh | 546 | mov bh, [MMIO_BAR] |
1351 | art_zh | 547 | or bx, 12 ; function 12 |
548 | mov ecx, 4096 ; =1 page to map |
||
549 | mcall 62 |
||
1982 | mario79 | 550 | |
1358 | art_zh | 551 | mov [MMIO_Map], eax ; store MMIO lin.addr. |
1351 | art_zh | 552 | mov ecx, 0x80990022 ; print color : red |
553 | add bh, '0' |
||
554 | cmp eax, -3 |
||
555 | jne @f |
||
1982 | mario79 | 556 | |
1351 | art_zh | 557 | mov [bar_um+3], bh |
558 | mov ebx, [gr_pos] |
||
559 | mov edx, bar_um |
||
560 | mcall 4 |
||
1982 | mario79 | 561 | |
1351 | art_zh | 562 | jmp mmio_next_bar |
563 | @@: |
||
564 | cmp eax, -4 |
||
565 | jne @f |
||
566 | mov [bar_io+3], bh |
||
567 | mov ebx, [gr_pos] |
||
568 | mov edx, bar_io |
||
569 | mcall 4 |
||
1982 | mario79 | 570 | |
1351 | art_zh | 571 | jmp mmio_next_bar |
572 | @@: |
||
1358 | art_zh | 573 | cmp bh, '6' ; expansion ROM ? |
574 | je @f |
||
1351 | art_zh | 575 | mov [bar_ram+3], bh |
576 | mov ebx, [gr_pos] |
||
577 | mov edx, bar_ram |
||
578 | mcall 4 |
||
1982 | mario79 | 579 | |
1358 | art_zh | 580 | jmp mmio_dump |
1982 | mario79 | 581 | ;----------------------------------------------------------------------------- |
1353 | art_zh | 582 | @@: |
583 | mov ebx, [gr_pos] |
||
584 | mov edx, bar_rom |
||
585 | mcall 4 |
||
205 | heavyiron | 586 | |
1353 | art_zh | 587 | mmio_dump: |
1358 | art_zh | 588 | mov edx, [MMIO_Map] |
1351 | art_zh | 589 | mov esi, 64 |
590 | mov ecx, 0x099 ; dump color : blue |
||
591 | add ebx, 10 |
||
592 | mov [gr_pos], ebx |
||
593 | mcall 4 |
||
1982 | mario79 | 594 | |
1358 | art_zh | 595 | mov ecx, [MMIO_Map] ; release the tried page |
1351 | art_zh | 596 | mcall 62,13 |
597 | |||
598 | mmio_next_bar: |
||
599 | mov bh, [MMIO_BAR] |
||
600 | inc bh |
||
1353 | art_zh | 601 | cmp bh,7 |
1351 | art_zh | 602 | je @f |
1982 | mario79 | 603 | |
1351 | art_zh | 604 | mov [MMIO_BAR], bh |
605 | add [gr_pos], 10 |
||
606 | jmp Try_MMIO |
||
1982 | mario79 | 607 | ;----------------------------------------------------------------------------- |
1351 | art_zh | 608 | @@: |
609 | xor bh,bh |
||
610 | mov [MMIO_BAR], bh |
||
611 | ret |
||
1982 | mario79 | 612 | ;----------------------------------------------------------------------------- |
613 | store_CR: |
||
614 | pusha |
||
615 | mov edi,[store_text_area_end] |
||
616 | mov [edi],word 0A20h ; CR (carriage return) + SPACE |
||
617 | add dword [store_text_area_end],2 |
||
618 | popa |
||
619 | ret |
||
620 | ;----------------------------------------------------------------------------- |
||
621 | store_text: |
||
622 | pusha |
||
623 | inc dword [store_text_area_end] |
||
624 | mov esi,edx |
||
625 | mov edi,[store_text_area_end] |
||
626 | push edi |
||
627 | xor eax,eax |
||
628 | cld |
||
629 | @@: |
||
630 | lodsb |
||
631 | test eax,eax |
||
632 | jz @f |
||
633 | stosb |
||
634 | inc dword [store_text_area_end] |
||
635 | jmp @r |
||
636 | @@: |
||
637 | pop esi |
||
638 | mov eax,[store_text_size] |
||
639 | test eax,eax |
||
640 | jz @f |
||
641 | sub edi,esi |
||
642 | sub eax,edi |
||
643 | add [store_text_area_end],eax |
||
644 | @@: |
||
645 | popa |
||
646 | ret |
||
647 | ;----------------------------------------------------------------------------- |
||
648 | store_4_digits: |
||
649 | pusha |
||
650 | mov ebx,ecx |
||
651 | mov ecx,4 |
||
652 | mov edi,[store_text_area_end] |
||
653 | call binary_to_hex_string |
||
654 | add [store_text_area_end],dword 6 |
||
655 | popa |
||
656 | ret |
||
657 | ;----------------------------------------------------------------------------- |
||
658 | store_2_digits: |
||
659 | pusha |
||
660 | inc [store_text_area_end] |
||
661 | mov ebx,ecx |
||
662 | mov ecx,2 |
||
663 | mov edi,[store_text_area_end] |
||
664 | call binary_to_hex_string |
||
665 | add [store_text_area_end],dword 4 |
||
666 | popa |
||
667 | ret |
||
668 | ;----------------------------------------------------------------------------- |
||
669 | ; ebx - value |
||
670 | ; ecx - digits |
||
671 | ; edi - output string |
||
672 | binary_to_hex_string: |
||
673 | add edi,ecx |
||
674 | dec edi |
||
675 | std |
||
676 | .1: |
||
677 | mov al,bl |
||
678 | and al,0xf |
||
679 | shr ebx,4 |
||
680 | cmp al,9 |
||
681 | jbe @f |
||
1351 | art_zh | 682 | |
1982 | mario79 | 683 | add al,0x27 |
684 | @@: |
||
685 | add al,0x30 |
||
686 | stosb |
||
687 | dec ecx |
||
688 | jnz .1 |
||
689 | cld |
||
690 | ret |
||
691 | ;----------------------------------------------------------------------------- |
||
1728 | clevermous | 692 | include 'vendors.inc' |
1982 | mario79 | 693 | ;----------------------------------------------------------------------------- |
132 | diamond | 694 | ; DATA AREA |
475 | Ghost | 695 | DATA |
132 | diamond | 696 | |
475 | Ghost | 697 | Form: dw 800 ; window width (no more, special for 800x600) |
698 | dw 100 ; window x start |
||
1358 | art_zh | 699 | dw 620 ; window height |
700 | dw 20 ; window y start |
||
205 | heavyiron | 701 | |
1982 | mario79 | 702 | title db 'PCI Device Enumerator v 2.3 by J.Delozier, S.Kuzmin, V.Hanla, M.Zakiyanov, A.Jerdev, E.Grechnikov, V.Clever Mouse, Y.Ezra', 0 |
205 | heavyiron | 703 | |
475 | Ghost | 704 | PCIWin mls \ |
1351 | art_zh | 705 | ' Don`t forget to enable PCI Access to Applications in Setup Menu.',\ |
475 | Ghost | 706 | '',\ |
1351 | art_zh | 707 | 'PCI Version = x.xx; Last PCI Bus = x',\ |
708 | 'User MMIO channel = 0F.F:F ',\ |
||
709 | 'Number of PCI units =',\ |
||
475 | Ghost | 710 | '',\ |
711 | 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Company Description',\ |
||
712 | ' Interface',\ |
||
1982 | mario79 | 713 | '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ --------------------------------' |
205 | heavyiron | 714 | |
1351 | art_zh | 715 | bar_ram db 'BARx: MMIO block', 0 |
716 | bar_io db 'BARx: IO ports',0 |
||
717 | bar_um db 'BARx: unmapped',0 |
||
1358 | art_zh | 718 | bar_rom db 'BAR6: Expansion ROM', 0 |
1351 | art_zh | 719 | |
1982 | mario79 | 720 | text_save_button: |
721 | db 'Save PCI list',0 |
||
722 | .1: db '(Press S key)',0 |
||
723 | ;--------------------------------------------------------------------- |
||
724 | system_dir_ProcLib db '/sys/lib/proc_lib.obj',0 |
||
725 | |||
726 | err_message_found_lib2 db 'proc_lib.obj - Not found!',0 |
||
727 | |||
728 | err_message_import2 db 'proc_lib.obj - Wrong import!',0 |
||
729 | |||
730 | head_f_i: |
||
731 | head_f_l db 'error',0 |
||
732 | ;--------------------------------------------------------------------- |
||
733 | l_libs_start: |
||
734 | |||
735 | library02 l_libs system_dir_ProcLib+9, path, library_path, system_dir_ProcLib, \ |
||
736 | err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i |
||
737 | |||
738 | end_l_libs: |
||
739 | ;--------------------------------------------------------------------- |
||
740 | align 4 |
||
741 | ProcLib_import: |
||
742 | OpenDialog_Init dd aOpenDialog_Init |
||
743 | OpenDialog_Start dd aOpenDialog_Start |
||
744 | ;OpenDialog__Version dd aOpenDialog_Version |
||
745 | dd 0 |
||
746 | dd 0 |
||
747 | aOpenDialog_Init db 'OpenDialog_init',0 |
||
748 | aOpenDialog_Start db 'OpenDialog_start',0 |
||
749 | ;aOpenDialog_Version db 'Version_OpenDialog',0 |
||
750 | ;--------------------------------------------------------------------- |
||
751 | align 4 |
||
752 | OpenDialog_data: |
||
753 | .type dd 0 |
||
754 | .procinfo dd Proc_Info ;+4 |
||
755 | .com_area_name dd communication_area_name ;+8 |
||
756 | .com_area dd 0 ;+12 |
||
757 | .opendir_pach dd temp_dir_pach ;+16 |
||
758 | .dir_default_pach dd communication_area_default_pach ;+20 |
||
759 | .start_path dd open_dialog_path ;+24 |
||
760 | .draw_window dd draw_window ;+28 |
||
761 | .status dd 0 ;+32 |
||
762 | .openfile_pach dd file_name ;+36 |
||
763 | .filename_area dd filename_area ;+40 |
||
764 | .filter_area dd Filter |
||
765 | .x: |
||
766 | .x_size dw 420 ;+48 ; Window X size |
||
767 | .x_start dw 10 ;+50 ; Window X position |
||
768 | .y: |
||
769 | .y_size dw 320 ;+52 ; Window y size |
||
770 | .y_start dw 10 ;+54 ; Window Y position |
||
771 | |||
772 | communication_area_name: |
||
773 | db 'FFFFFFFF_open_dialog',0 |
||
774 | open_dialog_path: |
||
775 | db '/sys/File Managers/opendial',0 |
||
776 | communication_area_default_pach: |
||
777 | db '/sys',0 |
||
778 | Filter: |
||
779 | dd Filter.end - Filter.1 |
||
780 | .1: |
||
781 | db 'TXT',0 |
||
782 | db 'LOG',0 |
||
783 | .end: |
||
784 | dd 0 |
||
785 | |||
786 | file_default_path: |
||
787 | db '/sys/' |
||
788 | start_temp_file_name: |
||
789 | db 'pcidev.txt',0 |
||
790 | ;--------------------------------------------------------------------- |
||
791 | align 4 |
||
792 | fileinfo: |
||
793 | .subfunction dd 2 |
||
794 | .Offset dd 0 |
||
795 | .Offset_1 dd 0 |
||
796 | .size dd 4096 |
||
797 | .return dd 0 |
||
798 | db 0 |
||
799 | .name: dd file_name |
||
800 | ;----------------------------------------------------------------------------- |
||
801 | |||
475 | Ghost | 802 | ; UNINITIALIZED DATA AREA |
1982 | mario79 | 803 | IM_END: |
475 | Ghost | 804 | total db ? |
805 | V_Bus db ? |
||
806 | V_Dev db ? |
||
807 | PCI_Version dw ? |
||
808 | PCI_LastBus db ? |
||
809 | PCI_Device dw ? |
||
810 | PCI_Vendor dw ? |
||
1351 | art_zh | 811 | PCI_Bus db ? |
812 | PCI_Dev db ? |
||
813 | PCI_Rev db ? |
||
475 | Ghost | 814 | ; don`t change order!!! |
815 | PCI_Class db ? |
||
816 | PCI_SubClass db ? |
||
817 | PCI_Interface db ? |
||
1351 | art_zh | 818 | PCI_IRQ db ? |
205 | heavyiron | 819 | |
1351 | art_zh | 820 | align 4 |
1386 | art_zh | 821 | MMIO_Bus db 255 |
822 | MMIO_Dev db 255 |
||
1351 | art_zh | 823 | MMIO_BAR db 0 |
1386 | art_zh | 824 | MMIO_allowed db 1 |
1351 | art_zh | 825 | MMIO_Map rd 8 |
826 | |||
827 | gr_pos dd ? |
||
828 | |||
1982 | mario79 | 829 | store_text_area_start dd ? |
830 | store_text_area_end dd ? |
||
831 | store_text_size dd ? |
||
832 | |||
833 | extended_key rb 1 |
||
834 | ;--------------------------------------------------------------------- |
||
835 | library_path: |
||
836 | rb 4096 |
||
837 | ;--------------------------------------------------------------------- |
||
838 | path: |
||
839 | rb 4096 |
||
840 | ;--------------------------------------------------------------------- |
||
841 | temp_dir_pach: |
||
842 | rb 4096 |
||
843 | ;--------------------------------------------------------------------- |
||
844 | file_name: |
||
845 | rb 4096 |
||
846 | ;--------------------------------------------------------------------- |
||
847 | file_name_1: |
||
848 | rb 4096 |
||
849 | ;--------------------------------------------------------------------- |
||
850 | filename_area: |
||
851 | rb 256 |
||
852 | ;--------------------------------------------------------------------- |
||
853 | rb 4096 |
||
854 | stacktop: |
||
855 | ;--------------------------------------------------------------------- |
||
475 | Ghost | 856 | Proc_Info process_information |
1982 | mario79 | 857 | ;--------------------------------------------------------------------- |
858 | I_END: |
||
859 | ;----------------------------------------------------------------------------->25,25>450,100> |