Rev 205 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
132 | diamond | 1 | ;*************************************************************** |
2 | ; project name: PCI Device Enumeration |
||
475 | Ghost | 3 | ; target platform: KolibriOS |
205 | heavyiron | 4 | ; compiler: flat assmebler 1.66 |
475 | Ghost | 5 | ; version: 2.1 |
6 | ; last update: April 2007 |
||
7 | ; maintained by: Jason Delozier (cordata51@hotmail.com) |
||
8 | ; Sergey Kuzmin (kuzmin_serg@list.ru) |
||
9 | ; Mihailov Ilia (ghost.nsk@gmail.com) |
||
205 | heavyiron | 10 | ; project site: http://www.coolthemes.narod.ru/pcidev.html |
132 | diamond | 11 | ;*************************************************************** |
12 | ;Summary: This program will attempt to scan the PCI Bus |
||
13 | ; and display basic information about each device |
||
14 | ; connected to the PCI Bus. |
||
15 | ;*************************************************************** |
||
16 | ;HISTORY: |
||
17 | ;keep dates in european format (dd/mm/yyyy), please |
||
18 | ; '!' means big changes |
||
205 | heavyiron | 19 | ; |
20 | ;to-do: |
||
475 | Ghost | 21 | ; more vendors |
205 | heavyiron | 22 | ; vendor's website |
23 | ; Subsystem id and Subsystem vendor id detection |
||
24 | |||
25 | ; Full device detection (like "ATI Radeon 9200") will increase app |
||
26 | ; size a lot and probably it is function of particular drivers |
||
132 | diamond | 27 | ;---------------------------------------------------------------- |
475 | Ghost | 28 | ;2.1: PCIDEV ??/04/2007 |
29 | ;Author: Mihailov Ilia aka Ghost |
||
30 | ;Features: |
||
31 | ; fixed |
||
32 | ; * Same little bugs |
||
33 | ; * Source code formating |
||
34 | ; * PCI version normalized 0210 -> 2.10 |
||
35 | ; added |
||
36 | ; * + 13 vendor (total now 1000!) |
||
37 | ; * + 3 class type |
||
38 | ; * Fast call source ready |
||
39 | ; * Device IRQ detection |
||
40 | ; optimized |
||
41 | ; * ! size optimized (61025 -> 32501 see added) |
||
42 | ; * easy to add new vendor & class names |
||
43 | ;---------------------------------------------------------------- |
||
205 | heavyiron | 44 | ;2.0: PCIDEV 30/08/2006 |
45 | ;(it differs a lot from the version 1.0, which was introduced 19 months ago) |
||
46 | ;Author: Marat Zakiyanov aka Mario79 |
||
47 | ; Sergey Kuzmin aka Wildwest |
||
48 | ;Features: |
||
49 | ; added |
||
50 | ; * Detection of Interface by Mario79 |
||
51 | ; * 122 vendor id's by Wildwest |
||
52 | ; * Description is based on Class, SubClass and Interface now (PCI 3.0) by Wildwest |
||
53 | ;---------------------------------------------------------------- |
||
132 | diamond | 54 | ;1.31: PCIDEV 13/05/2006 |
55 | ;Author: Jason Delozier |
||
56 | ;Features: |
||
57 | ; fixed |
||
58 | ; * ! bug in Company Name look up code that would cause Unknown Name errors. |
||
59 | ; * ! possible bugs, many instructions missing byte, word, dword prefixes |
||
60 | ; * ! possible bug which could have occured after removing "PREVIOUSVERSIONLIST" |
||
61 | ; entry in loop up code and not fixing jump parameters. |
||
62 | ; added |
||
63 | ; * comments to various parts of the code |
||
64 | ; optimized |
||
65 | ; * various parts of the source, too many to remember and mention. |
||
66 | ; * changed entries for Subclasses in vendors.inc to Byte format, saves a little space. |
||
67 | ;---------------------------------------------------------------- |
||
68 | ;1.30: PCIDEV 11/05/2006 |
||
69 | ;Author: Sergey Kuzmin aka Wildwest |
||
70 | ;Features: |
||
71 | ; added |
||
72 | ; * 3 new vendor id's (ESS from Madis Kalme and 2 id's |
||
73 | ; forgotten from 1.15 release: Broadcom -SiByte and Chaintech Comp.) |
||
205 | heavyiron | 74 | ; changed |
75 | ; * I don't know why other devs (Jason or Victor) changed window style |
||
132 | diamond | 76 | ; to old ugly one, so I changed it back to skinned type 3. |
77 | ; * the same goes to the use of macroc.inc - it is enabled again. |
||
78 | ; deleted |
||
79 | ; * there is no more label "PREVIOUSVERSIONLIST" - id's moved to the |
||
80 | ; appropriate parts of global list. |
||
81 | ;---------------------------------------------------------------- |
||
82 | ;1.29: PCIDEV 30/04/2006 |
||
83 | ;Author: Jason Delozier |
||
84 | ;Features: |
||
85 | ; fixed |
||
86 | ; * ! bug that would not allow devices with device |
||
87 | ; numbers > 16 to be displayed. |
||
88 | ; added |
||
89 | ; * ! another heading called "FNC" (function) which allows |
||
90 | ; the multipurpose Device/Function varible to be split and |
||
91 | ; displayed to the user properly. |
||
92 | ; * horizontal bars to display for easier reading. |
||
93 | ; optimized |
||
94 | ; * vendor/description search routines for speed and space. |
||
95 | ;---------------------------------------------------------------- |
||
96 | ;1.25: PCIDEV 02/10/2005 |
||
97 | ;Author: Sergey Kuzmin aka Wildwest |
||
98 | ;Features: |
||
99 | ; changed |
||
205 | heavyiron | 100 | ; * ! Description is based on Class and SubClass |
132 | diamond | 101 | ; now (PCI 3.0). The Names of Classes and SubClasses |
102 | ; are in the end of Vendors.inc |
||
103 | ; deleted |
||
104 | ; * label "Descriptions" (names of Classes) |
||
105 | ; |
||
106 | ;---------------------------------------------------------------- |
||
107 | ;1.20: PCIDEV 16/08/2005 |
||
108 | ;Author: Victor Alberto Gil Hanla a.k.a. vhanla |
||
109 | ;Features: |
||
110 | ; added |
||
111 | ; * ! many vendor lists (865) |
||
112 | ; deleted |
||
113 | ; * previous version's list |
||
114 | ; changed |
||
115 | ; * previous Company Name searching and printing |
||
116 | ;---------------------------------------------------------------- |
||
117 | ;1.15: PCIDEV 03/06/2005 |
||
118 | ;Author: Sergey Kuzmin aka Wildwest |
||
119 | ;Features: |
||
120 | ; added |
||
475 | Ghost | 121 | ; * quantity of devices, |
122 | ; * ! detection of Company Name based on Vendor ID, |
||
123 | ; * database of VenID (35 ID's), |
||
124 | ; * macros.inc for smaller size, |
||
132 | diamond | 125 | ; changed |
475 | Ghost | 126 | ; * interface+(skinned window), |
127 | ; * VenID before DevID in 'table'(was DevID before VenID) |
||
132 | diamond | 128 | ;---------------------------------------------------------------- |
129 | ;1.0: PCIDEV 30/01/2005 |
||
130 | ;Author: Jason Delozier |
||
131 | ;Features: |
||
132 | ; able to |
||
133 | ; * detect PCI version, |
||
134 | ; * quantity of PCI buses, |
||
135 | ; * Vendor&Device ID for appropriate Device on Bus; |
||
136 | ; * detect Revision, Class and Subclass of Device, |
||
137 | ; * and make Description based on Class |
||
138 | ;------------------------------------------------------------- |
||
475 | Ghost | 139 | include 'macros.inc' |
140 | MEOS_APP_START |
||
141 | CODE |
||
142 | call draw_window |
||
132 | diamond | 143 | |
475 | Ghost | 144 | still: mcall 10 ; wait here for event |
145 | dec eax ; redraw request ? |
||
146 | jz red |
||
147 | dec eax ; key in buffer ? |
||
148 | jz key |
||
149 | dec eax ; button in buffer ? |
||
150 | jz button |
||
151 | jmp still |
||
132 | diamond | 152 | |
475 | Ghost | 153 | red: ; redraw |
154 | mcall 9, Proc_Info, -1 ; window redraw requested so get new window coordinates and size |
||
155 | mov eax, [Proc_Info.x_start]; store the window coordinates into the Form Structure |
||
156 | mov [Form + 2], ax ; x start position |
||
157 | mov eax, [Proc_Info.y_start]; |
||
158 | mov [Form + 6], ax ; ystart position |
||
159 | mov eax, [Proc_Info.x_size] ; |
||
160 | mov [Form], ax ; window width |
||
161 | mov eax, [Proc_Info.y_size] ; |
||
162 | mov [Form + 4] ,ax ; window height |
||
163 | call draw_window ; go redraw window now |
||
164 | jmp still |
||
132 | diamond | 165 | |
475 | Ghost | 166 | key: ; key |
167 | mcall 2 ; just read it and ignore |
||
168 | jmp still |
||
169 | button: ; button |
||
170 | mcall 17 ; get id |
||
171 | cmp ah, 1 ; button id = 1 ? |
||
172 | jne still |
||
173 | mcall -1 ; close this program |
||
132 | diamond | 174 | |
175 | draw_window: |
||
475 | Ghost | 176 | mov byte [total], 0 |
177 | mcall 12, 1 ; start of draw |
||
178 | ; DRAW WINDOW |
||
179 | mcall 0, dword [Form], dword [Form + 4], 0x13ffffff, 0x805080d0, title |
||
180 | ; Insert horizontal bars in list area |
||
181 | mov eax, 13 ; draw bar system function |
||
182 | mov ebx, 18 ; set Xstart position of bar |
||
183 | shl ebx, 16 ; |
||
184 | mov bx, word [Form] ; get width of window |
||
185 | sub bx, 32 ; bar is 32 pixels shorter then window width |
||
186 | mov ecx, 119 * 65536 + 10 ; set Ystart(109) and Height(10) of bar 109 |
||
187 | mov edx, 0xC0C0C0 ; set color of bar |
||
188 | again: ;begin draw bar loop |
||
189 | mcall ; draw bar to window area |
||
190 | shr ecx, 16 ; move the Ystart position to working area |
||
191 | add ecx, 34 ; add 34 pixels to Y Start (moves bar down) |
||
192 | cmp cx, word [Form + 4] ; is the Ystart position outside of window area |
||
193 | jae nomo ; if so stop drawing bars |
||
194 | sub ecx, 14 ; if not, we only need 20 pixels between bar tops |
||
195 | shl ecx, 16 ; set that values as Ystart |
||
196 | add ecx, 10 ; Bar Height is always 10 pixels |
||
197 | jmp again ; draw another bar |
||
198 | nomo: ;done drawing bars here |
||
199 | ; start PCI stuff |
||
200 | call Get_PCI_Info ; get pci version and last bus, scan for and draw each pci device |
||
132 | diamond | 201 | |
475 | Ghost | 202 | ; Window inteface |
203 | mov cx, [PCI_Version] |
||
204 | add ch, '0' |
||
205 | mov [PCIWin + 85], ch ; 0xBADCODE but it work ! |
||
206 | mov ch, cl |
||
207 | shr cl, 4 |
||
208 | and ch, 0x0f |
||
209 | add cx, '00' |
||
210 | mov [PCIWin + 87], cx |
||
211 | mov cl, [PCI_LastBus] |
||
212 | add cl, '0' |
||
213 | mov [PCIWin + 105], cl |
||
214 | |||
215 | mov edx, PCIWin |
||
216 | mov ebx, 20 * 65536 + 25 ; x start, ystart of text |
||
217 | mov ecx, 0x224466 ; color of text |
||
218 | mov eax, 4 |
||
219 | @@: movzx esi, byte[edx] |
||
220 | inc edx |
||
221 | mcall |
||
222 | add ebx, 10 |
||
223 | add edx, esi |
||
224 | cmp byte[edx], -1 |
||
225 | jne @b |
||
226 | ; Quantity of devices... |
||
227 | movzx ecx, byte [total] ; number to draw |
||
228 | mcall 47, 0x00020000,,150 * 65536 + 65, 0x224466 |
||
132 | diamond | 229 | |
475 | Ghost | 230 | mcall 12, 2 ; end of draw |
231 | ret |
||
132 | diamond | 232 | |
475 | Ghost | 233 | ;------------------------------------------------------------------ |
205 | heavyiron | 234 | ;* Gets the PCI Version and Last Bus |
132 | diamond | 235 | Get_PCI_Info: |
475 | Ghost | 236 | mcall 62, 0 |
237 | mov word [PCI_Version], ax |
||
238 | mcall 62, 1 |
||
239 | mov byte [PCI_LastBus], al |
||
240 | ;---------------------------------------------------------- |
||
241 | ;* Get all devices on PCI Bus |
||
242 | cmp al, 0xff ; 0xFF means no pci bus found |
||
243 | jne Pci_Exists ; |
||
244 | ret ; if no bus then leave |
||
132 | diamond | 245 | Pci_Exists: |
475 | Ghost | 246 | mov byte [V_Bus], 0 ; reset varibles |
247 | mov byte [V_Dev], 0 ; |
||
248 | mov edx, 20 * 65536 + 110 ; set start write position |
||
132 | diamond | 249 | Start_Enum: |
475 | Ghost | 250 | mov bl, 6 ; get a dword |
251 | mov bh, byte [V_Bus] ; bus of pci device |
||
252 | mov ch, byte [V_Dev] ; device number/function |
||
253 | mov cl, 0 ; offset to device/vendor id |
||
254 | mcall 62 ; get ID's |
||
132 | diamond | 255 | |
475 | Ghost | 256 | cmp ax, 0 ; Vendor ID should not be 0 or 0xFFFF |
257 | je nextDev ; check next device if nothing exists here |
||
258 | cmp ax, 0xffff ; |
||
259 | je nextDev ; |
||
132 | diamond | 260 | |
475 | Ghost | 261 | mov word [PCI_Vendor], ax ; There is a device here, save the ID's |
262 | shr eax, 16 ; |
||
263 | mov word [PCI_Device], ax ; |
||
264 | mov bl, 4 ; Read config byte |
||
265 | mov bh, byte [V_Bus] ; Bus # |
||
266 | mov ch, byte [V_Dev] ; Device # on bus |
||
267 | mov cl, 0x08 ; Register to read (Get Revision) |
||
268 | mcall 62 ; Read it |
||
269 | mov byte [PCI_Rev], al ; Save it |
||
270 | mov cl, 0x0b ; Register to read (Get class) |
||
271 | mcall 62 ; Read it |
||
272 | |||
273 | mov byte [PCI_Class], al ; Save it |
||
274 | mov cl, 0x0a ; Register to read (Get Subclass) |
||
275 | mcall 62 ; Read it |
||
276 | mov byte [PCI_SubClass], al; Save it |
||
205 | heavyiron | 277 | ; from Mario79 august 2006 |
475 | Ghost | 278 | mov cl, 0x09 ; Register to read (Get Interface) |
279 | mcall 62 ; Read it |
||
280 | mov [PCI_Interface], al ; Save it |
||
205 | heavyiron | 281 | ; |
475 | Ghost | 282 | ; from Ghost april 2007 |
283 | mov cl, 0x3c ; Register to read (Get IRQ) |
||
284 | @@: mcall 62 ; Read it |
||
285 | mov [PCI_IRQ], al ; Save it |
||
286 | ; |
||
287 | inc byte [total] ; one more device found |
||
288 | call Print_New_Device ; print device info to screen |
||
132 | diamond | 289 | nextDev: |
475 | Ghost | 290 | inc byte [V_Dev] ; next device on this bus |
291 | jnz Start_Enum ; jump until we reach zero |
||
292 | ;(used to be JNO which caused bug!!! 30-4-2006, JMD) |
||
293 | mov byte [V_Dev], 0 ; reset device number |
||
294 | inc byte [V_Bus] ; next bus |
||
295 | mov al, byte [PCI_LastBus] ; get last bus |
||
296 | cmp byte [V_Bus], al ; was it last bus |
||
297 | jbe Start_Enum ; if not jump to keep searching |
||
298 | ret |
||
132 | diamond | 299 | |
475 | Ghost | 300 | ;------------------------------------------------------------------ |
132 | diamond | 301 | ;* Print device info to screen |
302 | Print_New_Device: |
||
475 | Ghost | 303 | xor esi, esi ; Color of text |
304 | movzx ecx,word [PCI_Vendor] ; Pointer to number to be written |
||
305 | mcall 47, 0x00040100 ; Write Vendor ID |
||
306 | and edx, 0xFFFF ;***************************************** |
||
307 | or edx, 54 * 65536 ; X start becomes 54 |
||
308 | movzx ecx, word [PCI_Device] ; get Vendor ID |
||
309 | mcall ; Draw Vendor ID to Window |
||
310 | and edx, 0xFFFF ;***************************************** |
||
311 | or edx, 98 * 65536 ; X start becomes 98 |
||
312 | movzx ecx, byte [V_Bus] ; get bus number |
||
313 | mcall ,0x00020100 ; draw bus number to screen |
||
314 | and edx, 0xFFFF ;***************************************** |
||
315 | or edx, 128 * 65536 ; X start becomes 128 |
||
316 | movzx ecx, byte [V_Dev] ; get device number |
||
317 | shr ecx, 3 ; device number is bits 3-7 |
||
318 | mcall ; Draw device Number To Window |
||
319 | |||
320 | and edx, 0xFFFF ;***************************************** |
||
321 | or edx, 155 * 65536 ; X start becomes 155 |
||
322 | movzx ecx, byte [V_Dev] ; get Function number |
||
323 | and ecx, 7 ; function is first 3 bits |
||
324 | mcall ; Draw Function Number To Window |
||
325 | and edx, 0xFFFF ;***************************************** |
||
326 | or edx, 179 * 65536 ; X start becomes 179 |
||
327 | movzx ecx, byte [PCI_Rev] ; get revision number |
||
328 | mcall ; Draw Revision to screen |
||
329 | and edx, 0xFFFF ;***************************************** |
||
330 | or edx, 215*65536 ; X start becomes 215 |
||
331 | movzx ecx, byte [PCI_Class] ; get PCI_Class |
||
332 | mcall ; Draw Class to screen |
||
333 | and edx, 0xFFFF ;***************************************** |
||
334 | or edx, 250*65536 ; X start becomes 250 |
||
335 | movzx ecx, byte [PCI_SubClass]; get sub class |
||
336 | mcall ; Draw Sub Class to screen |
||
205 | heavyiron | 337 | ; from Mario79 august 2006 |
475 | Ghost | 338 | and edx, 0xFFFF ;***************************************** |
339 | or edx, 280 * 65536 ; X start becomes 280 |
||
340 | movzx ecx, [PCI_Interface] ; get Interface |
||
341 | mcall |
||
205 | heavyiron | 342 | ; |
475 | Ghost | 343 | ; from Ghost april 2007 ;***************************************** |
344 | movzx ecx, [PCI_IRQ] ; get Interface |
||
345 | cmp cl, 0x0f ; IRQ between 0..15 |
||
346 | ja @f |
||
347 | and edx, 0xFFFF |
||
348 | or edx, 310 * 65536 ; X start becomes 310 |
||
349 | mcall |
||
350 | @@: |
||
351 | ; |
||
352 | ;Write Names |
||
353 | movzx ebx, dx ; Set y position |
||
354 | or ebx, 340 * 65536 ; set Xposition to 340 |
||
132 | diamond | 355 | |
475 | Ghost | 356 | ;------------------------------------------------------------------ |
357 | ; Prints the Vendor's Name based on Vendor ID |
||
132 | diamond | 358 | ; |
475 | Ghost | 359 | ; Modified on ??-04-2007 by Ghost for size |
360 | ;------------------------------------------------------------------ |
||
361 | mov edx, VendorsTab |
||
362 | mov cx, word[PCI_Vendor] |
||
363 | |||
364 | .fn: mov ax, [edx] |
||
365 | add edx, 6 |
||
366 | test ax, ax |
||
367 | jz .find |
||
368 | cmp ax, cx |
||
369 | jne .fn |
||
370 | .find: mov edx, [edx - 4] |
||
371 | mcall 4,, 0x80000000 ; lets print the vendor Name |
||
132 | diamond | 372 | |
373 | ;------------------------------------------------------------------ |
||
475 | Ghost | 374 | ; Get description based on Class/Subclass |
375 | ; |
||
376 | ; Modified on ??-04-2007 by Ghost for size |
||
377 | ;------------------------------------------------------------------ |
||
378 | mov eax, dword [PCI_Class] |
||
379 | and eax, 0xffffff |
||
380 | xor edx, edx |
||
381 | xor esi, esi |
||
382 | .fnc: inc esi |
||
383 | mov ecx, [Classes + esi * 8 - 8] |
||
384 | cmp cx, 0xffff |
||
385 | je .endfc |
||
386 | cmp cx, ax |
||
387 | jne .fnc |
||
388 | test ecx, 0xff000000 |
||
389 | jz @f |
||
390 | mov edx, [Classes + esi * 8 - 4] |
||
391 | jmp .fnc |
||
392 | @@: cmp eax, ecx |
||
393 | jne .fnc |
||
394 | xor edx, edx |
||
395 | .endfc: test edx, edx |
||
396 | jnz @f |
||
397 | mov edx, [Classes + esi * 8 - 4] |
||
398 | @@: |
||
399 | and ebx, 0x0000FFFF ; clear X position |
||
400 | or ebx, 0x24E0000 ; set X position to 590 pixels |
||
401 | mcall 4,, 0x80000000,, 32 ; draw the text |
||
402 | movzx edx, bx ; get y coordinate |
||
403 | add edx, 0x0014000A ; add 10 to y coordinate and set x coordinate to 20 |
||
404 | ret |
||
205 | heavyiron | 405 | |
475 | Ghost | 406 | include 'VENDORS.INC' |
132 | diamond | 407 | ;------------------------------------------------------------------ |
408 | ; DATA AREA |
||
475 | Ghost | 409 | DATA |
132 | diamond | 410 | |
411 | |||
475 | Ghost | 412 | Form: dw 800 ; window width (no more, special for 800x600) |
413 | dw 100 ; window x start |
||
414 | dw 420 ; window height |
||
415 | dw 100 ; window y start |
||
205 | heavyiron | 416 | |
475 | Ghost | 417 | title db 'PCI Device Enumeration v 2.1 by J. Delozier, S. Kuzmin, V. Hanla, M. Zakiyanov', 0 |
205 | heavyiron | 418 | |
475 | Ghost | 419 | PCIWin mls \ |
420 | 'Please remember to enable PCI Access to Applications in Setup Menu.',\ |
||
421 | '',\ |
||
422 | 'PCI Version = x.xx',\ |
||
423 | 'Last PCI Bus = x',\ |
||
424 | 'Quantity of devices =',\ |
||
425 | '',\ |
||
426 | 'VenID DevID Bus# Dev# Fnc Rev Class Subclass/ IRQ Company Description',\ |
||
427 | ' Interface',\ |
||
428 | '----- ----- ---- ---- --- --- ----- --------- --- ------------------------------------------ ----------------' |
||
205 | heavyiron | 429 | |
475 | Ghost | 430 | ;------------------------------------------------------------------ |
431 | ; UNINITIALIZED DATA AREA |
||
432 | UDATA |
||
205 | heavyiron | 433 | |
475 | Ghost | 434 | total db ? |
435 | V_Bus db ? |
||
436 | V_Dev db ? |
||
437 | PCI_Version dw ? |
||
438 | PCI_LastBus db ? |
||
439 | PCI_Device dw ? |
||
440 | PCI_Vendor dw ? |
||
441 | PCI_Bus db ? |
||
442 | PCI_Dev db ? |
||
443 | PCI_Rev db ? |
||
444 | ; don`t change order!!! |
||
445 | PCI_Class db ? |
||
446 | PCI_SubClass db ? |
||
447 | PCI_Interface db ? |
||
448 | PCI_IRQ db ? |
||
205 | heavyiron | 449 | |
475 | Ghost | 450 | Proc_Info process_information |
451 | MEOS_APP_END |